From a85c7c8086efaacb0db8a6461d691eae6a621f50 Mon Sep 17 00:00:00 2001 From: Mridul Bajpai <30709399+bmridul@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:18:29 -0700 Subject: [PATCH] Memory exhaustion test case takes an indeterminate amount of time to trigger Kernel panic. (#11738) * Turned swapping off so kernel catches OOM in a shorter time. --- tests/platform_tests/test_memory_exhaustion.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/platform_tests/test_memory_exhaustion.py b/tests/platform_tests/test_memory_exhaustion.py index b829baab406..141df3dc657 100644 --- a/tests/platform_tests/test_memory_exhaustion.py +++ b/tests/platform_tests/test_memory_exhaustion.py @@ -64,6 +64,12 @@ def test_memory_exhaustion(self, duthosts, enum_rand_one_per_hwsku_hostname, loc # background process. # * Some DUTs with few free memory may reboot before ansible receive the result of shell # command, so we add `sleep 5` to ensure ansible receive the result first. + # Swapping is turned off so the OOM is triggered in a shorter time. + + res = duthost.command("sudo swapoff -a") + if res['rc']: + logging.error("Swapoff command failed: {}".format(res)) + cmd = 'nohup bash -c "sleep 5 && tail /dev/zero" &' res = duthost.shell(cmd) if not res.is_successful: