From 461f5a4320e1ca0014f6a41a200c5966f7e300d1 Mon Sep 17 00:00:00 2001 From: Javier-Tan <47554099+Javier-Tan@users.noreply.github.com> Date: Wed, 15 Jan 2025 04:35:55 +0000 Subject: [PATCH 1/4] [bgp/test_reliable_tsa.py] Add wait_until to let routes on neighbours update * Add wait_until for verify_only_loopback_routes Signed-off-by: Javier Tan javiertan@microsoft.com --- tests/bgp/test_reliable_tsa.py | 116 ++++++++++++++++++++++----------- 1 file changed, 77 insertions(+), 39 deletions(-) diff --git a/tests/bgp/test_reliable_tsa.py b/tests/bgp/test_reliable_tsa.py index 06ef29717f..8440ed6d4a 100644 --- a/tests/bgp/test_reliable_tsa.py +++ b/tests/bgp/test_reliable_tsa.py @@ -309,8 +309,10 @@ def verify_linecard_after_sup_tsa(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state @@ -381,8 +383,10 @@ def verify_linecard_after_sup_tsa(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state @@ -439,8 +443,10 @@ def verify_linecard_after_sup_tsa(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") # Issue TSB on the supervisor @@ -537,8 +543,10 @@ def verify_linecard_after_sup_tsb(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state @@ -597,8 +605,10 @@ def run_tsa_on_linecard_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") # Verify supervisor still has tsa_enabled 'false' config @@ -680,8 +690,10 @@ def run_tsa_on_linecard_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") # Verify supervisor still has tsa_enabled 'true' config @@ -747,8 +759,10 @@ def run_tsa_on_linecard_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") def run_tsb_on_linecard_and_verify(lc): @@ -845,8 +859,10 @@ def run_tsb_on_linecard_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") # Verify supervisor still has tsa_enabled 'true' config @@ -991,8 +1007,10 @@ def verify_linecard_tsa_tsb(lc): executor.submit(verify_linecard_tsa_tsb, linecard) for linecard in duthosts.frontend_nodes: - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state @@ -1098,8 +1116,10 @@ def verify_line_card_after_sup_config_reload(lc): executor.submit(verify_line_card_after_sup_config_reload, linecard) for linecard in duthosts.frontend_nodes: - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state @@ -1214,8 +1234,10 @@ def reboot_linecard_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced to neighbors when the linecards are in TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") # Verify supervisor still has tsa_enabled 'false' config @@ -1303,8 +1325,10 @@ def verify_line_card_after_sup_tsa(lc): pytest_assert(TS_MAINTENANCE == get_traffic_shift_state(first_linecard, cmd='TSC no-stats'), "DUT is not in maintenance state after config reload") - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, first_linecard, dut_nbrhosts[first_linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, first_linecard, dut_nbrhosts[first_linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") # Verify supervisor still has tsa_enabled 'true' config @@ -1393,8 +1417,10 @@ def verify_linecard_after_sup_tsa(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced with TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state @@ -1478,9 +1504,11 @@ def verify_linecard_after_sup_tsb(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced with TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state set_tsb_on_sup_duts_before_and_after_test(duthosts, enum_supervisor_dut_hostname) @@ -1602,8 +1630,10 @@ def verify_linecard_after_sup_tsa(lc): # Verify only loopback routes are announced to neighbors at this state for linecard in duthosts.frontend_nodes: - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state @@ -1776,8 +1806,10 @@ def test_sup_tsb_followed_by_dut_bgp_restart_when_sup_on_tsa_duts_on_tsb( pytest_assert(TS_MAINTENANCE == get_traffic_shift_state(linecard, cmd='TSC no-stats'), "DUT is not in maintenance state") # Verify only loopback routes are announced after TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") # Issue TSB on the supervisor @@ -1897,8 +1929,10 @@ def restart_bgp_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state @@ -1962,8 +1996,10 @@ def run_tsa_on_linecard_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") def run_tsb_on_linecard_and_verify(lc): @@ -2112,8 +2148,10 @@ def restart_bgp_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), + pytest_assert( + wait_until(180, 10, 10, + verify_only_loopback_routes_are_announced_to_neighs, + duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state From ba5a0966c9674a630da4d1bd6c175ee8bc7261f8 Mon Sep 17 00:00:00 2001 From: Javier-Tan <47554099+Javier-Tan@users.noreply.github.com> Date: Fri, 17 Jan 2025 06:04:21 +0000 Subject: [PATCH 2/4] [bgp/test_reliable_tsa.py] Remove trailing whitespace * Remove trailing whitespace Signed-off-by: Javier Tan javiertan@microsoft.com --- tests/bgp/test_reliable_tsa.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bgp/test_reliable_tsa.py b/tests/bgp/test_reliable_tsa.py index 8440ed6d4a..36ea036a1a 100644 --- a/tests/bgp/test_reliable_tsa.py +++ b/tests/bgp/test_reliable_tsa.py @@ -1508,7 +1508,7 @@ def verify_linecard_after_sup_tsb(lc): wait_until(180, 10, 10, verify_only_loopback_routes_are_announced_to_neighs, duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state set_tsb_on_sup_duts_before_and_after_test(duthosts, enum_supervisor_dut_hostname) From d85dccadf32d35c45ddc92a38a0ab67cf2793b2b Mon Sep 17 00:00:00 2001 From: Javier-Tan <47554099+Javier-Tan@users.noreply.github.com> Date: Tue, 21 Jan 2025 10:45:18 +0000 Subject: [PATCH 3/4] [bgp/...] Add assert_only_loopback_routes_announced_to_neighs_function * Add function which wraps verify_only_loopback_routes_... with assert and wait_until Signed-off-by: Javier Tan javiertan@microsoft.com --- tests/bgp/route_checker.py | 13 ++ tests/bgp/test_reliable_tsa.py | 156 ++++++++-------------- tests/bgp/test_seq_idf_isolation.py | 14 +- tests/bgp/test_startup_tsa_tsb_service.py | 57 ++++---- tests/bgp/test_traffic_shift.py | 18 +-- 5 files changed, 117 insertions(+), 141 deletions(-) diff --git a/tests/bgp/route_checker.py b/tests/bgp/route_checker.py index ea0555839d..a74bb04c36 100644 --- a/tests/bgp/route_checker.py +++ b/tests/bgp/route_checker.py @@ -6,6 +6,7 @@ from tests.common.devices.eos import EosHost from tests.common.helpers.assertions import pytest_assert from tests.common.helpers.parallel import parallel_run +from tests.common.utilities import wait_until logger = logging.getLogger(__name__) @@ -206,6 +207,18 @@ def verify_only_loopback_routes_are_announced_to_neighs(dut_hosts, duthost, neig dut_hosts, duthost, neigh_hosts, 6, community) +def assert_only_loopback_routes_announced_to_neighs(dut_hosts, duthost, neigh_hosts, community, + error_msg=""): + if not error_msg: + error_msg = "Failed to verify only loopback routes are announced to neighbours" + + pytest_assert( + wait_until(180, 10, 5, verify_only_loopback_routes_are_announced_to_neighs, + dut_hosts, duthost, neigh_hosts, community), + error_msg + ) + + def parse_routes_on_neighbors(dut_host, neigh_hosts, ip_ver, exp_community=[]): if isinstance(list(neigh_hosts.items())[0][1]['host'], EosHost): routes_on_all_nbrs = parse_routes_on_eos(dut_host, neigh_hosts, ip_ver, exp_community) diff --git a/tests/bgp/test_reliable_tsa.py b/tests/bgp/test_reliable_tsa.py index 36ea036a1a..a7a58fb127 100644 --- a/tests/bgp/test_reliable_tsa.py +++ b/tests/bgp/test_reliable_tsa.py @@ -13,7 +13,7 @@ from tests.bgp.bgp_helpers import get_tsa_chassisdb_config, get_sup_cfggen_tsa_value, verify_dut_configdb_tsa_value from tests.bgp.traffic_checker import get_traffic_shift_state from tests.bgp.route_checker import parse_routes_on_neighbors, check_and_log_routes_diff, \ - verify_current_routes_announced_to_neighs, verify_only_loopback_routes_are_announced_to_neighs + verify_current_routes_announced_to_neighs, assert_only_loopback_routes_announced_to_neighs from tests.bgp.constants import TS_NORMAL, TS_MAINTENANCE from tests.bgp.test_startup_tsa_tsb_service import get_tsa_tsb_service_uptime, get_tsa_tsb_service_status, \ get_startup_tsb_timer, enable_disable_startup_tsa_tsb_service # noqa: F401 @@ -309,11 +309,9 @@ def verify_linecard_after_sup_tsa(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state set_tsb_on_sup_duts_before_and_after_test(duthosts, enum_supervisor_dut_hostname) @@ -383,11 +381,9 @@ def verify_linecard_after_sup_tsa(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state set_tsb_on_sup_duts_before_and_after_test(duthosts, enum_supervisor_dut_hostname) @@ -443,11 +439,9 @@ def verify_linecard_after_sup_tsa(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") # Issue TSB on the supervisor suphost.shell('TSB') @@ -543,11 +537,9 @@ def verify_linecard_after_sup_tsb(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state set_tsb_on_sup_duts_before_and_after_test(duthosts, enum_supervisor_dut_hostname) @@ -605,11 +597,9 @@ def run_tsa_on_linecard_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") # Verify supervisor still has tsa_enabled 'false' config pytest_assert('false' == get_tsa_chassisdb_config(suphost), @@ -690,11 +680,9 @@ def run_tsa_on_linecard_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") # Verify supervisor still has tsa_enabled 'true' config pytest_assert('true' == get_tsa_chassisdb_config(suphost), @@ -759,11 +747,9 @@ def run_tsa_on_linecard_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") def run_tsb_on_linecard_and_verify(lc): lc.shell('TSB') @@ -859,11 +845,9 @@ def run_tsb_on_linecard_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") # Verify supervisor still has tsa_enabled 'true' config pytest_assert('true' == get_tsa_chassisdb_config(suphost), @@ -1007,11 +991,9 @@ def verify_linecard_tsa_tsb(lc): executor.submit(verify_linecard_tsa_tsb, linecard) for linecard in duthosts.frontend_nodes: - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state set_tsb_on_sup_duts_before_and_after_test(duthosts, enum_supervisor_dut_hostname) @@ -1116,11 +1098,9 @@ def verify_line_card_after_sup_config_reload(lc): executor.submit(verify_line_card_after_sup_config_reload, linecard) for linecard in duthosts.frontend_nodes: - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state set_tsb_on_sup_duts_before_and_after_test(duthosts, enum_supervisor_dut_hostname) @@ -1234,11 +1214,9 @@ def reboot_linecard_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced to neighbors when the linecards are in TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") # Verify supervisor still has tsa_enabled 'false' config pytest_assert('false' == get_tsa_chassisdb_config(suphost), @@ -1324,12 +1302,10 @@ def verify_line_card_after_sup_tsa(lc): # Verify DUT is in maintenance state. pytest_assert(TS_MAINTENANCE == get_traffic_shift_state(first_linecard, cmd='TSC no-stats'), "DUT is not in maintenance state after config reload") - - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, first_linecard, dut_nbrhosts[first_linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, first_linecard, + dut_nbrhosts[first_linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") # Verify supervisor still has tsa_enabled 'true' config pytest_assert('true' == get_tsa_chassisdb_config(suphost), @@ -1417,11 +1393,9 @@ def verify_linecard_after_sup_tsa(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced with TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state set_tsb_on_sup_duts_before_and_after_test(duthosts, enum_supervisor_dut_hostname) @@ -1504,11 +1478,9 @@ def verify_linecard_after_sup_tsb(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced with TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state set_tsb_on_sup_duts_before_and_after_test(duthosts, enum_supervisor_dut_hostname) @@ -1630,11 +1602,9 @@ def verify_linecard_after_sup_tsa(lc): # Verify only loopback routes are announced to neighbors at this state for linecard in duthosts.frontend_nodes: - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state set_tsb_on_sup_duts_before_and_after_test(duthosts, enum_supervisor_dut_hostname) @@ -1806,11 +1776,9 @@ def test_sup_tsb_followed_by_dut_bgp_restart_when_sup_on_tsa_duts_on_tsb( pytest_assert(TS_MAINTENANCE == get_traffic_shift_state(linecard, cmd='TSC no-stats'), "DUT is not in maintenance state") # Verify only loopback routes are announced after TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") # Issue TSB on the supervisor suphost.shell('TSB') @@ -1929,11 +1897,9 @@ def restart_bgp_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state set_tsb_on_sup_duts_before_and_after_test(duthosts, enum_supervisor_dut_hostname) @@ -1996,11 +1962,9 @@ def run_tsa_on_linecard_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") def run_tsb_on_linecard_and_verify(lc): lc.shell('TSB') @@ -2148,11 +2112,9 @@ def restart_bgp_and_verify(lc): for linecard in duthosts.frontend_nodes: # Verify only loopback routes are announced after TSA - pytest_assert( - wait_until(180, 10, 10, - verify_only_loopback_routes_are_announced_to_neighs, - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: # Bring back the supervisor and line cards to the normal state set_tsb_on_sup_duts_before_and_after_test(duthosts, enum_supervisor_dut_hostname) diff --git a/tests/bgp/test_seq_idf_isolation.py b/tests/bgp/test_seq_idf_isolation.py index 75c57c613e..e6525f845b 100644 --- a/tests/bgp/test_seq_idf_isolation.py +++ b/tests/bgp/test_seq_idf_isolation.py @@ -5,7 +5,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.helpers.constants import DEFAULT_ASIC_ID from tests.common.utilities import wait_until -from route_checker import verify_only_loopback_routes_are_announced_to_neighs, parse_routes_on_neighbors +from route_checker import assert_only_loopback_routes_announced_to_neighs, parse_routes_on_neighbors from route_checker import verify_current_routes_announced_to_neighs, check_and_log_routes_diff pytestmark = [ @@ -167,9 +167,9 @@ def test_idf_isolated_withdraw_all(duthosts, rand_one_downlink_duthost, # Verify DUT is in isolated-withdraw-all state. pytest_assert(IDF_ISOLATED_WITHDRAW_ALL == get_idf_isolation_state(duthost), "DUT is not in isolated_withdraw_all state") - if not wait_until(60, 3, 0, verify_only_loopback_routes_are_announced_to_neighs, - duthosts, duthost, nbrs, traffic_shift_community): - pytest.fail("Failed to verify only loopback route in isolated_withdraw_all state") + assert_only_loopback_routes_announced_to_neighs(duthosts, duthost, nbrs, traffic_shift_community, + "Failed to verify only loopback route \ + in isolated_withdraw_all state") finally: # Recover to unisolated state duthost.shell("sudo idf_isolation unisolated") @@ -281,9 +281,9 @@ def test_idf_isolation_withdraw_all_with_config_reload(duthosts, rand_one_downli # Verify DUT is in isolated-withdraw-all state. pytest_assert(IDF_ISOLATED_WITHDRAW_ALL == get_idf_isolation_state(duthost), "DUT is not isolated_no_export state") - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs(duthosts, duthost, nbrs, - traffic_shift_community), - "Failed to verify only loopback route in isolated_withdraw_all state") + assert_only_loopback_routes_announced_to_neighs(duthosts, duthost, nbrs, traffic_shift_community, + "Failed to verify only loopback route in \ + isolated_withdraw_all state") finally: """ Recover to unisolated state diff --git a/tests/bgp/test_startup_tsa_tsb_service.py b/tests/bgp/test_startup_tsa_tsb_service.py index 099555c06d..aa5795e257 100644 --- a/tests/bgp/test_startup_tsa_tsb_service.py +++ b/tests/bgp/test_startup_tsa_tsb_service.py @@ -13,7 +13,7 @@ from tests.bgp.bgp_helpers import initial_tsa_check_before_and_after_test from tests.bgp.traffic_checker import get_traffic_shift_state, check_tsa_persistence_support from tests.bgp.route_checker import parse_routes_on_neighbors, check_and_log_routes_diff, \ - verify_current_routes_announced_to_neighs, verify_only_loopback_routes_are_announced_to_neighs + verify_current_routes_announced_to_neighs, assert_only_loopback_routes_announced_to_neighs from tests.bgp.constants import TS_NORMAL, TS_MAINTENANCE from tests.conftest import get_hosts_per_hwsku @@ -295,9 +295,9 @@ def reboot_and_verify(lc): executor.submit(reboot_and_verify, linecard) for linecard in frontend_nodes_per_hwsku: - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") def further_verify_linecard(lc): # Verify startup_tsa_tsb service stopped after expected time @@ -444,9 +444,9 @@ def abnormal_reboot_linecard_and_verify(lc): executor.submit(abnormal_reboot_linecard_and_verify, linecard) for linecard in frontend_nodes_per_hwsku: - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") def further_verify_linecard(lc): # Verify startup_tsa_tsb service stopped after expected time @@ -588,9 +588,9 @@ def verify_linecard_after_sup_reboot(lc): executor.submit(verify_linecard_after_sup_reboot, linecard) for linecard in duthosts.frontend_nodes: - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") # Once all line cards are in maintenance state, proceed further def further_verify_linecard(lc): @@ -752,9 +752,9 @@ def verify_linecard_after_sup_reboot(lc): executor.submit(verify_linecard_after_sup_reboot, linecard) for linecard in duthosts.frontend_nodes: - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") # Once all line cards are in maintenance state, proceed further def further_verify_linecard(lc): @@ -900,9 +900,10 @@ def run_tsa_and_reboot_and_verify(lc): executor.submit(run_tsa_and_reboot_and_verify, linecard) for linecard in frontend_nodes_per_hwsku: - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") + finally: """ Test TSB after config save and config reload @@ -1035,9 +1036,10 @@ def run_tsa_and_verify(lc): executor.submit(run_tsa_and_verify, linecard) for linecard in frontend_nodes_per_hwsku: - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") + finally: """ Test TSB after config save and config reload @@ -1303,9 +1305,9 @@ def verify_linecard_after_sup_reboot(lc): executor.submit(verify_linecard_after_sup_reboot, linecard) for linecard in duthosts.frontend_nodes: - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") # Issue user initiated TSB on the supervisor suphost.shell('TSB') @@ -1588,15 +1590,14 @@ def verify_linecard_after_sup_reboot(lc): wait_until( 900, 10, 0, lc.check_bgp_session_state_all_asics, up_bgp_neighbors[lc], "established"), "All BGP sessions are not up. No point in continuing the test") - with SafeThreadPoolExecutor(max_workers=8) as executor: for linecard in duthosts.frontend_nodes: executor.submit(verify_linecard_after_sup_reboot, linecard) for linecard in duthosts.frontend_nodes: - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs( - duthosts, linecard, dut_nbrhosts[linecard], traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, linecard, dut_nbrhosts[linecard], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") def further_verify_linecard(lc): # Verify startup_tsa_tsb service stopped after expected time @@ -1608,10 +1609,14 @@ def further_verify_linecard(lc): # Verify TSA is configured on the dut after startup_tsa_tsb service is stopped pytest_assert(TS_MAINTENANCE == get_traffic_shift_state(lc), "DUT is not in maintenance state after startup_tsa_tsb service is stopped") + assert_only_loopback_routes_announced_to_neighs(duthosts, lc, dut_nbrhosts[lc], + traffic_shift_community, + "Failed to verify routes on nbr in TSA") with SafeThreadPoolExecutor(max_workers=8) as executor: for linecard in duthosts.frontend_nodes: executor.submit(further_verify_linecard, linecard) + finally: # Bring back the supervisor and line cards to the BGP operational normal state initial_tsa_check_before_and_after_test(duthosts) diff --git a/tests/bgp/test_traffic_shift.py b/tests/bgp/test_traffic_shift.py index 28c9743107..368554af97 100644 --- a/tests/bgp/test_traffic_shift.py +++ b/tests/bgp/test_traffic_shift.py @@ -9,7 +9,7 @@ from tests.common.helpers.constants import DEFAULT_ASIC_ID from tests.common.platform.processes_utils import wait_critical_processes from tests.common.utilities import wait_until -from tests.bgp.route_checker import verify_only_loopback_routes_are_announced_to_neighs, parse_routes_on_neighbors, \ +from tests.bgp.route_checker import assert_only_loopback_routes_announced_to_neighs, parse_routes_on_neighbors, \ verify_current_routes_announced_to_neighs, check_and_log_routes_diff from tests.bgp.traffic_checker import get_traffic_shift_state, check_tsa_persistence_support, \ verify_traffic_shift_per_asic @@ -88,9 +88,8 @@ def test_TSA(duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, bgpmon_setup_teardown['namespace']) == [], "Not all routes are announced to bgpmon") - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs(duthosts, duthost, nbrhosts_to_dut, - traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, duthost, nbrhosts_to_dut, traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: # Recover to Normal state duthost.shell("TSB") @@ -249,10 +248,8 @@ def test_TSA_TSB_with_config_reload(duthosts, enum_rand_one_per_hwsku_frontend_h pytest_assert(get_routes_not_announced_to_bgpmon(duthost, ptfhost, bgpmon_setup_teardown['namespace']) == [], "Not all routes are announced to bgpmon") - - pytest_assert(wait_until(90, 10, 0, verify_only_loopback_routes_are_announced_to_neighs, duthosts, duthost, - nbrhosts_to_dut, traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, duthost, nbrhosts_to_dut, traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: """ Test TSB after config save and config reload @@ -319,9 +316,8 @@ def test_load_minigraph_with_traffic_shift_away(duthosts, enum_rand_one_per_hwsk bgpmon_setup_teardown['namespace']) == [], "Not all routes are announced to bgpmon") - pytest_assert(verify_only_loopback_routes_are_announced_to_neighs(duthosts, duthost, nbrhosts_to_dut, - traffic_shift_community), - "Failed to verify routes on nbr in TSA") + assert_only_loopback_routes_announced_to_neighs(duthosts, duthost, nbrhosts_to_dut, traffic_shift_community, + "Failed to verify routes on nbr in TSA") finally: """ Recover with TSB and verify route advertisement From db72b3ec5304c8b13e1648362657d0d3463f85c7 Mon Sep 17 00:00:00 2001 From: Javier-Tan <47554099+Javier-Tan@users.noreply.github.com> Date: Wed, 29 Jan 2025 00:37:02 +0000 Subject: [PATCH 4/4] [bgp/test_reliable_tsa.py] Remove trailing whitespace * Remove trailing whitespace Signed-off-by: Javier Tan javiertan@microsoft.com --- tests/bgp/test_reliable_tsa.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/bgp/test_reliable_tsa.py b/tests/bgp/test_reliable_tsa.py index a7a58fb127..3ffe62fcb2 100644 --- a/tests/bgp/test_reliable_tsa.py +++ b/tests/bgp/test_reliable_tsa.py @@ -1302,8 +1302,8 @@ def verify_line_card_after_sup_tsa(lc): # Verify DUT is in maintenance state. pytest_assert(TS_MAINTENANCE == get_traffic_shift_state(first_linecard, cmd='TSC no-stats'), "DUT is not in maintenance state after config reload") - assert_only_loopback_routes_announced_to_neighs(duthosts, first_linecard, - dut_nbrhosts[first_linecard], + assert_only_loopback_routes_announced_to_neighs(duthosts, first_linecard, + dut_nbrhosts[first_linecard], traffic_shift_community, "Failed to verify routes on nbr in TSA")