Skip to content

Commit

Permalink
ktest: Add CONNECT_TIMEOUT to change the connection timeout time
Browse files Browse the repository at this point in the history
Before ktest issues a reboot, it will try to connect to the target machine
to make sure that it is still alive. If the target does not respond within 5
seconds, it will power cycle the box instead of issuing a reboot.

Five seconds may be too short, and ktest may unnecessarially power cycle the
box. I have found 25 seconds seems to be a better timeout for this purpose.
But even 25 may be too arbitrary. Add a CONNECT_TIMEOUT option to let the
user determine the timeout time before rebooting. By default, it has been
raised to 25 seconds.

Signed-off-by: Steven Rostedt (VMware) <[email protected]>
  • Loading branch information
rostedt committed Mar 21, 2018
1 parent 9f23b12 commit 3e1d367
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tools/testing/ktest/ktest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"GRUB_REBOOT" => "grub2-reboot",
"SYSLINUX" => "extlinux",
"SYSLINUX_PATH" => "/boot/extlinux",
"CONNECT_TIMEOUT" => 25,

# required, and we will ask users if they don't have them but we keep the default
# value something that is common.
Expand Down Expand Up @@ -163,6 +164,7 @@
my $store_successes;
my $test_name;
my $timeout;
my $connect_timeout;
my $booted_timeout;
my $detect_triplefault;
my $console;
Expand Down Expand Up @@ -296,6 +298,7 @@
"STORE_SUCCESSES" => \$store_successes,
"TEST_NAME" => \$test_name,
"TIMEOUT" => \$timeout,
"CONNECT_TIMEOUT" => \$connect_timeout,
"BOOTED_TIMEOUT" => \$booted_timeout,
"CONSOLE" => \$console,
"CLOSE_CONSOLE_SIGNAL" => \$close_console_signal,
Expand Down Expand Up @@ -1328,8 +1331,8 @@ sub reboot {
my ($time) = @_;
my $powercycle = 0;

# test if the machine can be connected to within 5 seconds
my $stat = run_ssh("echo check machine status", 5);
# test if the machine can be connected to within a few seconds
my $stat = run_ssh("echo check machine status", $connect_timeout);
if (!$stat) {
doprint("power cycle\n");
$powercycle = 1;
Expand Down
7 changes: 7 additions & 0 deletions tools/testing/ktest/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,13 @@
# (default 120)
#TIMEOUT = 120

# The timeout in seconds when to test if the box can be rebooted
# or not. Before issuing the reboot command, a ssh connection
# is attempted to see if the target machine is still active.
# If the target does not connect within this timeout, a power cycle
# is issued instead of a reboot.
# CONNECT_TIMEOUT = 25

# In between tests, a reboot of the box may occur, and this
# is the time to wait for the console after it stops producing
# output. Some machines may not produce a large lag on reboot
Expand Down

0 comments on commit 3e1d367

Please sign in to comment.