aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2017-02-07 12:13:08 -0500
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2017-02-07 12:23:38 -0500
commit6474ace999edd714151c04c0b0534b89c2e9b6d8 (patch)
treecf3361fcb4a14faa1ba05640ad7e15d664b688d3
parent6e98d1b4415fe681ceb245e1374ed5e1942a332b (diff)
ktest.pl: Powercycle the box on reboot if no connection can be made
When performing a reboot of the test box, try to ssh to it. If it can't connect for 5 seconds, then powercycle the box. This is useful because the reboot is done via ssh, and if you can't ssh to the box because it is hung, the reboot fails to reboot. Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rwxr-xr-xtools/testing/ktest/ktest.pl40
1 files changed, 29 insertions, 11 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index d9bdd3d6dba6..6a1484cc4436 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -1325,26 +1325,44 @@ sub wait_for_monitor;
1325 1325
1326sub reboot { 1326sub reboot {
1327 my ($time) = @_; 1327 my ($time) = @_;
1328 my $powercycle = 0;
1328 1329
1329 # Make sure everything has been written to disk 1330 # test if the machine can be connected to within 5 seconds
1330 run_ssh("sync"); 1331 my $stat = run_ssh("echo check machine status", 5);
1332 if (!$stat) {
1333 doprint("power cycle\n");
1334 $powercycle = 1;
1335 }
1336
1337 if ($powercycle) {
1338 run_command "$power_cycle";
1331 1339
1332 if (defined($time)) {
1333 start_monitor; 1340 start_monitor;
1334 # flush out current monitor 1341 # flush out current monitor
1335 # May contain the reboot success line 1342 # May contain the reboot success line
1336 wait_for_monitor 1; 1343 wait_for_monitor 1;
1337 }
1338 1344
1339 # try to reboot normally 1345 } else {
1340 if (run_command $reboot) { 1346 # Make sure everything has been written to disk
1341 if (defined($powercycle_after_reboot)) { 1347 run_ssh("sync");
1342 sleep $powercycle_after_reboot; 1348
1349 if (defined($time)) {
1350 start_monitor;
1351 # flush out current monitor
1352 # May contain the reboot success line
1353 wait_for_monitor 1;
1354 }
1355
1356 # try to reboot normally
1357 if (run_command $reboot) {
1358 if (defined($powercycle_after_reboot)) {
1359 sleep $powercycle_after_reboot;
1360 run_command "$power_cycle";
1361 }
1362 } else {
1363 # nope? power cycle it.
1343 run_command "$power_cycle"; 1364 run_command "$power_cycle";
1344 } 1365 }
1345 } else {
1346 # nope? power cycle it.
1347 run_command "$power_cycle";
1348 } 1366 }
1349 1367
1350 if (defined($time)) { 1368 if (defined($time)) {