Skip to content

Commit

Permalink
Fix flake8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vperumal committed Oct 4, 2024
1 parent 27e5bb5 commit d908492
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions tests/bgp/test_startup_tsa_tsb_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,12 @@ def test_tsa_tsb_service_with_dut_abnormal_reboot(duthosts, localhost, enum_rand
out = duthost.command('show kdump config')
reboot_cause = get_reboot_cause(duthost)
if "Enabled" not in out["stdout"]:
pytest_assert(reboot_cause == UNKNOWN_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}"
.format(reboot_cause, UNKNOWN_REBOOT_CAUSE))
pytest_assert(reboot_cause == UNKNOWN_REBOOT_CAUSE,
"Reboot cause {} did not match the trigger {}"
.format(reboot_cause, UNKNOWN_REBOOT_CAUSE))
else:
pytest_assert(reboot_cause == KERNEL_PANIC_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}"
pytest_assert(reboot_cause == KERNEL_PANIC_REBOOT_CAUSE,
"Reboot cause {} did not match the trigger {}"
.format(reboot_cause, KERNEL_PANIC_REBOOT_CAUSE))


Expand Down Expand Up @@ -502,7 +504,7 @@ def test_tsa_tsb_service_with_supervisor_cold_reboot(duthosts, localhost, enum_s
pytest_assert(
wait_until(
600, 10, 0, linecard.check_bgp_session_state_all_asics, up_bgp_neighbors[linecard], "established"),
"All BGP sessions are not up. No point in continuing the test")
"All BGP sessions are not up. No point in continuing the test")

pytest_assert(verify_only_loopback_routes_are_announced_to_neighs(
duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community),
Expand Down Expand Up @@ -544,13 +546,15 @@ def test_tsa_tsb_service_with_supervisor_cold_reboot(duthosts, localhost, enum_s
# Make sure the dut's reboot cause is as expected
logger.info("Check reboot cause of the dut {}".format(linecard))
reboot_cause = get_reboot_cause(linecard)
pytest_assert(reboot_cause == SUP_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}"
pytest_assert(reboot_cause == SUP_REBOOT_CAUSE,
"Reboot cause {} did not match the trigger {}"
.format(reboot_cause, SUP_REBOOT_CAUSE))

# Make sure the Supervisor's reboot cause is as expected
logger.info("Check reboot cause of the supervisor")
reboot_cause = get_reboot_cause(suphost)
pytest_assert(reboot_cause == COLD_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}"
pytest_assert(reboot_cause == COLD_REBOOT_CAUSE,
"Reboot cause {} did not match the trigger {}"
.format(reboot_cause, COLD_REBOOT_CAUSE))


Expand Down Expand Up @@ -640,7 +644,7 @@ def test_tsa_tsb_service_with_supervisor_abnormal_reboot(duthosts, localhost, en
pytest_assert(
wait_until(
600, 10, 0, linecard.check_bgp_session_state_all_asics, up_bgp_neighbors[linecard], "established"),
"All BGP sessions are not up. No point in continuing the test")
"All BGP sessions are not up. No point in continuing the test")

pytest_assert(verify_only_loopback_routes_are_announced_to_neighs(
duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community),
Expand Down Expand Up @@ -691,10 +695,12 @@ def test_tsa_tsb_service_with_supervisor_abnormal_reboot(duthosts, localhost, en
out = suphost.command('show kdump config')
reboot_cause = get_reboot_cause(suphost)
if "Enabled" not in out["stdout"]:
pytest_assert(reboot_cause == UNKNOWN_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}"
pytest_assert(reboot_cause == UNKNOWN_REBOOT_CAUSE,
"Reboot cause {} did not match the trigger {}"
.format(reboot_cause, UNKNOWN_REBOOT_CAUSE))
else:
pytest_assert(reboot_cause == KERNEL_PANIC_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}"
pytest_assert(reboot_cause == KERNEL_PANIC_REBOOT_CAUSE,
"Reboot cause {} did not match the trigger {}"
.format(reboot_cause, KERNEL_PANIC_REBOOT_CAUSE))


Expand Down Expand Up @@ -762,7 +768,7 @@ def test_tsa_tsb_service_with_user_init_tsa(duthosts, localhost, enum_rand_one_p
pytest_assert(
wait_until(
600, 10, 0, duthost.check_bgp_session_state_all_asics, up_bgp_neighbors, "established"),
"All BGP sessions are not up. No point in continuing the test")
"All BGP sessions are not up. No point in continuing the test")

pytest_assert(verify_only_loopback_routes_are_announced_to_neighs(
duthosts, duthost, dut_nbrhosts, traffic_shift_community),
Expand Down Expand Up @@ -805,7 +811,8 @@ def test_tsa_tsb_service_with_user_init_tsa(duthosts, localhost, enum_rand_one_p
# Make sure the dut's reboot cause is as expected
logger.info("Check reboot cause of the dut")
reboot_cause = get_reboot_cause(duthost)
pytest_assert(reboot_cause == COLD_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}"
pytest_assert(reboot_cause == COLD_REBOOT_CAUSE,
"Reboot cause {} did not match the trigger {}"
.format(reboot_cause, COLD_REBOOT_CAUSE))


Expand Down Expand Up @@ -883,7 +890,7 @@ def test_user_init_tsa_while_service_run_on_dut(duthosts, localhost, enum_rand_o
pytest_assert(
wait_until(
600, 10, 0, duthost.check_bgp_session_state_all_asics, up_bgp_neighbors, "established"),
"All BGP sessions are not up. No point in continuing the test")
"All BGP sessions are not up. No point in continuing the test")


pytest_assert(verify_only_loopback_routes_are_announced_to_neighs(
Expand Down Expand Up @@ -919,7 +926,8 @@ def test_user_init_tsa_while_service_run_on_dut(duthosts, localhost, enum_rand_o
# Make sure the dut's reboot cause is as expected
logger.info("Check reboot cause of the dut")
reboot_cause = get_reboot_cause(duthost)
pytest_assert(reboot_cause == COLD_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}"
pytest_assert(reboot_cause == COLD_REBOOT_CAUSE,
"Reboot cause {} did not match the trigger {}"
.format(reboot_cause, COLD_REBOOT_CAUSE))


Expand Down Expand Up @@ -994,7 +1002,7 @@ def test_user_init_tsb_while_service_run_on_dut(duthosts, localhost, enum_rand_o
pytest_assert(
wait_until(
600, 10, 0, duthost.check_bgp_session_state_all_asics, up_bgp_neighbors, "established"),
"All BGP sessions are not up. No point in continuing the test")
"All BGP sessions are not up. No point in continuing the test")

# Wait until all routes are announced to neighbors
cur_v4_routes = {}
Expand All @@ -1019,7 +1027,8 @@ def test_user_init_tsb_while_service_run_on_dut(duthosts, localhost, enum_rand_o
# Make sure the dut's reboot cause is as expected
logger.info("Check reboot cause of the dut")
reboot_cause = get_reboot_cause(duthost)
pytest_assert(reboot_cause == COLD_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}"
pytest_assert(reboot_cause == COLD_REBOOT_CAUSE,
"Reboot cause {} did not match the trigger {}"
.format(reboot_cause, COLD_REBOOT_CAUSE))


Expand Down Expand Up @@ -1122,7 +1131,7 @@ def test_user_init_tsb_on_sup_while_service_run_on_dut(duthosts, localhost,
pytest_assert(
wait_until(
600, 10, 0, linecard.check_bgp_session_state_all_asics, up_bgp_neighbors[linecard], "established"),
"All BGP sessions are not up. No point in continuing the test")
"All BGP sessions are not up. No point in continuing the test")

# Verify that all routes advertised to neighbor at the start of the test
if not wait_until(300, 3, 0, verify_current_routes_announced_to_neighs, linecard, dut_nbrhosts[linecard],
Expand All @@ -1149,13 +1158,15 @@ def test_user_init_tsb_on_sup_while_service_run_on_dut(duthosts, localhost,
# Make sure the dut's reboot cause is as expected
logger.info("Check reboot cause of the dut {}".format(linecard))
reboot_cause = get_reboot_cause(linecard)
pytest_assert(reboot_cause == SUP_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}"
pytest_assert(reboot_cause == SUP_REBOOT_CAUSE,
"Reboot cause {} did not match the trigger {}"
.format(reboot_cause, SUP_REBOOT_CAUSE))

# Make sure the Supervisor's reboot cause is as expected
logger.info("Check reboot cause of the supervisor")
reboot_cause = get_reboot_cause(suphost)
pytest_assert(reboot_cause == COLD_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}"
pytest_assert(reboot_cause == COLD_REBOOT_CAUSE,
"Reboot cause {} did not match the trigger {}"
.format(reboot_cause, COLD_REBOOT_CAUSE))


Expand Down Expand Up @@ -1216,7 +1227,7 @@ def test_tsa_tsb_timer_efficiency(duthosts, localhost, enum_rand_one_per_hwsku_f
pytest_assert(
wait_until(
600, 10, 0, duthost.check_bgp_session_state_all_asics, up_bgp_neighbors, "established"),
"All BGP sessions are not up. No point in continuing the test")
"All BGP sessions are not up. No point in continuing the test")

stability_check_time = datetime.datetime.now()
time_to_stabilize = (stability_check_time - service_uptime).total_seconds()
Expand Down Expand Up @@ -1263,5 +1274,6 @@ def test_tsa_tsb_timer_efficiency(duthosts, localhost, enum_rand_one_per_hwsku_f
# Make sure the dut's reboot cause is as expected
logger.info("Check reboot cause of the dut")
reboot_cause = get_reboot_cause(duthost)
pytest_assert(reboot_cause == COLD_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}"
pytest_assert(reboot_cause == COLD_REBOOT_CAUSE,
"Reboot cause {} did not match the trigger {}"
.format(reboot_cause, COLD_REBOOT_CAUSE))

0 comments on commit d908492

Please sign in to comment.