Skip to content

Commit ec9a2c8

Browse files
cyw233mssonicbld
authored andcommitted
fix: disable route check for po cleanup test cases (sonic-net#21320)
1 parent 1997103 commit ec9a2c8

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

tests/common/fixtures/duthost_utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ def backup_and_restore_config_db_session(duthosts):
9393
yield func
9494

9595

96+
def stop_route_checker_on_duthost(duthost):
97+
duthost.command("sudo monit stop routeCheck", module_ignore_errors=True)
98+
99+
100+
def start_route_checker_on_duthost(duthost):
101+
duthost.command("sudo monit start routeCheck", module_ignore_errors=True)
102+
103+
96104
def _disable_route_checker(duthost):
97105
"""
98106
Some test cases will add static routes for test, which may trigger route_checker
@@ -102,9 +110,9 @@ def _disable_route_checker(duthost):
102110
Args:
103111
duthost: DUT fixture
104112
"""
105-
duthost.command('monit stop routeCheck', module_ignore_errors=True)
113+
stop_route_checker_on_duthost(duthost)
106114
yield
107-
duthost.command('monit start routeCheck', module_ignore_errors=True)
115+
start_route_checker_on_duthost(duthost)
108116

109117

110118
@pytest.fixture

tests/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
from tests.common.devices.vmhost import VMHost
3131
from tests.common.devices.base import NeighborDevice
3232
from tests.common.devices.cisco import CiscoHost
33-
from tests.common.fixtures.duthost_utils import backup_and_restore_config_db_session # noqa: F401
33+
from tests.common.fixtures.duthost_utils import backup_and_restore_config_db_session, \
34+
stop_route_checker_on_duthost, start_route_checker_on_duthost # noqa: F401
3435
from tests.common.fixtures.ptfhost_utils import ptf_portmap_file # noqa: F401
3536
from tests.common.fixtures.ptfhost_utils import ptf_test_port_map_active_active # noqa: F401
3637
from tests.common.fixtures.ptfhost_utils import run_icmp_responder_session # noqa: F401
@@ -2899,7 +2900,7 @@ def run_route_check():
28992900

29002901
with SafeThreadPoolExecutor(max_workers=8) as executor:
29012902
for duthost in duthosts.frontend_nodes:
2902-
executor.submit(duthost.shell, "sudo monit stop routeCheck")
2903+
executor.submit(stop_route_checker_on_duthost, duthost)
29032904

29042905
yield
29052906

@@ -2909,7 +2910,7 @@ def run_route_check():
29092910
finally:
29102911
with SafeThreadPoolExecutor(max_workers=8) as executor:
29112912
for duthost in duthosts.frontend_nodes:
2912-
executor.submit(duthost.shell, "sudo monit start routeCheck")
2913+
executor.submit(start_route_checker_on_duthost, duthost)
29132914
else:
29142915
logger.info("Skipping temporarily_disable_route_check fixture")
29152916
yield

tests/pc/test_po_cleanup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pytest
22
import logging
3+
4+
from tests.common.fixtures.duthost_utils import stop_route_checker_on_duthost
35
from tests.common.utilities import wait_until
46
from tests.common import config_reload
57
from tests.common.plugins.loganalyzer.loganalyzer import LogAnalyzer
@@ -37,6 +39,15 @@ def ignore_expected_loganalyzer_exceptions(enum_rand_one_per_hwsku_frontend_host
3739
loganalyzer[enum_rand_one_per_hwsku_frontend_hostname].expect_regex.extend(expectRegex)
3840

3941

42+
@pytest.fixture(autouse=True)
43+
def disable_route_check_for_duthost(duthosts, enum_rand_one_per_hwsku_frontend_hostname):
44+
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
45+
logging.info("Stopping route check on DUT {}".format(duthost.hostname))
46+
stop_route_checker_on_duthost(duthost)
47+
48+
yield
49+
50+
4051
def check_kernel_po_interface_cleaned(duthost, asic_index):
4152
namespace = duthost.get_namespace_from_asic_id(asic_index)
4253
res = duthost.shell(duthost.get_linux_ip_cmd_for_namespace("ip link show | grep -c PortChannel", namespace),

0 commit comments

Comments
 (0)