From 9a86f28b07bbe96f941344b5027fe6cdb61643c2 Mon Sep 17 00:00:00 2001 From: Chenyang Wang <49756587+cyw233@users.noreply.github.com> Date: Wed, 12 Feb 2025 17:11:22 +1100 Subject: [PATCH] feat: add fixture for disabling route check (#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--']" 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: {{#012 "asic1": {#012 "Unaccounted_ROUTE_ENTRY_TABLE_entries": [#012 "100.1.0.22/32",#012 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: jianquanye@microsoft.com --- tests/conftest.py | 35 +++++++++++++++++++ .../link_flap/test_cont_link_flap.py | 1 + 2 files changed, 36 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 1803b97f16c..9c3af23299e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2548,6 +2548,41 @@ def _remove_entry(table_name, key_name, config): add_custom_msg(request, f"{DUT_CHECK_NAMESPACE}.config_db_check_pass", config_db_check_pass) +@pytest.fixture(scope="module", autouse=True) +def temporarily_disable_route_check(request, duthosts): + check_flag = False + for m in request.node.iter_markers(): + if m.name == "disable_route_check": + check_flag = True + break + + def run_route_check(dut): + rc = dut.shell("sudo route_check.py", module_ignore_errors=True) + if rc['rc'] != 0: + pytest.fail("route_check.py failed on DUT {} in test setup/teardown stage".format(dut.hostname)) + + if check_flag: + with SafeThreadPoolExecutor(max_workers=8) as executor: + for duthost in duthosts.frontend_nodes: + executor.submit(run_route_check, duthost) + + with SafeThreadPoolExecutor(max_workers=8) as executor: + for duthost in duthosts.frontend_nodes: + executor.submit(duthost.shell, "sudo monit stop routeCheck") + + yield + + if check_flag: + try: + with SafeThreadPoolExecutor(max_workers=8) as executor: + for duthost in duthosts.frontend_nodes: + executor.submit(run_route_check, duthost) + finally: + with SafeThreadPoolExecutor(max_workers=8) as executor: + for duthost in duthosts.frontend_nodes: + executor.submit(duthost.shell, "sudo monit start routeCheck") + + @pytest.fixture(scope="function") def on_exit(): ''' diff --git a/tests/platform_tests/link_flap/test_cont_link_flap.py b/tests/platform_tests/link_flap/test_cont_link_flap.py index 62743ed4cc6..dfc7ff31f05 100644 --- a/tests/platform_tests/link_flap/test_cont_link_flap.py +++ b/tests/platform_tests/link_flap/test_cont_link_flap.py @@ -23,6 +23,7 @@ from tests.common.platform.device_utils import toggle_one_link pytestmark = [ + pytest.mark.disable_route_check, pytest.mark.disable_loganalyzer, pytest.mark.topology('any') ]