1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-03 05:41:09 +03:00

Merge with 5.2

This commit is contained in:
Michael Widenius
2011-03-09 15:47:59 +02:00
1617 changed files with 25609 additions and 41019 deletions

View File

@@ -1,6 +1,5 @@
#!/usr/bin/perl
# -*- cperl -*-
#
##############################################################################
#
@@ -617,6 +616,11 @@ sub run_test_server ($$$) {
if ( !$opt_force ) {
# Test has failed, force is off
push(@$completed, $result);
if ($result->{'dont_kill_server'})
{
print $sock "BYE\n";
next;
}
return ("Failure", 1, $completed, $extra_warnings);
}
elsif ($opt_max_test_fail > 0 and
@@ -722,16 +726,6 @@ sub run_test_server ($$$) {
next;
}
# Prefer same configuration, or just use next if --noreorder
if (!$opt_reorder or (defined $result and
$result->{template_path} eq $t->{template_path}))
{
#mtr_report("Test uses same config => good match");
# Test uses same config => good match
$next= splice(@$tests, $i, 1);
last;
}
# From secondary choices, we prefer to pick a 'long-running' test if
# possible; this helps avoid getting stuck with a few of those at the
# end of high --parallel runs, with most workers being idle.
@@ -740,6 +734,34 @@ sub run_test_server ($$$) {
#mtr_report("Setting second_best to $i");
$second_best= $i;
}
# Smart allocation of next test within this thread.
if ($opt_reorder and $opt_parallel > 1 and defined $result)
{
my $wid= $result->{worker};
# Reserved for other thread, try next
next if (defined $t->{reserved} and $t->{reserved} != $wid);
if (! defined $t->{reserved})
{
# Force-restart not relevant when comparing *next* test
$t->{criteria} =~ s/force-restart$/no-restart/;
my $criteria= $t->{criteria};
# Reserve similar tests for this worker, but not too many
my $maxres= (@$tests - $i) / $opt_parallel + 1;
for (my $j= $i+1; $j <= $i + $maxres; $j++)
{
my $tt= $tests->[$j];
last unless defined $tt;
last if $tt->{criteria} ne $criteria;
$tt->{reserved}= $wid;
}
}
}
# At this point we have found next suitable test
$next= splice(@$tests, $i, 1);
last;
}
# Use second best choice if no other test has been found
@@ -748,12 +770,14 @@ sub run_test_server ($$$) {
mtr_error("Internal error, second best too large($second_best)")
if $second_best > $#$tests;
$next= splice(@$tests, $second_best, 1);
delete $next->{reserved};
}
xterm_stat(scalar(@$tests));
if ($next) {
#$next->print_test();
# We don't need this any more
delete $next->{criteria};
$next->write_test($sock, 'TESTCASE');
$running{$next->key()}= $next;
$num_ndb_tests++ if ($next->{ndb_test});
@@ -835,6 +859,11 @@ sub run_worker ($) {
delete($test->{'comment'});
delete($test->{'logfile'});
# A sanity check. Should this happen often we need to look at it.
if (defined $test->{reserved} && $test->{reserved} != $thread_num) {
my $tres= $test->{reserved};
mtr_warning("Test reserved for w$tres picked up by w$thread_num");
}
$test->{worker} = $thread_num if $opt_parallel > 1;
run_testcase($test, $server);
@@ -857,10 +886,14 @@ sub run_worker ($) {
else {
stop_all_servers($opt_shutdown_timeout);
}
my $valgrind_reports= 0;
if ($opt_valgrind_mysqld) {
$valgrind_reports= valgrind_exit_reports();
}
if ( $opt_gprof ) {
gprof_collect (find_mysqld($basedir), keys %gprof_dirs);
}
exit(0);
exit($valgrind_reports);
}
else {
mtr_error("Could not understand server, '$line'");
@@ -905,7 +938,7 @@ sub command_line_setup {
my $opt_list_options;
# Read the command line options
# Note: Keep list, and the order, in sync with usage at end of this file
# Note: Keep list in sync with usage at end of this file
Getopt::Long::Configure("pass_through");
my %options=(
# Control what engine/variation to run
@@ -941,6 +974,7 @@ sub command_line_setup {
'combination=s' => \@opt_combinations,
'skip-combinations' => \&collect_option,
'experimental=s' => \@opt_experimentals,
# skip-im is deprecated and silently ignored
'skip-im' => \&ignore_option,
'staging-run' => \$opt_staging_run,
@@ -1042,8 +1076,9 @@ sub command_line_setup {
'max-connections=i' => \$opt_max_connections,
'help|h' => \$opt_usage,
'list-options' => \$opt_list_options,
);
# list-options is internal, not listed in help
'list-options' => \$opt_list_options,
);
GetOptions(%options) or usage("Can't read options");
usage("") if $opt_usage;
@@ -1599,16 +1634,16 @@ sub set_build_thread_ports($) {
$ENV{MTR_BUILD_THREAD}= $build_thread;
# Calculate baseport
$baseport= $build_thread * 10 + 10000;
if ( $baseport < 5001 or $baseport + 9 >= 32767 )
$baseport= $build_thread * 20 + 10000;
if ( $baseport < 5001 or $baseport + 19 >= 32767 )
{
mtr_error("MTR_BUILD_THREAD number results in a port",
"outside 5001 - 32767",
"($baseport - $baseport + 9)");
"($baseport - $baseport + 19)");
}
mtr_report("Using MTR_BUILD_THREAD $build_thread,",
"with reserved ports $baseport..".($baseport+9));
"with reserved ports $baseport..".($baseport+19));
}
@@ -2088,6 +2123,16 @@ sub environment_setup {
$ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'} || 3306;
$ENV{'MYSQL_TMP_DIR'}= $opt_tmpdir;
$ENV{'MYSQLTEST_VARDIR'}= $opt_vardir;
if (IS_WINDOWS)
{
$ENV{'SECURE_LOAD_PATH'}= $glob_mysql_test_dir."\\std_data";
}
else
{
$ENV{'SECURE_LOAD_PATH'}= $glob_mysql_test_dir."/std_data";
}
#
# Some stupid^H^H^H^H^H^Hignorant network providers set up "wildcard DNS"
@@ -2290,10 +2335,10 @@ sub remove_stale_vardir () {
# 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
mtr_verbose("Removing $default_vardir");
rmtree($default_vardir);
# Don't remove the var/ dir in mysql-test dir as it may be in
# use by another mysql-test-run run with --vardir
# mtr_verbose("Removing $default_vardir");
# rmtree($default_vardir);
# Remove the "var" dir
mtr_verbose("Removing $opt_vardir/");
@@ -3610,13 +3655,14 @@ 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
sub restart_forced_by_test($)
{
my $file = shift;
my $restart = 0;
foreach my $mysqld ( mysqlds() )
{
my $datadir = $mysqld->value('datadir');
my $force_restart_file = "$datadir/mtr/force_restart";
my $force_restart_file = "$datadir/mtr/$file";
if ( -f $force_restart_file )
{
mtr_verbose("Restart of servers forced by test");
@@ -3780,6 +3826,7 @@ sub run_testcase ($$) {
# Generate new config file from template
$config= My::ConfigFactory->new_config
( {
testname => $tinfo->{name},
basedir => $basedir,
testdir => $glob_mysql_test_dir,
template_path => $tinfo->{template_path},
@@ -3951,7 +3998,7 @@ sub run_testcase ($$) {
if ( $res == 0 )
{
my $check_res;
if ( restart_forced_by_test() )
if ( restart_forced_by_test('force_restart') )
{
stop_all_servers($opt_shutdown_timeout);
}
@@ -3990,8 +4037,11 @@ sub run_testcase ($$) {
find_testcase_skipped_reason($tinfo);
mtr_report_test_skipped($tinfo);
# Restart if skipped due to missing perl, it may have had side effects
stop_all_servers($opt_shutdown_timeout)
if ($tinfo->{'comment'} =~ /^perl not found/);
if ( restart_forced_by_test('force_restart_if_skipped') ||
$tinfo->{'comment'} =~ /^perl not found/ )
{
stop_all_servers($opt_shutdown_timeout);
}
}
elsif ( $res == 65 )
{
@@ -4042,7 +4092,6 @@ sub run_testcase ($$) {
# ----------------------------------------------------
# Check if it was an expected crash
# ----------------------------------------------------
SRVDIED:
my $check_crash = check_expected_crash_and_restart($proc);
if ($check_crash)
{
@@ -4052,6 +4101,7 @@ sub run_testcase ($$) {
next;
}
SRVDIED:
# ----------------------------------------------------
# Stop the test case timer
# ----------------------------------------------------
@@ -4315,6 +4365,7 @@ sub extract_warning_lines ($) {
qr/Plugin 'ndbcluster' will be forced to shutdown/,
qr/InnoDB: Error: in ALTER TABLE `test`.`t[12]`/,
qr/InnoDB: Error: table `test`.`t[12]` does not exist in the InnoDB internal/,
qr/InnoDB: Warning: a long semaphore wait:/,
qr/Slave: Unknown table 't1' Error_code: 1051/,
qr/Slave SQL:.*(Error_code: [[:digit:]]+|Query:.*)/,
qr/slave SQL thread aborted/,
@@ -4695,6 +4746,19 @@ sub after_failure ($) {
mkpath($save_dir) if ! -d $save_dir;
#
# Create a log of files in vardir (good for buildbot)
#
if (!IS_WINDOWS)
{
my $Flog= IO::File->new("$opt_vardir/log/files.log", "w");
if ($Flog)
{
print $Flog scalar(`/bin/ls -Rl $opt_vardir/*`);
close($Flog);
}
}
# Save the used config files
my %config_files = config_files($tinfo);
while (my ($file, $generate) = each %config_files) {
@@ -4714,7 +4778,12 @@ sub after_failure ($) {
sub report_failure_and_restart ($) {
my $tinfo= shift;
stop_all_servers();
if ($opt_valgrind_mysqld && ($tinfo->{'warnings'} || $tinfo->{'timeout'})) {
# In these cases we may want valgrind report from normal termination
$tinfo->{'dont_kill_server'}= 1;
}
# Shotdown properly if not to be killed (for valgrind)
stop_all_servers($tinfo->{'dont_kill_server'} ? $opt_shutdown_timeout : 0);
$tinfo->{'result'}= 'MTR_RES_FAILED';
@@ -5101,17 +5170,6 @@ sub server_need_restart {
}
}
# Temporary re-enable the "always restart slave" hack
# this should be removed asap, but will require that each rpl
# testcase cleanup better after itself - ie. stop and reset
# replication
# Use the "#!use-slave-opt" marker to detect that this is a "slave"
# server
if ( $server->option("#!use-slave-opt") ){
mtr_verbose_restart($server, "Always restart slave(s)");
return 1;
}
if ($server->name() =~ /^mysqld\./)
{
@@ -5252,7 +5310,7 @@ sub start_servers($) {
for (all_servers()) {
next unless $_->{WAIT} and started($_);
if ($_->{WAIT}->($_)) {
$tinfo->{comment}= "Failed to start ".$_->name();
$tinfo->{comment}= "Failed to start ".$_->name() . "\n";
return 1;
}
}
@@ -5712,6 +5770,72 @@ sub strace_arguments {
}
}
#
# Search server logs for valgrind reports printed at mysqld termination
#
sub valgrind_exit_reports() {
my $found_err= 0;
foreach my $log_file (keys %mysqld_logs)
{
my @culprits= ();
my $valgrind_rep= "";
my $found_report= 0;
my $err_in_report= 0;
my $LOGF = IO::File->new($log_file)
or mtr_error("Could not open file '$log_file' for reading: $!");
while ( my $line = <$LOGF> )
{
if ($line =~ /^CURRENT_TEST: (.+)$/)
{
my $testname= $1;
# If we have a report, report it if needed and start new list of tests
if ($found_report)
{
if ($err_in_report)
{
mtr_print ("Valgrind report from $log_file after tests:\n",
@culprits);
mtr_print_line();
print ("$valgrind_rep\n");
$err_in_report= 0;
}
# Make ready to collect new report
@culprits= ();
$found_report= 0;
$valgrind_rep= "";
}
push (@culprits, $testname);
next;
}
# This line marks the start of a valgrind report
$found_report= 1 if $line =~ /^==\d+== .* SUMMARY:/;
if ($found_report) {
$line=~ s/^==\d+== //;
$valgrind_rep .= $line;
$err_in_report= 1 if $line =~ /ERROR SUMMARY: [1-9]/;
$err_in_report= 1 if $line =~ /definitely lost: [1-9]/;
$err_in_report= 1 if $line =~ /possibly lost: [1-9]/;
}
}
$LOGF= undef;
if ($err_in_report) {
mtr_print ("Valgrind report from $log_file after tests:\n", @culprits);
mtr_print_line();
print ("$valgrind_rep\n");
$found_err= 1;
}
}
return $found_err;
}
#
# Usage
@@ -5746,7 +5870,7 @@ Options to control what engine/variation to run
parallel=# How many parallell test should be run
defaults-file=<config template> Use fixed config template for all
tests
defaults_extra_file=<config template> Extra config template to add to
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
@@ -5840,6 +5964,9 @@ Options for debugging the product
test(s)
manual-ddd Let user manually start mysqld in ddd, before running
test(s)
strace-client[=path] Create strace output for mysqltest client, optionally
specifying name and path to the trace program to use.
Example: $0 --strace-client=ktrace
max-save-core Limit the number of core files saved (to avoid filling
up disks for heavily crashing server). Defaults to
$opt_max_save_core, set to 0 for no limit. Set
@@ -5879,7 +6006,7 @@ Options for strace
Misc options
user=USER User for connecting to mysqld(default: $opt_user)
comment=STR Write STR to the output
notimer Don't show test case execution time
timer 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
@@ -5933,6 +6060,7 @@ Misc options
gcov-src-dir=subdir Colllect coverage only within the given subdirectory.
For example, if you're only developing the SQL layer,
it makes sense to use --gcov-src-dir=sql
gprof Collect profiling information using gprof.
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
@@ -5941,6 +6069,10 @@ Misc options
*previous* test started
max-connections=N Max number of open connection to server in mysqltest
Some options that control enabling a feature for normal test runs,
can be turned off by prepending 'no' to the option, e.g. --notimer.
This applies to reorder, timer, check-testcases and warnings.
HERE
exit(1);