Skip to content

Commit

Permalink
refactor: optimize startup tsa tsb test
Browse files Browse the repository at this point in the history
  • Loading branch information
cyw233 committed Jan 22, 2025
1 parent 97f8fb4 commit b3ea1fb
Show file tree
Hide file tree
Showing 3 changed files with 949 additions and 689 deletions.
19 changes: 12 additions & 7 deletions tests/bgp/bgp_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from tests.common.helpers.assertions import pytest_assert
from tests.common.helpers.constants import UPSTREAM_NEIGHBOR_MAP, DOWNSTREAM_NEIGHBOR_MAP, DEFAULT_NAMESPACE, \
DEFAULT_ASIC_ID
from tests.common.helpers.multi_thread_utils import SafeThreadPoolExecutor
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
Expand Down Expand Up @@ -896,12 +897,16 @@ def initial_tsa_check_before_and_after_test(duthosts):
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) is not 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')
def run_tsb_on_linecard_and_verify(lc):
if verify_dut_configdb_tsa_value(lc) is not False or get_tsa_chassisdb_config(lc) != 'false' or \
get_traffic_shift_state(lc, cmd='TSC no-stats') != TS_NORMAL:
lc.shell('TSB')
lc.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'),
pytest_assert(TS_NORMAL == get_traffic_shift_state(lc, cmd='TSC no-stats'),
"DUT is not in normal state")

# Issue TSB on the line card before proceeding further
with SafeThreadPoolExecutor(max_workers=8) as executor:
for linecard in duthosts.frontend_nodes:
executor.submit(run_tsb_on_linecard_and_verify, linecard)
Loading

0 comments on commit b3ea1fb

Please sign in to comment.