Skip to content

Commit 3b0baae

Browse files
Fix RunHostTest reboot handling to avoid unnecessary power cycle
- Execute reboot command via SSH instead of forcing power cycle - Wait for SSH to reconnect after reboot (no goto_state OFF/ON) - Prevents unnecessary LPAR shutdown and restart - Faster reboot handling with proper SSH reconnection Signed-off-by: Praveen K Pandey <praveen@linux.vnet.ibm.com>
1 parent 7cf487e commit 3b0baae

1 file changed

Lines changed: 33 additions & 11 deletions

File tree

testcases/RunHostTest.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import unittest
3131
import os
32+
import time
3233

3334
from common.OpTestSSHConnection import OpTestSSHConnection, OpTestCommandResult
3435
from common.OpTestCommandExecutor import OpTestCommandExecutor
@@ -105,21 +106,42 @@ def runTest(self):
105106
continue
106107

107108
if "reboot" in line:
108-
log.info("Reboot command detected - system will restart")
109-
if self.console_thread:
110-
self.console_thread.console_terminate()
111-
self.cv_SYSTEM.goto_state(OpSystemState.OFF)
112-
self.cv_SYSTEM.goto_state(OpSystemState.OS)
109+
log.info("Reboot command detected - executing reboot and waiting for system to come back")
113110

114-
# Reconnect after reboot
111+
# Execute reboot command
115112
if use_new_ssh:
116-
executor = self.cv_SYSTEM.cv_HOST.get_command_executor()
113+
try:
114+
executor.run_command(line, timeout=10)
115+
except:
116+
pass # SSH will disconnect during reboot
117117
else:
118-
con = self.cv_SYSTEM.cv_HOST.get_ssh_connection()
118+
try:
119+
con.run_command(line, timeout=10)
120+
except:
121+
pass # SSH will disconnect during reboot
122+
123+
# Wait for system to reboot and SSH to come back
124+
log.info("Waiting for system to reboot...")
125+
time.sleep(60) # Give system time to start rebooting
126+
127+
# Wait for SSH to become available again
128+
log.info("Waiting for SSH to become available after reboot...")
129+
max_wait = 300 # 5 minutes
130+
for i in range(max_wait):
131+
try:
132+
if use_new_ssh:
133+
executor = self.cv_SYSTEM.cv_HOST.get_command_executor()
134+
executor.run_command("echo 'SSH is back'", timeout=10)
135+
else:
136+
con = self.cv_SYSTEM.cv_HOST.get_ssh_connection()
137+
con.run_command("echo 'SSH is back'", timeout=10)
138+
log.info(f"SSH reconnected after {i + 60}s")
139+
break
140+
except:
141+
if i % 10 == 0:
142+
log.info(f"Still waiting for SSH... ({i + 60}s elapsed)")
143+
time.sleep(1)
119144

120-
if not use_new_ssh:
121-
self.console_thread = OpSOLMonitorThread(1, "console")
122-
self.console_thread.start()
123145
continue
124146

125147
if use_new_ssh:

0 commit comments

Comments
 (0)