Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tests/common/fixtures/duthost_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions tests/pc/test_po_cleanup.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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),
Expand Down
Loading