272
225
my $opt_valgrind_path;
273
226
my $opt_callgrind;
276
our $opt_stress_suite= "main";
277
our $opt_stress_mode= "random";
278
our $opt_stress_threads= 5;
279
our $opt_stress_test_count= 0;
280
our $opt_stress_loop_count= 0;
281
our $opt_stress_test_duration= 0;
282
our $opt_stress_init_file= "";
283
our $opt_stress_test_file= "";
228
our $opt_warnings= 1;
287
230
our $opt_skip_ndbcluster= 0;
288
our $opt_skip_ndbcluster_slave= 0;
289
our $opt_with_ndbcluster= 0;
290
our $opt_with_ndbcluster_only= 0;
291
our $glob_ndbcluster_supported= 0;
292
our $opt_ndb_extra_test= 0;
293
our $opt_skip_master_binlog= 0;
294
our $opt_skip_slave_binlog= 0;
298
our $path_ndb_tools_dir;
299
our $path_ndb_examples_dir;
300
our $exe_ndb_example;
301
our $path_ndb_testrun_log;
307
our $used_binlog_format;
308
our $used_default_engine;
309
236
our $debug_compiled_binaries;
311
238
our %mysqld_variables;
313
240
my $source_dist= 0;
315
our $opt_max_save_core= 5;
316
my $num_saved_cores= 0; # Number of core files saved in vardir/log/ so far.
318
######################################################################
320
# Function declarations
322
######################################################################
325
sub initial_setup ();
326
sub command_line_setup ();
327
sub set_mtr_build_thread_ports($);
328
sub datadir_list_setup ();
329
sub executable_setup ();
330
sub environment_setup ();
331
sub kill_running_servers ();
332
sub remove_stale_vardir ();
334
sub check_ssl_support ($);
335
sub check_running_as_root();
336
sub check_ndbcluster_support ($);
337
sub rm_ndbcluster_tables ($);
338
sub ndbcluster_start_install ($);
339
sub ndbcluster_start ($$);
340
sub ndbcluster_wait_started ($$);
341
sub mysqld_wait_started($);
342
sub run_benchmarks ($);
343
sub initialize_servers ();
344
sub mysql_install_db ();
346
sub copy_install_db ($$);
347
sub run_testcase ($);
348
sub run_testcase_stop_servers ($$$);
349
sub run_testcase_start_servers ($);
350
sub run_testcase_check_skip_test($);
351
sub report_failure_and_restart ($);
352
sub do_before_start_master ($);
353
sub do_before_start_slave ($);
354
sub ndbd_start ($$$);
355
sub ndb_mgmd_start ($);
356
sub mysqld_start ($$$);
357
sub mysqld_arguments ($$$$);
358
sub stop_all_servers ();
359
sub run_mysqltest ($);
363
######################################################################
367
######################################################################
242
my $opt_max_save_core= $ENV{MTR_MAX_SAVE_CORE} || 5;
243
my $opt_max_save_datadir= $ENV{MTR_MAX_SAVE_DATADIR} || 20;
244
my $opt_max_test_fail= $ENV{MTR_MAX_TEST_FAIL} || 10;
246
my $opt_parallel= $ENV{MTR_PARALLEL} || 1;
249
$| = 1; # Automatically flush STDOUT
255
# Default, verbosity on
256
report_option('verbose', 0);
258
# This is needed for test log evaluation in "gen-build-status-page"
259
# in all cases where the calling tool does not log the commands
260
# directly before it executes them, like "make test-force-pl" in RPM builds.
261
mtr_report("Logging: $0 ", join(" ", @ARGV));
373
263
command_line_setup();
375
check_ndbcluster_support(\%mysqld_variables);
376
check_ssl_support(\%mysqld_variables);
377
check_debug_support(\%mysqld_variables);
266
gcov_prepare($basedir);
270
$opt_suites= $DEFAULT_SUITES;
272
# Check for any extra suites to enable based on the path name
275
"mysql-5.1-new-ndb" => "ndb_team",
276
"mysql-5.1-new-ndb-merge" => "ndb_team",
277
"mysql-5.1-telco-6.2" => "ndb_team",
278
"mysql-5.1-telco-6.2-merge" => "ndb_team",
279
"mysql-5.1-telco-6.3" => "ndb_team",
280
"mysql-6.0-ndb" => "ndb_team",
283
foreach my $dir ( reverse splitdir($basedir) ) {
284
my $extra_suite= $extra_suites{$dir};
285
if (defined $extra_suite) {
286
mtr_report("Found extra suite: $extra_suite");
287
$opt_suites= "$extra_suite,$opt_suites";
293
mtr_report("Collecting tests...");
294
my $tests= collect_test_cases($opt_suites, \@opt_cases);
296
if ( $opt_report_features ) {
297
# Put "report features" as the first test to run
298
my $tinfo = My::Test->new
300
name => 'report_features',
301
# No result_file => Prints result
302
path => 'include/report-features.test',
303
template_path => "include/default_my.cnf",
307
unshift(@$tests, $tinfo);
310
print "vardir: $opt_vardir\n";
311
initialize_servers();
313
#######################################################################
314
my $num_tests= @$tests;
315
if ( not defined $opt_parallel ) {
316
# Try to find a suitable value for number of workers
317
my $sys_info= My::SysInfo->new();
319
$opt_parallel= $sys_info->num_cpus();
320
for my $limit (2000, 1500, 1000, 500){
321
$opt_parallel-- if ($sys_info->min_bogomips() < $limit);
323
$opt_parallel= 8 if ($opt_parallel > 8);
324
$opt_parallel= $num_tests if ($opt_parallel > $num_tests);
325
$opt_parallel= 1 if (IS_WINDOWS and $sys_info->isvm());
326
$opt_parallel= 1 if ($opt_parallel < 1);
327
mtr_report("Using parallel: $opt_parallel");
330
# Create server socket on any free port
331
my $server = new IO::Socket::INET
333
LocalAddr => 'localhost',
335
Listen => $opt_parallel,
337
mtr_error("Could not create testcase server port: $!") unless $server;
338
my $server_port = $server->sockport();
339
mtr_report("Using server port $server_port");
341
# Create child processes
343
for my $child_num (1..$opt_parallel){
344
my $child_pid= My::SafeProcess::Base::_safe_fork();
345
if ($child_pid == 0){
346
$server= undef; # Close the server port in child
347
$tests= {}; # Don't need the tests list in child
349
# Use subdir of var and tmp unless only one worker
350
if ($opt_parallel > 1) {
351
set_vardir("$opt_vardir/$child_num");
352
$opt_tmpdir= "$opt_tmpdir/$child_num";
355
run_worker($server_port, $child_num);
359
$children{$child_pid}= 1;
361
#######################################################################
364
mtr_print_thick_line();
367
my $completed= run_test_server($server, $tests, $opt_parallel);
369
# Send Ctrl-C to any children still running
370
kill("INT", keys(%children));
372
# Wait for childs to exit
373
foreach my $pid (keys %children)
375
my $ret_pid= waitpid($pid, 0);
376
if ($ret_pid != $pid){
377
mtr_report("Unknown process $ret_pid exited");
380
delete $children{$ret_pid};
384
if ( not defined @$completed ) {
385
mtr_error("Test suite aborted");
388
if ( @$completed != $num_tests){
391
# All test should have been run, print any that are still in $tests
392
#foreach my $test ( @$tests ){
393
# $test->print_test();
397
# Not all tests completed, failure
399
mtr_report("Only ", int(@$completed), " of $num_tests completed.");
400
mtr_error("Not all tests completed");
406
gcov_collect($basedir, $opt_gcov_exe,
407
$opt_gcov_msg, $opt_gcov_err);
410
mtr_report_stats($completed);
416
sub run_test_server ($$$) {
417
my ($server, $tests, $childs) = @_;
419
my $num_saved_cores= 0; # Number of core files saved in vardir/log/ so far.
420
my $num_saved_datadir= 0; # Number of datadirs saved in vardir/log/ so far.
421
my $num_failed_test= 0; # Number of tests failed so far
423
# Scheduler variables
424
my $max_ndb= $childs / 2;
425
$max_ndb = 4 if $max_ndb > 4;
426
$max_ndb = 1 if $max_ndb < 1;
427
my $num_ndb_tests= 0;
433
my $suite_timeout_proc= My::SafeProcess->timer(suite_timeout());
435
my $s= IO::Select->new();
438
my @ready = $s->can_read(1); # Wake up once every second
439
foreach my $sock (@ready) {
440
if ($sock == $server) {
441
# New client connected
442
my $child= $sock->accept();
443
mtr_verbose("Client connected");
445
print $child "HELLO\n";
449
if (!defined $line) {
450
# Client disconnected
451
mtr_verbose("Child closed socket");
454
$suite_timeout_proc->kill();
461
if ($line eq 'TESTRESULT'){
462
$result= My::Test::read_test($sock);
463
# $result->print_test();
466
mtr_report_test($result);
468
if ( $result->is_failed() ) {
470
# Save the workers "savedir" in var/log
471
my $worker_savedir= $result->{savedir};
472
my $worker_savename= basename($worker_savedir);
473
my $savedir= "$opt_vardir/log/$worker_savename";
475
if ($opt_max_save_datadir > 0 &&
476
$num_saved_datadir >= $opt_max_save_datadir)
478
mtr_report(" - skipping '$worker_savedir/'");
479
rmtree($worker_savedir);
482
mtr_report(" - saving '$worker_savedir/' to '$savedir/'");
483
rename($worker_savedir, $savedir);
484
# Move any core files from e.g. mysqltest
485
foreach my $coref (glob("core*"), glob("*.dmp"))
487
mtr_report(" - found '$coref', moving it to '$savedir'");
488
move($coref, $savedir);
490
if ($opt_max_save_core > 0) {
491
# Limit number of core files saved
492
find({ no_chdir => 1,
494
my $core_file= $File::Find::name;
495
my $core_name= basename($core_file);
497
if ($core_name =~ /^core/ or # Starting with core
498
(IS_WINDOWS and $core_name =~ /\.dmp$/)){
500
mtr_report(" - found '$core_name'",
501
"($num_saved_cores/$opt_max_save_core)");
503
My::CoreDump->show($core_file);
505
if ($num_saved_cores >= $opt_max_save_core) {
506
mtr_report(" - deleting it, already saved",
507
"$opt_max_save_core");
508
unlink("$core_file");
517
$num_saved_datadir++;
520
# Test has failed, force is off
521
$suite_timeout_proc->kill();
522
push(@$completed, $result);
525
elsif ($opt_max_test_fail > 0 and
526
$num_failed_test >= $opt_max_test_fail) {
527
$suite_timeout_proc->kill();
528
mtr_report("Too many tests($num_failed_test) failed!",
535
# Retry test run after test failure
536
my $retries= $result->{retries} || 2;
537
my $test_has_failed= $result->{failures} || 0;
538
if ($test_has_failed and $retries <= $opt_retry){
539
# Test should be run one more time unless it has failed
540
# too many times already
541
my $failures= $result->{failures};
542
if ($opt_retry > 1 and $failures >= $opt_retry_failure){
543
mtr_report("\nTest has failed $failures times,",
544
"no more retries!\n");
547
mtr_report("\nRetrying test, attempt($retries/$opt_retry)...\n");
548
delete($result->{result});
549
$result->{retries}= $retries+1;
550
$result->write_test($sock, 'TESTCASE');
555
# Repeat test $opt_repeat number of times
556
my $repeat= $result->{repeat} || 1;
557
if ($repeat < $opt_repeat)
559
$result->{retries}= 0;
560
$result->{failures}= 0;
561
delete($result->{result});
562
$result->{repeat}= $repeat+1;
563
$result->write_test($sock, 'TESTCASE');
567
# Remove from list of running
568
mtr_error("'", $result->{name},"' is not known to be running")
569
unless delete $running{$result->key()};
571
# Update scheduler variables
572
$num_ndb_tests-- if ($result->{ndb_test});
574
# Save result in completed list
575
push(@$completed, $result);
578
elsif ($line eq 'START'){
582
mtr_error("Unknown response: '$line' from client");
585
# Find next test to schedule
586
# - Try to use same configuration as worker used last time
587
# - Limit number of parallel ndb tests
591
for(my $i= 0; $i <= @$tests; $i++)
595
last unless defined $t;
597
if (run_testcase_check_skip_test($t)){
598
# Move the test to completed list
599
#mtr_report("skip - Moving test $i to completed");
600
push(@$completed, splice(@$tests, $i, 1));
602
# Since the test at pos $i was taken away, next
603
# test will also be at $i -> redo
607
# Limit number of parallell NDB tests
608
if ($t->{ndb_test} and $num_ndb_tests >= $max_ndb){
609
#mtr_report("Skipping, num ndb is already at max, $num_ndb_tests");
613
# Prefer same configuration
614
if (defined $result and
615
$result->{template_path} eq $t->{template_path})
617
#mtr_report("Test uses same config => good match");
618
# Test uses same config => good match
619
$next= splice(@$tests, $i, 1);
623
# Second best choice is the first that does not fulfill
624
# any of the above conditions
625
if (!defined $second_best){
626
#mtr_report("Setting second_best to $i");
631
# Use second best choice if no other test has been found
632
if (!$next and defined $second_best){
633
#mtr_report("Take second best choice $second_best");
634
mtr_error("Internal error, second best too large($second_best)")
635
if $second_best > $#$tests;
636
$next= splice(@$tests, $second_best, 1);
640
#$next->print_test();
641
$next->write_test($sock, 'TESTCASE');
642
$running{$next->key()}= $next;
643
$num_ndb_tests++ if ($next->{ndb_test});
646
# No more test, tell child to exit
647
#mtr_report("Saying BYE to child");
653
# ----------------------------------------------------
654
# Check if test suite timer expired
655
# ----------------------------------------------------
656
if ( ! $suite_timeout_proc->wait_one(0) )
658
mtr_report("Test suite timeout! Terminating...");
666
my ($server_port, $thread_num)= @_;
668
$SIG{INT}= sub { exit(1); };
671
my $server = new IO::Socket::INET
673
PeerAddr => 'localhost',
674
PeerPort => $server_port,
677
mtr_error("Could not connect to server at port $server_port: $!")
680
# --------------------------------------------------------------------------
682
# --------------------------------------------------------------------------
683
report_option('name',"worker[$thread_num]");
685
# --------------------------------------------------------------------------
686
# Set different ports per thread
687
# --------------------------------------------------------------------------
688
set_build_thread_ports($thread_num);
690
# --------------------------------------------------------------------------
691
# Turn off verbosity in workers, unless explicitly specified
692
# --------------------------------------------------------------------------
693
report_option('verbose', undef) if ($opt_verbose == 0);
381
695
environment_setup();
396
initialize_servers();
397
run_benchmarks(shift); # Shift what? Extra arguments?!
399
elsif ( $opt_stress )
401
initialize_servers();
406
# Figure out which tests we are going to run
409
$opt_suites= $opt_suites_default;
411
# Check for any extra suites to enable based on the path name
414
"mysql-5.1-new-ndb" => "ndb_team",
415
"mysql-5.1-new-ndb-merge" => "ndb_team",
416
"mysql-5.1-telco-6.2" => "ndb_team",
417
"mysql-5.1-telco-6.2-merge" => "ndb_team",
418
"mysql-5.1-telco-6.3" => "ndb_team",
419
"mysql-6.0-ndb" => "ndb_team",
422
foreach my $dir ( reverse splitdir($glob_basedir) )
424
my $extra_suite= $extra_suites{$dir};
425
if (defined $extra_suite){
426
mtr_report("Found extra suite: $extra_suite");
427
$opt_suites= "$extra_suite,$opt_suites";
433
my $tests= collect_test_cases($opt_suites);
435
# Turn off NDB and other similar options if no tests use it
436
my ($need_ndbcluster,$need_im);
437
foreach my $test (@$tests)
439
next if $test->{skip};
443
$need_ndbcluster||= $test->{ndb_test};
444
$need_im||= $test->{component_id} eq 'im';
446
# Count max number of slaves used by a test case
447
if ( $test->{slave_num} > $max_slave_num) {
448
$max_slave_num= $test->{slave_num};
449
mtr_error("Too many slaves") if $max_slave_num > 3;
452
# Count max number of masters used by a test case
453
if ( $test->{master_num} > $max_master_num) {
454
$max_master_num= $test->{master_num};
455
mtr_error("Too many masters") if $max_master_num > 2;
456
mtr_error("Too few masters") if $max_master_num < 1;
459
$use_innodb||= $test->{'innodb_test'};
462
# Check if cluster can be skipped
463
if ( !$need_ndbcluster )
465
$opt_skip_ndbcluster= 1;
466
$opt_skip_ndbcluster_slave= 1;
469
# Check if slave cluster can be skipped
470
if ($max_slave_num == 0)
472
$opt_skip_ndbcluster_slave= 1;
475
# Check if im can be skipped
481
initialize_servers();
483
if ( $opt_report_features ) {
484
run_report_features();
493
##############################################################################
497
##############################################################################
500
# When an option is no longer used by this program, it must be explicitly
501
# ignored or else it will be passed through to mysqld. GetOptions will call
502
# this subroutine once for each such option on the command line. See
503
# Getopt::Long documentation.
506
sub warn_about_removed_option {
507
my ($option, $value, $hash_value) = @_;
509
warn "WARNING: This option is no longer used, and is ignored: --$option\n";
512
sub command_line_setup () {
514
# These are defaults for things that are set on the command line
697
# Read hello from server which it will send when shared
698
# resources have been setup
699
my $hello= <$server>;
702
check_running_as_root();
704
if ( using_extern() ) {
705
create_config_file_for_extern(%opts_extern);
708
# Ask server for first test
709
print $server "START\n";
711
while(my $line= <$server>){
713
if ($line eq 'TESTCASE'){
714
my $test= My::Test::read_test($server);
715
#$test->print_test();
717
# Clear comment and logfile, to avoid
718
# reusing them from previous test
719
delete($test->{'comment'});
720
delete($test->{'logfile'});
723
#$test->{result}= 'MTR_RES_PASSED';
724
# Send it back, now with results set
725
#$test->print_test();
726
$test->write_test($server, 'TESTRESULT');
728
elsif ($line eq 'BYE'){
729
mtr_report("Server said BYE");
733
mtr_error("Could not understand server, '$line'");
744
my ($opt, $value)= @_;
745
mtr_report("Ignoring option '$opt'");
750
# Setup any paths that are $opt_vardir related
754
$opt_vardir= $vardir;
756
$path_vardir_trace= $opt_vardir;
757
# Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
758
$path_vardir_trace=~ s/^\w://;
760
# Location of my.cnf that all clients use
761
$path_config_file= "$opt_vardir/my.cnf";
763
$path_testlog= "$opt_vardir/log/mysqltest.log";
764
$path_current_testlog= "$opt_vardir/log/current_test";
769
sub command_line_setup {
518
# Magic number -69.4 results in traditional test ports starting from 9306.
519
set_mtr_build_thread_ports(-69.4);
521
# If so requested, we try to avail ourselves of a unique build thread number.
522
if ( $ENV{'MTR_BUILD_THREAD'} ) {
523
if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) {
524
print "Requesting build thread... ";
525
$ENV{'MTR_BUILD_THREAD'} = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299);
526
print "got ".$ENV{'MTR_BUILD_THREAD'}."\n";
530
if ( $ENV{'MTR_BUILD_THREAD'} )
532
set_mtr_build_thread_ports($ENV{'MTR_BUILD_THREAD'});
535
# This is needed for test log evaluation in "gen-build-status-page"
536
# in all cases where the calling tool does not log the commands
537
# directly before it executes them, like "make test-force-pl" in RPM builds.
538
print "Logging: $0 ", join(" ", @ARGV), "\n";
540
# Read the command line
773
# Read the command line options
541
774
# Note: Keep list, and the order, in sync with usage at end of this file
543
# Options that are no longer used must still be processed, because all
544
# unprocessed options are passed directly to mysqld. The user will be
545
# warned that the option is being ignored.
547
# Put the complete option string here. For example, to remove the --suite
548
# option, remove it from GetOptions() below and put 'suite|suites=s' here.
549
my @removed_options = (
552
775
Getopt::Long::Configure("pass_through");
554
777
# Control what engine/variation to run
1101
1292
join(" ", @valgrind_args), "\"");
1104
if ( ! $opt_testcase_timeout )
1106
$opt_testcase_timeout= $default_testcase_timeout;
1107
$opt_testcase_timeout*= 10 if $opt_valgrind;
1108
$opt_testcase_timeout*= 10 if ($opt_debug and $glob_win32);
1111
if ( ! $opt_suite_timeout )
1113
$opt_suite_timeout= $default_suite_timeout;
1114
$opt_suite_timeout*= 6 if $opt_valgrind;
1115
$opt_suite_timeout*= 6 if ($opt_debug and $glob_win32);
1126
$opt_user= "root"; # We want to do FLUSH xxx commands
1130
# On QNX, /tmp/dir/master.sock and /tmp/dir//master.sock seem to be
1131
# considered different, so avoid the extra slash (/) in the socket
1133
my $sockdir = $opt_tmpdir;
1134
$sockdir =~ s|/+$||;
1136
# On some operating systems, there is a limit to the length of a
1137
# UNIX domain socket's path far below PATH_MAX, so try to avoid long
1138
# socket path names.
1139
$sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) >= 70 );
1146
path_myddir => "$opt_vardir/master-data",
1147
path_myerr => "$opt_vardir/log/master.err",
1148
path_pid => "$opt_vardir/run/master.pid",
1149
path_sock => "$sockdir/master.sock",
1150
port => $opt_master_myport,
1151
start_timeout => 400, # enough time create innodb tables
1152
cluster => 0, # index in clusters list
1161
path_myddir => "$opt_vardir/master1-data",
1162
path_myerr => "$opt_vardir/log/master1.err",
1163
path_pid => "$opt_vardir/run/master1.pid",
1164
path_sock => "$sockdir/master1.sock",
1165
port => $opt_master_myport + 1,
1166
start_timeout => 400, # enough time create innodb tables
1167
cluster => 0, # index in clusters list
1176
path_myddir => "$opt_vardir/slave-data",
1177
path_myerr => "$opt_vardir/log/slave.err",
1178
path_pid => "$opt_vardir/run/slave.pid",
1179
path_sock => "$sockdir/slave.sock",
1180
port => $opt_slave_myport,
1181
start_timeout => 400,
1183
cluster => 1, # index in clusters list
1192
path_myddir => "$opt_vardir/slave1-data",
1193
path_myerr => "$opt_vardir/log/slave1.err",
1194
path_pid => "$opt_vardir/run/slave1.pid",
1195
path_sock => "$sockdir/slave1.sock",
1196
port => $opt_slave_myport + 1,
1197
start_timeout => 300,
1198
cluster => -1, # index in clusters list
1207
path_myddir => "$opt_vardir/slave2-data",
1208
path_myerr => "$opt_vardir/log/slave2.err",
1209
path_pid => "$opt_vardir/run/slave2.pid",
1210
path_sock => "$sockdir/slave2.sock",
1211
port => $opt_slave_myport + 2,
1212
start_timeout => 300,
1213
cluster => -1, # index in clusters list
1219
path_err => "$opt_vardir/log/im.err",
1220
path_log => "$opt_vardir/log/im.log",
1221
path_pid => "$opt_vardir/run/im.pid",
1222
path_angel_pid => "$opt_vardir/run/im.angel.pid",
1223
path_sock => "$sockdir/im.sock",
1225
start_timeout => $master->[0]->{'start_timeout'},
1226
admin_login => 'im_admin',
1227
admin_password => 'im_admin_secret',
1228
admin_sha1 => '*598D51AD2DFF7792045D6DF3DDF9AA1AF737B295',
1229
password_file => "$opt_vardir/im.passwd",
1230
defaults_file => "$opt_vardir/im.cnf",
1233
$instance_manager->{'instances'}->[0]=
1236
port => $im_mysqld1_port,
1237
path_datadir => "$opt_vardir/im_mysqld_1.data",
1238
path_sock => "$sockdir/mysqld_1.sock",
1239
path_pid => "$opt_vardir/run/mysqld_1.pid",
1240
start_timeout => 400, # enough time create innodb tables
1244
$instance_manager->{'instances'}->[1]=
1247
port => $im_mysqld2_port,
1248
path_datadir => "$opt_vardir/im_mysqld_2.data",
1249
path_sock => "$sockdir/mysqld_2.sock",
1250
path_pid => "$opt_vardir/run/mysqld_2.pid",
1252
start_timeout => 400, # enough time create innodb tables
1256
my $data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port";
1261
port => "$opt_ndbcluster_port",
1262
data_dir => "$data_dir",
1263
connect_string => "host=localhost:$opt_ndbcluster_port",
1264
path_pid => "$data_dir/ndb_3.pid", # Nodes + 1
1265
pid => 0, # pid of ndb_mgmd
1269
$data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port_slave";
1274
port => "$opt_ndbcluster_port_slave",
1275
data_dir => "$data_dir",
1276
connect_string => "host=localhost:$opt_ndbcluster_port_slave",
1277
path_pid => "$data_dir/ndb_2.pid", # Nodes + 1
1278
pid => 0, # pid of ndb_mgmd
1282
# Init pids of ndbd's
1283
foreach my $cluster ( @{$clusters} )
1285
for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ )
1288
$cluster->{'ndbds'}->[$idx]=
1292
path_pid => "$cluster->{'data_dir'}/ndb_${nodeid}.pid",
1293
path_fs => "$cluster->{'data_dir'}/ndb_${nodeid}_fs",
1298
# --------------------------------------------------------------------------
1300
# --------------------------------------------------------------------------
1303
# Turn off features not supported when running with extern server
1305
$opt_skip_ndbcluster= 1;
1307
# Setup master->[0] with the settings for the extern server
1308
$master->[0]->{'path_sock'}= $opt_socket ? $opt_socket : "/tmp/mysql.sock";
1309
mtr_report("Using extern server at '$master->[0]->{path_sock}'");
1313
mtr_error("--socket can only be used in combination with --extern")
1318
# --------------------------------------------------------------------------
1319
# ndbconnectstring and ndbconnectstring_slave
1320
# --------------------------------------------------------------------------
1321
if ( $opt_ndbconnectstring )
1323
# ndbconnectstring was supplied by user, the tests shoudl be run
1324
# against an already started cluster, change settings
1325
my $cluster= $clusters->[0]; # Master cluster
1326
$cluster->{'connect_string'}= $opt_ndbconnectstring;
1327
$cluster->{'use_running'}= 1;
1329
mtr_error("Can't specify --ndb-connectstring and --skip-ndbcluster")
1330
if $opt_skip_ndbcluster;
1332
$ENV{'NDB_CONNECTSTRING'}= $clusters->[0]->{'connect_string'};
1335
if ( $opt_ndbconnectstring_slave )
1337
# ndbconnectstring-slave was supplied by user, the tests should be run
1338
# agains an already started slave cluster, change settings
1339
my $cluster= $clusters->[1]; # Slave cluster
1340
$cluster->{'connect_string'}= $opt_ndbconnectstring_slave;
1341
$cluster->{'use_running'}= 1;
1343
mtr_error("Can't specify ndb-connectstring_slave and " .
1344
"--skip-ndbcluster-slave")
1345
if $opt_skip_ndbcluster_slave;
1349
$path_timefile= "$opt_vardir/log/mysqltest-time";
1350
$path_mysqltest_log= "$opt_vardir/log/mysqltest.log";
1351
$path_current_test_log= "$opt_vardir/log/current_test";
1352
$path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
1354
$path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
1356
if ( $opt_valgrind and $opt_debug )
1358
# When both --valgrind and --debug is selected, send
1359
# all output to the trace file, making it possible to
1360
# see the exact location where valgrind complains
1361
foreach my $mysqld (@{$master}, @{$slave})
1363
my $sidx= $mysqld->{idx} ? "$mysqld->{idx}" : "";
1364
$mysqld->{path_myerr}=
1365
"$opt_vardir/log/" . $mysqld->{type} . "$sidx.trace";
1295
mtr_report("Checking supported features...");
1297
check_ndbcluster_support(\%mysqld_variables);
1298
check_ssl_support(\%mysqld_variables);
1299
check_debug_support(\%mysqld_variables);
1371
1307
# To make it easier for different devs to work on the same host,
1372
1308
# an environment variable can be used to control all ports. A small
1952
1812
$ENV{'LC_ALL'}= "C";
1953
1813
$ENV{'LC_CTYPE'}= "C";
1955
1815
$ENV{'LC_COLLATE'}= "C";
1956
$ENV{'USE_RUNNING_SERVER'}= $opt_extern;
1816
$ENV{'USE_RUNNING_SERVER'}= using_extern();
1957
1817
$ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir;
1818
$ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'} || 3306;
1819
$ENV{'MYSQL_TMP_DIR'}= $opt_tmpdir;
1958
1820
$ENV{'MYSQLTEST_VARDIR'}= $opt_vardir;
1959
$ENV{'MYSQL_TMP_DIR'}= $opt_tmpdir;
1960
$ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_sock'};
1961
$ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_sock'};
1962
$ENV{'MASTER_MYPORT'}= $master->[0]->{'port'};
1963
$ENV{'MASTER_MYPORT1'}= $master->[1]->{'port'};
1964
$ENV{'SLAVE_MYSOCK'}= $slave->[0]->{'path_sock'};
1965
$ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
1966
$ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
1967
$ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
1968
$ENV{'MYSQL_TCP_PORT'}= $mysqld_variables{'port'};
1969
$ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'};
1971
$ENV{'IM_PATH_SOCK'}= $instance_manager->{path_sock};
1972
$ENV{'IM_USERNAME'}= $instance_manager->{admin_login};
1973
$ENV{'IM_PASSWORD'}= $instance_manager->{admin_password};
1974
$ENV{MTR_BUILD_THREAD}= $opt_mtr_build_thread;
1976
$ENV{'EXE_MYSQL'}= $exe_mysql;
1979
1822
# ----------------------------------------------------
1980
1823
# Setup env for NDB
1981
1824
# ----------------------------------------------------
1982
1825
if ( ! $opt_skip_ndbcluster )
1984
$ENV{'NDB_MGM'}= $exe_ndb_mgm;
1986
$ENV{'NDBCLUSTER_PORT'}= $opt_ndbcluster_port;
1987
$ENV{'NDBCLUSTER_PORT_SLAVE'}= $opt_ndbcluster_port_slave;
1989
$ENV{'NDB_EXTRA_TEST'}= $opt_ndb_extra_test;
1991
$ENV{'NDB_BACKUP_DIR'}= $clusters->[0]->{'data_dir'};
1992
$ENV{'NDB_DATA_DIR'}= $clusters->[0]->{'data_dir'};
1993
$ENV{'NDB_TOOLS_DIR'}= $path_ndb_tools_dir;
1828
my_find_bin($basedir,
1829
["storage/ndb/src/mgmclient", "bin"],
1832
$ENV{'NDB_TOOLS_DIR'}=
1833
my_find_dir($basedir,
1834
["storage/ndb/tools", "bin"]);
1836
$ENV{'NDB_EXAMPLES_DIR'}=
1837
my_find_dir($basedir,
1838
["storage/ndb/ndbapi-examples", "bin"]);
1840
$ENV{'NDB_EXAMPLES_BINARY'}=
1841
my_find_bin($basedir,
1842
["storage/ndb/ndbapi-examples/ndbapi_simple", "bin"],
1843
"ndbapi_simple", NOT_REQUIRED);
1845
my $path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
1994
1846
$ENV{'NDB_TOOLS_OUTPUT'}= $path_ndb_testrun_log;
1996
if ( $mysql_version_id >= 50000 )
1998
$ENV{'NDB_EXAMPLES_DIR'}= $path_ndb_examples_dir;
1999
$ENV{'MY_NDB_EXAMPLES_BINARY'}= $exe_ndb_example;
2001
1847
$ENV{'NDB_EXAMPLES_OUTPUT'}= $path_ndb_testrun_log;
2004
1850
# ----------------------------------------------------
2006
# ----------------------------------------------------
2007
if ( ! $opt_skip_im )
2009
$ENV{'IM_EXE'}= $exe_im;
2010
$ENV{'IM_PATH_PID'}= $instance_manager->{path_pid};
2011
$ENV{'IM_PATH_ANGEL_PID'}= $instance_manager->{path_angel_pid};
2012
$ENV{'IM_PORT'}= $instance_manager->{port};
2013
$ENV{'IM_DEFAULTS_PATH'}= $instance_manager->{defaults_file};
2014
$ENV{'IM_PASSWORD_PATH'}= $instance_manager->{password_file};
2016
$ENV{'IM_MYSQLD1_SOCK'}=
2017
$instance_manager->{instances}->[0]->{path_sock};
2018
$ENV{'IM_MYSQLD1_PORT'}=
2019
$instance_manager->{instances}->[0]->{port};
2020
$ENV{'IM_MYSQLD1_PATH_PID'}=
2021
$instance_manager->{instances}->[0]->{path_pid};
2022
$ENV{'IM_MYSQLD2_SOCK'}=
2023
$instance_manager->{instances}->[1]->{path_sock};
2024
$ENV{'IM_MYSQLD2_PORT'}=
2025
$instance_manager->{instances}->[1]->{port};
2026
$ENV{'IM_MYSQLD2_PATH_PID'}=
2027
$instance_manager->{instances}->[1]->{path_pid};
2030
# ----------------------------------------------------
2031
# Setup env so childs can execute mysqlcheck
2032
# ----------------------------------------------------
2033
my $cmdline_mysqlcheck=
2034
mtr_native_path($exe_mysqlcheck) .
2035
" --no-defaults --debug-check -uroot " .
2036
"--port=$master->[0]->{'port'} " .
2037
"--socket=$master->[0]->{'path_sock'} --password=";
2041
$cmdline_mysqlcheck .=
2042
" --debug=d:t:A,$path_vardir_trace/log/mysqlcheck.trace";
2044
$ENV{'MYSQL_CHECK'}= $cmdline_mysqlcheck;
2046
# ----------------------------------------------------
2047
# Setup env to childs can execute myqldump
2048
# ----------------------------------------------------
2049
my $cmdline_mysqldump= generate_cmdline_mysqldump($master->[0]);
2050
my $cmdline_mysqldumpslave= generate_cmdline_mysqldump($slave->[0]);
2054
$cmdline_mysqldump .=
2055
" --debug=d:t:A,$path_vardir_trace/log/mysqldump-master.trace";
2056
$cmdline_mysqldumpslave .=
2057
" --debug=d:t:A,$path_vardir_trace/log/mysqldump-slave.trace";
2059
$ENV{'MYSQL_DUMP'}= $cmdline_mysqldump;
2060
$ENV{'MYSQL_DUMP_SLAVE'}= $cmdline_mysqldumpslave;
2063
# ----------------------------------------------------
2064
# Setup env so childs can execute mysqlslap
2065
# ----------------------------------------------------
2066
if ( $exe_mysqlslap )
2068
my $cmdline_mysqlslap=
2069
mtr_native_path($exe_mysqlslap) .
2071
"--port=$master->[0]->{'port'} " .
2072
"--socket=$master->[0]->{'path_sock'} --password= ";
2076
$cmdline_mysqlslap .=
2077
" --debug=d:t:A,$path_vardir_trace/log/mysqlslap.trace";
2079
$ENV{'MYSQL_SLAP'}= $cmdline_mysqlslap;
2082
# ----------------------------------------------------
2083
# Setup env so childs can execute mysqlimport
2084
# ----------------------------------------------------
2085
my $cmdline_mysqlimport=
2086
mtr_native_path($exe_mysqlimport) .
2087
" -uroot --debug-check " .
2088
"--port=$master->[0]->{'port'} " .
2089
"--socket=$master->[0]->{'path_sock'} --password=";
2093
$cmdline_mysqlimport .=
2094
" --debug=d:t:A,$path_vardir_trace/log/mysqlimport.trace";
2096
$ENV{'MYSQL_IMPORT'}= $cmdline_mysqlimport;
2099
# ----------------------------------------------------
2100
# Setup env so childs can execute mysqlshow
2101
# ----------------------------------------------------
2102
my $cmdline_mysqlshow=
2103
mtr_native_path($exe_mysqlshow) .
2104
" -uroot --debug-check " .
2105
"--port=$master->[0]->{'port'} " .
2106
"--socket=$master->[0]->{'path_sock'} --password=";
2110
$cmdline_mysqlshow .=
2111
" --debug=d:t:A,$path_vardir_trace/log/mysqlshow.trace";
2113
$ENV{'MYSQL_SHOW'}= $cmdline_mysqlshow;
2115
# ----------------------------------------------------
2116
# Setup env so childs can execute mysqlbinlog
2117
# ----------------------------------------------------
2118
my $cmdline_mysqlbinlog=
2119
mtr_native_path($exe_mysqlbinlog) .
2120
" --no-defaults --disable-force-if-open --debug-check";
2121
if ( !$opt_extern && $mysql_version_id >= 50000 )
2123
$cmdline_mysqlbinlog .=" --character-sets-dir=$path_charsetsdir";
2125
# Always use the given tmpdir for the LOAD files created
2127
$cmdline_mysqlbinlog .=" --local-load=$opt_tmpdir";
2131
$cmdline_mysqlbinlog .=
2132
" --debug=d:t:A,$path_vardir_trace/log/mysqlbinlog.trace";
2134
$ENV{'MYSQL_BINLOG'}= $cmdline_mysqlbinlog;
2136
# ----------------------------------------------------
2137
# Setup env so childs can execute mysql
2138
# ----------------------------------------------------
2140
mtr_native_path($exe_mysql) .
2141
" --no-defaults --debug-check --host=localhost --user=root --password= " .
2142
"--port=$master->[0]->{'port'} " .
2143
"--socket=$master->[0]->{'path_sock'} ".
2144
"--character-sets-dir=$path_charsetsdir";
2146
$ENV{'MYSQL'}= $cmdline_mysql;
2148
# ----------------------------------------------------
2149
# Setup env so childs can execute bug25714
2150
# ----------------------------------------------------
2151
$ENV{'MYSQL_BUG25714'}= $exe_bug25714;
2153
# ----------------------------------------------------
2154
# Setup env so childs can execute mysql_client_test
2155
# ----------------------------------------------------
2156
$ENV{'MYSQL_CLIENT_TEST'}= mysql_client_test_arguments();
2158
# ----------------------------------------------------
2159
# Setup env so childs can execute mysql_upgrade
2160
# ----------------------------------------------------
2161
if ( !$opt_extern && $mysql_version_id >= 50000 )
2163
$ENV{'MYSQL_UPGRADE'}= mysql_upgrade_arguments();
2166
# ----------------------------------------------------
2167
# Setup env so childs can execute mysql_fix_system_tables
2168
# ----------------------------------------------------
2169
if ( !$opt_extern && ! $glob_win32 )
2171
my $cmdline_mysql_fix_system_tables=
2172
"$exe_mysql_fix_system_tables --no-defaults --host=localhost " .
2173
"--user=root --password= " .
2174
"--basedir=$glob_basedir --bindir=$path_client_bindir --verbose " .
2175
"--port=$master->[0]->{'port'} " .
2176
"--socket=$master->[0]->{'path_sock'}";
2177
$ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables;
1852
# ----------------------------------------------------
1853
$ENV{'MYSQL_CHECK'}= client_arguments("mysqlcheck");
1854
$ENV{'MYSQL_DUMP'}= mysqldump_arguments(".1");
1855
$ENV{'MYSQL_DUMP_SLAVE'}= mysqldump_arguments(".2");
1856
$ENV{'MYSQL_SLAP'}= mysqlslap_arguments();
1857
$ENV{'MYSQL_IMPORT'}= client_arguments("mysqlimport");
1858
$ENV{'MYSQL_SHOW'}= client_arguments("mysqlshow");
1859
$ENV{'MYSQL_BINLOG'}= client_arguments("mysqlbinlog");
1860
$ENV{'MYSQL'}= client_arguments("mysql");
1861
$ENV{'MYSQL_UPGRADE'}= client_arguments("mysql_upgrade");
1862
$ENV{'MYSQLADMIN'}= native_path($exe_mysqladmin);
1863
$ENV{'MYSQL_CLIENT_TEST'}= mysql_client_test_arguments();
1864
$ENV{'MYSQL_FIX_SYSTEM_TABLES'}= mysql_fix_arguments();
1865
$ENV{'EXE_MYSQL'}= $exe_mysql;
1867
# ----------------------------------------------------
1868
# bug25714 executable may _not_ exist in
1869
# some versions, test using it should be skipped
1870
# ----------------------------------------------------
1872
mtr_exe_maybe_exists(vs_config_dirs('tests', 'bug25714'),
1873
"$basedir/tests/bug25714");
1874
$ENV{'MYSQL_BUG25714'}= native_path($exe_bug25714);
1876
# ----------------------------------------------------
1877
# mysql_fix_privilege_tables.sql
1878
# ----------------------------------------------------
1879
my $file_mysql_fix_privilege_tables=
1880
mtr_file_exists("$basedir/scripts/mysql_fix_privilege_tables.sql",
1881
"$basedir/share/mysql_fix_privilege_tables.sql",
1882
"$basedir/share/mysql/mysql_fix_privilege_tables.sql");
2180
1883
$ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables;
2182
1885
# ----------------------------------------------------
2183
# Setup env so childs can execute my_print_defaults
2184
# ----------------------------------------------------
2185
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
2187
# ----------------------------------------------------
2188
# Setup env so childs can execute mysqladmin
2189
# ----------------------------------------------------
2190
$ENV{'MYSQLADMIN'}= mtr_native_path($exe_mysqladmin);
2192
# ----------------------------------------------------
2193
# Setup env so childs can execute perror
2194
# ----------------------------------------------------
2195
$ENV{'MY_PERROR'}= mtr_native_path($exe_perror);
2197
# ----------------------------------------------------
2198
# Add the path where mysqld will find udf_example.so
2199
# ----------------------------------------------------
2200
$ENV{'UDF_EXAMPLE_LIB'}=
2201
($lib_udf_example ? basename($lib_udf_example) : "");
2202
$ENV{'UDF_EXAMPLE_LIB_OPT'}=
2203
($lib_udf_example ? "--plugin_dir=" . dirname($lib_udf_example) : "");
2205
# ----------------------------------------------------
2206
# Add the path where mysqld will find ha_example.so
2207
# ----------------------------------------------------
2208
$ENV{'EXAMPLE_PLUGIN'}=
2209
($lib_example_plugin ? basename($lib_example_plugin) : "");
2210
$ENV{'EXAMPLE_PLUGIN_OPT'}=
2211
($lib_example_plugin ? "--plugin_dir=" . dirname($lib_example_plugin) : "");
2213
# ----------------------------------------------------
2214
# Add the path where mysqld will find mypluglib.so
2215
# ----------------------------------------------------
2216
$ENV{'SIMPLE_PARSER'}=
2217
($lib_simple_parser ? basename($lib_simple_parser) : "");
2218
$ENV{'SIMPLE_PARSER_OPT'}=
2219
($lib_simple_parser ? "--plugin_dir=" . dirname($lib_simple_parser) : "");
1887
# ----------------------------------------------------
1888
my $exe_my_print_defaults=
1889
mtr_exe_exists(vs_config_dirs('extra', 'my_print_defaults'),
1890
"$path_client_bindir/my_print_defaults",
1891
"$basedir/extra/my_print_defaults");
1892
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= native_path($exe_my_print_defaults);
2221
1894
# ----------------------------------------------------
2222
1895
# Setup env so childs can execute myisampack and myisamchk
2223
1896
# ----------------------------------------------------
2224
$ENV{'MYISAMCHK'}= mtr_native_path(mtr_exe_exists(
1897
$ENV{'MYISAMCHK'}= native_path(mtr_exe_exists(
2225
1898
vs_config_dirs('storage/myisam', 'myisamchk'),
2226
1899
vs_config_dirs('myisam', 'myisamchk'),
2227
1900
"$path_client_bindir/myisamchk",
2228
"$glob_basedir/storage/myisam/myisamchk",
2229
"$glob_basedir/myisam/myisamchk"));
2230
$ENV{'MYISAMPACK'}= mtr_native_path(mtr_exe_exists(
1901
"$basedir/storage/myisam/myisamchk",
1902
"$basedir/myisam/myisamchk"));
1903
$ENV{'MYISAMPACK'}= native_path(mtr_exe_exists(
2231
1904
vs_config_dirs('storage/myisam', 'myisampack'),
2232
1905
vs_config_dirs('myisam', 'myisampack'),
2233
1906
"$path_client_bindir/myisampack",
2234
"$glob_basedir/storage/myisam/myisampack",
2235
"$glob_basedir/myisam/myisampack"));
1907
"$basedir/storage/myisam/myisampack",
1908
"$basedir/myisam/myisampack"));
2237
1910
# ----------------------------------------------------
2238
# We are nice and report a bit about our settings
2239
1912
# ----------------------------------------------------
2242
print "Using MTR_BUILD_THREAD = $ENV{MTR_BUILD_THREAD}\n";
2243
print "Using MASTER_MYPORT = $ENV{MASTER_MYPORT}\n";
2244
print "Using MASTER_MYPORT1 = $ENV{MASTER_MYPORT1}\n";
2245
print "Using SLAVE_MYPORT = $ENV{SLAVE_MYPORT}\n";
2246
print "Using SLAVE_MYPORT1 = $ENV{SLAVE_MYPORT1}\n";
2247
print "Using SLAVE_MYPORT2 = $ENV{SLAVE_MYPORT2}\n";
2248
if ( ! $opt_skip_ndbcluster )
2250
print "Using NDBCLUSTER_PORT = $ENV{NDBCLUSTER_PORT}\n";
2251
if ( ! $opt_skip_ndbcluster_slave )
2253
print "Using NDBCLUSTER_PORT_SLAVE = $ENV{NDBCLUSTER_PORT_SLAVE}\n";
2256
if ( ! $opt_skip_im )
2258
print "Using IM_PORT = $ENV{IM_PORT}\n";
2259
print "Using IM_MYSQLD1_PORT = $ENV{IM_MYSQLD1_PORT}\n";
2260
print "Using IM_MYSQLD2_PORT = $ENV{IM_MYSQLD2_PORT}\n";
1913
my $exe_perror= mtr_exe_exists(vs_config_dirs('extra', 'perror'),
1914
"$basedir/extra/perror",
1915
"$path_client_bindir/perror");
1916
$ENV{'MY_PERROR'}= native_path($exe_perror);
2264
1918
# Create an environment variable to make it possible
2265
1919
# to detect that valgrind is being used from test cases
2772
2279
my ($cluster)= @_;
2774
2281
my $retries= 100;
2775
while (ndbcluster_wait_started($cluster, "--no-contact") and
2778
# Millisceond sleep emulated with select
2779
select(undef, undef, undef, (0.1));
2284
my $result= ndbcluster_wait_started($cluster, "--no-contact");
2287
# ndb_mgmd is started
2288
mtr_verbose("ndb_mgmd is started");
2293
mtr_warning("Cluster process failed while waiting for start");
2297
mtr_milli_sleep(100);
2784
return $retries == 0;
2788
sub ndb_mgmd_start ($) {
2791
my $args; # Arg vector
2305
sub ndb_mgmd_start ($$) {
2306
my ($cluster, $ndb_mgmd)= @_;
2308
mtr_verbose("ndb_mgmd_start");
2310
my $dir= $ndb_mgmd->value("DataDir");
2311
mkpath($dir) unless -d $dir;
2794
2314
mtr_init_args(\$args);
2795
mtr_add_arg($args, "--no-defaults");
2796
mtr_add_arg($args, "--core");
2315
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
2316
mtr_add_arg($args, "--defaults-group-suffix=%s", $cluster->suffix());
2317
mtr_add_arg($args, "--mycnf");
2797
2318
mtr_add_arg($args, "--nodaemon");
2798
mtr_add_arg($args, "--config-file=%s", "$cluster->{'data_dir'}/config.ini");
2801
my $path_ndb_mgmd_log= "$cluster->{'data_dir'}/\l$cluster->{'name'}_ndb_mgmd.log";
2802
$pid= mtr_spawn($exe_ndb_mgmd, $args, "",
2806
{ append_log_file => 1 });
2320
my $path_ndb_mgmd_log= "$dir/ndb_mgmd.log";
2322
$ndb_mgmd->{'proc'}= My::SafeProcess->new
2324
name => $ndb_mgmd->after('cluster_config.'),
2325
path => $exe_ndb_mgmd,
2327
output => $path_ndb_mgmd_log,
2328
error => $path_ndb_mgmd_log,
2330
verbose => $opt_verbose,
2332
mtr_verbose("Started $ndb_mgmd->{proc}");
2808
2334
# FIXME Should not be needed
2809
2335
# Unfortunately the cluster nodes will fail to start
2810
2336
# if ndb_mgmd has not started properly
2811
2337
if (ndb_mgmd_wait_started($cluster))
2813
mtr_error("Failed to wait for start of ndb_mgmd");
2339
mtr_warning("Failed to wait for start of ndb_mgmd");
2816
# Remember pid of ndb_mgmd
2817
$cluster->{'pid'}= $pid;
2819
mtr_verbose("ndb_mgmd_start, pid: $pid");
2825
sub ndbd_start ($$$) {
2828
my $extra_args= shift;
2830
my $args; # Arg vector
2348
my ($cluster, $ndbd)= @_;
2350
mtr_verbose("ndbd_start");
2352
my $dir= $ndbd->value("DataDir");
2353
mkpath($dir) unless -d $dir;
2833
2356
mtr_init_args(\$args);
2834
mtr_add_arg($args, "--no-defaults");
2835
mtr_add_arg($args, "--core");
2836
mtr_add_arg($args, "--ndb-connectstring=%s", "$cluster->{'connect_string'}");
2837
if ( $mysql_version_id >= 50000)
2839
mtr_add_arg($args, "--character-sets-dir=%s", "$path_charsetsdir");
2357
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
2358
mtr_add_arg($args, "--defaults-group-suffix=%s", $cluster->suffix());
2841
2359
mtr_add_arg($args, "--nodaemon");
2842
mtr_add_arg($args, "$extra_args");
2844
my $nodeid= $cluster->{'ndbds'}->[$idx]->{'nodeid'};
2845
my $path_ndbd_log= "$cluster->{'data_dir'}/ndb_${nodeid}.log";
2846
$pid= mtr_spawn($exe_ndbd, $args, "",
2850
{ append_log_file => 1 });
2852
# Add pid to list of pids for this cluster
2853
$cluster->{'ndbds'}->[$idx]->{'pid'}= $pid;
2855
# Rememeber options used when starting
2856
$cluster->{'ndbds'}->[$idx]->{'start_extra_args'}= $extra_args;
2857
$cluster->{'ndbds'}->[$idx]->{'idx'}= $idx;
2859
mtr_verbose("ndbd_start, pid: $pid");
2361
# > 5.0 { 'character-sets-dir' => \&fix_charset_dir },
2364
my $path_ndbd_log= "$dir/ndbd.log";
2365
my $proc= My::SafeProcess->new
2367
name => $ndbd->after('cluster_config.'),
2370
output => $path_ndbd_log,
2371
error => $path_ndbd_log,
2373
verbose => $opt_verbose,
2375
mtr_verbose("Started $proc");
2377
$ndbd->{proc}= $proc;
2865
sub ndbcluster_start ($$) {
2383
sub ndbcluster_start ($) {
2866
2384
my $cluster= shift;
2867
my $extra_args= shift;
2869
mtr_verbose("ndbcluster_start '$cluster->{'name'}'");
2871
if ( $cluster->{'use_running'} )
2876
if ( $cluster->{'pid'} )
2878
mtr_error("Cluster '$cluster->{'name'}' already started");
2881
ndb_mgmd_start($cluster);
2883
for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ )
2885
ndbd_start($cluster, $idx, $extra_args);
2386
mtr_verbose("ndbcluster_start '".$cluster->name()."'");
2388
foreach my $ndb_mgmd ( in_cluster($cluster, ndb_mgmds()) )
2390
next if started($ndb_mgmd);
2391
ndb_mgmd_start($cluster, $ndb_mgmd);
2394
foreach my $ndbd ( in_cluster($cluster, ndbds()) )
2396
next if started($ndbd);
2397
ndbd_start($cluster, $ndbd);
2892
sub rm_ndbcluster_tables ($) {
2894
foreach my $bin ( glob("$dir/mysql/ndb_apply_status*"),
2895
glob("$dir/mysql/ndb_schema*"))
2902
##############################################################################
2904
# Run the benchmark suite
2906
##############################################################################
2908
sub run_benchmarks ($) {
2909
my $benchmark= shift;
2913
if ( ! $glob_use_embedded_server )
2915
mysqld_start($master->[0],[],[]);
2916
if ( ! $master->[0]->{'pid'} )
2918
mtr_error("Can't start the mysqld server");
2922
mtr_init_args(\$args);
2924
mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_sock'});
2925
mtr_add_arg($args, "--user=%s", $opt_user);
2927
if ( $opt_small_bench )
2929
mtr_add_arg($args, "--small-test");
2930
mtr_add_arg($args, "--small-tables");
2933
if ( $opt_with_ndbcluster )
2935
mtr_add_arg($args, "--create-options=TYPE=ndb");
2938
chdir($glob_mysql_bench_dir)
2939
or mtr_error("Couldn't chdir to '$glob_mysql_bench_dir': $!");
2943
mtr_add_arg($args, "--log");
2944
mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", "");
2945
# FIXME check result code?!
2947
elsif ( -x $benchmark )
2949
mtr_run("$glob_mysql_bench_dir/$benchmark", $args, "", "", "", "");
2950
# FIXME check result code?!
2954
mtr_error("Benchmark $benchmark not found");
2957
chdir($glob_mysql_test_dir); # Go back
2959
if ( ! $glob_use_embedded_server )
2966
##############################################################################
2970
##############################################################################
2975
mtr_print_thick_line();
2977
mtr_timer_start($glob_timers,"suite", 60 * $opt_suite_timeout);
2979
mtr_report_tests_not_skipped_though_disabled($tests);
2983
foreach my $tinfo ( @$tests )
2985
if (run_testcase_check_skip_test($tinfo))
2990
mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
2991
run_testcase($tinfo);
2992
mtr_timer_stop($glob_timers,"testcase");
2997
if ( ! $glob_debugger and
2999
! $glob_use_embedded_server )
3006
gcov_collect(); # collect coverage information
3010
gprof_collect(); # collect coverage information
3013
mtr_report_stats($tests);
3015
mtr_timer_stop($glob_timers,"suite");
3019
##############################################################################
3021
# Initiate the test databases
3023
##############################################################################
3025
sub initialize_servers () {
3027
datadir_list_setup();
2404
sub create_config_file_for_extern {
2407
socket => '/tmp/mysqld.sock',
2414
mtr_report("Creating my.cnf file for extern server...");
2415
my $F= IO::File->new($path_config_file, "w")
2416
or mtr_error("Can't write to $path_config_file: $!");
2418
print $F "[client]\n";
2419
while (my ($option, $value)= each( %opts )) {
2420
print $F "$option= $value\n";
2421
mtr_report(" $option= $value");
2426
# binlog reads from [client] and [mysqlbinlog]
2428
character-sets-dir= $path_charsetsdir
2430
# mysql_fix_privilege_tables.sh don't read from [client]
2431
[mysql_fix_privilege_tables]
2432
socket = $opts{'socket'}
2433
port = $opts{'port'}
2434
user = $opts{'user'}
2435
password = $opts{'password'}
2441
$F= undef; # Close file
2446
# Kill processes left from previous runs, normally
2447
# there should be none so make sure to warn
2450
sub kill_leftovers ($) {
2452
return unless ( -d $rundir );
2454
mtr_report("Checking leftover processes...");
2456
# Scan the "run" directory for process id's to kill
2457
opendir(RUNDIR, $rundir)
2458
or mtr_error("kill_leftovers, can't open dir \"$rundir\": $!");
2459
while ( my $elem= readdir(RUNDIR) )
2461
# Only read pid from files that end with .pid
2462
if ( $elem =~ /.*[.]pid$/ )
2464
my $pidfile= "$rundir/$elem";
2465
next unless -f $pidfile;
2466
my $pid= mtr_fromfile($pidfile);
2468
unless ($pid=~ /^(\d+)/){
2469
# The pid was not a valid number
2470
mtr_warning("Got invalid pid '$pid' from '$elem'");
2473
mtr_report(" - found old pid $pid in '$elem', killing it...");
2475
my $ret= kill("KILL", $pid);
2477
mtr_report(" process did not exist!");
2481
my $check_counter= 100;
2482
while ($ret > 0 and $check_counter--) {
2483
mtr_milli_sleep(100);
2484
$ret= kill(0, $pid);
2486
mtr_report($check_counter ? " ok!" : " failed!");
2490
mtr_warning("Found non pid file '$elem' in '$rundir'")
2491
if -f "$rundir/$elem";
2498
# Check that all the ports that are going to
2501
sub check_ports_free ($)
2504
my $portbase = $bthread * 10 + 10000;
2505
for ($portbase..$portbase+9){
2506
if (mtr_ping_port($_)){
2507
mtr_report(" - 'localhost:$_' was not free");
2508
return 0; # One port was not free
2512
return 1; # All ports free
2516
sub initialize_servers {
2518
if ( using_extern() )
3031
2520
# Running against an already started server, if the specified
3032
2521
# vardir does not already exist it should be created
3033
2522
if ( ! -d $opt_vardir )
3035
mtr_report("Creating '$opt_vardir'");
3036
2524
setup_vardir();
3045
kill_running_servers();
2533
# Kill leftovers from previous run
2534
# using any pidfiles found in var/run
2535
kill_leftovers("$opt_vardir/run");
3047
2537
if ( ! $opt_start_dirty )
3049
2539
remove_stale_vardir();
3050
2540
setup_vardir();
3055
# Save a snapshot of the freshly installed db
3056
# to make it possible to restore to a known point in time
3057
save_installed_db();
2542
mysql_install_db(default_mysqld(), "$opt_vardir/install.db");
2549
# Remove all newline characters expect after semicolon
2551
sub sql_to_bootstrap {
2553
my @lines= split(/\n/, $sql);
2557
foreach my $line (@lines) {
2559
# Change current delimiter if line starts with "delimiter"
2560
if ( $line =~ /^delimiter (.*)/ ) {
2562
# Remove old delimiter from end of new
2563
$new=~ s/\Q$delimiter\E$//;
2565
mtr_debug("changed delimiter to $delimiter");
2566
# No need to add the delimiter to result
2570
# Add newline if line ends with $delimiter
2571
# and convert the current delimiter to semicolon
2572
if ( $line =~ /\Q$delimiter\E$/ ){
2573
$line =~ s/\Q$delimiter\E$/;/;
2574
$result.= "$line\n";
2575
mtr_debug("Added default delimiter");
2579
# Remove comments starting with --
2580
if ( $line =~ /^\s*--/ ) {
2581
mtr_debug("Discarded $line");
2585
# Replace @HOSTNAME with localhost
2586
$line=~ s/\'\@HOSTNAME\@\'/localhost/;
2588
# Default, just add the line without newline
2589
# but with a space as separator
2597
sub default_mysqld {
2598
# Generate new config file from template
2599
my $config= My::ConfigFactory->new_config
2601
basedir => $basedir,
2602
template_path => "include/default_my.cnf",
2603
vardir => $opt_vardir,
2604
tmpdir => $opt_tmpdir,
3061
check_running_as_root();
3063
mtr_log_init("$opt_vardir/log/mysql-test-run.log");
3067
sub mysql_install_db () {
3069
install_db('master', $master->[0]->{'path_myddir'});
3071
if ($max_master_num > 1)
3073
copy_install_db('master', $master->[1]->{'path_myddir'});
3076
# Install the number of slave databses needed
3077
for (my $idx= 0; $idx < $max_slave_num; $idx++)
3079
copy_install_db("slave".($idx+1), $slave->[$idx]->{'path_myddir'});
3082
if ( ! $opt_skip_im )
3084
im_prepare_env($instance_manager);
3087
my $cluster_started_ok= 1; # Assume it can be started
3089
my $cluster= $clusters->[0]; # Master cluster
3090
if ($opt_skip_ndbcluster ||
3091
$cluster->{'use_running'} ||
3092
$cluster->{executable_setup_failed})
3094
# Don't install master cluster
3096
elsif (ndbcluster_start_install($cluster))
3098
mtr_warning("Failed to start install of $cluster->{name}");
3099
$cluster_started_ok= 0;
3102
$cluster= $clusters->[1]; # Slave cluster
3103
if ($max_slave_num == 0 ||
3104
$opt_skip_ndbcluster_slave ||
3105
$cluster->{'use_running'} ||
3106
$cluster->{executable_setup_failed})
3108
# Don't install slave cluster
3110
elsif (ndbcluster_start_install($cluster))
3112
mtr_warning("Failed to start install of $cluster->{name}");
3113
$cluster_started_ok= 0;
3116
foreach $cluster (@{$clusters})
3119
next if !$cluster->{'pid'};
3121
$cluster->{'installed_ok'}= 1; # Assume install suceeds
3123
if (ndbcluster_wait_started($cluster, ""))
3125
# failed to install, disable usage and flag that its no ok
3126
mtr_report("ndbcluster_install of $cluster->{'name'} failed");
3127
$cluster->{"installed_ok"}= 0;
3129
$cluster_started_ok= 0;
3133
if ( ! $cluster_started_ok )
3137
# Continue without cluster
3141
mtr_error("To continue, re-run with '--force'.");
3149
sub copy_install_db ($$) {
3151
my $data_dir= shift;
3153
mtr_report("Installing \u$type Database");
3155
# Just copy the installed db from first master
3156
mtr_copy_dir($master->[0]->{'path_myddir'}, $data_dir);
3161
sub install_db ($$) {
3163
my $data_dir= shift;
3165
mtr_report("Installing \u$type Database");
2611
my $mysqld= $config->group('mysqld.1')
2612
or mtr_error("Couldn't find mysqld.1 in default config");
2617
sub mysql_install_db {
2618
my ($mysqld, $datadir)= @_;
2620
my $install_datadir= $datadir || $mysqld->value('datadir');
2621
my $install_basedir= $mysqld->value('basedir');
2622
my $install_lang= $mysqld->value('language');
2623
my $install_chsdir= $mysqld->value('character-sets-dir');
2625
mtr_report("Installing system database...");
3169
2628
mtr_init_args(\$args);
3170
2629
mtr_add_arg($args, "--no-defaults");
3171
2630
mtr_add_arg($args, "--bootstrap");
3172
mtr_add_arg($args, "--basedir=%s", $path_my_basedir);
3173
mtr_add_arg($args, "--datadir=%s", $data_dir);
2631
mtr_add_arg($args, "--basedir=%s", $install_basedir);
2632
mtr_add_arg($args, "--datadir=%s", $install_datadir);
3174
2633
mtr_add_arg($args, "--loose-skip-innodb");
2634
mtr_add_arg($args, "--loose-skip-falcon");
3175
2635
mtr_add_arg($args, "--loose-skip-ndbcluster");
3176
mtr_add_arg($args, "--tmpdir=.");
2636
mtr_add_arg($args, "--tmpdir=%s", "$opt_vardir/tmp/");
3177
2637
mtr_add_arg($args, "--core-file");
3179
2639
if ( $opt_debug )
3181
mtr_add_arg($args, "--debug=d:t:i:A,%s/log/bootstrap_%s.trace",
3182
$path_vardir_trace, $type);
2641
mtr_add_arg($args, "--debug=d:t:i:A,%s/log/bootstrap.trace",
2642
$path_vardir_trace);
3185
if ( ! $glob_netware )
3187
mtr_add_arg($args, "--language=%s", $path_language);
3188
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
2645
mtr_add_arg($args, "--language=%s", $install_lang);
2646
mtr_add_arg($args, "--character-sets-dir=%s", $install_chsdir);
3191
2648
# If DISABLE_GRANT_OPTIONS is defined when the server is compiled (e.g.,
3192
2649
# configure --disable-grant-options), mysqld will not recognize the
3193
2650
# --bootstrap or --skip-grant-tables options. The user can set
3194
2651
# MYSQLD_BOOTSTRAP to the full path to a mysqld which does accept
3195
2652
# --bootstrap, to accommodate this.
3196
my $exe_mysqld_bootstrap = $ENV{'MYSQLD_BOOTSTRAP'} || $exe_mysqld;
2653
my $exe_mysqld_bootstrap =
2654
$ENV{'MYSQLD_BOOTSTRAP'} || find_mysqld($install_basedir);
3198
2656
# ----------------------------------------------------------------------
3199
2657
# export MYSQLD_BOOTSTRAP_CMD variable containing <path>/mysqld <args>
3200
2658
# ----------------------------------------------------------------------
3201
2659
$ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args);
3203
2663
# ----------------------------------------------------------------------
3204
2664
# Create the bootstrap.sql file
3205
2665
# ----------------------------------------------------------------------
3206
2666
my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql";
3208
# Use the mysql database for system tables
3209
mtr_tofile($bootstrap_sql_file, "use mysql");
3211
# Add the offical mysql system tables
3212
# for a production system
3213
mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables.sql",
3214
$bootstrap_sql_file);
3216
# Add the mysql system tables initial data
3217
# for a production system
3218
mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables_data.sql",
3219
$bootstrap_sql_file);
3221
# Add test data for timezone - this is just a subset, on a real
3222
# system these tables will be populated either by mysql_tzinfo_to_sql
3223
# or by downloading the timezone table package from our website
3224
mtr_appendfile_to_file("$path_sql_dir/mysql_test_data_timezone.sql",
3225
$bootstrap_sql_file);
3227
# Fill help tables, just an empty file when running from bk repo
3228
# but will be replaced by a real fill_help_tables.sql when
3229
# building the source dist
3230
mtr_appendfile_to_file("$path_sql_dir/fill_help_tables.sql",
3231
$bootstrap_sql_file);
2668
my $path_sql= my_find_file($install_basedir,
2669
["mysql", "sql/share", "share/mysql",
2670
"share", "scripts"],
2671
"mysql_system_tables.sql",
2676
my $sql_dir= dirname($path_sql);
2677
# Use the mysql database for system tables
2678
mtr_tofile($bootstrap_sql_file, "use mysql\n");
2680
# Add the offical mysql system tables
2681
# for a production system
2682
mtr_appendfile_to_file("$sql_dir/mysql_system_tables.sql",
2683
$bootstrap_sql_file);
2685
# Add the mysql system tables initial data
2686
# for a production system
2687
mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql",
2688
$bootstrap_sql_file);
2690
# Add test data for timezone - this is just a subset, on a real
2691
# system these tables will be populated either by mysql_tzinfo_to_sql
2692
# or by downloading the timezone table package from our website
2693
mtr_appendfile_to_file("$sql_dir/mysql_test_data_timezone.sql",
2694
$bootstrap_sql_file);
2696
# Fill help tables, just an empty file when running from bk repo
2697
# but will be replaced by a real fill_help_tables.sql when
2698
# building the source dist
2699
mtr_appendfile_to_file("$sql_dir/fill_help_tables.sql",
2700
$bootstrap_sql_file);
2705
# Install db from init_db.sql that exist in early 5.1 and 5.0
2707
my $init_file= "$install_basedir/mysql-test/lib/init_db.sql";
2708
mtr_report(" - from '$init_file'");
2709
my $text= mtr_grab_file($init_file) or
2710
mtr_error("Can't open '$init_file': $!");
2712
mtr_tofile($bootstrap_sql_file,
2713
sql_to_bootstrap($text));
3233
2716
# Remove anonymous users
3234
2717
mtr_tofile($bootstrap_sql_file,
3235
"DELETE FROM mysql.user where user= '';");
2718
"DELETE FROM mysql.user where user= '';\n");
2720
# Create mtr database
2721
mtr_tofile($bootstrap_sql_file,
2722
"CREATE DATABASE mtr;\n");
2724
# Add help tables and data for warning detection and supression
2725
mtr_tofile($bootstrap_sql_file,
2726
sql_to_bootstrap(mtr_grab_file("include/mtr_warnings.sql")));
2728
# Add procedures for checking server is restored after testcase
2729
mtr_tofile($bootstrap_sql_file,
2730
sql_to_bootstrap(mtr_grab_file("include/mtr_check.sql")));
3237
2732
# Log bootstrap command
3238
2733
my $path_bootstrap_log= "$opt_vardir/log/bootstrap.log";
3239
2734
mtr_tofile($path_bootstrap_log,
3240
2735
"$exe_mysqld_bootstrap " . join(" ", @$args) . "\n");
3243
if ( mtr_run($exe_mysqld_bootstrap, $args, $bootstrap_sql_file,
3244
$path_bootstrap_log, $path_bootstrap_log,
3245
"", { append_log_file => 1 }) != 0 )
2737
# Create directories mysql and test
2738
mkpath("$install_datadir/mysql");
2739
mkpath("$install_datadir/test");
2741
if ( My::SafeProcess->run
2743
name => "bootstrap",
2744
path => $exe_mysqld_bootstrap,
2746
input => $bootstrap_sql_file,
2747
output => $path_bootstrap_log,
2748
error => $path_bootstrap_log,
2750
verbose => $opt_verbose,
3248
2753
mtr_error("Error executing mysqld --bootstrap\n" .
3249
2754
"Could not install system database from $bootstrap_sql_file\n" .
3385
2771
if ( $tinfo->{'skip'} )
3387
mtr_report_test_name($tinfo);
3388
2773
mtr_report_test_skipped($tinfo);
3392
if ($tinfo->{'ndb_test'})
3394
foreach my $cluster (@{$clusters})
3396
# Slave cluster is skipped and thus not
3397
# installed, no need to perform checks
3398
last if ($opt_skip_ndbcluster_slave and
3399
$cluster->{'name'} eq 'Slave');
3401
# Using running cluster - no need
3402
# to check if test should be skipped
3403
# will be done by test itself
3404
last if ($cluster->{'use_running'});
3406
# If test needs this cluster, check binaries was found ok
3407
if ( $cluster->{'executable_setup_failed'} )
3409
mtr_report_test_name($tinfo);
3411
"Failed to find cluster binaries";
3412
mtr_report_test_failed($tinfo);
3416
# If test needs this cluster, check it was installed ok
3417
if ( !$cluster->{'installed_ok'} )
3419
mtr_report_test_name($tinfo);
3421
"Cluster $cluster->{'name'} was not installed ok";
3422
mtr_report_test_failed($tinfo);
3429
if ( $tinfo->{'component_id'} eq 'im' )
3431
# If test needs im, check binaries was found ok
3432
if ( $instance_manager->{'executable_setup_failed'} )
3434
mtr_report_test_name($tinfo);
3436
"Failed to find MySQL manager binaries";
3437
mtr_report_test_failed($tinfo);
2782
my ($tinfo, $mysqld, $query)= @_;
2785
mtr_init_args(\$args);
2786
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
2787
mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
2789
mtr_add_arg($args, "-e %s", $query);
2791
my $res= My::SafeProcess->run
2793
name => "run_query -> ".$mysqld->name(),
2796
output => '/dev/null',
2797
error => '/dev/null'
3446
2804
sub do_before_run_mysqltest($)
3448
2806
my $tinfo= shift;
3451
2808
# Remove old files produced by mysqltest
3452
my $base_file= mtr_match_extension($tinfo->{'result_file'},
3453
"result"); # Trim extension
3454
unlink("$base_file.reject");
3455
unlink("$base_file.progress");
3456
unlink("$base_file.log");
3457
unlink("$base_file.warnings");
2809
my $base_file= mtr_match_extension($tinfo->{result_file},
2810
"result"); # Trim extension
2811
if (defined $base_file ){
2812
unlink("$base_file.reject");
2813
unlink("$base_file.progress");
2814
unlink("$base_file.log");
2815
unlink("$base_file.warnings");
2818
if ( $mysql_version_id < 50000 ) {
2819
# Set environment variable NDB_STATUS_OK to 1
2820
# if script decided to run mysqltest cluster _is_ installed ok
2821
$ENV{'NDB_STATUS_OK'} = "1";
2822
} elsif ( $mysql_version_id < 50100 ) {
2823
# Set environment variable NDB_STATUS_OK to YES
2824
# if script decided to run mysqltest cluster _is_ installed ok
2825
$ENV{'NDB_STATUS_OK'} = "YES";
2831
# Check all server for sideffects
2838
sub check_testcase($$)
2840
my ($tinfo, $mode)= @_;
2841
my $tname= $tinfo->{name};
2843
# Start the mysqltest processes in parallel to save time
2844
# also makes it possible to wait for any process to exit during the check
2846
foreach my $mysqld ( mysqlds() )
3461
if ( $mysql_version_id < 50000 ) {
3462
# Set environment variable NDB_STATUS_OK to 1
3463
# if script decided to run mysqltest cluster _is_ installed ok
3464
$ENV{'NDB_STATUS_OK'} = "1";
3465
} elsif ( $mysql_version_id < 50100 ) {
3466
# Set environment variable NDB_STATUS_OK to YES
3467
# if script decided to run mysqltest cluster _is_ installed ok
3468
$ENV{'NDB_STATUS_OK'} = "YES";
2848
if ( defined $mysqld->{'proc'} )
2850
my $proc= start_check_testcase($tinfo, $mode, $mysqld);
2851
$started{$proc->pid()}= $proc;
3470
if (defined $tinfo->{binlog_format} and $mysql_version_id > 50100 )
3472
# Dynamically switch binlog format of
3473
# master, slave is always restarted
3474
foreach my $server ( @$master )
2855
# Return immediately if no check proceess was started
2856
return 0 unless ( keys %started );
2858
my $timeout_proc= My::SafeProcess->timer(check_timeout());
2862
my $proc= My::SafeProcess->wait_any();
2863
mtr_report("Got $proc");
2865
if ( delete $started{$proc->pid()} ) {
2867
my $err_file= $proc->user_data();
2868
my $base_file= mtr_match_extension($err_file, "err"); # Trim extension
2870
# One check testcase process returned
2871
my $res= $proc->exit_status();
2874
# Check completed without problem
2876
# Remove the .err file the check generated
2879
# Remove the .result file the check generated
2880
if ( $mode eq 'after' ){
2881
unlink("$base_file.result");
2884
if ( keys(%started) == 0){
2885
# All checks completed
2887
$timeout_proc->kill();
2891
# Wait for next process to exit
3476
next unless ($server->{'pid'});
3478
mtr_init_args(\$args);
3479
mtr_add_arg($args, "--no-defaults");
3480
mtr_add_arg($args, "--user=root");
3481
mtr_add_arg($args, "--port=$server->{'port'}");
3482
mtr_add_arg($args, "--socket=$server->{'path_sock'}");
3484
my $sql= "include/set_binlog_format_".$tinfo->{binlog_format}.".sql";
3485
mtr_verbose("Setting binlog format:", $tinfo->{binlog_format});
3486
if (mtr_run($exe_mysql, $args, $sql, "", "", "") != 0)
3488
mtr_error("Failed to switch binlog format");
3495
sub do_after_run_mysqltest($)
3499
# Save info from this testcase run to mysqltest.log
3500
mtr_appendfile_to_file($path_current_test_log, $path_mysqltest_log)
3501
if -f $path_current_test_log;
3502
mtr_appendfile_to_file($path_timefile, $path_mysqltest_log)
3503
if -f $path_timefile;
3507
sub run_testcase_mark_logs($$)
3509
my ($tinfo, $log_msg)= @_;
3511
# Write a marker to all log files
3513
# The file indicating current test name
3514
mtr_tonewfile($path_current_test_log, $log_msg);
3516
# each mysqld's .err file
3517
foreach my $mysqld (@{$master}, @{$slave})
3519
mtr_tofile($mysqld->{path_myerr}, $log_msg);
3522
if ( $tinfo->{'component_id'} eq 'im')
3524
mtr_tofile($instance_manager->{path_err}, $log_msg);
3525
mtr_tofile($instance_manager->{path_log}, $log_msg);
3528
# ndbcluster log file
3529
mtr_tofile($path_ndb_testrun_log, $log_msg);
2896
if ( $mode eq "after" and $res == 1 )
2898
# Test failed, grab the report mysqltest has created
2899
my $report= mtr_grab_file($err_file);
2901
"\nMTR's internal check of the test case '$tname' failed.
2902
This means that the test case does not preserve the state that existed
2903
before the test case was executed. Most likely the test case did not
2904
do a proper clean-up.
2905
This is the diff of the states of the servers before and after the
2906
test case was executed:\n";
2907
$tinfo->{check}.= $report;
2909
# Check failed, mark the test case with that info
2910
$tinfo->{'check_testcase_failed'}= 1;
2915
my $report= mtr_grab_file($err_file);
2917
"Could not execute 'check-testcase' $mode ".
2918
"testcase '$tname' (res: $res):\n";
2919
$tinfo->{comment}.= $report;
2924
# Remove the .result file the check generated
2925
unlink("$base_file.result");
2929
elsif ( $proc eq $timeout_proc ) {
2930
$tinfo->{comment}.= "Timeout $timeout_proc for ".
2931
"'check-testcase' expired after ".check_timeout().
2936
# Unknown process returned, most likley a crash, abort everything
2938
"The server $proc crashed while running ".
2939
"'check testcase $mode test'";
2943
# Kill any check processes still running
2944
map($_->kill(), values(%started));
2946
$timeout_proc->kill();
2951
mtr_error("INTERNAL_ERROR: check_testcase");
2955
# Start run mysqltest on one server
2961
sub start_run_one ($$) {
2962
my ($mysqld, $run)= @_;
2964
my $name= "$run-".$mysqld->name();
2967
mtr_init_args(\$args);
2969
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
2970
mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
2972
mtr_add_arg($args, "--silent");
2973
mtr_add_arg($args, "--skip-safemalloc");
2974
mtr_add_arg($args, "--test-file=%s", "include/$run.test");
2976
my $errfile= "$opt_vardir/tmp/$name.err";
2977
my $proc= My::SafeProcess->new
2980
path => $exe_mysqltest,
2984
user_data => $errfile,
2985
verbose => $opt_verbose,
2987
mtr_verbose("Started $proc");
2993
# Run script on all servers, collect results
3001
my ($tinfo, $run)= @_;
3003
# Start the mysqltest processes in parallel to save time
3004
# also makes it possible to wait for any process to exit during the check
3005
# and to have a timeout process
3007
foreach my $mysqld ( mysqlds() )
3009
if ( defined $mysqld->{'proc'} )
3011
my $proc= start_run_one($mysqld, $run);
3012
$started{$proc->pid()}= $proc;
3016
# Return immediately if no check proceess was started
3017
return 0 unless ( keys %started );
3019
my $timeout_proc= My::SafeProcess->timer(check_timeout());
3023
my $proc= My::SafeProcess->wait_any();
3024
mtr_report("Got $proc");
3026
if ( delete $started{$proc->pid()} ) {
3028
# One mysqltest process returned
3029
my $err_file= $proc->user_data();
3030
my $res= $proc->exit_status();
3032
# Append the report from .err file
3033
$tinfo->{comment}.= " == $err_file ==\n";
3034
$tinfo->{comment}.= mtr_grab_file($err_file);
3035
$tinfo->{comment}.= "\n";
3037
# Remove the .err file
3040
if ( keys(%started) == 0){
3042
$timeout_proc->kill();
3046
# Wait for next process to exit
3049
elsif ( $proc eq $timeout_proc ) {
3050
$tinfo->{comment}.= "Timeout $timeout_proc for '$run' ".
3051
"expired after ". check_timeout().
3055
# Unknown process returned, most likley a crash, abort everything
3057
"The server $proc crashed while running '$run'";
3060
# Kill any check processes still running
3061
map($_->kill(), values(%started));
3063
$timeout_proc->kill();
3067
mtr_error("INTERNAL_ERROR: run_on_all");
3072
my ($log, $tinfo)= @_;
3073
my $log_msg= "CURRENT_TEST: $tinfo->{name}\n";
3074
mtr_tofile($log, $log_msg);
3533
3078
sub find_testcase_skipped_reason($)
3554
3099
if ( ! $reason )
3556
mtr_warning("Could not find reason for skipping test in $path_timefile");
3101
mtr_warning("Could not find reason for skipping test in $path_current_testlog");
3557
3102
$reason= "Detected by testcase(reason unknown) ";
3559
3104
$tinfo->{'comment'}= $reason;
3563
##############################################################################
3565
# Run a single test case
3567
##############################################################################
3569
# When we get here, we have already filtered out test cases that doesn't
3570
# apply to the current setup, for example if we use a running server, test
3571
# cases that restart the server are dropped. So this function should mostly
3572
# be about doing things, not a lot of logic.
3574
# We don't start and kill the servers for each testcase. But some
3575
# testcases needs a restart, because they specify options to start
3576
# mysqld with. After that testcase, we need to restart again, to set
3577
# back the normal options.
3108
sub find_analyze_request
3110
# Open the test log file
3111
my $F= IO::File->new($path_current_testlog)
3115
while ( my $line= <$F> )
3117
# Look for "reason: <reason for skipping test>"
3118
if ( $line =~ /analyze: (.*)/ )
3128
# Return timezone value of tinfo or default value
3131
return $tinfo->{timezone} || "GMT-3";
3135
# Storage for changed environment variables
3139
# Run a single test case
3579
3146
sub run_testcase ($) {
3580
3147
my $tinfo= shift;
3149
mtr_verbose("Running test:", $tinfo->{name});
3582
3151
# -------------------------------------------------------
3583
3152
# Init variables that can change between each test case
3584
3153
# -------------------------------------------------------
3586
$ENV{'TZ'}= $tinfo->{'timezone'};
3587
mtr_verbose("Setting timezone: $tinfo->{'timezone'}");
3589
my $master_restart= run_testcase_need_master_restart($tinfo);
3590
my $slave_restart= run_testcase_need_slave_restart($tinfo);
3592
if ($master_restart or $slave_restart)
3594
# Can't restart a running server that may be in use
3597
mtr_report_test_name($tinfo);
3598
$tinfo->{comment}= "Can't restart a running server";
3599
mtr_report_test_skipped($tinfo);
3603
run_testcase_stop_servers($tinfo, $master_restart, $slave_restart);
3606
# Write to all log files to indicate start of testcase
3607
run_testcase_mark_logs($tinfo, "CURRENT_TEST: $tinfo->{name}\n");
3609
my $died= mtr_record_dead_children();
3610
if ($died or $master_restart or $slave_restart)
3612
if (run_testcase_start_servers($tinfo))
3614
mtr_report_test_name($tinfo);
3154
my $timezone= timezone($tinfo);
3155
$ENV{'TZ'}= $timezone;
3156
mtr_verbose("Setting timezone: $timezone");
3158
if ( ! using_extern() )
3160
my @restart= servers_need_restart($tinfo);
3161
if ( @restart != 0) {
3162
stop_servers($tinfo, @restart );
3165
if ( started(all_servers()) == 0 )
3168
# Remove old datadirs
3172
while (my ($option, $value)= each( %old_env )) {
3173
if (defined $value){
3174
mtr_verbose("Restoring $option to $value");
3175
$ENV{$option}= $value;
3178
mtr_verbose("Removing $option");
3179
delete($ENV{$option});
3184
mtr_verbose("Generating my.cnf from '$tinfo->{template_path}'");
3186
# Generate new config file from template
3187
$config= My::ConfigFactory->new_config
3189
basedir => $basedir,
3190
template_path => $tinfo->{template_path},
3191
extra_template_path => $tinfo->{extra_template_path},
3192
vardir => $opt_vardir,
3193
tmpdir => $opt_tmpdir,
3194
baseport => $baseport,
3195
#hosts => [ 'host1', 'host2' ],
3198
ssl => $opt_ssl_supported,
3199
embedded => $opt_embedded_server,
3203
# Write the new my.cnf
3204
$config->save($path_config_file);
3206
# Remember current config so a restart can occur when a test need
3207
# to use a different one
3208
$current_config_name= $tinfo->{template_path};
3211
# Set variables in the ENV section
3213
foreach my $option ($config->options_in_group("ENV"))
3215
# Save old value to restore it before next time
3216
$old_env{$option->name()}= $ENV{$option->name()};
3218
mtr_verbose($option->name(), "=",$option->value());
3219
$ENV{$option->name()}= $option->value();
3223
# Write start of testcase to log
3224
mark_log($path_current_testlog, $tinfo);
3226
if (start_servers($tinfo))
3615
3228
report_failure_and_restart($tinfo);
3619
elsif ($glob_use_embedded_server)
3621
run_master_init_script($tinfo);
3624
# ----------------------------------------------------------------------
3625
# If --start-and-exit or --start-dirty given, stop here to let user manually
3233
# --------------------------------------------------------------------
3234
# If --start or --start-dirty given, stop here to let user manually
3627
3236
# ----------------------------------------------------------------------
3628
if ( $opt_start_and_exit or $opt_start_dirty )
3630
mtr_timer_stop_all($glob_timers);
3631
mtr_report("\nServers started, exiting");
3632
if ($glob_win32_perl)
3634
#ActiveState perl hangs when using normal exit, use POSIX::_exit instead
3635
use POSIX qw[ _exit ];
3645
do_before_run_mysqltest($tinfo);
3647
my $res= run_mysqltest($tinfo);
3648
mtr_report_test_name($tinfo);
3650
do_after_run_mysqltest($tinfo);
3654
mtr_report_test_passed($tinfo);
3656
elsif ( $res == 62 )
3658
# Testcase itself tell us to skip this one
3660
# Try to get reason from mysqltest.log
3661
find_testcase_skipped_reason($tinfo);
3662
mtr_report_test_skipped($tinfo);
3664
elsif ( $res == 63 )
3666
$tinfo->{'timeout'}= 1; # Mark as timeout
3667
report_failure_and_restart($tinfo);
3671
# Test case failure reported by mysqltest
3672
report_failure_and_restart($tinfo);
3676
# mysqltest failed, probably crashed
3678
"mysqltest returned unexpected code $res, it has probably crashed";
3679
report_failure_and_restart($tinfo);
3683
# Remove the file that mysqltest writes info to
3684
unlink($path_timefile);
3686
# ----------------------------------------------------------------------
3687
# Stop Instance Manager if we are processing an IM-test case.
3688
# ----------------------------------------------------------------------
3689
if ( $tinfo->{'component_id'} eq 'im' and
3690
!mtr_im_stop($instance_manager, $tinfo->{'name'}))
3692
mtr_error("Failed to stop Instance Manager.")
3698
# Save a snapshot of the installed test db(s)
3699
# I.e take a snapshot of the var/ dir
3701
sub save_installed_db () {
3703
mtr_report("Saving snapshot of installed databases");
3704
mtr_rmtree($path_snapshot);
3706
foreach my $data_dir (@data_dir_lst)
3708
my $name= basename($data_dir);
3709
mtr_copy_dir("$data_dir", "$path_snapshot/$name");
3715
# Save any interesting files in the data_dir
3716
# before the data dir is removed.
3718
sub save_files_before_restore($$) {
3719
my $test_name= shift;
3720
my $data_dir= shift;
3721
my $save_name= "$opt_vardir/log/$test_name";
3723
# Look for core files
3724
foreach my $core_file ( glob("$data_dir/core*") )
3726
last if $opt_max_save_core > 0 && $num_saved_cores >= $opt_max_save_core;
3727
my $core_name= basename($core_file);
3728
mtr_report("Saving $core_name");
3729
mkdir($save_name) if ! -d $save_name;
3730
rename("$core_file", "$save_name/$core_name");
3737
# Restore snapshot of the installed test db(s)
3738
# if the snapshot exists
3740
sub restore_installed_db ($) {
3741
my $test_name= shift;
3743
if ( -d $path_snapshot)
3745
mtr_report("Restoring snapshot of databases");
3747
foreach my $data_dir (@data_dir_lst)
3749
my $name= basename($data_dir);
3750
save_files_before_restore($test_name, $data_dir);
3751
mtr_rmtree("$data_dir");
3752
mtr_copy_dir("$path_snapshot/$name", "$data_dir");
3755
# Remove the ndb_*_fs dirs for all ndbd nodes
3756
# forcing a clean start of ndb
3757
foreach my $cluster (@{$clusters})
3759
foreach my $ndbd (@{$cluster->{'ndbds'}})
3761
mtr_rmtree("$ndbd->{'path_fs'}" );
3767
# No snapshot existed
3768
mtr_error("No snapshot existed");
3237
if ( $opt_start or $opt_start_dirty )
3239
mtr_print("\nStarted", started(all_servers()));
3240
mtr_print("Waiting for server(s) to exit...");
3241
my $proc= My::SafeProcess->wait_any();
3242
if ( grep($proc eq $_, started(all_servers())) )
3244
mtr_print("Server $proc died");
3247
mtr_print("Unknown process $proc died");
3251
my $test_timeout_proc= My::SafeProcess->timer(testcase_timeout());
3253
do_before_run_mysqltest($tinfo);
3255
if ( $opt_check_testcases and check_testcase($tinfo, "before") ){
3256
# Failed to record state of server or server crashed
3257
report_failure_and_restart($tinfo);
3259
# Stop the test case timer
3260
$test_timeout_proc->kill();
3265
my $test= start_mysqltest($tinfo);
3269
my $proc= My::SafeProcess->wait_any();
3270
unless ( defined $proc )
3272
mtr_error("wait_any failed");
3274
mtr_verbose("Got $proc");
3276
# ----------------------------------------------------
3277
# Was it the test program that exited
3278
# ----------------------------------------------------
3281
# Stop the test case timer
3282
$test_timeout_proc->kill();
3284
my $res= $test->exit_status();
3286
if ($res == 0 and $opt_warnings and check_warnings($tinfo) )
3288
# Test case suceeded, but it has produced unexpected
3289
# warnings, continue in $res == 1
3296
if ( $opt_check_testcases and
3297
$check_res= check_testcase($tinfo, "after"))
3299
if ($check_res == 1) {
3300
# Test case had sideeffects, not fatal error, just continue
3302
mtr_report("Resuming tests...\n");
3305
# Test case check failed fatally, probably a server crashed
3306
report_failure_and_restart($tinfo);
3310
mtr_report_test_passed($tinfo);
3312
elsif ( $res == 62 )
3314
# Testcase itself tell us to skip this one
3315
$tinfo->{skip_detected_by_test}= 1;
3316
# Try to get reason from test log file
3317
find_testcase_skipped_reason($tinfo);
3318
mtr_report_test_skipped($tinfo);
3320
elsif ( $res == 65 )
3322
# Testprogram killed by signal
3324
"testprogram crashed(returned code $res)";
3325
report_failure_and_restart($tinfo);
3329
# Check if the test tool requests that
3330
# an analyze script should be run
3331
my $analyze= find_analyze_request();
3333
run_on_all($tinfo, "analyze-$analyze");
3336
# Test case failure reported by mysqltest
3337
report_failure_and_restart($tinfo);
3341
# mysqltest failed, probably crashed
3343
"mysqltest failed with unexpected return code $res";
3344
report_failure_and_restart($tinfo);
3347
# Save info from this testcase run to mysqltest.log
3348
if( -f $path_current_testlog)
3350
mtr_appendfile_to_file($path_current_testlog, $path_testlog);
3351
unlink($path_current_testlog);
3354
return ($res == 62) ? 0 : $res;
3358
# ----------------------------------------------------
3359
# Check if it was an expected crash
3360
# ----------------------------------------------------
3361
if ( check_expected_crash_and_restart($proc) )
3366
# ----------------------------------------------------
3367
# Stop the test case timer
3368
# ----------------------------------------------------
3369
$test_timeout_proc->kill();
3371
# ----------------------------------------------------
3372
# Check if it was a server that died
3373
# ----------------------------------------------------
3374
if ( grep($proc eq $_, started(all_servers())) )
3376
# Server failed, probably crashed
3378
"Server $proc failed during test run";
3380
# ----------------------------------------------------
3381
# It's not mysqltest that has exited, kill it
3382
# ----------------------------------------------------
3385
report_failure_and_restart($tinfo);
3389
# Try to dump core for mysqltest and all servers
3390
foreach my $proc ($test, started(all_servers()))
3392
mtr_print("Trying to dump core for $proc");
3393
if ($proc->dump_core())
3395
$proc->wait_one(20);
3399
# ----------------------------------------------------
3400
# It's not mysqltest that has exited, kill it
3401
# ----------------------------------------------------
3404
# ----------------------------------------------------
3405
# Check if testcase timer expired
3406
# ----------------------------------------------------
3407
if ( $proc eq $test_timeout_proc )
3409
my $log_file_name= $opt_vardir."/log/".$tinfo->{shortname}.".log";
3411
"Test case timeout after ".testcase_timeout().
3413
# Add 20 last executed commands from test case log file
3414
if (-e $log_file_name)
3417
"== $log_file_name == \n".
3418
mtr_lastlinesfromfile($log_file_name, 20)."\n";
3420
$tinfo->{'timeout'}= testcase_timeout(); # Mark as timeout
3421
run_on_all($tinfo, 'analyze-timeout');
3423
report_failure_and_restart($tinfo);
3427
mtr_error("Unhandled process $proc exited");
3429
mtr_error("Should never come here");
3434
# Perform a rough examination of the servers
3435
# error log and write all lines that look
3436
# suspicious into $error_log.warnings
3438
sub extract_warning_lines ($) {
3439
my ($error_log) = @_;
3441
# Open the servers .err log file and read all lines
3442
# belonging to current tets into @lines
3443
my $Ferr = IO::File->new($error_log)
3444
or mtr_error("Could not open file '$error_log' for reading: $!");
3447
while ( my $line = <$Ferr> )
3449
if ( $line =~ /^CURRENT_TEST:/ )
3451
# Throw away lines from previous tests
3454
push(@lines, $line);
3456
$Ferr = undef; # Close error log file
3458
# mysql_client_test.test sends a COM_DEBUG packet to the server
3459
# to provoke a SAFEMALLOC leak report, ignore any warnings
3460
# between "Begin/end safemalloc memory dump"
3461
if ( grep(/Begin safemalloc memory dump:/, @lines) > 0)
3463
my $discard_lines= 1;
3464
foreach my $line ( @lines )
3466
if ($line =~ /Begin safemalloc memory dump:/){
3468
} elsif ($line =~ /End safemalloc memory dump./){
3472
if ($discard_lines){
3478
# Write all suspicious lines to $error_log.warnings file
3479
my $warning_log = "$error_log.warnings";
3480
my $Fwarn = IO::File->new($warning_log, "w")
3481
or die("Could not open file '$warning_log' for writing: $!");
3482
print $Fwarn "Suspicious lines from $error_log\n";
3486
# The patterns for detection of [Warning] and [ERROR]
3487
# in the server log files have been faulty for a longer period
3488
# and correcting them shows a few additional harmless warnings.
3489
# Thus those patterns are temporarily removed from the list
3490
# of patterns. For more info see BUG#42408
3491
# qr/^Warning:|mysqld: Warning|\[Warning\]/,
3492
# qr/^Error:|\[ERROR\]/,
3493
qr/^Warning:|mysqld: Warning/,
3496
qr/InnoDB: Warning|InnoDB: Error/,
3497
qr/^safe_mutex:|allocated at line/,
3498
qr/missing DBUG_RETURN/,
3499
qr/Attempting backtrace/,
3500
qr/Assertion .* failed/,
3503
foreach my $line ( @lines )
3505
foreach my $pat ( @patterns )
3507
if ( $line =~ /$pat/ )
3514
$Fwarn = undef; # Close file
3519
# Run include/check-warnings.test
3525
sub start_check_warnings ($$) {
3529
my $name= "warnings-".$mysqld->name();
3531
my $log_error= $mysqld->value('#log-error');
3532
# To be communicated to the test
3533
$ENV{MTR_LOG_ERROR}= $log_error;
3534
extract_warning_lines($log_error);
3537
mtr_init_args(\$args);
3539
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
3540
mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
3542
mtr_add_arg($args, "--skip-safemalloc");
3543
mtr_add_arg($args, "--test-file=%s", "include/check-warnings.test");
3544
mtr_add_arg($args, "--verbose");
3546
if ( $opt_embedded_server )
3549
# Get the args needed for the embedded server
3550
# and append them to args prefixed
3553
my $mysqld= $config->group('embedded')
3554
or mtr_error("Could not get [embedded] section");
3557
mtr_init_args(\$mysqld_args);
3558
my $extra_opts= get_extra_opts($mysqld, $tinfo);
3559
mysqld_arguments($mysqld_args, $mysqld, $extra_opts);
3560
mtr_add_arg($args, "--server-arg=%s", $_) for @$mysqld_args;
3563
my $errfile= "$opt_vardir/tmp/$name.err";
3564
my $proc= My::SafeProcess->new
3567
path => $exe_mysqltest,
3571
user_data => $errfile,
3572
verbose => $opt_verbose,
3574
mtr_verbose("Started $proc");
3580
# Loop through our list of processes and check the error log
3581
# for unexepcted errors and warnings
3583
sub check_warnings ($) {
3587
my $tname= $tinfo->{name};
3589
# Clear previous warnings
3590
delete($tinfo->{warnings});
3592
# Start the mysqltest processes in parallel to save time
3593
# also makes it possible to wait for any process to exit during the check
3595
foreach my $mysqld ( mysqlds() )
3597
if ( defined $mysqld->{'proc'} )
3599
my $proc= start_check_warnings($tinfo, $mysqld);
3600
$started{$proc->pid()}= $proc;
3604
# Return immediately if no check proceess was started
3605
return 0 unless ( keys %started );
3607
my $timeout_proc= My::SafeProcess->timer(check_timeout());
3611
my $proc= My::SafeProcess->wait_any();
3612
mtr_report("Got $proc");
3614
if ( delete $started{$proc->pid()} ) {
3615
# One check warning process returned
3616
my $res= $proc->exit_status();
3617
my $err_file= $proc->user_data();
3619
if ( $res == 0 or $res == 62 ){
3622
# Check completed with problem
3623
my $report= mtr_grab_file($err_file);
3624
# Log to var/log/warnings file
3625
mtr_tofile("$opt_vardir/log/warnings",
3626
$tname."\n".$report);
3628
$tinfo->{'warnings'}.= $report;
3633
# Test case was ok and called "skip"
3634
# Remove the .err file the check generated
3638
if ( keys(%started) == 0){
3639
# All checks completed
3641
$timeout_proc->kill();
3645
# Wait for next process to exit
3650
my $report= mtr_grab_file($err_file);
3652
"Could not execute 'check-warnings' for ".
3653
"testcase '$tname' (res: $res):\n";
3654
$tinfo->{comment}.= $report;
3659
elsif ( $proc eq $timeout_proc ) {
3660
$tinfo->{comment}.= "Timeout $timeout_proc for ".
3661
"'check warnings' expired after ".check_timeout().
3666
# Unknown process returned, most likley a crash, abort everything
3668
"The server $proc crashed while running 'check warnings'";
3672
# Kill any check processes still running
3673
map($_->kill(), values(%started));
3675
$timeout_proc->kill();
3680
mtr_error("INTERNAL_ERROR: check_warnings");
3685
# Loop through our list of processes and look for and entry
3686
# with the provided pid, if found check for the file indicating
3687
# expected crash and restart it.
3689
sub check_expected_crash_and_restart {
3692
foreach my $mysqld ( mysqlds() )
3694
next unless ( $mysqld->{proc} eq $proc );
3696
# Check if crash expected by looking at the .expect file
3698
my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect";
3699
if ( -f $expect_file )
3701
mtr_verbose("Crash was expected, file '$expect_file' exists");
3705
# If last line in expect file starts with "wait"
3706
# sleep a little and try again, thus allowing the
3707
# test script to control when the server should start
3709
my $last_line= mtr_lastlinesfromfile($expect_file, 1);
3710
if ($last_line =~ /^wait/ )
3712
mtr_verbose("Test says wait before restart");
3713
mtr_milli_sleep(100);
3717
unlink($expect_file);
3719
# Start server with same settings as last time
3720
mysqld_start($mysqld, $mysqld->{'started_opts'});
3729
# Not an expected crash
3734
# Remove all files and subdirectories of a directory
3737
mtr_verbose("clean_dir: $dir");
3747
mtr_verbose("rmdir: '$_'");
3748
rmdir($_) or mtr_warning("rmdir($_) failed: $!");
3752
mtr_verbose("unlink: '$_'");
3753
unlink($_) or mtr_warning("unlink($_) failed: $!");
3763
mtr_verbose("Cleaning datadirs...");
3765
if (started(all_servers()) != 0){
3766
mtr_error("Trying to clean datadir before all servers stopped");
3769
foreach my $cluster ( clusters() )
3771
my $cluster_dir= "$opt_vardir/".$cluster->{name};
3772
mtr_verbose(" - removing '$cluster_dir'");
3773
rmtree($cluster_dir);
3777
foreach my $mysqld ( mysqlds() )
3779
my $mysqld_dir= dirname($mysqld->value('datadir'));
3780
if (-d $mysqld_dir ) {
3781
mtr_verbose(" - removing '$mysqld_dir'");
3782
rmtree($mysqld_dir);
3786
# Remove all files in tmp and var/tmp
3787
clean_dir("$opt_vardir/tmp");
3788
if ($opt_tmpdir ne "$opt_vardir/tmp"){
3789
clean_dir($opt_tmpdir);
3795
# Save datadir before it's removed
3797
sub save_datadir_after_failure($$) {
3798
my ($dir, $savedir)= @_;
3800
mtr_report(" - saving '$dir'");
3801
my $dir_name= basename($dir);
3802
rename("$dir", "$savedir/$dir_name");
3806
sub remove_ndbfs_from_ndbd_datadir {
3807
my ($ndbd_datadir)= @_;
3808
# Remove the ndb_*_fs directory from ndbd.X/ dir
3809
foreach my $ndbfs_dir ( glob("$ndbd_datadir/ndb_*_fs") )
3811
next unless -d $ndbfs_dir; # Skip if not a directory
3817
sub after_failure ($) {
3820
mtr_report("Saving datadirs...");
3822
my $save_dir= "$opt_vardir/log/";
3823
$save_dir.= $tinfo->{name};
3824
# Add combination name if any
3825
$save_dir.= "-$tinfo->{combination}"
3826
if defined $tinfo->{combination};
3828
# Save savedir path for server
3829
$tinfo->{savedir}= $save_dir;
3831
mkpath($save_dir) if ! -d $save_dir;
3833
# Save the used my.cnf file
3834
copy($path_config_file, $save_dir);
3837
copytree("$opt_vardir/tmp/", "$save_dir/tmp/");
3840
foreach my $cluster ( clusters() ) {
3841
my $cluster_dir= "$opt_vardir/".$cluster->{name};
3843
# Remove the fileystem of each ndbd
3844
foreach my $ndbd ( in_cluster($cluster, ndbds()) )
3846
my $ndbd_datadir= $ndbd->value("DataDir");
3847
remove_ndbfs_from_ndbd_datadir($ndbd_datadir);
3850
save_datadir_after_failure($cluster_dir, $save_dir);
3854
foreach my $mysqld ( mysqlds() ) {
3855
my $data_dir= $mysqld->value('datadir');
3856
save_datadir_after_failure(dirname($data_dir), $save_dir);
3772
3862
sub report_failure_and_restart ($) {
3773
3863
my $tinfo= shift;
3775
mtr_report_test_failed($tinfo);
3779
# Stop all servers that are known to be running
3782
# Restore the snapshot of the installed test db
3783
restore_installed_db($tinfo->{'name'});
3784
mtr_report("Resuming Tests\n");
3788
my $test_mode= join(" ", @::glob_test_mode) || "default";
3789
mtr_report("Aborting: $tinfo->{'name'} failed in $test_mode mode. ");
3790
mtr_report("To continue, re-run with '--force'.");
3791
if ( ! $glob_debugger and
3793
! $glob_use_embedded_server )
3802
sub run_master_init_script ($) {
3804
my $init_script= $tinfo->{'master_sh'};
3806
# Run master initialization shell script if one exists
3809
my $ret= mtr_run("/bin/sh", [$init_script], "", "", "", "");
3812
# FIXME rewrite those scripts to return 0 if successful
3813
# mtr_warning("$init_script exited with code $ret");
3819
##############################################################################
3821
# Start and stop servers
3823
##############################################################################
3826
sub do_before_start_master ($) {
3829
my $tname= $tinfo->{'name'};
3831
# FIXME what about second master.....
3833
# Don't delete anything if starting dirty
3834
return if ($opt_start_dirty);
3836
foreach my $bin ( glob("$opt_vardir/log/master*-bin*") )
3841
# FIXME only remove the ones that are tied to this master
3842
# Remove old master.info and relay-log.info files
3843
unlink("$master->[0]->{'path_myddir'}/master.info");
3844
unlink("$master->[0]->{'path_myddir'}/relay-log.info");
3845
unlink("$master->[1]->{'path_myddir'}/master.info");
3846
unlink("$master->[1]->{'path_myddir'}/relay-log.info");
3848
run_master_init_script($tinfo);
3852
sub do_before_start_slave ($) {
3855
my $tname= $tinfo->{'name'};
3856
my $init_script= $tinfo->{'master_sh'};
3858
# Don't delete anything if starting dirty
3859
return if ($opt_start_dirty);
3861
foreach my $bin ( glob("$opt_vardir/log/slave*-bin*") )
3866
unlink("$slave->[0]->{'path_myddir'}/master.info");
3867
unlink("$slave->[0]->{'path_myddir'}/relay-log.info");
3869
# Run slave initialization shell script if one exists
3872
my $ret= mtr_run("/bin/sh", [$init_script], "", "", "", "");
3875
# FIXME rewrite those scripts to return 0 if successful
3876
# mtr_warning("$init_script exited with code $ret");
3880
foreach my $bin ( glob("$slave->[0]->{'path_myddir'}/log.*") )
3887
sub mysqld_arguments ($$$$) {
3867
$tinfo->{'result'}= 'MTR_RES_FAILED';
3869
my $test_failures= $tinfo->{'failures'} || 0;
3870
$tinfo->{'failures'}= $test_failures + 1;
3873
if ( $tinfo->{comment} )
3875
# The test failure has been detected by mysql-test-run.pl
3876
# when starting the servers or due to other error, the reason for
3877
# failing the test is saved in "comment"
3881
if ( !defined $tinfo->{logfile} )
3883
my $logfile= $path_current_testlog;
3884
if ( defined $logfile )
3888
# Test failure was detected by test tool and its report
3889
# about what failed has been saved to file. Save the report
3891
$tinfo->{logfile}= mtr_fromfile($logfile);
3895
# The test tool report didn't exist, display an
3897
$tinfo->{logfile}= "Could not open test tool report '$logfile'";
3902
after_failure($tinfo);
3904
mtr_report_test($tinfo);
3912
return 0 unless defined $script;
3914
mtr_verbose("Running '$script'");
3915
my $ret= system("/bin/sh $script") >> 8;
3921
my $mysqld= shift or die "usage: mysqld_stop(<mysqld>)";
3924
mtr_init_args(\$args);
3926
mtr_add_arg($args, "--no-defaults");
3927
mtr_add_arg($args, "--user=%s", $opt_user);
3928
mtr_add_arg($args, "--password=");
3929
mtr_add_arg($args, "--port=%d", $mysqld->value('port'));
3930
mtr_add_arg($args, "--host=%s", $mysqld->value('#host'));
3931
mtr_add_arg($args, "--connect_timeout=20");
3932
mtr_add_arg($args, "--protocol=tcp");
3934
mtr_add_arg($args, "shutdown");
3936
My::SafeProcess->run
3938
name => "mysqladmin shutdown ".$mysqld->name(),
3939
path => $exe_mysqladmin,
3941
error => "/dev/null",
3947
sub mysqld_arguments ($$$) {
3888
3948
my $args= shift;
3889
3949
my $mysqld= shift;
3890
my $extra_opt= shift;
3891
my $slave_master_info= shift;
3893
my $idx= $mysqld->{'idx'};
3894
my $sidx= ""; # Index as string, 0 is empty string
3900
my $prefix= ""; # If mysqltest server arg
3901
if ( $glob_use_embedded_server )
3903
$prefix= "--server-arg=";
3906
mtr_add_arg($args, "%s--no-defaults", $prefix);
3908
mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir);
3909
mtr_add_arg($args, "%s--character-sets-dir=%s", $prefix, $path_charsetsdir);
3911
if ( $mysql_version_id >= 50036)
3913
# By default, prevent the started mysqld to access files outside of vardir
3914
mtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir);
3917
if ( $mysql_version_id >= 50000 )
3919
mtr_add_arg($args, "%s--log-bin-trust-function-creators", $prefix);
3922
mtr_add_arg($args, "%s--default-character-set=latin1", $prefix);
3923
mtr_add_arg($args, "%s--language=%s", $prefix, $path_language);
3924
mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
3926
# Increase default connect_timeout to avoid intermittent
3927
# disconnects when test servers are put under load
3929
mtr_add_arg($args, "%s--connect-timeout=60", $prefix);
3950
my $extra_opts= shift;
3952
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
3932
3954
# When mysqld is run by a root user(euid is 0), it will fail
3933
3955
# to start unless we specify what user to run as, see BUG#30630
3935
if (!$glob_win32 and $euid == 0 and
3936
grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt) == 0) {
3937
mtr_add_arg($args, "%s--user=root", $prefix);
3957
if (!IS_WINDOWS and $euid == 0 and
3958
(grep(/^--user/, @$extra_opts)) == 0) {
3959
mtr_add_arg($args, "--user=root");
3940
3962
if ( $opt_valgrind_mysqld )
3942
mtr_add_arg($args, "%s--skip-safemalloc", $prefix);
3964
mtr_add_arg($args, "--skip-safemalloc");
3944
3966
if ( $mysql_version_id < 50100 )
3946
mtr_add_arg($args, "%s--skip-bdb", $prefix);
3968
mtr_add_arg($args, "--skip-bdb");
3950
mtr_add_arg($args, "%s--pid-file=%s", $prefix,
3951
$mysqld->{'path_pid'});
3953
mtr_add_arg($args, "%s--port=%d", $prefix,
3956
mtr_add_arg($args, "%s--socket=%s", $prefix,
3957
$mysqld->{'path_sock'});
3959
mtr_add_arg($args, "%s--datadir=%s", $prefix,
3960
$mysqld->{'path_myddir'});
3963
3972
if ( $mysql_version_id >= 50106 )
3965
# Turn on logging to bothe tables and file
3966
mtr_add_arg($args, "%s--log-output=table,file", $prefix);
3969
my $log_base_path= "$opt_vardir/log/$mysqld->{'type'}$sidx";
3970
mtr_add_arg($args, "%s--log=%s.log", $prefix, $log_base_path);
3972
"%s--log-slow-queries=%s-slow.log", $prefix, $log_base_path);
3974
# Check if "extra_opt" contains --skip-log-bin
3975
my $skip_binlog= grep(/^--skip-log-bin/, @$extra_opt, @opt_extra_mysqld_opt);
3976
if ( $mysqld->{'type'} eq 'master' )
3978
if (! ($opt_skip_master_binlog || $skip_binlog) )
3980
mtr_add_arg($args, "%s--log-bin=%s/log/master-bin%s", $prefix,
3981
$opt_vardir, $sidx);
3984
mtr_add_arg($args, "%s--server-id=%d", $prefix,
3985
$idx > 0 ? $idx + 101 : 1);
3987
mtr_add_arg($args, "%s--loose-innodb_data_file_path=ibdata1:10M:autoextend",
3990
mtr_add_arg($args, "%s--local-infile", $prefix);
3992
if ( $idx > 0 or !$use_innodb)
3994
mtr_add_arg($args, "%s--loose-skip-innodb", $prefix);
3997
my $cluster= $clusters->[$mysqld->{'cluster'}];
3998
if ( $cluster->{'pid'} || # Cluster is started
3999
$cluster->{'use_running'} ) # Using running cluster
4001
mtr_add_arg($args, "%s--ndbcluster", $prefix);
4002
mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
4003
$cluster->{'connect_string'});
4004
if ( $mysql_version_id >= 50100 )
4006
mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
4011
mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
4016
mtr_error("unknown mysqld type")
4017
unless $mysqld->{'type'} eq 'slave';
4019
mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
4020
if (! ( $opt_skip_slave_binlog || $skip_binlog ))
4022
mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
4023
$opt_vardir, $sidx); # FIXME use own dir for binlogs
4024
mtr_add_arg($args, "%s--log-slave-updates", $prefix);
4027
mtr_add_arg($args, "%s--master-retry-count=10", $prefix);
4029
mtr_add_arg($args, "%s--relay-log=%s/log/slave%s-relay-bin", $prefix,
4030
$opt_vardir, $sidx);
4031
mtr_add_arg($args, "%s--report-host=127.0.0.1", $prefix);
4032
mtr_add_arg($args, "%s--report-port=%d", $prefix,
4034
mtr_add_arg($args, "%s--report-user=root", $prefix);
4035
mtr_add_arg($args, "%s--loose-skip-innodb", $prefix);
4036
mtr_add_arg($args, "%s--skip-slave-start", $prefix);
4038
# Directory where slaves find the dumps generated by "load data"
4039
# on the server. The path need to have constant length otherwise
4040
# test results will vary, thus a relative path is used.
4041
my $slave_load_path= "../tmp";
4042
mtr_add_arg($args, "%s--slave-load-tmpdir=%s", $prefix,
4044
mtr_add_arg($args, "%s--set-variable=slave_net_timeout=120", $prefix);
4046
if ( @$slave_master_info )
4048
foreach my $arg ( @$slave_master_info )
4050
mtr_add_arg($args, "%s%s", $prefix, $arg);
4055
if ($mysql_version_id < 50200)
4057
mtr_add_arg($args, "%s--master-user=root", $prefix);
4058
mtr_add_arg($args, "%s--master-connect-retry=1", $prefix);
4059
mtr_add_arg($args, "%s--master-host=127.0.0.1", $prefix);
4060
mtr_add_arg($args, "%s--master-password=", $prefix);
4061
mtr_add_arg($args, "%s--master-port=%d", $prefix,
4062
$master->[0]->{'port'}); # First master
4064
my $slave_server_id= 2 + $idx;
4065
my $slave_rpl_rank= $slave_server_id;
4066
mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
4067
mtr_add_arg($args, "%s--rpl-recovery-rank=%d", $prefix, $slave_rpl_rank);
4070
my $cluster= $clusters->[$mysqld->{'cluster'}];
4071
if ( $cluster->{'pid'} || # Slave cluster is started
4072
$cluster->{'use_running'} ) # Using running slave cluster
4074
mtr_add_arg($args, "%s--ndbcluster", $prefix);
4075
mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
4076
$cluster->{'connect_string'});
4078
if ( $mysql_version_id >= 50100 )
4080
mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
4085
mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
4092
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/%s%s.trace",
4093
$prefix, $path_vardir_trace, $mysqld->{'type'}, $sidx);
4096
mtr_add_arg($args, "%s--key_buffer_size=1M", $prefix);
4097
mtr_add_arg($args, "%s--sort_buffer=256K", $prefix);
4098
mtr_add_arg($args, "%s--max_heap_table_size=1M", $prefix);
4100
if ( $opt_ssl_supported )
4102
mtr_add_arg($args, "%s--ssl-ca=%s/std_data/cacert.pem", $prefix,
4103
$glob_mysql_test_dir);
4104
mtr_add_arg($args, "%s--ssl-cert=%s/std_data/server-cert.pem", $prefix,
4105
$glob_mysql_test_dir);
4106
mtr_add_arg($args, "%s--ssl-key=%s/std_data/server-key.pem", $prefix,
4107
$glob_mysql_test_dir);
4110
if ( $opt_warnings )
4112
mtr_add_arg($args, "%s--log-warnings", $prefix);
4115
# Indicate to "mysqld" it will be debugged in debugger
3974
# Turn on logging to both tables and file
3975
mtr_add_arg($args, "--log-output=table,file");
3978
# Check if "extra_opt" contains skip-log-bin
3979
my $skip_binlog= grep(/^(--|--loose-)skip-log-bin/, @$extra_opts);
3981
# Indicate to mysqld it will be debugged in debugger
4116
3982
if ( $glob_debugger )
4118
mtr_add_arg($args, "%s--gdb", $prefix);
3984
mtr_add_arg($args, "--gdb");
4121
3987
my $found_skip_core= 0;
4122
foreach my $arg ( @opt_extra_mysqld_opt, @$extra_opt )
3988
foreach my $arg ( @$extra_opts )
4124
3990
# Allow --skip-core-file to be set in <testname>-[master|slave].opt file
4125
3991
if ($arg eq "--skip-core-file")
4227
4081
$wait_for_pid_file= 0;
4230
# Remove the pidfile
4231
unlink($mysqld->{'path_pid'});
4084
# Remove the old pidfile if any
4085
unlink($mysqld->value('pid-file'));
4087
my $output= $mysqld->value('#log-error');
4088
if ( $opt_valgrind and $opt_debug )
4090
# When both --valgrind and --debug is selected, send
4091
# all output to the trace file, making it possible to
4092
# see the exact location where valgrind complains
4093
$output= "$opt_vardir/log/".$mysqld->name().".trace";
4233
4096
if ( defined $exe )
4235
$pid= mtr_spawn($exe, $args, "",
4236
$mysqld->{'path_myerr'},
4237
$mysqld->{'path_myerr'},
4239
{ append_log_file => 1 });
4098
$mysqld->{'proc'}= My::SafeProcess->new
4100
name => $mysqld->name(),
4106
verbose => $opt_verbose,
4107
nocore => $opt_skip_core,
4109
shutdown => sub { mysqld_stop($mysqld) },
4111
mtr_verbose("Started $mysqld->{proc}");
4243
if ( $wait_for_pid_file && !sleep_until_file_created($mysqld->{'path_pid'},
4244
$mysqld->{'start_timeout'},
4114
if ( $wait_for_pid_file &&
4115
!sleep_until_file_created($mysqld->value('pid-file'),
4248
mtr_error("Failed to start mysqld $mysqld->{'type'}");
4119
mtr_error("Failed to start mysqld $mysqld->name()");
4252
# Remember pid of the started process
4253
$mysqld->{'pid'}= $pid;
4255
4122
# Remember options used when starting
4256
$mysqld->{'start_opts'}= $extra_opt;
4257
$mysqld->{'start_slave_master_info'}= $slave_master_info;
4123
$mysqld->{'started_opts'}= $extra_opts;
4259
mtr_verbose("mysqld pid: $pid");
4264
4129
sub stop_all_servers () {
4266
mtr_report("Stopping All Servers");
4268
if ( ! $opt_skip_im )
4270
mtr_report("Shutting-down Instance Manager");
4271
unless (mtr_im_stop($instance_manager, "stop_all_servers"))
4273
mtr_error("Failed to stop Instance Manager.")
4277
my %admin_pids; # hash of admin processes that requests shutdown
4278
my @kill_pids; # list of processes to shutdown/kill
4281
# Start shutdown of all started masters
4282
foreach my $mysqld (@{$slave}, @{$master})
4284
if ( $mysqld->{'pid'} )
4286
$pid= mtr_mysqladmin_start($mysqld, "shutdown", 70);
4287
$admin_pids{$pid}= 1;
4290
pid => $mysqld->{'pid'},
4291
real_pid => $mysqld->{'real_pid'},
4292
pidfile => $mysqld->{'path_pid'},
4293
sockfile => $mysqld->{'path_sock'},
4294
port => $mysqld->{'port'},
4295
errfile => $mysqld->{'path_myerr'},
4298
$mysqld->{'pid'}= 0; # Assume we are done with it
4302
# Start shutdown of clusters
4303
foreach my $cluster (@{$clusters})
4305
if ( $cluster->{'pid'} )
4307
$pid= mtr_ndbmgm_start($cluster, "shutdown");
4308
$admin_pids{$pid}= 1;
4311
pid => $cluster->{'pid'},
4312
pidfile => $cluster->{'path_pid'}
4315
$cluster->{'pid'}= 0; # Assume we are done with it
4317
foreach my $ndbd (@{$cluster->{'ndbds'}})
4319
if ( $ndbd->{'pid'} )
4322
pid => $ndbd->{'pid'},
4323
pidfile => $ndbd->{'path_pid'},
4331
# Wait blocking until all shutdown processes has completed
4332
mtr_wait_blocking(\%admin_pids);
4334
# Make sure that process has shutdown else try to kill them
4335
mtr_check_stop_servers(\@kill_pids);
4337
foreach my $mysqld (@{$master}, @{$slave})
4339
rm_ndbcluster_tables($mysqld->{'path_myddir'});
4344
sub run_testcase_need_master_restart($)
4348
# We try to find out if we are to restart the master(s)
4349
my $do_restart= 0; # Assumes we don't have to
4351
if ( $glob_use_embedded_server )
4353
mtr_verbose("Never start or restart for embedded server");
4356
elsif ( $tinfo->{'master_sh'} )
4358
$do_restart= 1; # Always restart if script to run
4359
mtr_verbose("Restart master: Always restart if script to run");
4361
if ( $tinfo->{'force_restart'} )
4363
$do_restart= 1; # Always restart if --force-restart in -opt file
4364
mtr_verbose("Restart master: Restart forced with --force-restart");
4366
elsif ( ! $opt_skip_ndbcluster and
4367
!$tinfo->{'ndb_test'} and
4368
$clusters->[0]->{'pid'} != 0 )
4370
$do_restart= 1; # Restart without cluster
4371
mtr_verbose("Restart master: Test does not need cluster");
4373
elsif ( ! $opt_skip_ndbcluster and
4374
$tinfo->{'ndb_test'} and
4375
$clusters->[0]->{'pid'} == 0 )
4377
$do_restart= 1; # Restart with cluster
4378
mtr_verbose("Restart master: Test need cluster");
4380
elsif( $tinfo->{'component_id'} eq 'im' )
4383
mtr_verbose("Restart master: Always restart for im tests");
4385
elsif ( $master->[0]->{'running_master_options'} and
4386
$master->[0]->{'running_master_options'}->{'timezone'} ne
4387
$tinfo->{'timezone'})
4390
mtr_verbose("Restart master: Different timezone");
4392
# Check that running master was started with same options
4393
# as the current test requires
4394
elsif (! mtr_same_opts($master->[0]->{'start_opts'},
4395
$tinfo->{'master_opt'}) )
4398
mtr_verbose("Restart master: running with different options '" .
4399
join(" ", @{$tinfo->{'master_opt'}}) . "' != '" .
4400
join(" ", @{$master->[0]->{'start_opts'}}) . "'" );
4402
elsif( ! $master->[0]->{'pid'} )
4407
mtr_verbose("No restart: using extern master");
4412
mtr_verbose("Restart master: master is not started");
4418
sub run_testcase_need_slave_restart($)
4422
# We try to find out if we are to restart the slaves
4423
my $do_slave_restart= 0; # Assumes we don't have to
4425
if ( $glob_use_embedded_server )
4427
mtr_verbose("Never start or restart for embedded server");
4428
return $do_slave_restart;
4430
elsif ( $max_slave_num == 0)
4432
mtr_verbose("Skip slave restart: No testcase use slaves");
4437
# Check if any slave is currently started
4438
my $any_slave_started= 0;
4439
foreach my $mysqld (@{$slave})
4441
if ( $mysqld->{'pid'} )
4443
$any_slave_started= 1;
4448
if ($any_slave_started)
4450
mtr_verbose("Restart slave: Slave is started, always restart");
4451
$do_slave_restart= 1;
4453
elsif ( $tinfo->{'slave_num'} )
4455
mtr_verbose("Restart slave: Test need slave");
4456
$do_slave_restart= 1;
4460
return $do_slave_restart;
4464
# ----------------------------------------------------------------------
4465
# If not using a running servers we may need to stop and restart.
4466
# We restart in the case we have initiation scripts, server options
4467
# etc to run. But we also restart again after the test first restart
4468
# and test is run, to get back to normal server settings.
4470
# To make the code a bit more clean, we actually only stop servers
4471
# here, and mark this to be done. Then a generic "start" part will
4472
# start up the needed servers again.
4473
# ----------------------------------------------------------------------
4475
sub run_testcase_stop_servers($$$) {
4476
my ($tinfo, $do_restart, $do_slave_restart)= @_;
4478
my %admin_pids; # hash of admin processes that requests shutdown
4479
my @kill_pids; # list of processes to shutdown/kill
4131
mtr_verbose("Stopping all servers...");
4133
# Kill all started servers
4134
My::SafeProcess::shutdown(0, # shutdown timeout 0 => kill
4135
started(all_servers()));
4138
foreach my $server ( all_servers() )
4140
my $pid_file= $server->if_exist('pid-file');
4141
unlink($pid_file) if defined $pid_file;
4144
# Mark servers as stopped
4145
map($_->{proc}= undef, all_servers());
4150
# Find out if server should be restarted for this test
4151
sub server_need_restart {
4152
my ($tinfo, $server)= @_;
4154
if ( using_extern() )
4156
mtr_verbose_restart($server, "no restart for --extern server");
4160
if ( $tinfo->{'force_restart'} ) {
4161
mtr_verbose_restart($server, "forced in .opt file");
4165
if ( $tinfo->{template_path} ne $current_config_name)
4167
mtr_verbose_restart($server, "using different config file");
4171
if ( $tinfo->{'master_sh'} || $tinfo->{'slave_sh'} )
4173
mtr_verbose_restart($server, "sh script to run");
4177
if ( ! started($server) )
4179
mtr_verbose_restart($server, "not started");
4183
my $started_tinfo= $server->{'started_tinfo'};
4184
if ( defined $started_tinfo )
4187
# Check if timezone of test that server was started
4188
# with differs from timezone of next test
4189
if ( timezone($started_tinfo) ne timezone($tinfo) )
4191
mtr_verbose_restart($server, "different timezone");
4196
# Temporary re-enable the "always restart slave" hack
4197
# this should be removed asap, but will require that each rpl
4198
# testcase cleanup better after itself - ie. stop and reset
4200
# Use the "#!use-slave-opt" marker to detect that this is a "slave"
4202
if ( $server->option("#!use-slave-opt") ){
4203
mtr_verbose_restart($server, "Always restart slave(s)");
4207
my $is_mysqld= grep ($server eq $_, mysqlds());
4211
# Check that running process was started with same options
4212
# as the current test requires
4213
my $extra_opts= get_extra_opts($server, $tinfo);
4214
my $started_opts= $server->{'started_opts'};
4216
if (!My::Options::same($started_opts, $extra_opts) )
4218
my $use_dynamic_option_switch= 0;
4219
if (!$use_dynamic_option_switch)
4221
mtr_verbose_restart($server, "running with different options '" .
4222
join(" ", @{$extra_opts}) . "' != '" .
4223
join(" ", @{$started_opts}) . "'" );
4227
mtr_verbose(My::Options::toStr("started_opts", @$started_opts));
4228
mtr_verbose(My::Options::toStr("extra_opts", @$extra_opts));
4230
# Get diff and check if dynamic switch is possible
4231
my @diff_opts= My::Options::diff($started_opts, $extra_opts);
4232
mtr_verbose(My::Options::toStr("diff_opts", @diff_opts));
4234
my $query= My::Options::toSQL(@diff_opts);
4235
mtr_verbose("Attempting dynamic switch '$query'");
4236
if (run_query($tinfo, $server, $query)){
4237
mtr_verbose("Restart: running with different options '" .
4238
join(" ", @{$extra_opts}) . "' != '" .
4239
join(" ", @{$started_opts}) . "'" );
4243
# Remember the dynamically set options
4244
$server->{'started_opts'}= $extra_opts;
4248
# Default, no restart
4253
sub servers_need_restart($) {
4255
return grep { server_need_restart($tinfo, $_); } all_servers();
4261
# Return list of specific servers
4262
# - there is no servers in an empty config
4264
sub _like { return $config ? $config->like($_[0]) : (); }
4265
sub mysqlds { return _like('mysqld.'); }
4266
sub ndbds { return _like('cluster_config.ndbd.');}
4267
sub ndb_mgmds { return _like('cluster_config.ndb_mgmd.'); }
4268
sub clusters { return _like('mysql_cluster.'); }
4269
sub all_servers { return ( mysqlds(), ndb_mgmds(), ndbds() ); }
4273
# Filter a list of servers and return only those that are part
4274
# of the specified cluster
4277
my ($cluster)= shift;
4278
# Return only processes for a specific cluster
4279
return grep { $_->suffix() eq $cluster->suffix() } @_;
4285
# Filter a list of servers and return the SafeProcess
4286
# for only those that are started or stopped
4288
sub started { return grep(defined $_, map($_->{proc}, @_)); }
4289
sub stopped { return grep(!defined $_, map($_->{proc}, @_)); }
4295
if ( ! defined $ENV{$string} )
4297
mtr_error(".opt file references '$string' which is not set");
4300
return $ENV{$string};
4304
sub get_extra_opts {
4305
my ($mysqld, $tinfo)= @_;
4308
$mysqld->option("#!use-slave-opt") ?
4309
$tinfo->{slave_opt} : $tinfo->{master_opt};
4311
# Expand environment variables
4312
foreach my $opt ( @$opts )
4314
$opt =~ s/\$\{(\w+)\}/envsubst($1)/ge;
4315
$opt =~ s/\$(\w+)/envsubst($1)/ge;
4321
sub stop_servers($$) {
4322
my ($tinfo, @servers)= @_;
4481
4324
# Remember if we restarted for this test case (count restarts)
4482
$tinfo->{'restarted'}= $do_restart;
4486
delete $master->[0]->{'running_master_options'}; # Forget history
4488
# Start shutdown of all started masters
4489
foreach my $mysqld (@{$master})
4491
if ( $mysqld->{'pid'} )
4493
$pid= mtr_mysqladmin_start($mysqld, "shutdown", 20);
4495
$admin_pids{$pid}= 1;
4498
pid => $mysqld->{'pid'},
4499
real_pid => $mysqld->{'real_pid'},
4500
pidfile => $mysqld->{'path_pid'},
4501
sockfile => $mysqld->{'path_sock'},
4502
port => $mysqld->{'port'},
4503
errfile => $mysqld->{'path_myerr'},
4506
$mysqld->{'pid'}= 0; # Assume we are done with it
4510
# Start shutdown of master cluster
4511
my $cluster= $clusters->[0];
4512
if ( $cluster->{'pid'} )
4514
$pid= mtr_ndbmgm_start($cluster, "shutdown");
4515
$admin_pids{$pid}= 1;
4518
pid => $cluster->{'pid'},
4519
pidfile => $cluster->{'path_pid'}
4522
$cluster->{'pid'}= 0; # Assume we are done with it
4524
foreach my $ndbd (@{$cluster->{'ndbds'}})
4527
pid => $ndbd->{'pid'},
4528
pidfile => $ndbd->{'path_pid'},
4530
$ndbd->{'pid'}= 0; # Assume we are done with it
4535
if ( $do_restart || $do_slave_restart )
4538
delete $slave->[0]->{'running_slave_options'}; # Forget history
4540
# Start shutdown of all started slaves
4541
foreach my $mysqld (@{$slave})
4543
if ( $mysqld->{'pid'} )
4545
$pid= mtr_mysqladmin_start($mysqld, "shutdown", 20);
4547
$admin_pids{$pid}= 1;
4550
pid => $mysqld->{'pid'},
4551
real_pid => $mysqld->{'real_pid'},
4552
pidfile => $mysqld->{'path_pid'},
4553
sockfile => $mysqld->{'path_sock'},
4554
port => $mysqld->{'port'},
4555
errfile => $mysqld->{'path_myerr'},
4559
$mysqld->{'pid'}= 0; # Assume we are done with it
4563
# Start shutdown of slave cluster
4564
my $cluster= $clusters->[1];
4565
if ( $cluster->{'pid'} )
4567
$pid= mtr_ndbmgm_start($cluster, "shutdown");
4569
$admin_pids{$pid}= 1;
4572
pid => $cluster->{'pid'},
4573
pidfile => $cluster->{'path_pid'}
4576
$cluster->{'pid'}= 0; # Assume we are done with it
4578
foreach my $ndbd (@{$cluster->{'ndbds'}} )
4581
pid => $ndbd->{'pid'},
4582
pidfile => $ndbd->{'path_pid'},
4584
$ndbd->{'pid'}= 0; # Assume we are done with it
4589
# ----------------------------------------------------------------------
4590
# Shutdown has now been started and lists for the shutdown processes
4591
# and the processes to be killed has been created
4592
# ----------------------------------------------------------------------
4594
# Wait blocking until all shutdown processes has completed
4595
mtr_wait_blocking(\%admin_pids);
4598
# Make sure that process has shutdown else try to kill them
4599
mtr_check_stop_servers(\@kill_pids);
4601
foreach my $mysqld (@{$master}, @{$slave})
4603
if ( ! $mysqld->{'pid'} )
4605
# Remove ndbcluster tables if server is stopped
4606
rm_ndbcluster_tables($mysqld->{'path_myddir'});
4325
$tinfo->{'restarted'}= 1;
4327
if ( join('|', @servers) eq join('|', all_servers()) )
4329
# All servers are going down, use some kind of order to
4330
# avoid too many warnings in the log files
4332
mtr_report("Restarting all servers");
4335
My::SafeProcess::shutdown( $opt_shutdown_timeout, started(mysqlds()) );
4338
My::SafeProcess::shutdown( $opt_shutdown_timeout,
4339
started(ndbds(), ndb_mgmds()) );
4343
mtr_report("Restarting ", started(@servers));
4345
# Stop only some servers
4346
My::SafeProcess::shutdown( $opt_shutdown_timeout,
4347
started(@servers) );
4350
foreach my $server (@servers)
4352
# Mark server as stopped
4353
$server->{proc}= undef;
4356
delete $server->{'started_tinfo'};
4357
delete $server->{'started_opts'};
4358
delete $server->{'started_cnf'};
4613
# run_testcase_start_servers
4615
# Start the servers needed by this test case
4366
# Start servers not already started
4619
4370
# 1 Start failed
4622
sub run_testcase_start_servers($) {
4624
my $tname= $tinfo->{'name'};
4626
if ( $tinfo->{'component_id'} eq 'mysqld' )
4628
if ( ! $opt_skip_ndbcluster and
4629
!$clusters->[0]->{'pid'} and
4630
$tinfo->{'ndb_test'} )
4632
# Test need cluster, cluster is not started, start it
4633
ndbcluster_start($clusters->[0], "");
4636
if ( !$master->[0]->{'pid'} )
4638
# Master mysqld is not started
4639
do_before_start_master($tinfo);
4641
mysqld_start($master->[0],$tinfo->{'master_opt'},[]);
4645
if ( $clusters->[0]->{'pid'} || $clusters->[0]->{'use_running'}
4646
and ! $master->[1]->{'pid'} and
4647
$tinfo->{'master_num'} > 1 )
4649
# Test needs cluster, start an extra mysqld connected to cluster
4651
if ( $mysql_version_id >= 50100 )
4653
# First wait for first mysql server to have created ndb system
4654
# tables ok FIXME This is a workaround so that only one mysqld
4656
if ( ! sleep_until_file_created(
4657
"$master->[0]->{'path_myddir'}/mysql/ndb_apply_status.ndb",
4658
$master->[0]->{'start_timeout'},
4659
$master->[0]->{'pid'}))
4662
$tinfo->{'comment'}= "Failed to create 'mysql/ndb_apply_status' table";
4666
mysqld_start($master->[1],$tinfo->{'master_opt'},[]);
4669
# Save this test case information, so next can examine it
4670
$master->[0]->{'running_master_options'}= $tinfo;
4672
elsif ( ! $opt_skip_im and $tinfo->{'component_id'} eq 'im' )
4674
# We have to create defaults file every time, in order to ensure that it
4675
# will be the same for each test. The problem is that test can change the
4676
# file (by SET/UNSET commands), so w/o recreating the file, execution of
4677
# one test can affect the other.
4679
im_create_defaults_file($instance_manager);
4681
if ( ! mtr_im_start($instance_manager, $tinfo->{im_opts}) )
4683
$tinfo->{'comment'}= "Failed to start Instance Manager. ";
4688
# ----------------------------------------------------------------------
4689
# Start slaves - if needed
4690
# ----------------------------------------------------------------------
4691
if ( $tinfo->{'slave_num'} )
4693
restore_slave_databases($tinfo->{'slave_num'});
4695
do_before_start_slave($tinfo);
4697
if ( ! $opt_skip_ndbcluster_slave and
4698
!$clusters->[1]->{'pid'} and
4699
$tinfo->{'ndb_test'} )
4701
# Test need slave cluster, cluster is not started, start it
4702
ndbcluster_start($clusters->[1], "");
4705
for ( my $idx= 0; $idx < $tinfo->{'slave_num'}; $idx++ )
4707
if ( ! $slave->[$idx]->{'pid'} )
4709
mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
4710
$tinfo->{'slave_mi'});
4715
# Save this test case information, so next can examine it
4716
$slave->[0]->{'running_slave_options'}= $tinfo;
4372
sub start_servers($) {
4376
foreach my $cluster ( clusters() )
4378
ndbcluster_start($cluster);
4382
foreach my $mysqld ( mysqlds() )
4384
if ( $mysqld->{proc} )
4388
# Write start of testcase to log file
4389
mark_log($mysqld->value('#log-error'), $tinfo);
4394
my $datadir= $mysqld->value('datadir');
4395
if ($opt_start_dirty)
4397
# Don't delete anything if starting dirty
4403
my @options= ('log-bin', 'relay-log');
4404
foreach my $option_name ( @options ) {
4405
next unless $mysqld->option($option_name);
4407
my $file_name= $mysqld->value($option_name);
4409
defined $file_name and
4412
mtr_debug(" -removing '$file_name'");
4413
unlink($file_name) or die ("unable to remove file '$file_name'");
4417
mtr_verbose(" - removing '$datadir'");
4422
my $mysqld_basedir= $mysqld->value('basedir');
4423
if ( $basedir eq $mysqld_basedir )
4425
# Copy datadir from installed system db
4426
for my $path ( "$opt_vardir", "$opt_vardir/..") {
4427
my $install_db= "$path/install.db";
4428
copytree($install_db, $datadir)
4431
mtr_error("Failed to copy system db to '$datadir'")
4436
mysql_install_db($mysqld); # For versional testing
4438
mtr_error("Failed to install system db to '$datadir'")
4443
# Create the servers tmpdir
4444
my $tmpdir= $mysqld->value('tmpdir');
4445
mkpath($tmpdir) unless -d $tmpdir;
4447
# Write start of testcase to log file
4448
mark_log($mysqld->value('#log-error'), $tinfo);
4450
# Run <tname>-master.sh
4451
if ($mysqld->option('#!run-master-sh') and
4452
run_sh_script($tinfo->{master_sh}) )
4454
$tinfo->{'comment'}= "Failed to execute '$tinfo->{master_sh}'";
4458
# Run <tname>-slave.sh
4459
if ($mysqld->option('#!run-slave-sh') and
4460
run_sh_script($tinfo->{slave_sh}))
4462
$tinfo->{'comment'}= "Failed to execute '$tinfo->{slave_sh}'";
4466
if (!$opt_embedded_server)
4468
my $extra_opts= get_extra_opts($mysqld, $tinfo);
4469
mysqld_start($mysqld,$extra_opts);
4471
# Save this test case information, so next can examine it
4472
$mysqld->{'started_tinfo'}= $tinfo;
4719
4477
# Wait for clusters to start
4720
foreach my $cluster (@{$clusters})
4478
foreach my $cluster ( clusters() )
4723
next if !$cluster->{'pid'};
4725
4480
if (ndbcluster_wait_started($cluster, ""))
4727
4482
# failed to start
4728
$tinfo->{'comment'}= "Start of $cluster->{'name'} cluster failed";
4483
$tinfo->{'comment'}= "Start of '".$cluster->name()."' cluster failed";
4733
# Wait for mysqld's to start
4734
foreach my $mysqld (@{$master},@{$slave})
4488
# Wait for mysqlds to start
4489
foreach my $mysqld ( mysqlds() )
4737
next if !$mysqld->{'pid'};
4739
if (mysqld_wait_started($mysqld))
4742
$tinfo->{'comment'}=
4743
"Failed to start $mysqld->{'type'} mysqld $mysqld->{'idx'}";
4491
next if !started($mysqld);
4493
if (sleep_until_file_created($mysqld->value('pid-file'),
4495
$mysqld->{'proc'}) == 0) {
4497
"Failed to start ".$mysqld->name();
4499
my $logfile= $mysqld->value('#log-error');
4500
if ( defined $logfile and -f $logfile )
4502
$tinfo->{logfile}= mtr_fromfile($logfile);
4506
$tinfo->{logfile}= "Could not open server logfile: '$logfile'";
4751
4516
# Run include/check-testcase.test
4752
# Before a testcase, run in record mode, save result file to var
4517
# Before a testcase, run in record mode and save result file to var/tmp
4753
4518
# After testcase, run and compare with the recorded file, they should be equal!
4521
# The newly started process
4759
sub run_check_testcase ($$) {
4523
sub start_check_testcase ($$$) {
4761
4525
my $mode= shift;
4762
4526
my $mysqld= shift;
4764
my $name= "check-" . $mysqld->{'type'} . $mysqld->{'idx'};
4528
my $name= "check-".$mysqld->name();
4529
# Replace dots in name with underscore to avoid that mysqltest
4530
# misinterpret's what the filename extension is :(
4767
4534
mtr_init_args(\$args);
4769
mtr_add_arg($args, "--no-defaults");
4770
mtr_add_arg($args, "--silent");
4536
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
4537
mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
4771
4539
mtr_add_arg($args, "--skip-safemalloc");
4772
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
4773
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
4775
mtr_add_arg($args, "--socket=%s", $mysqld->{'path_sock'});
4776
mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
4777
mtr_add_arg($args, "--database=test");
4778
mtr_add_arg($args, "--user=%s", $opt_user);
4779
mtr_add_arg($args, "--password=");
4781
mtr_add_arg($args, "-R");
4782
mtr_add_arg($args, "$opt_vardir/tmp/$name.result");
4541
mtr_add_arg($args, "--result-file=%s", "$opt_vardir/tmp/$name.result");
4542
mtr_add_arg($args, "--test-file=%s", "include/check-testcase.test");
4543
mtr_add_arg($args, "--verbose");
4784
4545
if ( $mode eq "before" )
4786
4547
mtr_add_arg($args, "--record");
4789
my $res = mtr_run_test($exe_mysqltest,$args,
4790
"include/check-testcase.test", "", "", "");
4792
if ( $res == 1 and $mode eq "after")
4794
mtr_run("diff",["-u",
4795
"$opt_vardir/tmp/$name.result",
4796
"$opt_vardir/tmp/$name.reject"],
4801
mtr_error("Could not execute 'check-testcase' $mode testcase");
4806
##############################################################################
4808
# Report the features that were compiled in
4810
##############################################################################
4812
sub run_report_features () {
4815
if ( ! $glob_use_embedded_server )
4817
mysqld_start($master->[0],[],[]);
4818
if ( ! $master->[0]->{'pid'} )
4820
mtr_error("Can't start the mysqld server");
4822
mysqld_wait_started($master->[0]);
4826
$tinfo->{'name'} = 'report features';
4827
$tinfo->{'result_file'} = undef;
4828
$tinfo->{'component_id'} = 'mysqld';
4829
$tinfo->{'path'} = 'include/report-features.test';
4830
$tinfo->{'timezone'}= "GMT-3";
4831
$tinfo->{'slave_num'} = 0;
4832
$tinfo->{'master_opt'} = [];
4833
$tinfo->{'slave_opt'} = [];
4834
$tinfo->{'slave_mi'} = [];
4835
$tinfo->{'comment'} = 'report server features';
4836
run_mysqltest($tinfo);
4838
if ( ! $glob_use_embedded_server )
4549
my $errfile= "$opt_vardir/tmp/$name.err";
4550
my $proc= My::SafeProcess->new
4553
path => $exe_mysqltest,
4557
user_data => $errfile,
4558
verbose => $opt_verbose,
4561
mtr_report("Started $proc");
4845
4566
sub run_mysqltest ($) {
4567
my $proc= start_mysqltest(@_);
4572
sub start_mysqltest ($) {
4846
4573
my ($tinfo)= @_;
4847
4574
my $exe= $exe_mysqltest;
4850
4577
mtr_init_args(\$args);
4852
mtr_add_arg($args, "--no-defaults");
4579
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
4853
4580
mtr_add_arg($args, "--silent");
4854
4581
mtr_add_arg($args, "--skip-safemalloc");
4855
4582
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);