1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Implement WL#2789 "Instance Manager: test using mysql-test-run testing framework"

mysql-test/Makefile.am:
  Make installation procedure aware of the Instance Manager tests.
mysql-test/lib/mtr_cases.pl:
  Make collect_one_test_case() aware of the Instance Manager tests.
mysql-test/lib/mtr_process.pl:
  Minor changes:
    - open log files for append, not for overwrite. Append mode is very
      useful for debugging of several tests;
    - extract the code for killing processes into a separate function:
      mtr_kill_processes(). The function is used to stop IM-related processes.
mysql-test/mysql-test-run.pl:
  Added support for the Instance Manager tests.
This commit is contained in:
unknown
2005-08-29 22:28:42 +04:00
parent 901075ac22
commit d99d05e987
4 changed files with 473 additions and 65 deletions

View File

@ -12,16 +12,17 @@ use strict;
#use POSIX ":sys_wait_h";
use POSIX 'WNOHANG';
sub mtr_run ($$$$$$);
sub mtr_spawn ($$$$$$);
sub mtr_run ($$$$$$;$);
sub mtr_spawn ($$$$$$;$);
sub mtr_stop_mysqld_servers ($);
sub mtr_kill_leftovers ();
sub mtr_record_dead_children ();
sub mtr_exit ($);
sub sleep_until_file_created ($$$);
sub mtr_kill_processes ($);
# static in C
sub spawn_impl ($$$$$$$);
sub spawn_impl ($$$$$$$$);
##############################################################################
#
@ -32,37 +33,43 @@ sub spawn_impl ($$$$$$$);
# This function try to mimic the C version used in "netware/mysql_test_run.c"
# FIXME learn it to handle append mode as well, a "new" flag or a "append"
sub mtr_run ($$$$$$) {
sub mtr_run ($$$$$$;$) {
my $path= shift;
my $arg_list_t= shift;
my $input= shift;
my $output= shift;
my $error= shift;
my $pid_file= shift;
my $spawn_opts= shift;
return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,$pid_file);
return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,$pid_file,
$spawn_opts);
}
sub mtr_run_test ($$$$$$) {
sub mtr_run_test ($$$$$$;$) {
my $path= shift;
my $arg_list_t= shift;
my $input= shift;
my $output= shift;
my $error= shift;
my $pid_file= shift;
my $spawn_opts= shift;
return spawn_impl($path,$arg_list_t,'test',$input,$output,$error,$pid_file);
return spawn_impl($path,$arg_list_t,'test',$input,$output,$error,$pid_file,
$spawn_opts);
}
sub mtr_spawn ($$$$$$) {
sub mtr_spawn ($$$$$$;$) {
my $path= shift;
my $arg_list_t= shift;
my $input= shift;
my $output= shift;
my $error= shift;
my $pid_file= shift;
my $spawn_opts= shift;
return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,$pid_file);
return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,$pid_file,
$spawn_opts);
}
@ -72,7 +79,7 @@ sub mtr_spawn ($$$$$$) {
#
##############################################################################
sub spawn_impl ($$$$$$$) {
sub spawn_impl ($$$$$$$$) {
my $path= shift;
my $arg_list_t= shift;
my $mode= shift;
@ -80,6 +87,7 @@ sub spawn_impl ($$$$$$$) {
my $output= shift;
my $error= shift;
my $pid_file= shift; # FIXME
my $spawn_opts= shift;
if ( $::opt_script_debug )
{
@ -89,6 +97,18 @@ sub spawn_impl ($$$$$$$) {
print STDERR "#### ", "STDOUT $output\n" if $output;
print STDERR "#### ", "STDERR $error\n" if $error;
print STDERR "#### ", "$mode : $path ", join(" ",@$arg_list_t), "\n";
print STDERR "#### ", "spawn options:\n";
if ($spawn_opts)
{
foreach my $key (sort keys %{$spawn_opts})
{
print STDERR "#### ", " - $key: $spawn_opts->{$key}\n";
}
}
else
{
print STDERR "#### ", " none\n";
}
print STDERR "#### ", "-" x 78, "\n";
}
@ -135,9 +155,16 @@ sub spawn_impl ($$$$$$$) {
# $ENV{'COMSPEC'}= "$::glob_cygwin_shell -c";
}
my $log_file_open_mode = '>';
if ($spawn_opts and $spawn_opts->{'append_log_file'})
{
$log_file_open_mode = '>>';
}
if ( $output )
{
if ( ! open(STDOUT,">",$output) )
if ( ! open(STDOUT,$log_file_open_mode,$output) )
{
mtr_error("can't redirect STDOUT to \"$output\": $!");
}
@ -154,7 +181,7 @@ sub spawn_impl ($$$$$$$) {
}
else
{
if ( ! open(STDERR,">",$error) )
if ( ! open(STDERR,$log_file_open_mode,$error) )
{
mtr_error("can't redirect STDERR to \"$output\": $!");
}
@ -534,16 +561,7 @@ sub mtr_stop_mysqld_servers ($) {
start_reap_all(); # Avoid zombies
SIGNAL:
foreach my $sig (15,9)
{
my $retries= 20; # FIXME 20 seconds, this is silly!
kill($sig, keys %mysqld_pids);
while ( $retries-- and kill(0, keys %mysqld_pids) )
{
mtr_debug("Sleep 1 second waiting for processes to die");
sleep(1) # Wait one second
}
}
mtr_kill_processes(\keys (%mysqld_pids));
stop_reap_all(); # Get into control again
@ -805,7 +823,7 @@ sub sleep_until_file_created ($$$) {
}
# Check if it died after the fork() was successful
if ( waitpid($pid,&WNOHANG) == $pid )
if ( $pid > 0 && waitpid($pid,&WNOHANG) == $pid )
{
return 0;
}
@ -826,6 +844,21 @@ sub sleep_until_file_created ($$$) {
}
sub mtr_kill_processes ($) {
my $pids = shift;
foreach my $sig (15,9)
{
my $retries= 20; # FIXME 20 seconds, this is silly!
kill($sig, @{$pids});
while ( $retries-- and kill(0, @{$pids}) )
{
mtr_debug("Sleep 1 second waiting for processes to die");
sleep(1) # Wait one second
}
}
}
##############################################################################
#
# When we exit, we kill off all children