From 467db16b300e003aae1014b3bf27dd419c0d02d8 Mon Sep 17 00:00:00 2001 From: Chenyang Wang Date: Thu, 13 Nov 2025 11:31:52 +1100 Subject: [PATCH] fix: disable route check for po cleanup test cases --- tests/common/fixtures/duthost_utils.py | 12 ++++++++++-- tests/conftest.py | 7 ++++--- tests/pc/test_po_cleanup.py | 11 +++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/tests/common/fixtures/duthost_utils.py b/tests/common/fixtures/duthost_utils.py index af799f325da..c60d0fa162b 100755 --- a/tests/common/fixtures/duthost_utils.py +++ b/tests/common/fixtures/duthost_utils.py @@ -93,6 +93,14 @@ def backup_and_restore_config_db_session(duthosts): yield func +def stop_route_checker_on_duthost(duthost): + duthost.command("sudo monit stop routeCheck", module_ignore_errors=True) + + +def start_route_checker_on_duthost(duthost): + duthost.command("sudo monit start routeCheck", module_ignore_errors=True) + + def _disable_route_checker(duthost): """ Some test cases will add static routes for test, which may trigger route_checker @@ -102,9 +110,9 @@ def _disable_route_checker(duthost): Args: duthost: DUT fixture """ - duthost.command('monit stop routeCheck', module_ignore_errors=True) + stop_route_checker_on_duthost(duthost) yield - duthost.command('monit start routeCheck', module_ignore_errors=True) + start_route_checker_on_duthost(duthost) @pytest.fixture diff --git a/tests/conftest.py b/tests/conftest.py index 1d8d03484a1..8de06d24fa1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -34,7 +34,8 @@ from tests.common.devices.vmhost import VMHost from tests.common.devices.base import NeighborDevice from tests.common.devices.cisco import CiscoHost -from tests.common.fixtures.duthost_utils import backup_and_restore_config_db_session # noqa: F401 +from tests.common.fixtures.duthost_utils import backup_and_restore_config_db_session, \ + stop_route_checker_on_duthost, start_route_checker_on_duthost # noqa: F401 from tests.common.fixtures.ptfhost_utils import ptf_portmap_file # noqa: F401 from tests.common.fixtures.ptfhost_utils import ptf_test_port_map_active_active # noqa: F401 from tests.common.fixtures.ptfhost_utils import run_icmp_responder_session # noqa: F401 @@ -3019,7 +3020,7 @@ def run_route_check(): with SafeThreadPoolExecutor(max_workers=8) as executor: for duthost in duthosts.frontend_nodes: - executor.submit(duthost.shell, "sudo monit stop routeCheck") + executor.submit(stop_route_checker_on_duthost, duthost) yield @@ -3029,7 +3030,7 @@ def run_route_check(): finally: with SafeThreadPoolExecutor(max_workers=8) as executor: for duthost in duthosts.frontend_nodes: - executor.submit(duthost.shell, "sudo monit start routeCheck") + executor.submit(start_route_checker_on_duthost, duthost) else: logger.info("Skipping temporarily_disable_route_check fixture") yield diff --git a/tests/pc/test_po_cleanup.py b/tests/pc/test_po_cleanup.py index 84fdb9e1728..936c93c2844 100644 --- a/tests/pc/test_po_cleanup.py +++ b/tests/pc/test_po_cleanup.py @@ -1,5 +1,7 @@ import pytest import logging + +from tests.common.fixtures.duthost_utils import stop_route_checker_on_duthost from tests.common.utilities import wait_until from tests.common import config_reload from tests.common.plugins.loganalyzer.loganalyzer import LogAnalyzer @@ -37,6 +39,15 @@ def ignore_expected_loganalyzer_exceptions(enum_rand_one_per_hwsku_frontend_host loganalyzer[enum_rand_one_per_hwsku_frontend_hostname].expect_regex.extend(expectRegex) +@pytest.fixture(autouse=True) +def disable_route_check_for_duthost(duthosts, enum_rand_one_per_hwsku_frontend_hostname): + duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] + logging.info("Stopping route check on DUT {}".format(duthost.hostname)) + stop_route_checker_on_duthost(duthost) + + yield + + def check_kernel_po_interface_cleaned(duthost, asic_index): namespace = duthost.get_namespace_from_asic_id(asic_index) res = duthost.shell(duthost.get_linux_ip_cmd_for_namespace("ip link show | grep -c PortChannel", namespace),