Skip to content

Commit 93dca83

Browse files
committed
OpTestFastReboot: PTY handling
Tweak the timing of pexpect buffer management and add some debug logging to help aide problem determination when pty buffering issues. Signed-off-by: Deb McLemore <[email protected]>
1 parent 578a203 commit 93dca83

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

testcases/OpTestFastReboot.py

+29-7
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ def setUp(self):
5959
self.cv_HOST = conf.host()
6060
self.cv_IPMI = conf.ipmi()
6161
self.cv_SYSTEM = conf.system()
62+
self.timeout = 30
6263

6364
def number_reboots_to_do(self):
6465
return 2
6566

6667
def boot_to_os(self):
68+
self.timeout = 15
69+
self.target = OpSystemState.IPLing
6770
return False
6871

6972
def get_fast_reset_count(self, c):
@@ -91,8 +94,10 @@ def runTest(self):
9194
getting executed in both petitboot and host OS
9295
'''
9396
if self.boot_to_os():
97+
self.cv_SYSTEM.sys_set_bootdev_no_override()
9498
self.cv_SYSTEM.goto_state(OpSystemState.OS)
9599
else:
100+
self.cv_SYSTEM.sys_set_bootdev_setup()
96101
self.cv_SYSTEM.goto_state(OpSystemState.PETITBOOT_SHELL)
97102

98103
c = self.cv_SYSTEM.console
@@ -114,7 +119,7 @@ def runTest(self):
114119
"grep '^cpu' /proc/cpuinfo|uniq|sed -e 's/^.*: //;s/[,]* .*//;'"))
115120
log.debug(repr(cpu))
116121
if cpu not in ["POWER9", "POWER8", "POWER8E"]:
117-
self.skipTest("Fast Reboot not supported on %s" % cpu)
122+
self.skipTest("Fast Reboot not supported on {}".format(cpu))
118123

119124
if not self.cv_SYSTEM.has_mtd_pnor_access():
120125
self.skipTest("OpTestSystem does not have MTD PNOR access,"
@@ -128,34 +133,49 @@ def runTest(self):
128133
self.assertIn("feeling-lucky", res,
129134
"Failed to set the fast-reset mode")
130135
initialResetCount = self.get_fast_reset_count(c)
131-
log.debug("INITIAL reset count: %d" % initialResetCount)
136+
log.debug("FASTREBOOT initialResetCount={}".format(initialResetCount))
132137
for i in range(0, self.number_reboots_to_do()):
133138
loopResetCount = self.get_fast_reset_count(c)
134139
# We do some funny things with the raw pty here, as
135140
# 'reboot' isn't meant to return
136141
self.pty = self.cv_SYSTEM.console.get_console()
142+
log.debug("FASTREBOOT Expect Buffer ID={}".format(hex(id(self.pty))))
137143
self.pty.sendline("reboot")
138-
self.cv_SYSTEM.set_state(OpSystemState.IPLing)
144+
self.cv_SYSTEM.set_state(self.target)
145+
self.cv_SYSTEM.util.clear_state(self.cv_SYSTEM)
139146
# We're looking for a skiboot log message, that it's doing fast
140147
# reboot. We *may* not get this, as on some systems (notably IBM
141148
# FSP based systems) the skiboot log is *not* printed to IPMI
142149
# console
143150
if self.cv_SYSTEM.skiboot_log_on_console():
151+
log.debug("FASTREBOOT looking for RESET: Initiating fast reboot")
152+
# timeout is only long enough, if we wait too long the expect
153+
# buffer will not get the data to keep things moving
144154
rc = self.pty.expect([" RESET: Initiating fast reboot",
145155
pexpect.TIMEOUT, pexpect.EOF],
146-
timeout=100)
156+
timeout=self.timeout)
157+
log.debug("FASTREBOOT rc={} (0=We found RESET 1=TIMEOUT 2=EOF)".format(rc))
158+
log.debug("FASTREBOOT before={}".format(self.pty.before))
159+
log.debug("FASTREBOOT after={}".format(self.pty.after))
147160
if rc in [1, 2]:
161+
log.debug("FASTREBOOT CLOSE Expect Buffer ID={}".format(hex(id(self.pty))))
148162
c.close() # close the console obj
149163
if self.boot_to_os():
164+
log.debug("FASTREBOOT marker, we're now going to boot to OS")
165+
self.cv_SYSTEM.sys_set_bootdev_no_override()
150166
self.cv_SYSTEM.goto_state(OpSystemState.OS)
151167
else:
168+
log.debug("FASTREBOOT marker, we're now going to boot to PS")
169+
self.cv_SYSTEM.sys_set_bootdev_setup()
152170
self.cv_SYSTEM.goto_state(OpSystemState.PETITBOOT_SHELL)
153171
newResetCount = self.get_fast_reset_count(c)
154172
self.assertTrue(loopResetCount < newResetCount,
155-
"Did not do fast reboot")
173+
"FASTREBOOT encountered a problem, loopResetCount {} >= newResetCount {}, check the debug logs"
174+
.format(loopResetCount, newResetCount))
156175
self.assertTrue(initialResetCount < newResetCount,
157-
"Did not do fast reboot")
158-
log.debug("Completed Fast reboot cycle %d" % i)
176+
"FASTREBOOT encountered a problem, initialResetCount {} >= newResetCount {}, check the debug logs"
177+
.format(initialResetCount, newResetCount))
178+
log.debug("FASTREBOOT completed cycle i={}".format(i))
159179

160180
c.run_command(BMC_CONST.NVRAM_DISABLE_FAST_RESET_MODE)
161181
try:
@@ -170,11 +190,13 @@ def runTest(self):
170190

171191
class FastRebootHost(OpTestFastReboot):
172192
def boot_to_os(self):
193+
self.target = OpSystemState.BOOTING
173194
return True
174195

175196

176197
class FastRebootHostTorture(FastRebootHost):
177198
def boot_to_os(self):
199+
self.target = OpSystemState.BOOTING
178200
return True
179201

180202
def number_reboots_to_do(self):

0 commit comments

Comments
 (0)