diff --git a/tests/common/plugins/sanity_check/checks.py b/tests/common/plugins/sanity_check/checks.py index 81ff0df9466..8b1fff29f09 100644 --- a/tests/common/plugins/sanity_check/checks.py +++ b/tests/common/plugins/sanity_check/checks.py @@ -106,7 +106,7 @@ def _find_down_ports(dut, phy_interfaces, ip_interfaces): def check_interfaces(duthosts): def _check(): check_results = [] - for dut in duthosts: + for dut in duthosts.frontend_nodes: logger.info("Checking interfaces status on %s..." % dut.hostname) networking_uptime = dut.get_networking_uptime().seconds @@ -161,7 +161,7 @@ def _check(): def check_bgp(duthosts): def _check(): check_results = [] - for dut in duthosts: + for dut in duthosts.frontend_nodes: def _check_bgp_status_helper(): asic_check_results = [] bgp_facts = dut.bgp_facts(asic_index='all') diff --git a/tests/conftest.py b/tests/conftest.py index 739bf6be6d8..55f959c1169 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -880,3 +880,19 @@ def duthost_console(localhost, creds, request): console_password=creds['console_password'][vars['console_type']]) yield host host.disconnect() + +@pytest.fixture(scope='session') +def cleanup_cache_for_session(request): + """ + This fixture allows developers to cleanup the cached data for all DUTs in the testbed before test. + Use cases: + - Running tests where some 'facts' about the DUT that get cached are changed. + - Running tests/regression without running test_pretest which has a test to clean up cache (PR#2978) + - Test case development phase to work out testbed information changes. + + This fixture is not automatically applied, if you want to use it, you have to add a call to it in your tests. + """ + tbname, tbinfo = get_tbinfo(request) + cache.cleanup(zone=tbname) + for a_dut in tbinfo['duts']: + cache.cleanup(zone=a_dut)