Skip to content

Commit b647897

Browse files
cyw233nnelluri-cisco
authored andcommitted
feat: add fixture for disabling route check (sonic-net#16876)
Description of PR Add a module-level fixture for temporarily disabling route check for a test module Summary: Fixes # (issue) Microsoft ADO 31326413 Approach What is the motivation for this PR? In our recent Cisco T2 Nightly run, we observed that we would get the following error syslog during some test modules: E Failed: Processes "['analyze_logs--<MultiAsicSonicHost dut-lc1-1>']" failed with exit code "1" E Exception: E match: 1 E expected_match: 0 E expected_missing_match: 0 E E Match Messages: E 2025 Feb 3 03:03:29.550827 svcstr2-8800-lc1-1 ERR monit[914]: 'routeCheck' status failed (255) -- Failure results: {{sonic-net#12 "asic1": {sonic-net#12 "Unaccounted_ROUTE_ENTRY_TABLE_entries": [sonic-net#12 "100.1.0.22/32",sonic-net#12 After discussion, we decided to add a fixture so users can disable route check for a test module if they think that test tends to have such error syslog. How did you do it? How did you verify/test it? I ran the updated code and can confirm it's working well. co-authorized by: [email protected]
1 parent e55ed7b commit b647897

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,6 +2616,41 @@ def _remove_entry(table_name, key_name, config):
26162616
add_custom_msg(request, f"{DUT_CHECK_NAMESPACE}.config_db_check_failed", config_db_check_failed)
26172617

26182618

2619+
@pytest.fixture(scope="module", autouse=True)
2620+
def temporarily_disable_route_check(request, duthosts):
2621+
check_flag = False
2622+
for m in request.node.iter_markers():
2623+
if m.name == "disable_route_check":
2624+
check_flag = True
2625+
break
2626+
2627+
def run_route_check(dut):
2628+
rc = dut.shell("sudo route_check.py", module_ignore_errors=True)
2629+
if rc['rc'] != 0:
2630+
pytest.fail("route_check.py failed on DUT {} in test setup/teardown stage".format(dut.hostname))
2631+
2632+
if check_flag:
2633+
with SafeThreadPoolExecutor(max_workers=8) as executor:
2634+
for duthost in duthosts.frontend_nodes:
2635+
executor.submit(run_route_check, duthost)
2636+
2637+
with SafeThreadPoolExecutor(max_workers=8) as executor:
2638+
for duthost in duthosts.frontend_nodes:
2639+
executor.submit(duthost.shell, "sudo monit stop routeCheck")
2640+
2641+
yield
2642+
2643+
if check_flag:
2644+
try:
2645+
with SafeThreadPoolExecutor(max_workers=8) as executor:
2646+
for duthost in duthosts.frontend_nodes:
2647+
executor.submit(run_route_check, duthost)
2648+
finally:
2649+
with SafeThreadPoolExecutor(max_workers=8) as executor:
2650+
for duthost in duthosts.frontend_nodes:
2651+
executor.submit(duthost.shell, "sudo monit start routeCheck")
2652+
2653+
26192654
@pytest.fixture(scope="function")
26202655
def on_exit():
26212656
'''

tests/platform_tests/link_flap/test_cont_link_flap.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from tests.common.platform.device_utils import toggle_one_link
2424

2525
pytestmark = [
26+
pytest.mark.disable_route_check,
2627
pytest.mark.disable_loganalyzer,
2728
pytest.mark.topology('any')
2829
]

0 commit comments

Comments
 (0)