Skip to content

Commit b43b38a

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 316b793 commit b43b38a

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

testcases/OpTestFastReboot.py

+29-6
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,14 @@ def setUp(self):
6060
self.cv_IPMI = conf.ipmi()
6161
self.cv_SYSTEM = conf.system()
6262
self.bmc_type = conf.args.bmc_type
63+
self.timeout = 30
6364

6465
def number_reboots_to_do(self):
6566
return 2
6667

6768
def boot_to_os(self):
69+
self.timeout = 15
70+
self.target = OpSystemState.IPLing
6871
return False
6972

7073
def do_things_while_booted(self):
@@ -102,8 +105,10 @@ def runTest(self):
102105
self.skipTest("Qemu platform doesn't have fast-reboot support")
103106

104107
if self.boot_to_os():
108+
self.cv_SYSTEM.sys_set_bootdev_no_override()
105109
self.cv_SYSTEM.goto_state(OpSystemState.OS)
106110
else:
111+
self.cv_SYSTEM.sys_set_bootdev_setup()
107112
self.cv_SYSTEM.goto_state(OpSystemState.PETITBOOT_SHELL)
108113

109114
c = self.cv_SYSTEM.console
@@ -125,7 +130,7 @@ def runTest(self):
125130
"grep '^cpu' /proc/cpuinfo|uniq|sed -e 's/^.*: //;s/[,]* .*//;'"))
126131
log.debug(repr(cpu))
127132
if cpu not in ["POWER9", "POWER8", "POWER8E"]:
128-
self.skipTest("Fast Reboot not supported on %s" % cpu)
133+
self.skipTest("Fast Reboot not supported on {}".format(cpu))
129134

130135
if not self.cv_SYSTEM.has_mtd_pnor_access():
131136
self.skipTest("OpTestSystem does not have MTD PNOR access,"
@@ -139,34 +144,50 @@ def runTest(self):
139144
self.assertIn("feeling-lucky", res,
140145
"Failed to set the fast-reset mode")
141146
initialResetCount = self.get_fast_reset_count(c)
142-
log.debug("INITIAL reset count: %d" % initialResetCount)
147+
log.debug("FASTREBOOT initialResetCount={}".format(initialResetCount))
143148
for i in range(0, self.number_reboots_to_do()):
144149
loopResetCount = self.get_fast_reset_count(c)
145150
# We do some funny things with the raw pty here, as
146151
# 'reboot' isn't meant to return
147152
self.pty = self.cv_SYSTEM.console.get_console()
148153
self.pty.sendline(self.reboot_command())
149154
self.cv_SYSTEM.set_state(OpSystemState.IPLing)
155+
log.debug("FASTREBOOT Expect Buffer ID={}".format(hex(id(self.pty))))
156+
self.cv_SYSTEM.set_state(self.target)
157+
self.cv_SYSTEM.util.clear_state(self.cv_SYSTEM)
150158
# We're looking for a skiboot log message, that it's doing fast
151159
# reboot. We *may* not get this, as on some systems (notably IBM
152160
# FSP based systems) the skiboot log is *not* printed to IPMI
153161
# console
154162
if self.cv_SYSTEM.skiboot_log_on_console():
163+
log.debug("FASTREBOOT looking for RESET: Initiating fast reboot")
164+
# timeout is only long enough, if we wait too long the expect
165+
# buffer will not get the data to keep things moving
155166
rc = self.pty.expect([" RESET: Initiating fast reboot",
156167
pexpect.TIMEOUT, pexpect.EOF],
157-
timeout=100)
168+
timeout=self.timeout)
169+
log.debug("FASTREBOOT rc={} (0=We found RESET 1=TIMEOUT 2=EOF)".format(rc))
170+
log.debug("FASTREBOOT before={}".format(self.pty.before))
171+
log.debug("FASTREBOOT after={}".format(self.pty.after))
158172
if rc in [1, 2]:
173+
log.debug("FASTREBOOT CLOSE Expect Buffer ID={}".format(hex(id(self.pty))))
159174
c.close() # close the console obj
160175
if self.boot_to_os():
176+
log.debug("FASTREBOOT marker, we're now going to boot to OS")
177+
self.cv_SYSTEM.sys_set_bootdev_no_override()
161178
self.cv_SYSTEM.goto_state(OpSystemState.OS)
162179
else:
180+
log.debug("FASTREBOOT marker, we're now going to boot to PS")
181+
self.cv_SYSTEM.sys_set_bootdev_setup()
163182
self.cv_SYSTEM.goto_state(OpSystemState.PETITBOOT_SHELL)
164183
newResetCount = self.get_fast_reset_count(c)
165184
self.assertTrue(loopResetCount < newResetCount,
166-
"Did not do fast reboot")
185+
"FASTREBOOT encountered a problem, loopResetCount {} >= newResetCount {}, check the debug logs"
186+
.format(loopResetCount, newResetCount))
167187
self.assertTrue(initialResetCount < newResetCount,
168-
"Did not do fast reboot")
169-
log.debug("Completed Fast reboot cycle %d" % i)
188+
"FASTREBOOT encountered a problem, initialResetCount {} >= newResetCount {}, check the debug logs"
189+
.format(initialResetCount, newResetCount))
190+
log.debug("FASTREBOOT completed cycle i={}".format(i))
170191
self.do_things_while_booted()
171192

172193
c.run_command(BMC_CONST.NVRAM_DISABLE_FAST_RESET_MODE)
@@ -182,11 +203,13 @@ def runTest(self):
182203

183204
class FastRebootHost(OpTestFastReboot):
184205
def boot_to_os(self):
206+
self.target = OpSystemState.BOOTING
185207
return True
186208

187209

188210
class FastRebootHostTorture(FastRebootHost):
189211
def boot_to_os(self):
212+
self.target = OpSystemState.BOOTING
190213
return True
191214

192215
def number_reboots_to_do(self):

0 commit comments

Comments
 (0)