Skip to content

Commit 4a27059

Browse files
committed
fix: disable route check for po cleanup test cases
1 parent 1fa9b46 commit 4a27059

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

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
@@ -34,7 +34,8 @@
3434
from tests.common.devices.vmhost import VMHost
3535
from tests.common.devices.base import NeighborDevice
3636
from tests.common.devices.cisco import CiscoHost
37-
from tests.common.fixtures.duthost_utils import backup_and_restore_config_db_session # noqa: F401
37+
from tests.common.fixtures.duthost_utils import backup_and_restore_config_db_session, \
38+
stop_route_checker_on_duthost, start_route_checker_on_duthost # noqa: F401
3839
from tests.common.fixtures.ptfhost_utils import ptf_portmap_file # noqa: F401
3940
from tests.common.fixtures.ptfhost_utils import ptf_test_port_map_active_active # noqa: F401
4041
from tests.common.fixtures.ptfhost_utils import run_icmp_responder_session # noqa: F401
@@ -3019,7 +3020,7 @@ def run_route_check():
30193020

30203021
with SafeThreadPoolExecutor(max_workers=8) as executor:
30213022
for duthost in duthosts.frontend_nodes:
3022-
executor.submit(duthost.shell, "sudo monit stop routeCheck")
3023+
executor.submit(stop_route_checker_on_duthost, duthost)
30233024

30243025
yield
30253026

@@ -3029,7 +3030,7 @@ def run_route_check():
30293030
finally:
30303031
with SafeThreadPoolExecutor(max_workers=8) as executor:
30313032
for duthost in duthosts.frontend_nodes:
3032-
executor.submit(duthost.shell, "sudo monit start routeCheck")
3033+
executor.submit(start_route_checker_on_duthost, duthost)
30333034
else:
30343035
logger.info("Skipping temporarily_disable_route_check fixture")
30353036
yield

tests/pc/test_po_cleanup.py

Lines changed: 12 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, start_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,16 @@ 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+
stop_route_checker_on_duthost(duthost)
46+
47+
yield
48+
49+
start_route_checker_on_duthost(duthost)
50+
51+
4052
def check_kernel_po_interface_cleaned(duthost, asic_index):
4153
namespace = duthost.get_namespace_from_asic_id(asic_index)
4254
res = duthost.shell(duthost.get_linux_ip_cmd_for_namespace("ip link show | grep -c PortChannel", namespace),

0 commit comments

Comments
 (0)