mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Bug #44511 MTR2: add an option not to kill other servers when one from the group exits
MTR would die as soon as one server terminates Implemented --wait-all option and associated subroutine
This commit is contained in:
@@ -536,6 +536,18 @@ sub wait_any {
|
|||||||
return $proc;
|
return $proc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Wait for all processes to exit
|
||||||
|
#
|
||||||
|
sub wait_all {
|
||||||
|
while(keys %running)
|
||||||
|
{
|
||||||
|
wait_any();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check if any process has exited, but don't wait.
|
# Check if any process has exited, but don't wait.
|
||||||
#
|
#
|
||||||
|
@@ -209,6 +209,7 @@ sub check_timeout { return $opt_testcase_timeout * 6; };
|
|||||||
|
|
||||||
my $opt_start;
|
my $opt_start;
|
||||||
my $opt_start_dirty;
|
my $opt_start_dirty;
|
||||||
|
my $opt_wait_all;
|
||||||
my $opt_repeat= 1;
|
my $opt_repeat= 1;
|
||||||
my $opt_retry= 3;
|
my $opt_retry= 3;
|
||||||
my $opt_retry_failure= 2;
|
my $opt_retry_failure= 2;
|
||||||
@@ -879,6 +880,7 @@ sub command_line_setup {
|
|||||||
'sleep=i' => \$opt_sleep,
|
'sleep=i' => \$opt_sleep,
|
||||||
'start-dirty' => \$opt_start_dirty,
|
'start-dirty' => \$opt_start_dirty,
|
||||||
'start' => \$opt_start,
|
'start' => \$opt_start,
|
||||||
|
'wait-all' => \$opt_wait_all,
|
||||||
'print-testcases' => \&collect_option,
|
'print-testcases' => \&collect_option,
|
||||||
'repeat=i' => \$opt_repeat,
|
'repeat=i' => \$opt_repeat,
|
||||||
'retry=i' => \$opt_retry,
|
'retry=i' => \$opt_retry,
|
||||||
@@ -1236,6 +1238,15 @@ sub command_line_setup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Check use of wait-all
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ($opt_wait_all && ! ($opt_start_dirty || $opt_start))
|
||||||
|
{
|
||||||
|
mtr_error("--wait-all can only be used with --start or --start-dirty");
|
||||||
|
}
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Check timeout arguments
|
# Check timeout arguments
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
@@ -3258,11 +3269,20 @@ sub run_testcase ($) {
|
|||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# If --start or --start-dirty given, stop here to let user manually
|
# If --start or --start-dirty given, stop here to let user manually
|
||||||
# run tests
|
# run tests
|
||||||
|
# If --wait-all is also given, do the same, but don't die if one
|
||||||
|
# server exits
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
if ( $opt_start or $opt_start_dirty )
|
if ( $opt_start or $opt_start_dirty )
|
||||||
{
|
{
|
||||||
mtr_print("\nStarted", started(all_servers()));
|
mtr_print("\nStarted", started(all_servers()));
|
||||||
mtr_print("Waiting for server(s) to exit...");
|
mtr_print("Waiting for server(s) to exit...");
|
||||||
|
if ( $opt_wait_all ) {
|
||||||
|
My::SafeProcess->wait_all();
|
||||||
|
mtr_print( "All servers exited" );
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
my $proc= My::SafeProcess->wait_any();
|
my $proc= My::SafeProcess->wait_any();
|
||||||
if ( grep($proc eq $_, started(all_servers())) )
|
if ( grep($proc eq $_, started(all_servers())) )
|
||||||
{
|
{
|
||||||
@@ -3272,6 +3292,7 @@ sub run_testcase ($) {
|
|||||||
mtr_print("Unknown process $proc died");
|
mtr_print("Unknown process $proc died");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $test_timeout_proc= My::SafeProcess->timer(testcase_timeout());
|
my $test_timeout_proc= My::SafeProcess->timer(testcase_timeout());
|
||||||
|
|
||||||
@@ -5153,6 +5174,8 @@ Misc options
|
|||||||
$0 --start alias &
|
$0 --start alias &
|
||||||
start-dirty Only start the servers (without initialization) for
|
start-dirty Only start the servers (without initialization) for
|
||||||
the first specified test case
|
the first specified test case
|
||||||
|
wait-all If --start or --start-dirty option is used, wait for all
|
||||||
|
servers to exit before finishing the process
|
||||||
fast Run as fast as possible, dont't wait for servers
|
fast Run as fast as possible, dont't wait for servers
|
||||||
to shutdown etc.
|
to shutdown etc.
|
||||||
repeat=N Run each test N number of times
|
repeat=N Run each test N number of times
|
||||||
|
Reference in New Issue
Block a user