Commit e32054e4 authored by kent@mysql.com's avatar kent@mysql.com

mysql-test-run.pl, mtr_cases.pl

  - Back porting of some changes in later releases
  - Corrected valgrind support
  - Removed work around for TZ needed in VisualStudio 6
  - Don't restart master to add special settings from "<testcase>-master.opt",
    if same settngs as running master, feature request in bug#12433
  - With --reorder, keep tests with same *-master.opt content together,
    to save even more master restarts
parent 72f509e2
...@@ -85,11 +85,24 @@ sub collect_test_cases ($) { ...@@ -85,11 +85,24 @@ sub collect_test_cases ($) {
if ( $::opt_reorder ) if ( $::opt_reorder )
{ {
@$cases = sort { @$cases = sort {
if ( $a->{'master_restart'} and $b->{'master_restart'} or if ( ! $a->{'master_restart'} and ! $b->{'master_restart'} )
! $a->{'master_restart'} and ! $b->{'master_restart'} )
{ {
return $a->{'name'} cmp $b->{'name'}; return $a->{'name'} cmp $b->{'name'};
} }
if ( $a->{'master_restart'} and $b->{'master_restart'} )
{
my $cmp= mtr_cmp_opts($a->{'master_opt'}, $b->{'master_opt'});
if ( $cmp == 0 )
{
return $a->{'name'} cmp $b->{'name'};
}
else
{
return $cmp;
}
}
if ( $a->{'master_restart'} ) if ( $a->{'master_restart'} )
{ {
return 1; # Is greater return 1; # Is greater
...@@ -189,8 +202,8 @@ sub collect_one_test_case($$$$$$) { ...@@ -189,8 +202,8 @@ sub collect_one_test_case($$$$$$) {
my $slave_sh= "$testdir/$tname-slave.sh"; my $slave_sh= "$testdir/$tname-slave.sh";
my $disabled_file= "$testdir/$tname.disabled"; my $disabled_file= "$testdir/$tname.disabled";
$tinfo->{'master_opt'}= $::glob_win32 ? ["--default-time-zone=+3:00"] : []; $tinfo->{'master_opt'}= [];
$tinfo->{'slave_opt'}= $::glob_win32 ? ["--default-time-zone=+3:00"] : []; $tinfo->{'slave_opt'}= [];
$tinfo->{'slave_mi'}= []; $tinfo->{'slave_mi'}= [];
if ( -f $master_opt_file ) if ( -f $master_opt_file )
...@@ -213,7 +226,6 @@ sub collect_one_test_case($$$$$$) { ...@@ -213,7 +226,6 @@ sub collect_one_test_case($$$$$$) {
if ( defined $value ) if ( defined $value )
{ {
$tinfo->{'timezone'}= $value; $tinfo->{'timezone'}= $value;
$tinfo->{'skip'}= 1 if $::glob_win32; # FIXME server unsets TZ
last MASTER_OPT; last MASTER_OPT;
} }
......
...@@ -13,6 +13,9 @@ sub mtr_add_arg ($$); ...@@ -13,6 +13,9 @@ sub mtr_add_arg ($$);
sub mtr_path_exists(@); sub mtr_path_exists(@);
sub mtr_script_exists(@); sub mtr_script_exists(@);
sub mtr_exe_exists(@); sub mtr_exe_exists(@);
sub mtr_copy_dir($$);
sub mtr_same_opts($$);
sub mtr_cmp_opts($$);
############################################################################## ##############################################################################
# #
...@@ -108,5 +111,44 @@ sub mtr_exe_exists (@) { ...@@ -108,5 +111,44 @@ sub mtr_exe_exists (@) {
} }
} }
sub mtr_copy_dir($$) {
my $srcdir= shift;
my $dstdir= shift;
# Create destination directory
mkpath($dstdir);
find(\&mtr_copy_one_file, $dstdir);
}
sub mtr_copy_one_file {
print $File::Find::name, "\n";
}
sub mtr_same_opts ($$) {
my $l1= shift;
my $l2= shift;
return mtr_cmp_opts($l1,$l2) == 0;
}
sub mtr_cmp_opts ($$) {
my $l1= shift;
my $l2= shift;
my @l1= @$l1;
my @l2= @$l2;
return -1 if @l1 < @l2;
return 1 if @l1 > @l2;
while ( @l1 ) # Same length
{
my $e1= shift @l1;
my $e2= shift @l2;
my $cmp= ($e1 cmp $e2);
return $cmp if $cmp != 0;
}
return 0; # They are the same
}
1; 1;
...@@ -76,6 +76,7 @@ $Devel::Trace::TRACE= 0; # Don't trace boring init stuff ...@@ -76,6 +76,7 @@ $Devel::Trace::TRACE= 0; # Don't trace boring init stuff
#require 5.6.1; #require 5.6.1;
use File::Path; use File::Path;
use File::Basename; use File::Basename;
use File::Copy;
use Cwd; use Cwd;
use Getopt::Long; use Getopt::Long;
use Sys::Hostname; use Sys::Hostname;
...@@ -152,6 +153,7 @@ our $path_language; ...@@ -152,6 +153,7 @@ our $path_language;
our $path_timefile; our $path_timefile;
our $path_manager_log; # Used by mysqldadmin our $path_manager_log; # Used by mysqldadmin
our $path_slave_load_tmpdir; # What is this?! our $path_slave_load_tmpdir; # What is this?!
our $path_mysqltest_log;
our $path_my_basedir; our $path_my_basedir;
our $opt_vardir; # A path but set directly on cmd line our $opt_vardir; # A path but set directly on cmd line
our $opt_tmpdir; # A path but set directly on cmd line our $opt_tmpdir; # A path but set directly on cmd line
...@@ -239,7 +241,7 @@ our $opt_sleep_time_after_restart= 1; ...@@ -239,7 +241,7 @@ our $opt_sleep_time_after_restart= 1;
our $opt_sleep_time_for_delete= 10; our $opt_sleep_time_for_delete= 10;
our $opt_testcase_timeout; our $opt_testcase_timeout;
our $opt_suite_timeout; our $opt_suite_timeout;
my $default_testcase_timeout= 10; # 10 min max my $default_testcase_timeout= 15; # 15 min max
my $default_suite_timeout= 120; # 2 hours max my $default_suite_timeout= 120; # 2 hours max
our $opt_socket; our $opt_socket;
...@@ -258,6 +260,7 @@ our $opt_user; ...@@ -258,6 +260,7 @@ our $opt_user;
our $opt_user_test; our $opt_user_test;
our $opt_valgrind; our $opt_valgrind;
our $opt_valgrind_mysqld;
our $opt_valgrind_mysqltest; our $opt_valgrind_mysqltest;
our $opt_valgrind_all; our $opt_valgrind_all;
our $opt_valgrind_options; our $opt_valgrind_options;
...@@ -476,7 +479,8 @@ sub command_line_setup () { ...@@ -476,7 +479,8 @@ sub command_line_setup () {
# #
if ( $ENV{'MTR_BUILD_THREAD'} ) if ( $ENV{'MTR_BUILD_THREAD'} )
{ {
$opt_master_myport= $ENV{'MTR_BUILD_THREAD'} * 10 + 10000; # Up to two masters, up to three slaves
$opt_master_myport= $ENV{'MTR_BUILD_THREAD'} * 10 + 10000; # and 1
$opt_slave_myport= $opt_master_myport + 2; # and 3 4 $opt_slave_myport= $opt_master_myport + 2; # and 3 4
$opt_ndbcluster_port= $opt_master_myport + 5; $opt_ndbcluster_port= $opt_master_myport + 5;
} }
...@@ -619,6 +623,7 @@ sub command_line_setup () { ...@@ -619,6 +623,7 @@ sub command_line_setup () {
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
$opt_tmpdir= "$opt_vardir/tmp" unless $opt_tmpdir; $opt_tmpdir= "$opt_vardir/tmp" unless $opt_tmpdir;
$opt_tmpdir =~ s,/+$,,; # Remove ending slash if any
# FIXME maybe not needed? # FIXME maybe not needed?
$path_manager_log= "$opt_vardir/log/manager.log" $path_manager_log= "$opt_vardir/log/manager.log"
unless $path_manager_log; unless $path_manager_log;
...@@ -735,6 +740,7 @@ sub command_line_setup () { ...@@ -735,6 +740,7 @@ sub command_line_setup () {
# "somestring" option is name/path of valgrind executable # "somestring" option is name/path of valgrind executable
# Take executable path from any of them, if any # Take executable path from any of them, if any
$opt_valgrind_mysqld= $opt_valgrind;
$opt_valgrind= $opt_valgrind_mysqltest if $opt_valgrind_mysqltest; $opt_valgrind= $opt_valgrind_mysqltest if $opt_valgrind_mysqltest;
$opt_valgrind= $opt_valgrind_all if $opt_valgrind_all; $opt_valgrind= $opt_valgrind_all if $opt_valgrind_all;
...@@ -844,6 +850,7 @@ sub command_line_setup () { ...@@ -844,6 +850,7 @@ sub command_line_setup () {
} }
$path_timefile= "$opt_vardir/log/mysqltest-time"; $path_timefile= "$opt_vardir/log/mysqltest-time";
$path_mysqltest_log= "$opt_vardir/log/mysqltest.log";
} }
...@@ -863,7 +870,8 @@ sub executable_setup () { ...@@ -863,7 +870,8 @@ sub executable_setup () {
"$glob_basedir/bin"); "$glob_basedir/bin");
$exe_mysqld= mtr_exe_exists ("$path_client_bindir/mysqld-nt", $exe_mysqld= mtr_exe_exists ("$path_client_bindir/mysqld-nt",
"$path_client_bindir/mysqld", "$path_client_bindir/mysqld",
"$path_client_bindir/mysqld-debug",); "$path_client_bindir/mysqld-debug",
"$path_client_bindir/mysqld-max");
$path_language= mtr_path_exists("$glob_basedir/share/english/"); $path_language= mtr_path_exists("$glob_basedir/share/english/");
$path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets"); $path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets");
} }
...@@ -884,8 +892,20 @@ sub executable_setup () { ...@@ -884,8 +892,20 @@ sub executable_setup () {
"/usr/bin/false"); "/usr/bin/false");
} }
else else
{
if ( $opt_valgrind_mysqltest )
{
# client/mysqltest might be a libtool .sh script, so look for real exe
# to avoid valgrinding bash ;)
$exe_mysqltest=
mtr_exe_exists("$path_client_bindir/.libs/lt-mysqltest",
"$path_client_bindir/.libs/mysqltest",
"$path_client_bindir/mysqltest");
}
else
{ {
$exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest"); $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
}
$exe_mysql_client_test= $exe_mysql_client_test=
mtr_exe_exists("$glob_basedir/tests/mysql_client_test", mtr_exe_exists("$glob_basedir/tests/mysql_client_test",
"/usr/bin/false"); "/usr/bin/false");
...@@ -995,6 +1015,7 @@ sub environment_setup () { ...@@ -995,6 +1015,7 @@ sub environment_setup () {
$ENV{'USE_RUNNING_SERVER'}= $glob_use_running_server; $ENV{'USE_RUNNING_SERVER'}= $glob_use_running_server;
$ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir; $ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir;
$ENV{'MYSQL_TEST_WINDIR'}= $glob_mysql_test_dir; $ENV{'MYSQL_TEST_WINDIR'}= $glob_mysql_test_dir;
$ENV{'MYSQLTEST_VARDIR'}= $opt_vardir;
$ENV{'MASTER_WINMYSOCK'}= $master->[0]->{'path_mysock'}; $ENV{'MASTER_WINMYSOCK'}= $master->[0]->{'path_mysock'};
$ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_mysock'}; $ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_mysock'};
$ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_mysock'}; $ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_mysock'};
...@@ -1006,6 +1027,8 @@ sub environment_setup () { ...@@ -1006,6 +1027,8 @@ sub environment_setup () {
# $ENV{'MYSQL_TCP_PORT'}= '@MYSQL_TCP_PORT@'; # FIXME # $ENV{'MYSQL_TCP_PORT'}= '@MYSQL_TCP_PORT@'; # FIXME
$ENV{'MYSQL_TCP_PORT'}= 3306; $ENV{'MYSQL_TCP_PORT'}= 3306;
$ENV{'NDBCLUSTER_PORT'}= $opt_ndbcluster_port;
if ( $glob_cygwin_perl ) if ( $glob_cygwin_perl )
{ {
foreach my $key ('MYSQL_TEST_WINDIR','MASTER_MYSOCK') foreach my $key ('MYSQL_TEST_WINDIR','MASTER_MYSOCK')
...@@ -1025,7 +1048,7 @@ sub environment_setup () { ...@@ -1025,7 +1048,7 @@ sub environment_setup () {
print "Using SLAVE_MYPORT = $ENV{SLAVE_MYPORT}\n"; print "Using SLAVE_MYPORT = $ENV{SLAVE_MYPORT}\n";
print "Using SLAVE_MYPORT1 = $ENV{SLAVE_MYPORT1}\n"; print "Using SLAVE_MYPORT1 = $ENV{SLAVE_MYPORT1}\n";
print "Using SLAVE_MYPORT2 = $ENV{SLAVE_MYPORT2}\n"; print "Using SLAVE_MYPORT2 = $ENV{SLAVE_MYPORT2}\n";
print "Using NDBCLUSTER_PORT = $opt_ndbcluster_port\n"; print "Using NDBCLUSTER_PORT = $ENV{NDBCLUSTER_PORT}\n";
} }
...@@ -1087,10 +1110,40 @@ sub kill_and_cleanup () { ...@@ -1087,10 +1110,40 @@ sub kill_and_cleanup () {
mtr_report("Removing Stale Files"); mtr_report("Removing Stale Files");
if ( $opt_vardir eq "$glob_mysql_test_dir/var" )
{
#
# Running with "var" in mysql-test dir
#
if ( -l "$glob_mysql_test_dir/var" )
{
# Some users creates a soft link in mysql-test/var to another area
# - allow it
mtr_report("WARNING: Using the 'mysql-test/var' symlink");
rmtree("$opt_vardir/log"); rmtree("$opt_vardir/log");
rmtree("$opt_vardir/ndbcluster-$opt_ndbcluster_port"); rmtree("$opt_vardir/ndbcluster-$opt_ndbcluster_port");
rmtree("$opt_vardir/run"); rmtree("$opt_vardir/run");
rmtree("$opt_vardir/tmp"); rmtree("$opt_vardir/tmp");
}
else
{
# Remove the entire "var" dir
rmtree("$opt_vardir/");
}
}
else
{
#
# Running with "var" in some other place
#
# Remove the var/ dir in mysql-test dir if any
# this could be an old symlink that shouldn't be there
rmtree("$glob_mysql_test_dir/var");
# Remove the "var" dir
rmtree("$opt_vardir/");
}
mkpath("$opt_vardir/log"); mkpath("$opt_vardir/log");
mkpath("$opt_vardir/run"); mkpath("$opt_vardir/run");
...@@ -1114,14 +1167,22 @@ sub kill_and_cleanup () { ...@@ -1114,14 +1167,22 @@ sub kill_and_cleanup () {
mkpath("$data_dir/test"); mkpath("$data_dir/test");
} }
# To make some old test cases work, we create a soft # Make a link std_data_ln in var/ that points to std_data
# link from the old "var" location to the new one if ( ! $glob_win32 )
{
if ( ! $glob_win32 and $opt_vardir ne "$glob_mysql_test_dir/var" ) symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
}
else
{ {
# FIXME why bother with the above, why not always remove all of var?! # on windows, copy all files from std_data into var/std_data_ln
rmtree("$glob_mysql_test_dir/var"); # Clean old var, FIXME or rename it?! mkpath("$opt_vardir/std_data_ln");
symlink($opt_vardir, "$glob_mysql_test_dir/var"); opendir(DIR, "$glob_mysql_test_dir/std_data")
or mtr_error("Can't find the std_data directory: $!");
for my $elem ( readdir(DIR) ) {
next if -d "$glob_mysql_test_dir/std_data/$elem";
copy("$glob_mysql_test_dir/std_data/$elem", "$opt_vardir/std_data_ln/$elem");
}
closedir(DIR);
} }
} }
...@@ -1480,11 +1541,33 @@ sub run_testcase ($) { ...@@ -1480,11 +1541,33 @@ sub run_testcase ($) {
if ( ! $glob_use_running_server and ! $glob_use_embedded_server ) if ( ! $glob_use_running_server and ! $glob_use_embedded_server )
{ {
if ( $tinfo->{'master_restart'} or # We try to find out if we are to restart the server
my $do_restart= 0; # Assumes we don't have to
if ( $tinfo->{'master_sh'} )
{
$do_restart= 1; # Always restart if script to run
}
elsif ( $master->[0]->{'running_master_is_special'} and
$master->[0]->{'running_master_is_special'}->{'timezone'} eq
$tinfo->{'timezone'} and
mtr_same_opts($master->[0]->{'running_master_is_special'}->{'master_opt'},
$tinfo->{'master_opt'}) )
{
# If running master was started with special settings, but
# the current test requuires the same ones, we *don't* restart.
$do_restart= 0;
}
elsif ( $tinfo->{'master_restart'} or
$master->[0]->{'running_master_is_special'} ) $master->[0]->{'running_master_is_special'} )
{
$do_restart= 1;
}
if ( $do_restart )
{ {
stop_masters(); stop_masters();
$master->[0]->{'running_master_is_special'}= 0; # Forget why we stopped delete $master->[0]->{'running_master_is_special'}; # Forget history
} }
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -1553,6 +1636,7 @@ sub run_testcase ($) { ...@@ -1553,6 +1636,7 @@ sub run_testcase ($) {
} }
if ( $opt_with_ndbcluster and ! $master->[1]->{'pid'} ) if ( $opt_with_ndbcluster and ! $master->[1]->{'pid'} )
{ {
# Test needs cluster, start an extra mysqld connected to cluster
$master->[1]->{'pid'}= $master->[1]->{'pid'}=
mysqld_start('master',1,$tinfo->{'master_opt'},[]); mysqld_start('master',1,$tinfo->{'master_opt'},[]);
if ( ! $master->[1]->{'pid'} ) if ( ! $master->[1]->{'pid'} )
...@@ -1564,7 +1648,8 @@ sub run_testcase ($) { ...@@ -1564,7 +1648,8 @@ sub run_testcase ($) {
if ( $tinfo->{'master_restart'} ) if ( $tinfo->{'master_restart'} )
{ {
$master->[0]->{'running_master_is_special'}= 1; # Save this test case information, so next can examine it
$master->[0]->{'running_master_is_special'}= $tinfo;
} }
} }
...@@ -1797,7 +1882,7 @@ sub mysqld_arguments ($$$$$) { ...@@ -1797,7 +1882,7 @@ sub mysqld_arguments ($$$$$) {
mtr_add_arg($args, "%s--language=%s", $prefix, $path_language); mtr_add_arg($args, "%s--language=%s", $prefix, $path_language);
mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix); mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
if ( defined $opt_valgrind ) if ( defined $opt_valgrind_mysqld )
{ {
mtr_add_arg($args, "%s--skip-safemalloc", $prefix); mtr_add_arg($args, "%s--skip-safemalloc", $prefix);
mtr_add_arg($args, "%s--skip-bdb", $prefix); mtr_add_arg($args, "%s--skip-bdb", $prefix);
...@@ -1864,6 +1949,10 @@ sub mysqld_arguments ($$$$$) { ...@@ -1864,6 +1949,10 @@ sub mysqld_arguments ($$$$$) {
mtr_add_arg($args, "%s--skip-innodb", $prefix); mtr_add_arg($args, "%s--skip-innodb", $prefix);
mtr_add_arg($args, "%s--skip-ndbcluster", $prefix); mtr_add_arg($args, "%s--skip-ndbcluster", $prefix);
mtr_add_arg($args, "%s--skip-slave-start", $prefix); mtr_add_arg($args, "%s--skip-slave-start", $prefix);
# Directory where slaves find the dumps generated by "load data"
# on the server. The path need to have constant length otherwise
# test results will vary, thus a relative path is used.
mtr_add_arg($args, "%s--slave-load-tmpdir=%s", $prefix, mtr_add_arg($args, "%s--slave-load-tmpdir=%s", $prefix,
$path_slave_load_tmpdir); $path_slave_load_tmpdir);
mtr_add_arg($args, "%s--socket=%s", $prefix, mtr_add_arg($args, "%s--socket=%s", $prefix,
...@@ -2022,7 +2111,7 @@ sub mysqld_start ($$$$) { ...@@ -2022,7 +2111,7 @@ sub mysqld_start ($$$$) {
mtr_init_args(\$args); mtr_init_args(\$args);
if ( defined $opt_valgrind ) if ( defined $opt_valgrind_mysqld )
{ {
valgrind_arguments($args, \$exe); valgrind_arguments($args, \$exe);
} }
......
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