summaryrefslogtreecommitdiff
path: root/mysql-test/mysql-test-run.pl
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/mysql-test-run.pl')
-rwxr-xr-xmysql-test/mysql-test-run.pl223
1 files changed, 174 insertions, 49 deletions
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index cd92d4367ee..e48bc1954cb 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -126,7 +126,8 @@ my $path_config_file; # The generated config file, var/my.cnf
# executables will be used by the test suite.
our $opt_vs_config = $ENV{'MTR_VS_CONFIG'};
-my $DEFAULT_SUITES= "binlog,federated,main,maria,ndb,rpl,rpl_ndb";
+my $DEFAULT_SUITES= "binlog,federated,main,maria,ndb,rpl,rpl_ndb,innodb";
+my $opt_suites;
our $opt_usage;
our $opt_list_options;
@@ -215,6 +216,7 @@ sub check_timeout { return $opt_testcase_timeout * 6; };
my $opt_start;
my $opt_start_dirty;
+my $opt_wait_all;
my $opt_repeat= 1;
my $opt_retry= 3;
my $opt_retry_failure= 2;
@@ -324,7 +326,7 @@ sub main {
#######################################################################
my $num_tests= @$tests;
- if ( not defined $opt_parallel ) {
+ if ( $opt_parallel eq "auto" ) {
# Try to find a suitable value for number of workers
my $sys_info= My::SysInfo->new();
@@ -444,6 +446,7 @@ sub run_test_server ($$$) {
my $completed= [];
my %running;
my $result;
+ my $exe_mysqld= find_mysqld($basedir) || ""; # Used as hint to CoreDump
my $suite_timeout_proc= My::SafeProcess->timer(suite_timeout());
@@ -515,7 +518,7 @@ sub run_test_server ($$$) {
mtr_report(" - found '$core_name'",
"($num_saved_cores/$opt_max_save_core)");
- My::CoreDump->show($core_file);
+ My::CoreDump->show($core_file, $exe_mysqld);
if ($num_saved_cores >= $opt_max_save_core) {
mtr_report(" - deleting it, already saved",
@@ -530,6 +533,7 @@ sub run_test_server ($$$) {
}
}
$num_saved_datadir++;
+ $num_failed_test++ unless $result->{retries};
$test_failure= 1;
if ( !$opt_force ) {
@@ -541,11 +545,11 @@ sub run_test_server ($$$) {
elsif ($opt_max_test_fail > 0 and
$num_failed_test >= $opt_max_test_fail) {
$suite_timeout_proc->kill();
+ push(@$completed, $result);
mtr_report("Too many tests($num_failed_test) failed!",
"Terminating...");
return (1, $completed, $extra_warnings);
}
- $num_failed_test++;
}
# Retry test run after test failure
@@ -570,9 +574,11 @@ sub run_test_server ($$$) {
# Repeat test $opt_repeat number of times
my $repeat= $result->{repeat} || 1;
- if ($repeat < $opt_repeat)
+ # Don't repeat if test was skipped
+ if ($repeat < $opt_repeat && $result->{'result'} ne 'MTR_RES_SKIPPED')
{
$result->{retries}= 0;
+ $result->{rep_failures}++ if $result->{failures};
$result->{failures}= 0;
delete($result->{result});
$result->{repeat}= $repeat+1;
@@ -747,6 +753,8 @@ sub run_worker ($) {
delete($test->{'comment'});
delete($test->{'logfile'});
+ $test->{worker} = $thread_num if $opt_parallel > 1;
+
run_testcase($test, $server);
#$test->{result}= 'MTR_RES_PASSED';
# Send it back, now with results set
@@ -824,7 +832,7 @@ sub command_line_setup {
'vs-config' => \$opt_vs_config,
# Max number of parallel threads to use
- 'parallel=i' => \$opt_parallel,
+ 'parallel=s' => \$opt_parallel,
# Config file to use as template for all tests
'defaults-file=s' => \&collect_option,
@@ -919,6 +927,7 @@ sub command_line_setup {
'sleep=i' => \$opt_sleep,
'start-dirty' => \$opt_start_dirty,
'start' => \$opt_start,
+ 'wait-all' => \$opt_wait_all,
'print-testcases' => \&collect_option,
'repeat=i' => \$opt_repeat,
'retry=i' => \$opt_retry,
@@ -1176,9 +1185,9 @@ sub command_line_setup {
# --------------------------------------------------------------------------
# Check parallel value
# --------------------------------------------------------------------------
- if ($opt_parallel < 1)
+ if ($opt_parallel ne "auto" && $opt_parallel < 1)
{
- mtr_error("0 or negative parallel value makes no sense, use positive number");
+ mtr_error("0 or negative parallel value makes no sense, use 'auto' or positive number");
}
# --------------------------------------------------------------------------
@@ -1298,6 +1307,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
# --------------------------------------------------------------------------
@@ -1399,29 +1417,31 @@ sub set_build_thread_ports($) {
if ( lc($opt_build_thread) eq 'auto' ) {
my $found_free = 0;
- $build_thread = 250; # Start attempts from here
+ $build_thread = 300; # Start attempts from here
while (! $found_free)
{
- $build_thread= mtr_get_unique_id($build_thread, 299);
+ $build_thread= mtr_get_unique_id($build_thread, 349);
if ( !defined $build_thread ) {
- mtr_error("Could not get a unique build thread id");
+ mtr_error("Could not get a unique build thread id");
}
$found_free= check_ports_free($build_thread);
# If not free, release and try from next number
- mtr_release_unique_id($build_thread++) unless $found_free;
+ if (! $found_free) {
+ mtr_release_unique_id();
+ $build_thread++;
+ }
}
}
else
{
$build_thread = $opt_build_thread + $thread - 1;
+ if (! check_ports_free($build_thread)) {
+ # Some port was not free(which one has already been printed)
+ mtr_error("Some port(s) was not free")
+ }
}
$ENV{MTR_BUILD_THREAD}= $build_thread;
- if (! check_ports_free($build_thread)) {
- # Some port was not free(which one has already been printed)
- mtr_error("Some port(s) was not free")
- }
-
# Calculate baseport
$baseport= $build_thread * 10 + 10000;
if ( $baseport < 5001 or $baseport + 9 >= 32767 )
@@ -1676,14 +1696,22 @@ sub mysql_fix_arguments () {
}
-sub client_arguments ($) {
+sub client_arguments ($;$) {
my $client_name= shift;
+ my $group_suffix= shift;
my $client_exe= mtr_exe_exists("$path_client_bindir/$client_name");
my $args;
mtr_init_args(\$args);
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
- client_debug_arg($args, $client_name);
+ if (defined($group_suffix)) {
+ mtr_add_arg($args, "--defaults-group-suffix=%s", $group_suffix);
+ client_debug_arg($args, "$client_name-$group_suffix");
+ }
+ else
+ {
+ client_debug_arg($args, $client_name);
+ }
return mtr_args2str($client_exe, @$args);
}
@@ -1837,15 +1865,26 @@ sub environment_setup {
# --------------------------------------------------------------------------
# Add the path where mysqld will find ha_example.so
# --------------------------------------------------------------------------
- if ($mysql_version_id >= 50100) {
+ if ($mysql_version_id >= 50100 && !(IS_WINDOWS && $opt_embedded_server)) {
+ my $plugin_filename;
+ if (IS_WINDOWS)
+ {
+ $plugin_filename = "ha_example.dll";
+ }
+ else
+ {
+ $plugin_filename = "ha_example.so";
+ }
my $lib_example_plugin=
- mtr_file_exists(vs_config_dirs('storage/example', 'ha_example.dll'),
- "$basedir/storage/example/.libs/ha_example.so",);
+ mtr_file_exists(vs_config_dirs('storage/example',$plugin_filename),
+ "$basedir/storage/example/.libs/".$plugin_filename);
$ENV{'EXAMPLE_PLUGIN'}=
($lib_example_plugin ? basename($lib_example_plugin) : "");
$ENV{'EXAMPLE_PLUGIN_OPT'}= "--plugin-dir=".
($lib_example_plugin ? dirname($lib_example_plugin) : "");
+ $ENV{'HA_EXAMPLE_SO'}="'".$plugin_filename."'";
+ $ENV{'EXAMPLE_PLUGIN_LOAD'}="--plugin_load=;EXAMPLE=".$plugin_filename.";";
}
# ----------------------------------------------------
@@ -1964,6 +2003,7 @@ sub environment_setup {
$ENV{'MYSQL_SHOW'}= client_arguments("mysqlshow");
$ENV{'MYSQL_BINLOG'}= mysqlbinlog_arguments();
$ENV{'MYSQL'}= client_arguments("mysql");
+ $ENV{'MYSQL_SLAVE'}= client_arguments("mysql", ".2");
$ENV{'MYSQL_UPGRADE'}= client_arguments("mysql_upgrade");
$ENV{'MYSQLADMIN'}= native_path($exe_mysqladmin);
$ENV{'MYSQL_CLIENT_TEST'}= mysql_client_test_arguments();
@@ -3265,6 +3305,26 @@ sub find_analyze_request
}
+# The test can leave a file in var/tmp/ to signal
+# that all servers should be restarted
+sub restart_forced_by_test
+{
+ my $restart = 0;
+ foreach my $mysqld ( mysqlds() )
+ {
+ my $datadir = $mysqld->value('datadir');
+ my $force_restart_file = "$datadir/mtr/force_restart";
+ if ( -f $force_restart_file )
+ {
+ mtr_verbose("Restart of servers forced by test");
+ $restart = 1;
+ last;
+ }
+ }
+ return $restart;
+}
+
+
# Return timezone value of tinfo or default value
sub timezone {
my ($tinfo)= @_;
@@ -3311,7 +3371,7 @@ sub run_testcase ($$) {
{
# Remove old datadirs
- clean_datadir();
+ clean_datadir() unless $opt_start_dirty;
# Restore old ENV
while (my ($option, $value)= each( %old_env )) {
@@ -3378,19 +3438,29 @@ sub run_testcase ($$) {
# --------------------------------------------------------------------
# If --start or --start-dirty given, stop here to let user manually
# 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 )
{
mtr_print("\nStarted", started(all_servers()));
mtr_print("Waiting for server(s) to exit...");
- my $proc= My::SafeProcess->wait_any();
- if ( grep($proc eq $_, started(all_servers())) )
- {
- mtr_print("Server $proc died");
+ if ( $opt_wait_all ) {
+ My::SafeProcess->wait_all();
+ mtr_print( "All servers exited" );
+ exit(1);
+ }
+ else {
+ my $proc= My::SafeProcess->wait_any();
+ if ( grep($proc eq $_, started(all_servers())) )
+ {
+ mtr_print("Server $proc died");
+ exit(1);
+ }
+ mtr_print("Unknown process $proc died");
exit(1);
}
- mtr_print("Unknown process $proc died");
- exit(1);
}
my $test_timeout_proc= My::SafeProcess->timer(testcase_timeout());
@@ -3408,10 +3478,38 @@ sub run_testcase ($$) {
}
my $test= start_mysqltest($tinfo);
+ # Set only when we have to keep waiting after expectedly died server
+ my $keep_waiting_proc = 0;
while (1)
{
- my $proc= My::SafeProcess->wait_any();
+ my $proc;
+ if ($keep_waiting_proc)
+ {
+ # Any other process exited?
+ $proc = My::SafeProcess->check_any();
+ if ($proc)
+ {
+ mtr_verbose ("Found exited process $proc");
+ # If that was the timeout, cancel waiting
+ if ( $proc eq $test_timeout_proc )
+ {
+ $keep_waiting_proc = 0;
+ }
+ }
+ else
+ {
+ $proc = $keep_waiting_proc;
+ }
+ }
+ else
+ {
+ $proc= My::SafeProcess->wait_any();
+ }
+
+ # Will be restored if we need to keep waiting
+ $keep_waiting_proc = 0;
+
unless ( defined $proc )
{
mtr_error("wait_any failed");
@@ -3438,7 +3536,11 @@ sub run_testcase ($$) {
if ( $res == 0 )
{
my $check_res;
- if ( $opt_check_testcases and
+ if ( restart_forced_by_test() )
+ {
+ stop_all_servers();
+ }
+ elsif ( $opt_check_testcases and
$check_res= check_testcase($tinfo, "after"))
{
if ($check_res == 1) {
@@ -3514,8 +3616,12 @@ sub run_testcase ($$) {
# ----------------------------------------------------
# Check if it was an expected crash
# ----------------------------------------------------
- if ( check_expected_crash_and_restart($proc) )
+ my $check_crash = check_expected_crash_and_restart($proc);
+ if ($check_crash)
{
+ # Keep waiting if it returned 2, if 1 don't wait or stop waiting.
+ $keep_waiting_proc = 0 if $check_crash == 1;
+ $keep_waiting_proc = $proc if $check_crash == 2;
next;
}
@@ -3953,16 +4059,16 @@ sub check_expected_crash_and_restart {
{
mtr_verbose("Crash was expected, file '$expect_file' exists");
- while (1){
-
+ for (my $waits = 0; $waits < 50; $waits++)
+ {
# If last line in expect file starts with "wait"
# sleep a little and try again, thus allowing the
# test script to control when the server should start
- # up again
+ # up again. Keep trying for up to 5s at a time.
my $last_line= mtr_lastlinesfromfile($expect_file, 1);
if ($last_line =~ /^wait/ )
{
- mtr_verbose("Test says wait before restart");
+ mtr_verbose("Test says wait before restart") if $waits == 0;
mtr_milli_sleep(100);
next;
}
@@ -3972,11 +4078,11 @@ sub check_expected_crash_and_restart {
# Start server with same settings as last time
mysqld_start($mysqld, $mysqld->{'started_opts'});
- last;
+ return 1;
}
+ # Loop ran through: we should keep waiting after a re-check
+ return 2;
}
-
- return 1;
}
# Not an expected crash
@@ -4692,14 +4798,17 @@ sub start_servers($) {
my $mysqld_basedir= $mysqld->value('basedir');
if ( $basedir eq $mysqld_basedir )
{
- # Copy datadir from installed system db
- for my $path ( "$opt_vardir", "$opt_vardir/..") {
- my $install_db= "$path/install.db";
- copytree($install_db, $datadir)
- if -d $install_db;
+ if (! $opt_start_dirty) # If dirty, keep possibly grown system db
+ {
+ # Copy datadir from installed system db
+ for my $path ( "$opt_vardir", "$opt_vardir/..") {
+ my $install_db= "$path/install.db";
+ copytree($install_db, $datadir)
+ if -d $install_db;
+ }
+ mtr_error("Failed to copy system db to '$datadir'")
+ unless -d $datadir;
}
- mtr_error("Failed to copy system db to '$datadir'")
- unless -d $datadir;
}
else
{
@@ -5250,10 +5359,13 @@ Options to control what engine/variation to run
vs-config Visual Studio configuration used to create executables
(default: MTR_VS_CONFIG environment variable)
parallel=# How many parallell test should be run
- config|defaults-file=<config template> Use fixed config template for all
+ defaults-file=<config template> Use fixed config template for all
tests
defaults_extra_file=<config template> Extra config template to add to
all generated configs
+ combination=<opt> Use at least twice to run tests with specified
+ options to mysqld
+ skip-combinations Ignore combination file (or options)
Options to control directories to use
tmpdir=DIR The directory where temporary files are stored
@@ -5276,7 +5388,6 @@ Options to control what test suites or cases to run
force Continue to run the suite after failure
with-ndbcluster-only Run only tests that include "ndb" in the filename
skip-ndb[cluster] Skip all tests that need cluster
- skip-ndb[cluster]-slave Skip all tests that need a slave cluster
do-test=PREFIX or REGEX
Run test cases which name are prefixed with PREFIX
or fulfills REGEX
@@ -5293,6 +5404,9 @@ Options to control what test suites or cases to run
big-test Also run tests marked as "big"
staging-run Run a limited number of tests (no slow tests). Used
for running staging trees with valgrind.
+ enable-disabled Run also tests marked as disabled
+ print_testcases Don't run the tests but print details about all the
+ selected tests, in the order they would be run.
Options that specify ports
@@ -5362,7 +5476,7 @@ Options for valgrind
valgrind-options=ARGS Deprecated, use --valgrind-option
valgrind-option=ARGS Option to give valgrind, replaces default option(s),
can be specified more then once
- valgrind-path=[EXE] Path to the valgrind executable
+ valgrind-path=<EXE> Path to the valgrind executable
callgrind Instruct valgrind to use callgrind
Misc options
@@ -5370,14 +5484,19 @@ Misc options
comment=STR Write STR to the output
notimer Don't show test case execution time
verbose More verbose output(use multiple times for even more)
+ verbose-restart Write when and why servers are restarted
start Only initialize and start the servers, using the
startup settings for the first specified test case
Example:
$0 --start alias &
start-dirty Only start the servers (without initialization) for
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
to shutdown etc.
+ parallel=N Run tests in N parallel threads (default=1)
+ Use parallel=auto for auto-setting of N
repeat=N Run each test N number of times
retry=N Retry tests that fail N times, limit number of failures
to $opt_retry_failure
@@ -5397,6 +5516,12 @@ Misc options
actions. Disable facility with NUM=0.
gcov Collect coverage information after the test.
The result is a gcov file per source and header file.
+ experimental=<file> Refer to list of tests considered experimental;
+ failures will be marked exp-fail instead of fail.
+ report-features First run a "test" that reports mysql features
+ timestamp Print timestamp before each test report line
+ timediff With --timestamp, also print time passed since
+ *previous* test started
HERE
exit(1);