Commit 29d4ac2c authored by Jan Lindström's avatar Jan Lindström Committed by GitHub

Merge pull request #665 from codership/10.2-fix-mtr-wait

Fix mtr to be able to wait for >1 exited mysqld
parents 47ea2227 72deed59
...@@ -3961,32 +3961,32 @@ sub run_testcase ($$) { ...@@ -3961,32 +3961,32 @@ sub run_testcase ($$) {
} }
my $test= $tinfo->{suite}->start_test($tinfo); my $test= $tinfo->{suite}->start_test($tinfo);
# Set only when we have to keep waiting after expectedly died server # Set to a list of processes we have to keep waiting (expectedly died servers)
my $keep_waiting_proc = 0; my %keep_waiting_proc = ();
my $print_timeout= start_timer($print_freq * 60); my $print_timeout= start_timer($print_freq * 60);
while (1) while (1)
{ {
my $proc; my $proc;
if ($keep_waiting_proc) if (scalar(keys(%keep_waiting_proc)) > 0)
{ {
# Any other process exited? # Any other process exited?
$proc = My::SafeProcess->check_any(); $proc = My::SafeProcess->check_any();
if ($proc) if ($proc)
{ {
mtr_verbose ("Found exited process $proc"); mtr_verbose ("Found exited process $proc");
$keep_waiting_proc{$proc} = 1;
} }
else else
{ {
$proc = $keep_waiting_proc;
# Also check if timer has expired, if so cancel waiting # Also check if timer has expired, if so cancel waiting
if ( has_expired($test_timeout) ) if ( has_expired($test_timeout) )
{ {
$keep_waiting_proc = 0; %keep_waiting_proc = ();
} }
} }
} }
if (! $keep_waiting_proc) if (scalar(keys(%keep_waiting_proc)) == 0)
{ {
if($test_timeout > $print_timeout) if($test_timeout > $print_timeout)
{ {
...@@ -4003,19 +4003,19 @@ sub run_testcase ($$) { ...@@ -4003,19 +4003,19 @@ sub run_testcase ($$) {
else else
{ {
$proc= My::SafeProcess->wait_any_timeout($test_timeout); $proc= My::SafeProcess->wait_any_timeout($test_timeout);
$keep_waiting_proc{$proc} = 1;
} }
} }
# Will be restored if we need to keep waiting if (scalar(keys(%keep_waiting_proc)) == 0)
$keep_waiting_proc = 0;
unless ( defined $proc )
{ {
mtr_error("wait_any failed"); mtr_error("wait_any failed");
} }
mtr_verbose("Got $proc"); mtr_verbose("Got " . join(",", keys(%keep_waiting_proc)));
mark_time_used('test'); mark_time_used('test');
my $expected_exit = 1;
foreach $proc (keys(%keep_waiting_proc)) {
# ---------------------------------------------------- # ----------------------------------------------------
# Was it the test program that exited # Was it the test program that exited
# ---------------------------------------------------- # ----------------------------------------------------
...@@ -4129,11 +4129,22 @@ sub run_testcase ($$) { ...@@ -4129,11 +4129,22 @@ sub run_testcase ($$) {
# Check if it was an expected crash # Check if it was an expected crash
# ---------------------------------------------------- # ----------------------------------------------------
my $check_crash = check_expected_crash_and_restart($proc); my $check_crash = check_expected_crash_and_restart($proc);
if ($check_crash) if ($check_crash == 0) # unexpected exit/crash of $proc
{ {
# Keep waiting if it returned 2, if 1 don't wait or stop waiting. $expected_exit = 0;
$keep_waiting_proc = 0 if $check_crash == 1; last;
$keep_waiting_proc = $proc if $check_crash == 2; }
elsif ($check_crash == 1) # $proc was started again by check_expected_crash_and_restart()
{
delete $keep_waiting_proc{$proc};
}
elsif ($check_crash == 2) # we must keep waiting
{
# do nothing
}
}
if ($expected_exit) {
next; next;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment