Backport from 5.1

 -Add support for detecting version and features from mysqld binary
 - Autodetect netware
 - Disable some features not available below 5.0
 - Cleanup executable_setup to look for one executable at a time, only llok for the ones that are needed based on the selected testcases and settings
parent 5aac9b58
This diff is collapsed.
This diff is collapsed.
...@@ -11,6 +11,8 @@ sub mtr_get_opts_from_file ($); ...@@ -11,6 +11,8 @@ sub mtr_get_opts_from_file ($);
sub mtr_fromfile ($); sub mtr_fromfile ($);
sub mtr_tofile ($@); sub mtr_tofile ($@);
sub mtr_tonewfile($@); sub mtr_tonewfile($@);
sub mtr_lastlinefromfile($);
sub mtr_appendfile_to_file ($$);
############################################################################## ##############################################################################
# #
...@@ -19,13 +21,39 @@ sub mtr_tonewfile($@); ...@@ -19,13 +21,39 @@ sub mtr_tonewfile($@);
############################################################################## ##############################################################################
sub mtr_get_pid_from_file ($) { sub mtr_get_pid_from_file ($) {
my $file= shift; my $pid_file_path= shift;
my $TOTAL_ATTEMPTS= 30;
my $timeout= 1;
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!"); # We should read from the file until we get correct pid. As it is
my $pid= <FILE>; # stated in BUG#21884, pid file can be empty at some moment. So, we should
chomp($pid); # read it until we get valid data.
close FILE;
return $pid; for (my $cur_attempt= 1; $cur_attempt <= $TOTAL_ATTEMPTS; ++$cur_attempt)
{
mtr_debug("Reading pid file '$pid_file_path' " .
"($cur_attempt of $TOTAL_ATTEMPTS)...");
open(FILE, '<', $pid_file_path)
or mtr_error("can't open file \"$pid_file_path\": $!");
my $pid= <FILE>;
chomp($pid) if defined $pid;
close FILE;
return $pid if defined $pid && $pid ne '';
mtr_debug("Pid file '$pid_file_path' is empty. " .
"Sleeping $timeout second(s)...");
sleep(1);
}
mtr_error("Pid file '$pid_file_path' is corrupted. " .
"Can not retrieve PID in " .
($timeout * $TOTAL_ATTEMPTS) . " seconds.");
} }
sub mtr_get_opts_from_file ($) { sub mtr_get_opts_from_file ($) {
...@@ -113,6 +141,20 @@ sub mtr_fromfile ($) { ...@@ -113,6 +141,20 @@ sub mtr_fromfile ($) {
return $text; return $text;
} }
sub mtr_lastlinefromfile ($) {
my $file= shift;
my $text;
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
while (my $line= <FILE>)
{
$text= $line;
}
close FILE;
return $text;
}
sub mtr_tofile ($@) { sub mtr_tofile ($@) {
my $file= shift; my $file= shift;
...@@ -129,5 +171,17 @@ sub mtr_tonewfile ($@) { ...@@ -129,5 +171,17 @@ sub mtr_tonewfile ($@) {
close FILE; close FILE;
} }
sub mtr_appendfile_to_file ($$) {
my $from_file= shift;
my $to_file= shift;
open(TOFILE,">>",$to_file) or mtr_error("can't open file \"$to_file\": $!");
open(FROMFILE,">>",$from_file)
or mtr_error("can't open file \"$from_file\": $!");
print TOFILE while (<FROMFILE>);
close FROMFILE;
close TOFILE;
}
1; 1;
...@@ -9,9 +9,10 @@ use strict; ...@@ -9,9 +9,10 @@ use strict;
sub mtr_full_hostname (); sub mtr_full_hostname ();
sub mtr_short_hostname (); sub mtr_short_hostname ();
sub mtr_init_args ($); sub mtr_init_args ($);
sub mtr_add_arg ($$); sub mtr_add_arg ($$@);
sub mtr_path_exists(@); sub mtr_path_exists(@);
sub mtr_script_exists(@); sub mtr_script_exists(@);
sub mtr_file_exists(@);
sub mtr_exe_exists(@); sub mtr_exe_exists(@);
sub mtr_copy_dir($$); sub mtr_copy_dir($$);
sub mtr_same_opts($$); sub mtr_same_opts($$);
...@@ -54,7 +55,7 @@ sub mtr_init_args ($) { ...@@ -54,7 +55,7 @@ sub mtr_init_args ($) {
$$args = []; # Empty list $$args = []; # Empty list
} }
sub mtr_add_arg ($$) { sub mtr_add_arg ($$@) {
my $args= shift; my $args= shift;
my $format= shift; my $format= shift;
my @fargs = @_; my @fargs = @_;
...@@ -101,6 +102,14 @@ sub mtr_script_exists (@) { ...@@ -101,6 +102,14 @@ sub mtr_script_exists (@) {
} }
} }
sub mtr_file_exists (@) {
foreach my $path ( @_ )
{
return $path if -e $path;
}
return "";
}
sub mtr_exe_exists (@) { sub mtr_exe_exists (@) {
my @path= @_; my @path= @_;
map {$_.= ".exe"} @path if $::glob_win32; map {$_.= ".exe"} @path if $::glob_win32;
...@@ -125,19 +134,30 @@ sub mtr_exe_exists (@) { ...@@ -125,19 +134,30 @@ sub mtr_exe_exists (@) {
} }
} }
sub mtr_copy_dir($$) { sub mtr_copy_dir($$) {
my $srcdir= shift; my $from_dir= shift;
my $dstdir= shift; my $to_dir= shift;
# Create destination directory # mtr_verbose("Copying from $from_dir to $to_dir");
mkpath($dstdir);
find(\&mtr_copy_one_file, $dstdir); mkpath("$to_dir");
} opendir(DIR, "$from_dir")
or mtr_error("Can't find $from_dir$!");
for(readdir(DIR)) {
next if "$_" eq "." or "$_" eq "..";
if ( -d "$from_dir/$_" )
{
mtr_copy_dir("$from_dir/$_", "$to_dir/$_");
next;
}
copy("$from_dir/$_", "$to_dir/$_");
}
closedir(DIR);
sub mtr_copy_one_file {
print $File::Find::name, "\n";
} }
sub mtr_same_opts ($$) { sub mtr_same_opts ($$) {
my $l1= shift; my $l1= shift;
my $l2= shift; my $l2= shift;
......
This diff is collapsed.
...@@ -10,6 +10,7 @@ sub mtr_report_test_name($); ...@@ -10,6 +10,7 @@ sub mtr_report_test_name($);
sub mtr_report_test_passed($); sub mtr_report_test_passed($);
sub mtr_report_test_failed($); sub mtr_report_test_failed($);
sub mtr_report_test_skipped($); sub mtr_report_test_skipped($);
sub mtr_report_test_not_skipped_though_disabled($);
sub mtr_show_failed_diff ($); sub mtr_show_failed_diff ($);
sub mtr_report_stats ($); sub mtr_report_stats ($);
...@@ -21,6 +22,7 @@ sub mtr_warning (@); ...@@ -21,6 +22,7 @@ sub mtr_warning (@);
sub mtr_error (@); sub mtr_error (@);
sub mtr_child_error (@); sub mtr_child_error (@);
sub mtr_debug (@); sub mtr_debug (@);
sub mtr_verbose (@);
############################################################################## ##############################################################################
...@@ -36,6 +38,7 @@ sub mtr_show_failed_diff ($) { ...@@ -36,6 +38,7 @@ sub mtr_show_failed_diff ($) {
my $reject_file= "r/$tname.reject"; my $reject_file= "r/$tname.reject";
my $result_file= "r/$tname.result"; my $result_file= "r/$tname.result";
my $log_file= "r/$tname.log";
my $eval_file= "r/$tname.eval"; my $eval_file= "r/$tname.eval";
if ( $::opt_suite ne "main" ) if ( $::opt_suite ne "main" )
...@@ -43,10 +46,11 @@ sub mtr_show_failed_diff ($) { ...@@ -43,10 +46,11 @@ sub mtr_show_failed_diff ($) {
$reject_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$reject_file"; $reject_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$reject_file";
$result_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$result_file"; $result_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$result_file";
$eval_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$eval_file"; $eval_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$eval_file";
$log_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$log_file";
} }
if ( -f $eval_file ) if ( -f $eval_file )
{ {
$result_file= $eval_file; $result_file= $eval_file;
} }
elsif ( $::opt_result_ext and elsif ( $::opt_result_ext and
...@@ -70,6 +74,12 @@ sub mtr_show_failed_diff ($) { ...@@ -70,6 +74,12 @@ sub mtr_show_failed_diff ($) {
print "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html\n"; print "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html\n";
print "to find the reason to this problem and how to report this.\n\n"; print "to find the reason to this problem and how to report this.\n\n";
} }
if ( -f $log_file )
{
print "Result from queries before failure can be found in $log_file\n";
# FIXME Maybe a tail -f -n 10 $log_file here
}
} }
sub mtr_report_test_name ($) { sub mtr_report_test_name ($) {
...@@ -88,7 +98,24 @@ sub mtr_report_test_skipped ($) { ...@@ -88,7 +98,24 @@ sub mtr_report_test_skipped ($) {
} }
else else
{ {
print "[ skipped ]\n"; print "[ skipped ] $tinfo->{'comment'}\n";
}
}
sub mtr_report_tests_not_skipped_though_disabled ($) {
my $tests= shift;
if ( $::opt_enable_disabled )
{
my @disabled_tests= grep {$_->{'dont_skip_though_disabled'}} @$tests;
if ( @disabled_tests )
{
print "\nTest(s) which will be run though they are marked as disabled:\n";
foreach my $tinfo ( sort {$a->{'name'} cmp $b->{'name'}} @disabled_tests )
{
printf " %-20s : %s\n", $tinfo->{'name'}, $tinfo->{'comment'};
}
}
} }
} }
...@@ -99,7 +126,7 @@ sub mtr_report_test_passed ($) { ...@@ -99,7 +126,7 @@ sub mtr_report_test_passed ($) {
if ( $::opt_timer and -f "$::opt_vardir/log/timer" ) if ( $::opt_timer and -f "$::opt_vardir/log/timer" )
{ {
$timer= mtr_fromfile("$::opt_vardir/log/timer"); $timer= mtr_fromfile("$::opt_vardir/log/timer");
$::glob_tot_real_time += $timer; $::glob_tot_real_time += ($timer/1000);
$timer= sprintf "%12s", $timer; $timer= sprintf "%12s", $timer;
} }
$tinfo->{'result'}= 'MTR_RES_PASSED'; $tinfo->{'result'}= 'MTR_RES_PASSED';
...@@ -114,6 +141,11 @@ sub mtr_report_test_failed ($) { ...@@ -114,6 +141,11 @@ sub mtr_report_test_failed ($) {
{ {
print "[ fail ] timeout\n"; print "[ fail ] timeout\n";
} }
elsif ( $tinfo->{'ndb_test'} and $::cluster->[0]->{'installed_ok'} eq "NO")
{
print "[ fail ] ndbcluster start failure\n";
return;
}
else else
{ {
print "[ fail ]\n"; print "[ fail ]\n";
...@@ -144,6 +176,8 @@ sub mtr_report_stats ($) { ...@@ -144,6 +176,8 @@ sub mtr_report_stats ($) {
my $tot_passed= 0; my $tot_passed= 0;
my $tot_failed= 0; my $tot_failed= 0;
my $tot_tests= 0; my $tot_tests= 0;
my $tot_restarts= 0;
my $found_problems= 0; # Some warnings are errors...
foreach my $tinfo (@$tests) foreach my $tinfo (@$tests)
{ {
...@@ -161,6 +195,10 @@ sub mtr_report_stats ($) { ...@@ -161,6 +195,10 @@ sub mtr_report_stats ($) {
$tot_tests++; $tot_tests++;
$tot_failed++; $tot_failed++;
} }
if ( $tinfo->{'restarted'} )
{
$tot_restarts++;
}
} }
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -183,41 +221,69 @@ sub mtr_report_stats ($) { ...@@ -183,41 +221,69 @@ sub mtr_report_stats ($) {
"the documentation at\n", "the documentation at\n",
"http://www.mysql.com/doc/en/MySQL_test_suite.html\n"; "http://www.mysql.com/doc/en/MySQL_test_suite.html\n";
} }
print
"The servers were restarted $tot_restarts times\n";
if ( $::opt_timer )
{
print
"Spent $::glob_tot_real_time seconds actually executing testcases\n"
}
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# If a debug run, there might be interesting information inside
# the "var/log/*.err" files. We save this info in "var/log/warnings"
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
if ( ! $::glob_use_running_server ) if ( ! $::glob_use_running_server )
{ {
# Save and report if there was any fatal warnings/errors in err logs
# Report if there was any fatal warnings/errors in the log files my $warnlog= "$::opt_vardir/log/warnings";
#
unlink("$::opt_vardir/log/warnings"); unless ( open(WARN, ">$warnlog") )
unlink("$::opt_vardir/log/warnings.tmp"); {
# Remove some non fatal warnings from the log files mtr_warning("can't write to the file \"$warnlog\": $!");
}
# FIXME what is going on ????? ;-) else
# sed -e 's!Warning: Table:.* on delete!!g' -e 's!Warning: Setting lower_case_table_names=2!!g' -e 's!Warning: One can only use the --user.*root!!g' \ {
# var/log/*.err \ # We report different types of problems in order
# | sed -e 's!Warning: Table:.* on rename!!g' \ foreach my $pattern ( "^Warning:", "^Error:", "^==.* at 0x",
# > var/log/warnings.tmp; "InnoDB: Warning", "missing DBUG_RETURN",
# "mysqld: Warning",
# found_error=0; "Attempting backtrace", "Assertion .* failed" )
# # Find errors {
# for i in "^Warning:" "^Error:" "^==.* at 0x" foreach my $errlog ( sort glob("$::opt_vardir/log/*.err") )
# do {
# if ( $GREP "$i" var/log/warnings.tmp >> var/log/warnings ) unless ( open(ERR, $errlog) )
# { {
# found_error=1 mtr_warning("can't read $errlog");
# } next;
# done }
# unlink("$::opt_vardir/log/warnings.tmp"); while ( <ERR> )
# if ( $found_error= "1" ) {
# { # Skip some non fatal warnings from the log files
# print "WARNING: Got errors/warnings while running tests. Please examine\n" if ( /Warning:\s+Table:.* on (delete|rename)/ or
# print "$::opt_vardir/log/warnings for details.\n" /Warning:\s+Setting lower_case_table_names=2/ or
# } /Warning:\s+One can only use the --user.*root/ or
# } /InnoDB: Warning: we did not need to do crash recovery/)
{
next; # Skip these lines
}
if ( /$pattern/ )
{
$found_problems= 1;
print WARN $_;
}
}
}
}
if ( $found_problems )
{
mtr_warning("Got errors/warnings while running tests, please examine",
"\"$warnlog\" for details.");
}
}
} }
print "\n"; print "\n";
...@@ -235,6 +301,9 @@ sub mtr_report_stats ($) { ...@@ -235,6 +301,9 @@ sub mtr_report_stats ($) {
} }
} }
print "\n"; print "\n";
}
if ( $tot_failed != 0 || $found_problems)
{
mtr_error("there where failing test cases"); mtr_error("there where failing test cases");
} }
} }
...@@ -298,5 +367,11 @@ sub mtr_debug (@) { ...@@ -298,5 +367,11 @@ sub mtr_debug (@) {
print STDERR "####: ",join(" ", @_),"\n"; print STDERR "####: ",join(" ", @_),"\n";
} }
} }
sub mtr_verbose (@) {
if ( $::opt_verbose )
{
print STDERR "> ",join(" ", @_),"\n";
}
}
1; 1;
# -*- cperl -*-
# This is a library file used by the Perl version of mysql-test-run,
# and is part of the translation of the Bourne shell script with the
# same name.
use strict;
use File::Spec;
# These are not to be prefixed with "mtr_"
sub run_stress_test ();
##############################################################################
#
# Run tests in the stress mode
#
##############################################################################
sub run_stress_test ()
{
my $args;
my $stress_suitedir;
mtr_report("Starting stress testing\n");
if ( ! $::glob_use_embedded_server )
{
if ( ! mysqld_start($::master->[0],[],[]) )
{
mtr_error("Can't start the mysqld server");
}
}
my $stress_basedir=File::Spec->catdir($::opt_vardir, "stress");
#Clean up stress dir
if ( -d $stress_basedir )
{
rmtree($stress_basedir);
}
mkpath($stress_basedir);
if ($::opt_stress_suite ne 'main' && $::opt_stress_suite ne 'default' )
{
$stress_suitedir=File::Spec->catdir($::glob_mysql_test_dir, "suite",
$::opt_stress_suite);
}
else
{
$stress_suitedir=$::glob_mysql_test_dir;
}
if ( -d $stress_suitedir )
{
#$stress_suite_t_dir=File::Spec->catdir($stress_suitedir, "t");
#$stress_suite_r_dir=File::Spec->catdir($stress_suitedir, "r");
#FIXME: check dirs above for existence to ensure that test suite
# contains tests and results dirs
}
else
{
mtr_error("Specified test suite $::opt_stress_suite doesn't exist");
}
if ( @::opt_cases )
{
$::opt_stress_test_file=File::Spec->catfile($stress_basedir, "stress_tests.txt");
open(STRESS_FILE, ">$::opt_stress_test_file");
print STRESS_FILE join("\n",@::opt_cases),"\n";
close(STRESS_FILE);
}
elsif ( $::opt_stress_test_file )
{
$::opt_stress_test_file=File::Spec->catfile($stress_suitedir,
$::opt_stress_test_file);
if ( ! -f $::opt_stress_test_file )
{
mtr_error("Specified file $::opt_stress_test_file with list of tests does not exist\n",
"Please ensure that file exists and has proper permissions");
}
}
else
{
$::opt_stress_test_file=File::Spec->catfile($stress_suitedir,
"stress_tests.txt");
if ( ! -f $::opt_stress_test_file )
{
mtr_error("Default file $::opt_stress_test_file with list of tests does not exist\n",
"Please use --stress-test-file option to specify custom one or you can\n",
"just specify name of test for testing as last argument in command line");
}
}
if ( $::opt_stress_init_file )
{
$::opt_stress_init_file=File::Spec->catfile($stress_suitedir,
$::opt_stress_init_file);
if ( ! -f $::opt_stress_init_file )
{
mtr_error("Specified file $::opt_stress_init_file with list of tests does not exist\n",
"Please ensure that file exists and has proper permissions");
}
}
else
{
$::opt_stress_init_file=File::Spec->catfile($stress_suitedir,
"stress_init.txt");
if ( ! -f $::opt_stress_init_file )
{
$::opt_stress_init_file='';
}
}
if ( $::opt_stress_mode ne 'random' && $::opt_stress_mode ne 'seq' )
{
mtr_error("You specified wrong mode $::opt_stress_mode for stress test\n",
"Correct values are 'random' or 'seq'");
}
mtr_init_args(\$args);
mtr_add_arg($args, "--server-socket=%s", $::master->[0]->{'path_mysock'});
mtr_add_arg($args, "--server-user=%s", $::opt_user);
mtr_add_arg($args, "--server-database=%s", "test");
mtr_add_arg($args, "--stress-suite-basedir=%s", $::glob_mysql_test_dir);
mtr_add_arg($args, "--suite=%s", $::opt_stress_suite);
mtr_add_arg($args, "--stress-tests-file=%s", $::opt_stress_test_file);
mtr_add_arg($args, "--stress-basedir=%s", $stress_basedir);
mtr_add_arg($args, "--server-logs-dir=%s", $stress_basedir);
mtr_add_arg($args, "--stress-mode=%s", $::opt_stress_mode);
mtr_add_arg($args, "--mysqltest=%s", $::exe_mysqltest);
mtr_add_arg($args, "--threads=%s", $::opt_stress_threads);
mtr_add_arg($args, "--verbose");
mtr_add_arg($args, "--cleanup");
mtr_add_arg($args, "--log-error-details");
mtr_add_arg($args, "--abort-on-error");
if ( $::opt_stress_init_file )
{
mtr_add_arg($args, "--stress-init-file=%", $::opt_stress_init_file);
}
if ( !$::opt_stress_loop_count && !$::opt_stress_test_count &&
!$::opt_stress_test_duration )
{
#Limit stress testing with 20 loops in case when any limit parameter
#was specified
$::opt_stress_test_count=20;
}
if ( $::opt_stress_loop_count )
{
mtr_add_arg($args, "--loop-count=%s", $::opt_stress_loop_count);
}
if ( $::opt_stress_test_count )
{
mtr_add_arg($args, "--test-count=%s", $::opt_stress_test_count);
}
if ( $::opt_stress_test_duration )
{
mtr_add_arg($args, "--test-duration=%s", $::opt_stress_test_duration);
}
#Run stress test
mtr_run("$::glob_mysql_test_dir/mysql-stress-test.pl", $args, "", "", "", "");
if ( ! $::glob_use_embedded_server )
{
stop_masters();
}
}
1;
This diff is collapsed.
...@@ -163,7 +163,7 @@ mysqltest: At line 1: Invalid argument to error: '1sssss' - the errno may only c ...@@ -163,7 +163,7 @@ mysqltest: At line 1: Invalid argument to error: '1sssss' - the errno may only c
mysqltest: At line 1: The sqlstate must be exactly 5 chars long mysqltest: At line 1: The sqlstate must be exactly 5 chars long
mysqltest: At line 1: The sqlstate may only consist of digits[0-9] and _uppercase_ letters mysqltest: At line 1: The sqlstate may only consist of digits[0-9] and _uppercase_ letters
mysqltest: At line 1: The sqlstate must be exactly 5 chars long mysqltest: At line 1: The sqlstate must be exactly 5 chars long
mysqltest: At line 1: Not available in mysqltest for MySQL 4.1.22 mysqltest: At line 1: Not available in this version of mysqltest
mysqltest: At line 1: Invalid argument to error: '999e9' - the errno may only consist of digits[0-9] mysqltest: At line 1: Invalid argument to error: '999e9' - the errno may only consist of digits[0-9]
mysqltest: At line 1: Invalid argument to error: '9b' - the errno may only consist of digits[0-9] mysqltest: At line 1: Invalid argument to error: '9b' - the errno may only consist of digits[0-9]
mysqltest: At line 1: Too many errorcodes specified mysqltest: At line 1: Too many errorcodes specified
......
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