Skip to content

Commit cde4ba1

Browse files
Merge pull request #903 from yeswanth6096/dlpar-mem-hotplug
Added Dlpar_mem_hotplug Tescase
2 parents 63a61af + dd676bf commit cde4ba1

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

common/OpTestInstallUtil.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,14 @@ def update_kernel_cmdline(self, distro, args="", remove_args="", reboot=True,
466466
if reboot and (req_args or req_remove_args):
467467
# Reboot the host for the kernel command to reflect
468468
if reboot_cmd:
469+
# Always reopen console fresh to avoid stale session after first reboot
470+
self.cv_SYSTEM.console.close()
469471
raw_pty = self.cv_SYSTEM.console.get_console()
470472
raw_pty.sendline("reboot")
471-
raw_pty.expect("login:", timeout=900)
473+
login_patterns = [
474+
"login:", "root login:", "Ubuntu login:", "Password:",
475+
]
476+
raw_pty.expect(login_patterns, timeout=900)
472477
else:
473478
self.cv_SYSTEM.goto_state(OpSystemState.OFF)
474479
self.cv_SYSTEM.goto_state(OpSystemState.OS)

common/OpTestSOL.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ def nontimeout_run(self):
9393
self.c.expect("\n", timeout=60)
9494
except pexpect.TIMEOUT:
9595
pass
96+
except OSError as e:
97+
# File descriptor closed (reboot / rmvterm)
98+
print(f"[OpTestSOL] Console closed: {e}, stopping SOL thread.")
99+
break
100+
except Exception as e:
101+
# Catch-all for any other console errors
102+
print(f"[OpTestSOL] Unexpected error in SOL thread: {e}, stopping.")
103+
break
96104
except pexpect.EOF:
97105
self.c.close()
98106
self.c = self.system.console.get_console()

testcases/OpTestDlpar.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,30 @@
3838
lpar2_name - name of destination lpar for move operation
3939
loop_num - number of times to run loop
4040
'''
41+
import time
4142
import unittest
4243
import logging
4344
import os.path
4445
from os import path
4546
import OpTestConfiguration
4647
import OpTestLogger
48+
from testcases.grub import Grub
4749
from common import OpTestHMC, OpTestFSP
4850
from common import OpTestHMC
4951
from common.OpTestSystem import OpSystemState
5052
from common.OpTestConstants import OpTestConstants as BMC_CONST
5153
from random import randint
5254
from common.OpTestSystem import OpSystemState
5355
from common.OpTestSOL import OpSOLMonitorThread
56+
from common import OpTestInstallUtil
57+
from common.OpTestUtil import OpTestUtil
58+
5459
log = OpTestLogger.optest_logger_glob.get_logger(__name__)
5560
class OpTestDlpar(unittest.TestCase):
5661
def setUp(self):
5762
conf = OpTestConfiguration.conf
63+
self.op_test_util = OpTestUtil(conf)
64+
self.distro = self.op_test_util.distro_name()
5865
self.cv_SYSTEM = conf.system()
5966
self.console = self.cv_SYSTEM.console
6067
conf = OpTestConfiguration.conf
@@ -315,6 +322,42 @@ def runTest(self):
315322
log.debug("Deleting smt script")
316323
self.console.run_command("rm ./smt_script")
317324

325+
326+
class DlparMemHotplug(OpTestDlpar, unittest.TestCase):
327+
"""Class for DLPAR Memory hotplug Tests
328+
This class executes test cases from OpTestDlpar.DlparMemBasic.
329+
330+
Step 1 : memory_hotplug.memmap_on_memory=0 * test dlpar memory add, memory remove
331+
Step 2 : memory_hotplug.memmap_on_memory=1 * test dlpar memory add, memory remove
332+
Step 3 : memory_hotplug.memmap_on_memory=force * test dlpar memory add, memory remove
333+
"""
334+
def setUp(self):
335+
super(DlparMemHotplug, self).setUp()
336+
337+
def runTest(self):
338+
OpIUobj = OpTestInstallUtil.InstallUtil()
339+
test_settings = [0,1,'force']
340+
for setting in test_settings:
341+
OpIUobj.update_kernel_cmdline(
342+
self.distro,
343+
args=f"memory_hotplug.memmap_on_memory={setting}",
344+
reboot=True,
345+
reboot_cmd=True
346+
)
347+
# Establish SSH connection
348+
con = self.cv_SYSTEM.cv_HOST.get_ssh_connection()
349+
log.debug("Memory hotplug with setting: %s", setting)
350+
log.debug("=================")
351+
# Add memory resource
352+
self.AddRemove("mem", "-q", "a", self.mem_resource)
353+
log.debug("Memory hotplug removal with setting: %s", setting)
354+
log.debug("=================")
355+
# Remove memory resource
356+
self.AddRemove("mem", "-q", "r", self.mem_resource)
357+
log.debug("Remove Memory hotplug as part of cleanup with setting: %s", setting)
358+
OpIUobj.update_kernel_cmdline(self.distro, remove_args=f"memory_hotplug.memmap_on_memory={setting}",
359+
reboot=True, reboot_cmd=True)
360+
318361
def tearDown(self):
319362
self.console_thread.console_terminate()
320363
#reboot machine & delete script smt_script

0 commit comments

Comments
 (0)