diff --git a/common/OpTestInstallUtil.py b/common/OpTestInstallUtil.py index 9f700c83..420e261d 100644 --- a/common/OpTestInstallUtil.py +++ b/common/OpTestInstallUtil.py @@ -466,9 +466,14 @@ def update_kernel_cmdline(self, distro, args="", remove_args="", reboot=True, if reboot and (req_args or req_remove_args): # Reboot the host for the kernel command to reflect if reboot_cmd: + # Always reopen console fresh to avoid stale session after first reboot + self.cv_SYSTEM.console.close() raw_pty = self.cv_SYSTEM.console.get_console() raw_pty.sendline("reboot") - raw_pty.expect("login:", timeout=900) + login_patterns = [ + "login:", "root login:", "Ubuntu login:", "Password:", + ] + raw_pty.expect(login_patterns, timeout=900) else: self.cv_SYSTEM.goto_state(OpSystemState.OFF) self.cv_SYSTEM.goto_state(OpSystemState.OS) diff --git a/common/OpTestSOL.py b/common/OpTestSOL.py index 49cb7f35..155282a8 100644 --- a/common/OpTestSOL.py +++ b/common/OpTestSOL.py @@ -93,6 +93,14 @@ def nontimeout_run(self): self.c.expect("\n", timeout=60) except pexpect.TIMEOUT: pass + except OSError as e: + # File descriptor closed (reboot / rmvterm) + print(f"[OpTestSOL] Console closed: {e}, stopping SOL thread.") + break + except Exception as e: + # Catch-all for any other console errors + print(f"[OpTestSOL] Unexpected error in SOL thread: {e}, stopping.") + break except pexpect.EOF: self.c.close() self.c = self.system.console.get_console() diff --git a/testcases/OpTestDlpar.py b/testcases/OpTestDlpar.py index 92d5fc4b..72dd8edd 100644 --- a/testcases/OpTestDlpar.py +++ b/testcases/OpTestDlpar.py @@ -38,12 +38,14 @@ lpar2_name - name of destination lpar for move operation loop_num - number of times to run loop ''' +import time import unittest import logging import os.path from os import path import OpTestConfiguration import OpTestLogger +from testcases.grub import Grub from common import OpTestHMC, OpTestFSP from common import OpTestHMC from common.OpTestSystem import OpSystemState @@ -51,10 +53,15 @@ from random import randint from common.OpTestSystem import OpSystemState from common.OpTestSOL import OpSOLMonitorThread +from common import OpTestInstallUtil +from common.OpTestUtil import OpTestUtil + log = OpTestLogger.optest_logger_glob.get_logger(__name__) class OpTestDlpar(unittest.TestCase): def setUp(self): conf = OpTestConfiguration.conf + self.op_test_util = OpTestUtil(conf) + self.distro = self.op_test_util.distro_name() self.cv_SYSTEM = conf.system() self.console = self.cv_SYSTEM.console conf = OpTestConfiguration.conf @@ -315,6 +322,43 @@ def runTest(self): log.debug("Deleting smt script") self.console.run_command("rm ./smt_script") + +class Dlpar_mem_hotplug(OpTestDlpar, unittest.TestCase): + """Class for DLPAR Memory hotplug Tests + This class executes test cases from OpTestDlpar.DlparMemBasic. + + Step 1 : memory_hotplug.memmap_on_memory=0 * test dlpar memory add, memory remove + Step 2 : memory_hotplug.memmap_on_memory=1 * test dlpar memory add, memory remove + Step 3 : memory_hotplug.memmap_on_memory=force * test dlpar memory add, memory remove + """ + + def setUp(self): + super(Dlpar_mem_hotplug, self).setUp() + + def runTest(self): + obj = OpTestInstallUtil.InstallUtil() + + test_settings = [0, 1, 'force'] + for setting in test_settings: + obj.update_kernel_cmdline( + self.distro, + args=f"memory_hotplug.memmap_on_memory={setting}", + reboot=True, + reboot_cmd=True + ) + # Establish SSH connection + con = self.cv_SYSTEM.cv_HOST.get_ssh_connection() + + log.debug("Memory hotplug with setting: %s", setting) + log.debug("=================") + # Add memory resource + self.AddRemove("mem", "-q", "a", self.mem_resource) + + #log.debug("Memory hotplug removal with setting: %s", setting) + log.debug("=================") + # Remove memory resource + self.AddRemove("mem", "-q", "r", self.mem_resource) + def tearDown(self): self.console_thread.console_terminate() #reboot machine & delete script smt_script