4
4
5
5
from tests .common .helpers .assertions import pytest_assert
6
6
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
8
8
9
9
pytestmark = [
10
10
pytest .mark .disable_loganalyzer ,
@@ -22,9 +22,17 @@ class TestMemoryExhaustion:
22
22
"""
23
23
This test case is used to verify that DUT will reboot when it runs out of memory.
24
24
"""
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 )
25
32
26
33
@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 ):
28
36
yield
29
37
# If the SSH connection is not established, or any critical process is exited,
30
38
# 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
41
49
'Recover {} by PDU reboot failed' .format (hostname ))
42
50
# Wait until all critical processes are healthy.
43
51
wait_critical_processes (duthost )
52
+ self .wait_lc_healthy_if_sup (duthost , duthosts )
44
53
45
54
def test_memory_exhaustion (self , duthosts , enum_rand_one_per_hwsku_hostname , localhost ):
46
55
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
68
77
'DUT {} did not startup' .format (hostname ))
69
78
# Wait until all critical processes are healthy.
70
79
wait_critical_processes (duthost )
80
+ self .wait_lc_healthy_if_sup (duthost , duthosts )
71
81
# Verify DUT uptime is later than the time when the test case started running.
72
82
dut_uptime = duthost .get_up_time ()
73
83
pytest_assert (dut_uptime > dut_datetime , "Device {} did not reboot" .format (hostname ))
0 commit comments