Skip to content

[chassis] accomodate test_memory_exhaustion.py if random dut is chassis sup #9075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Aug 3, 2023
4 changes: 4 additions & 0 deletions tests/common/platform/processes_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ def wait_critical_processes(dut):
@param dut: The AnsibleHost object of DUT. For interacting with DUT.
"""
timeout = reset_timeout(dut)
# No matter what we set in inventory file, we always set sup timeout to 900
# because most SUPs have 10+ dockers that need to come up
if dut.is_supervisor_node():
timeout = 900
logging.info("Wait until all critical processes are healthy in {} sec"
.format(timeout))
pytest_assert(wait_until(timeout, 20, 0, _all_critical_processes_healthy, dut),
Expand Down
16 changes: 14 additions & 2 deletions tests/platform_tests/test_memory_exhaustion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from tests.common.helpers.assertions import pytest_assert
from tests.common.platform.processes_utils import wait_critical_processes
from tests.common.reboot import SONIC_SSH_PORT, SONIC_SSH_REGEX
from tests.common.reboot import SONIC_SSH_PORT, SONIC_SSH_REGEX, wait_for_startup

pytestmark = [
pytest.mark.disable_loganalyzer,
Expand All @@ -24,7 +24,8 @@ class TestMemoryExhaustion:
"""

@pytest.fixture(autouse=True)
def tearDown(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, pdu_controller):
def tearDown(self, duthosts, enum_rand_one_per_hwsku_hostname,
localhost, pdu_controller,):
Copy link
Contributor

@arlakshm arlakshm Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra comma at end #Closed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also fix the line indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the comma.
Indentation is correct I believe:

xcvr_skip_list, conn_graph_facts, shutdown_ebgp): # noqa F811

yield
# If the SSH connection is not established, or any critical process is exited,
# try to recover the DUT by PDU reboot.
Expand All @@ -41,6 +42,12 @@ def tearDown(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, pdu_co
'Recover {} by PDU reboot failed'.format(hostname))
# Wait until all critical processes are healthy.
wait_critical_processes(duthost)
# For sup, we also need to ensure linecards are back and healthy for following tests
is_sup = duthost.get_facts().get("modular_chassis") and duthost.is_supervisor_node()
if is_sup:
for lc in duthosts.frontend_nodes:
wait_for_startup(lc, localhost, delay=10, timeout=300)
wait_critical_processes(lc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we write commmon function for this code, it is being used couple time here may be useful in other tests as well


def test_memory_exhaustion(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost):
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
Expand Down Expand Up @@ -68,6 +75,11 @@ def test_memory_exhaustion(self, duthosts, enum_rand_one_per_hwsku_hostname, loc
'DUT {} did not startup'.format(hostname))
# Wait until all critical processes are healthy.
wait_critical_processes(duthost)
is_sup = duthost.get_facts().get("modular_chassis") and duthost.is_supervisor_node()
if is_sup:
for lc in duthosts.frontend_nodes:
wait_for_startup(lc, localhost, delay=10, timeout=300)
wait_critical_processes(lc)
# Verify DUT uptime is later than the time when the test case started running.
dut_uptime = duthost.get_up_time()
pytest_assert(dut_uptime > dut_datetime, "Device {} did not reboot".format(hostname))
Expand Down