From d90849289b05cf70b169f6ae1eedbe9020248912 Mon Sep 17 00:00:00 2001 From: Perumal Venkatesh Date: Thu, 3 Oct 2024 18:10:26 -0700 Subject: [PATCH] Fix flake8 issues --- tests/bgp/test_startup_tsa_tsb_service.py | 52 ++++++++++++++--------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/tests/bgp/test_startup_tsa_tsb_service.py b/tests/bgp/test_startup_tsa_tsb_service.py index 0456c8a528..082fb721a3 100644 --- a/tests/bgp/test_startup_tsa_tsb_service.py +++ b/tests/bgp/test_startup_tsa_tsb_service.py @@ -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)) @@ -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), @@ -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)) @@ -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), @@ -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)) @@ -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), @@ -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)) @@ -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( @@ -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)) @@ -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 = {} @@ -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)) @@ -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], @@ -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)) @@ -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() @@ -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))