Skip to content

Commit f4b4c2d

Browse files
authored
sanity check fixes for chassis; and cache cleanup at the end of pytest session (#2958)
Approach What is the motivation for this PR? sanity check: The BGP and interface sanity checks for multi-dut were changed to iterate through all the nodes in a multi-dut setup. However, for a T2 chassis, the multi-dut testbed contains a supervisor card as well, which doesn't have any BGP/PORT configuration. Thus, these checks fail for supervisor card. cache cleanup: If we change the inventory file and re-run pytest, the old cached data for the inventory is used instead of picking up the changes. How did you do it? sanity_check: Iterate through frontend_nodes of duthosts instead of all the nodes. cache cleanup: Added fixture cleanup_cache_for_session that is called at the beginning of a session to remove the cached facts for all the DUTs in the testbed. This is not an automatic fixture, and is needed in the following scenarios: 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.
1 parent 4f88aa2 commit f4b4c2d

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

tests/common/plugins/sanity_check/checks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _find_down_ports(dut, phy_interfaces, ip_interfaces):
106106
def check_interfaces(duthosts):
107107
def _check():
108108
check_results = []
109-
for dut in duthosts:
109+
for dut in duthosts.frontend_nodes:
110110
logger.info("Checking interfaces status on %s..." % dut.hostname)
111111

112112
networking_uptime = dut.get_networking_uptime().seconds
@@ -161,7 +161,7 @@ def _check():
161161
def check_bgp(duthosts):
162162
def _check():
163163
check_results = []
164-
for dut in duthosts:
164+
for dut in duthosts.frontend_nodes:
165165
def _check_bgp_status_helper():
166166
asic_check_results = []
167167
bgp_facts = dut.bgp_facts(asic_index='all')

tests/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,3 +880,19 @@ def duthost_console(localhost, creds, request):
880880
console_password=creds['console_password'][vars['console_type']])
881881
yield host
882882
host.disconnect()
883+
884+
@pytest.fixture(scope='session')
885+
def cleanup_cache_for_session(request):
886+
"""
887+
This fixture allows developers to cleanup the cached data for all DUTs in the testbed before test.
888+
Use cases:
889+
- Running tests where some 'facts' about the DUT that get cached are changed.
890+
- Running tests/regression without running test_pretest which has a test to clean up cache (PR#2978)
891+
- Test case development phase to work out testbed information changes.
892+
893+
This fixture is not automatically applied, if you want to use it, you have to add a call to it in your tests.
894+
"""
895+
tbname, tbinfo = get_tbinfo(request)
896+
cache.cleanup(zone=tbname)
897+
for a_dut in tbinfo['duts']:
898+
cache.cleanup(zone=a_dut)

0 commit comments

Comments
 (0)