diff --git a/tests/bgp/bgp_helpers.py b/tests/bgp/bgp_helpers.py index fa71b4167a6..1934c352ae7 100644 --- a/tests/bgp/bgp_helpers.py +++ b/tests/bgp/bgp_helpers.py @@ -18,6 +18,8 @@ from tests.common.helpers.parallel import reset_ansible_local_tmp from tests.common.helpers.parallel import parallel_run from tests.common.utilities import wait_until +from tests.bgp.traffic_checker import get_traffic_shift_state +from tests.bgp.constants import TS_NORMAL BASE_DIR = os.path.dirname(os.path.realpath(__file__)) DUT_TMP_DIR = os.path.join('tmp', os.path.basename(BASE_DIR)) @@ -879,3 +881,27 @@ def verify_dut_configdb_tsa_value(duthost): tsa_enabled = 'true' return tsa_enabled + + +def initial_tsa_check_before_and_after_test(duthosts): + """ + @summary: Common method to make sure the supervisor and line cards are in normal state before and after the test + """ + for duthost in duthosts: + if duthost.is_supervisor_node(): + # Initially make sure both supervisor and line cards are in BGP operational normal state + if get_tsa_chassisdb_config(duthost) != 'false' or get_sup_cfggen_tsa_value(duthost) != 'false': + duthost.shell('TSB') + duthost.shell('sudo config save -y') + pytest_assert('false' == get_tsa_chassisdb_config(duthost), + "Supervisor {} tsa_enabled config is enabled".format(duthost.hostname)) + + for linecard in duthosts.frontend_nodes: + # Issue TSB on the line card before proceeding further + if verify_dut_configdb_tsa_value(linecard) != 'false' or get_tsa_chassisdb_config(linecard) != 'false' or \ + get_traffic_shift_state(linecard, cmd='TSC no-stats') != TS_NORMAL: + linecard.shell('TSB') + linecard.shell('sudo config save -y') + # Ensure that the DUT is not in maintenance already before start of the test + pytest_assert(TS_NORMAL == get_traffic_shift_state(linecard, cmd='TSC no-stats'), + "DUT is not in normal state") diff --git a/tests/bgp/route_checker.py b/tests/bgp/route_checker.py index 322288718d3..646dc0b86cb 100644 --- a/tests/bgp/route_checker.py +++ b/tests/bgp/route_checker.py @@ -2,7 +2,7 @@ import ipaddr as ipaddress import re import json -from bgp_helpers import parse_rib +from tests.bgp.bgp_helpers import parse_rib from tests.common.devices.eos import EosHost from tests.common.helpers.assertions import pytest_assert from tests.common.helpers.parallel import parallel_run diff --git a/tests/bgp/test_reliable_tsa.py b/tests/bgp/test_reliable_tsa.py index 3f1cdaa8ca2..3fd88bdcc10 100644 --- a/tests/bgp/test_reliable_tsa.py +++ b/tests/bgp/test_reliable_tsa.py @@ -8,8 +8,8 @@ from tests.common.platform.processes_utils import wait_critical_processes, _all_critical_processes_healthy from tests.common.platform.interface_utils import check_interface_status_of_up_ports from tests.bgp.bgp_helpers import get_tsa_chassisdb_config, get_sup_cfggen_tsa_value, verify_dut_configdb_tsa_value -from traffic_checker import get_traffic_shift_state -from route_checker import parse_routes_on_neighbors, check_and_log_routes_diff, \ +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 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, \ diff --git a/tests/bgp/test_startup_tsa_tsb_service.py b/tests/bgp/test_startup_tsa_tsb_service.py index f2d975a9798..d29a4d4c780 100644 --- a/tests/bgp/test_startup_tsa_tsb_service.py +++ b/tests/bgp/test_startup_tsa_tsb_service.py @@ -8,11 +8,11 @@ from tests.common.utilities import wait_until from tests.common.platform.processes_utils import wait_critical_processes, _all_critical_processes_healthy from tests.common.platform.interface_utils import check_interface_status_of_up_ports -from traffic_checker import get_traffic_shift_state, check_tsa_persistence_support -from route_checker import parse_routes_on_neighbors, check_and_log_routes_diff, \ +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 from tests.bgp.constants import TS_NORMAL, TS_MAINTENANCE -from tests.bgp.bgp_helpers import get_tsa_chassisdb_config, get_sup_cfggen_tsa_value, verify_dut_configdb_tsa_value pytestmark = [ pytest.mark.topology('t2') @@ -145,30 +145,6 @@ def nbrhosts_to_dut(duthost, nbrhosts): return dut_nbrhosts -def initial_check_before_and_after_test(duthosts): - """ - @summary: Common method to make sure the supervisor and line cards are in normal state before and after the test - """ - for duthost in duthosts: - if duthost.is_supervisor_node(): - # Initially make sure both supervisor and line cards are in BGP operational normal state - if get_tsa_chassisdb_config(duthost) != 'false' or get_sup_cfggen_tsa_value(duthost) != 'false': - duthost.shell('TSB') - duthost.shell('sudo config save -y') - pytest_assert('false' == get_tsa_chassisdb_config(duthost), - "Supervisor {} tsa_enabled config is enabled".format(duthost.hostname)) - - for linecard in duthosts.frontend_nodes: - # Issue TSB on the line card before proceeding further - if verify_dut_configdb_tsa_value(linecard) != 'false' or get_tsa_chassisdb_config(linecard) != 'false' or \ - get_traffic_shift_state(linecard, cmd='TSC no-stats') != TS_NORMAL: - linecard.shell('TSB') - linecard.shell('sudo config save -y') - # Ensure that the DUT is not in maintenance already before start of the test - pytest_assert(TS_NORMAL == get_traffic_shift_state(linecard, cmd='TSC no-stats'), - "DUT is not in normal state") - - def check_ssh_state(localhost, dut_ip, expected_state, timeout=60): """ Check the SSH state of DUT. @@ -208,7 +184,7 @@ def test_tsa_tsb_service_with_dut_cold_reboot(duthosts, localhost, enum_rand_one pytest.skip("TSA persistence not supported in the image") # Initially make sure both supervisor and line cards are in BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) try: # Get all routes on neighbors before doing reboot @@ -272,7 +248,7 @@ def test_tsa_tsb_service_with_dut_cold_reboot(duthosts, localhost, enum_rand_one finally: # Bring back the supervisor and line cards to the BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) # Verify DUT is in normal state after cold reboot scenario. if not (int_status_result and crit_process_check and TS_NORMAL == get_traffic_shift_state(duthost)): logging.info("DUT is not in normal state after cold reboot, doing config-reload") @@ -303,7 +279,7 @@ def test_tsa_tsb_service_with_dut_abnormal_reboot(duthosts, localhost, enum_rand pytest.skip("TSA persistence not supported in the image") # Initially make sure both supervisor and line cards are in BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) try: # Get all routes on neighbors before doing reboot @@ -383,7 +359,7 @@ def test_tsa_tsb_service_with_dut_abnormal_reboot(duthosts, localhost, enum_rand finally: # Bring back the supervisor and line cards to the BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) # Verify DUT is in normal state after abnormal reboot scenario. if not (int_status_result and crit_process_check and TS_NORMAL == get_traffic_shift_state(duthost)): logging.info("DUT is not in normal state after abnormal reboot, doing config-reload") @@ -418,7 +394,7 @@ def test_tsa_tsb_service_with_supervisor_cold_reboot(duthosts, localhost, enum_s if not check_tsa_persistence_support(linecard): pytest.skip("TSA persistence not supported in the image") # Initially make sure both supervisor and line cards are in BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) try: for linecard in duthosts.frontend_nodes: @@ -492,7 +468,7 @@ def test_tsa_tsb_service_with_supervisor_cold_reboot(duthosts, localhost, enum_s finally: # Bring back the supervisor and line cards to the BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) # Make sure DUT is in normal state after supervisor cold reboot for linecard in duthosts.frontend_nodes: @@ -540,7 +516,7 @@ def test_tsa_tsb_service_with_supervisor_abnormal_reboot(duthosts, localhost, en pytest.skip("TSA persistence not supported in the image") # Initially make sure both supervisor and line cards are in BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) try: for linecard in duthosts.frontend_nodes: @@ -635,7 +611,7 @@ def test_tsa_tsb_service_with_supervisor_abnormal_reboot(duthosts, localhost, en finally: # Bring back the supervisor and line cards to the BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) # Make sure DUT is in normal state after supervisor abnormal reboot for linecard in duthosts.frontend_nodes: @@ -677,7 +653,7 @@ def test_tsa_tsb_service_with_user_init_tsa(duthosts, localhost, enum_rand_one_p pytest.skip("TSA persistence not supported in the image") # Initially make sure both supervisor and line cards are in BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) try: # Get all routes on neighbors before doing reboot @@ -753,7 +729,7 @@ def test_tsa_tsb_service_with_user_init_tsa(duthosts, localhost, enum_rand_one_p pytest_assert(reboot_cause == COLD_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}".format(reboot_cause, COLD_REBOOT_CAUSE)) # Bring back the supervisor and line cards to the BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) @pytest.mark.disable_loganalyzer @@ -777,7 +753,7 @@ def test_user_init_tsa_while_service_run_on_dut(duthosts, localhost, enum_rand_o pytest.skip("TSA persistence not supported in the image") # Initially make sure both supervisor and line cards are in BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) try: # Get all routes on neighbors before doing reboot @@ -861,7 +837,7 @@ def test_user_init_tsa_while_service_run_on_dut(duthosts, localhost, enum_rand_o pytest_assert(reboot_cause == COLD_REBOOT_CAUSE, "Reboot cause {} did not match the trigger {}".format(reboot_cause, COLD_REBOOT_CAUSE)) # Bring back the supervisor and line cards to the BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) @pytest.mark.disable_loganalyzer @@ -884,7 +860,7 @@ def test_user_init_tsb_while_service_run_on_dut(duthosts, localhost, enum_rand_o pytest.skip("TSA persistence not supported in the image") # Initially make sure both supervisor and line cards are in BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) try: # Get all routes on neighbors before doing reboot @@ -948,7 +924,7 @@ def test_user_init_tsb_while_service_run_on_dut(duthosts, localhost, enum_rand_o finally: # Bring back the supervisor and line cards to the BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) # Verify DUT is in normal state after cold reboot scenario. if not (int_status_result and crit_process_check and TS_NORMAL == get_traffic_shift_state(duthost)): logging.info("DUT is not in normal state after cold reboot, doing config-reload") @@ -988,7 +964,7 @@ def test_user_init_tsb_on_sup_while_service_run_on_dut(duthosts, localhost, pytest.skip("TSA persistence not supported in the image") # Initially make sure both supervisor and line cards are in BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) try: for linecard in duthosts.frontend_nodes: @@ -1069,7 +1045,7 @@ def test_user_init_tsb_on_sup_while_service_run_on_dut(duthosts, localhost, finally: # Bring back the supervisor and line cards to the BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) for linecard in duthosts.frontend_nodes: # Make sure linecards are in Normal state and save the config to proceed further @@ -1107,7 +1083,7 @@ def test_tsa_tsb_timer_efficiency(duthosts, localhost, enum_rand_one_per_hwsku_f pytest.skip("TSA persistence not supported in the image") # Initially make sure both supervisor and line cards are in BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) try: # Get all routes on neighbors before doing reboot @@ -1185,7 +1161,7 @@ def test_tsa_tsb_timer_efficiency(duthosts, localhost, enum_rand_one_per_hwsku_f finally: # Bring back the supervisor and line cards to the BGP operational normal state - initial_check_before_and_after_test(duthosts) + initial_tsa_check_before_and_after_test(duthosts) # Verify DUT is in normal state after cold reboot scenario. if not (int_status_result and crit_process_check and TS_NORMAL == get_traffic_shift_state(duthost)): logging.info("DUT is not in normal state after cold reboot, doing config-reload") diff --git a/tests/bgp/test_traffic_shift.py b/tests/bgp/test_traffic_shift.py index e7f8bf62060..f13dc323810 100644 --- a/tests/bgp/test_traffic_shift.py +++ b/tests/bgp/test_traffic_shift.py @@ -2,15 +2,17 @@ import re import pytest from tests.common.devices.eos import EosHost -from bgp_helpers import get_routes_not_announced_to_bgpmon, remove_bgp_neighbors, restore_bgp_neighbors +from tests.bgp.bgp_helpers import get_routes_not_announced_to_bgpmon, remove_bgp_neighbors, restore_bgp_neighbors, \ + initial_tsa_check_before_and_after_test from tests.common import config_reload from tests.common.helpers.assertions import pytest_assert 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 route_checker import verify_only_loopback_routes_are_announced_to_neighs, parse_routes_on_neighbors, \ +from tests.bgp.route_checker import verify_only_loopback_routes_are_announced_to_neighs, parse_routes_on_neighbors, \ verify_current_routes_announced_to_neighs, check_and_log_routes_diff -from traffic_checker import get_traffic_shift_state, check_tsa_persistence_support, verify_traffic_shift_per_asic +from tests.bgp.traffic_checker import get_traffic_shift_state, check_tsa_persistence_support, \ + verify_traffic_shift_per_asic from tests.bgp.constants import TS_NORMAL, TS_MAINTENANCE, TS_NO_NEIGHBORS pytestmark = [ @@ -68,6 +70,9 @@ def test_TSA(duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, Verify all routes are announced to bgp monitor, and only loopback routes are announced to neighs """ duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] + # Initially make sure both supervisor and line cards are in BGP operational normal state + if tbinfo['topo']['type'] == 't2': + initial_tsa_check_before_and_after_test(duthosts) try: # Issue TSA on DUT duthost.shell("TSA") @@ -89,6 +94,9 @@ def test_TSA(duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, finally: # Recover to Normal state duthost.shell("TSB") + # Bring back the supervisor and line cards to the BGP operational normal state + if tbinfo['topo']['type'] == 't2': + initial_tsa_check_before_and_after_test(duthosts) def test_TSB(duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, nbrhosts, bgpmon_setup_teardown, tbinfo): @@ -98,6 +106,9 @@ def test_TSB(duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, nbrho and all routes are announced to neighbors """ duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] + # Initially make sure both supervisor and line cards are in BGP operational normal state + if tbinfo['topo']['type'] == 't2': + initial_tsa_check_before_and_after_test(duthosts) # Ensure that the DUT is not in maintenance already before start of the test pytest_assert(TS_NORMAL == get_traffic_shift_state(duthost), "DUT is not in normal state") @@ -131,9 +142,13 @@ def test_TSB(duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, nbrho if not check_and_log_routes_diff(duthost, nbrhosts, orig_v6_routes, cur_v6_routes, 6): pytest.fail("Not all ipv6 routes are announced to neighbors") + # Bring back the supervisor and line cards to the BGP operational normal state + if tbinfo['topo']['type'] == 't2': + initial_tsa_check_before_and_after_test(duthosts) + def test_TSA_B_C_with_no_neighbors(duthosts, enum_rand_one_per_hwsku_frontend_hostname, - bgpmon_setup_teardown, nbrhosts, core_dump_and_config_check): + bgpmon_setup_teardown, nbrhosts, core_dump_and_config_check, tbinfo): """ Test TSA, TSB, TSC with no neighbors on ASIC0 in case of multi-asic and single-asic. """ @@ -141,6 +156,9 @@ def test_TSA_B_C_with_no_neighbors(duthosts, enum_rand_one_per_hwsku_frontend_ho bgp_neighbors = {} duts_data = core_dump_and_config_check asic_index = 0 if duthost.is_multi_asic else DEFAULT_ASIC_ID + # Initially make sure both supervisor and line cards are in BGP operational normal state + if tbinfo['topo']['type'] == 't2': + initial_tsa_check_before_and_after_test(duthosts) # Ensure that the DUT is not in maintenance already before start of the test pytest_assert(TS_NORMAL == get_traffic_shift_state(duthost), "DUT is not in normal state") @@ -193,6 +211,10 @@ def test_TSA_B_C_with_no_neighbors(duthosts, enum_rand_one_per_hwsku_frontend_ho if not check_and_log_routes_diff(duthost, nbrhosts, orig_v6_routes, cur_v6_routes, 6): pytest.fail("Not all ipv6 routes are announced to neighbors") + # Bring back the supervisor and line cards to the BGP operational normal state + if tbinfo['topo']['type'] == 't2': + initial_tsa_check_before_and_after_test(duthosts) + @pytest.mark.disable_loganalyzer def test_TSA_TSB_with_config_reload(duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, nbrhosts, @@ -202,6 +224,9 @@ def test_TSA_TSB_with_config_reload(duthosts, enum_rand_one_per_hwsku_frontend_h Verify all routes are announced to bgp monitor, and only loopback routes are announced to neighs """ duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] + # Initially make sure both supervisor and line cards are in BGP operational normal state + if tbinfo['topo']['type'] == 't2': + initial_tsa_check_before_and_after_test(duthosts) # Ensure that the DUT is not in maintenance already before start of the test pytest_assert(TS_NORMAL == get_traffic_shift_state(duthost), "DUT is not in normal state") @@ -255,6 +280,9 @@ def test_TSA_TSB_with_config_reload(duthosts, enum_rand_one_per_hwsku_frontend_h duthost, nbrhosts, orig_v6_routes, cur_v6_routes, 6): if not check_and_log_routes_diff(duthost, nbrhosts, orig_v6_routes, cur_v6_routes, 6): pytest.fail("Not all ipv6 routes are announced to neighbors") + # Bring back the supervisor and line cards to the BGP operational normal state + if tbinfo['topo']['type'] == 't2': + initial_tsa_check_before_and_after_test(duthosts) @pytest.mark.disable_loganalyzer @@ -266,6 +294,9 @@ def test_load_minigraph_with_traffic_shift_away(duthosts, enum_rand_one_per_hwsk Verify all routes are announced to bgp monitor, and only loopback routes are announced to neighs """ duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] + # Initially make sure both supervisor and line cards are in BGP operational normal state + if tbinfo['topo']['type'] == 't2': + initial_tsa_check_before_and_after_test(duthosts) # Ensure that the DUT is not in maintenance already before start of the test pytest_assert(TS_NORMAL == get_traffic_shift_state(duthost), "DUT is not in normal state") @@ -316,3 +347,7 @@ def test_load_minigraph_with_traffic_shift_away(duthosts, enum_rand_one_per_hwsk duthost, nbrhosts, orig_v6_routes, cur_v6_routes, 6): if not check_and_log_routes_diff(duthost, nbrhosts, orig_v6_routes, cur_v6_routes, 6): pytest.fail("Not all ipv6 routes are announced to neighbors") + + # Bring back the supervisor and line cards to the BGP operational normal state + if tbinfo['topo']['type'] == 't2': + initial_tsa_check_before_and_after_test(duthosts) diff --git a/tests/bgp/test_traffic_shift_sup.py b/tests/bgp/test_traffic_shift_sup.py index 6a36c85d61f..f512867686c 100644 --- a/tests/bgp/test_traffic_shift_sup.py +++ b/tests/bgp/test_traffic_shift_sup.py @@ -4,7 +4,8 @@ import time from tests.common.helpers.assertions import pytest_assert from tests.common import config_reload -from traffic_checker import get_traffic_shift_state +from tests.bgp.traffic_checker import get_traffic_shift_state +from tests.bgp.bgp_helpers import initial_tsa_check_before_and_after_test pytestmark = [ pytest.mark.topology('t2') @@ -77,10 +78,12 @@ def test_TSA(self, duthosts, enum_supervisor_dut_hostname, check_support, creds) Test TSA Verify all linecards transition to maintenance state after TSA on supervisor """ + # Initially make sure both supervisor and line cards are in BGP operational normal state + initial_tsa_check_before_and_after_test(duthosts) self.setup_dutinfo(duthosts, enum_supervisor_dut_hostname, creds) try: # Issue TSA on DUT - self.run_cmd_on_sup("sudo TSA") + self.duthost.shell('TSA') # Verify DUT is in maintenance state. self.verify_traffic_shift_state_all_lcs(TS_MAINTENANCE, "maintenance") except Exception as e: @@ -88,23 +91,29 @@ def test_TSA(self, duthosts, enum_supervisor_dut_hostname, check_support, creds) logger.error("Exception caught in TSB test. Error message: {}".format(e)) finally: # Issue TSB on DUT to recover the chassis - self.run_cmd_on_sup("sudo TSB") + self.duthost.shell('TSB') + # Bring back the supervisor and line cards to the BGP operational normal state + initial_tsa_check_before_and_after_test(duthosts) def test_TSB(self, duthosts, enum_supervisor_dut_hostname, check_support, creds): """ Test TSB Verify all linecards transition back to normal state from maintenance after TSB on supervisor """ + # Initially make sure both supervisor and line cards are in BGP operational normal state + initial_tsa_check_before_and_after_test(duthosts) self.setup_dutinfo(duthosts, enum_supervisor_dut_hostname, creds) try: # Issue TSA on DUT to move chassis to maintenance - self.run_cmd_on_sup("sudo TSA") + self.duthost.shell('TSA') self.verify_traffic_shift_state_all_lcs(TS_MAINTENANCE, "maintenance") # Recover to Normal state - self.run_cmd_on_sup("sudo TSB") + self.duthost.shell('TSB') # Verify DUT is in normal state self.verify_traffic_shift_state_all_lcs(TS_NORMAL, "normal") + # Bring back the supervisor and line cards to the BGP operational normal state + initial_tsa_check_before_and_after_test(duthosts) except Exception as e: # Log exception logger.error("Exception caught in TSB test. Error message: {}".format(e)) @@ -116,27 +125,31 @@ def test_TSA_TSB_chassis_with_config_reload(self, duthosts, enum_supervisor_dut_ Verify all linecards remain in Maintenance state after TSA and config reload on supervisor Verify all linecards remain in Normal state after TSB and config reload on supervisor """ + # Initially make sure both supervisor and line cards are in BGP operational normal state + initial_tsa_check_before_and_after_test(duthosts) self.setup_dutinfo(duthosts, enum_supervisor_dut_hostname, creds) try: # Issue TSA on DUT to move chassis to maintenance - self.run_cmd_on_sup("sudo TSA") + self.duthost.shell('TSA') self.verify_traffic_shift_state_all_lcs(TS_MAINTENANCE, "maintenance") # Save config and perform config reload on all LCs - self.run_cmd_on_sup("rexec all -c 'sudo config save -y'") + self.duthost.shell('sudo config save -y') self.config_reload_all_lcs() # Verify DUT is still in maintenance state. self.verify_traffic_shift_state_all_lcs(TS_MAINTENANCE, "maintenance") finally: # Recover to Normal state - self.run_cmd_on_sup("sudo TSB") + self.duthost.shell('TSB') # Verify DUT is in normal state. self.verify_traffic_shift_state_all_lcs(TS_NORMAL, "normal") # Save config and perform config reload on all LCs - self.run_cmd_on_sup("rexec all -c 'sudo config save -y'") + self.duthost.shell('sudo config save -y') self.config_reload_all_lcs() # Verify DUT is in normal state. self.verify_traffic_shift_state_all_lcs(TS_NORMAL, "normal") + # Bring back the supervisor and line cards to the BGP operational normal state + initial_tsa_check_before_and_after_test(duthosts)