Skip to content

Commit 945d089

Browse files
wenyiz2021AharonMalkin
authored andcommitted
[chassis] accomodate test_memory_exhaustion.py if random dut is chassis sup (sonic-net#9075)
1 parent 99f1702 commit 945d089

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

tests/common/platform/processes_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def wait_critical_processes(dut):
6363
@param dut: The AnsibleHost object of DUT. For interacting with DUT.
6464
"""
6565
timeout = reset_timeout(dut)
66+
# No matter what we set in inventory file, we always set sup timeout to 900
67+
# because most SUPs have 10+ dockers that need to come up
68+
if dut.is_supervisor_node():
69+
timeout = 900
6670
logging.info("Wait until all critical processes are healthy in {} sec"
6771
.format(timeout))
6872
pytest_assert(wait_until(timeout, 20, 0, _all_critical_processes_healthy, dut),

tests/platform_tests/test_memory_exhaustion.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from tests.common.helpers.assertions import pytest_assert
66
from tests.common.platform.processes_utils import wait_critical_processes
7-
from tests.common.reboot import SONIC_SSH_PORT, SONIC_SSH_REGEX
7+
from tests.common.reboot import SONIC_SSH_PORT, SONIC_SSH_REGEX, wait_for_startup
88

99
pytestmark = [
1010
pytest.mark.disable_loganalyzer,
@@ -22,9 +22,17 @@ class TestMemoryExhaustion:
2222
"""
2323
This test case is used to verify that DUT will reboot when it runs out of memory.
2424
"""
25+
def wait_lc_healthy_if_sup(self, duthost, duthosts, localhost):
26+
# For sup, we also need to ensure linecards are back and healthy for following tests
27+
is_sup = duthost.get_facts().get("modular_chassis") and duthost.is_supervisor_node()
28+
if is_sup:
29+
for lc in duthosts.frontend_nodes:
30+
wait_for_startup(lc, localhost, delay=10, timeout=300)
31+
wait_critical_processes(lc)
2532

2633
@pytest.fixture(autouse=True)
27-
def tearDown(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, pdu_controller):
34+
def tearDown(self, duthosts, enum_rand_one_per_hwsku_hostname,
35+
localhost, pdu_controller):
2836
yield
2937
# If the SSH connection is not established, or any critical process is exited,
3038
# try to recover the DUT by PDU reboot.
@@ -41,6 +49,7 @@ def tearDown(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, pdu_co
4149
'Recover {} by PDU reboot failed'.format(hostname))
4250
# Wait until all critical processes are healthy.
4351
wait_critical_processes(duthost)
52+
self.wait_lc_healthy_if_sup(duthost, duthosts)
4453

4554
def test_memory_exhaustion(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost):
4655
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
@@ -68,6 +77,7 @@ def test_memory_exhaustion(self, duthosts, enum_rand_one_per_hwsku_hostname, loc
6877
'DUT {} did not startup'.format(hostname))
6978
# Wait until all critical processes are healthy.
7079
wait_critical_processes(duthost)
80+
self.wait_lc_healthy_if_sup(duthost, duthosts)
7181
# Verify DUT uptime is later than the time when the test case started running.
7282
dut_uptime = duthost.get_up_time()
7383
pytest_assert(dut_uptime > dut_datetime, "Device {} did not reboot".format(hostname))

0 commit comments

Comments
 (0)