9
11
# Tool used for executing a suite of .test file
11
# See the "MySQL Test framework manual" for more information
12
# http://dev.mysql.com/doc/drizzletest/en/index.html
13
# For now, see the "MySQL Test framework manual" for more information
14
# http://dev.mysql.com/doc/mysqltest/en/index.html
15
# (as the Drizzle test environment is currently still fairly similar)
14
17
# Please keep the test framework tools identical in all versions!
96
100
# Misc global variables
97
101
our $mysql_version_id;
102
our $glob_suite_path= undef;
98
103
our $glob_mysql_test_dir= undef;
99
104
our $glob_mysql_bench_dir= undef;
100
105
our $glob_scriptname= undef;
101
106
our $glob_timers= undef;
102
107
our @glob_test_mode;
104
111
our $glob_basedir;
106
our $path_charsetsdir;
107
113
our $path_client_bindir;
109
114
our $path_timefile;
110
115
our $path_snapshot;
111
116
our $path_drizzletest_log;
115
120
our $opt_vardir; # A path but set directly on cmd line
116
121
our $path_vardir_trace; # unix formatted opt_vardir for trace files
117
122
our $opt_tmpdir; # A path but set directly on cmd line
120
128
our $default_vardir;
124
our $opt_suites_default= "main,binlog,rpl"; # Default suites to run
132
our $opt_suites_default= "main"; # Default suites to run
125
133
our $opt_script_debug= 0; # Script debugging, enable with --script-debug
126
134
our $opt_verbose= 0; # Verbose output, enable with --verbose
136
our $opt_repeat_test= 1;
128
138
our $exe_master_mysqld;
129
139
our $exe_drizzle;
130
our $exe_drizzleadmin;
131
our $exe_drizzlebinlog;
132
140
our $exe_drizzle_client_test;
133
141
our $exe_bug25714;
134
142
our $exe_drizzled;
135
our $exe_drizzlecheck;
136
143
our $exe_drizzledump;
144
our $exe_drizzleslap;
138
145
our $exe_drizzleimport;
139
146
our $exe_drizzle_fix_system_tables;
140
147
our $exe_drizzletest;
423
# Magic number -69.4 results in traditional test ports starting from 9306.
424
set_mtr_build_thread_ports(-69.4);
426
435
# If so requested, we try to avail ourselves of a unique build thread number.
427
436
if ( $ENV{'MTR_BUILD_THREAD'} ) {
428
437
if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) {
465
474
# Control what test suites or cases to run
466
475
'force' => \$opt_force,
467
'skip-master-binlog' => \$opt_skip_master_binlog,
468
'skip-slave-binlog' => \$opt_skip_slave_binlog,
469
476
'do-test=s' => \$opt_do_test,
470
477
'start-from=s' => \$opt_start_from,
471
478
'suite|suites=s' => \$opt_suites,
472
479
'skip-rpl' => \$opt_skip_rpl,
473
480
'skip-test=s' => \$opt_skip_test,
474
'big-test' => \$opt_big_test,
475
481
'combination=s' => \@opt_combinations,
476
482
'skip-combination' => \$opt_skip_combination,
479
485
'master_port=i' => \$opt_master_myport,
480
486
'slave_port=i' => \$opt_slave_myport,
487
'memc_port=i' => \$opt_memc_myport,
481
488
'mtr-build-thread=i' => \$opt_mtr_build_thread,
483
490
# Test case authoring
488
495
# Extra options used when starting mysqld
489
496
'mysqld=s' => \@opt_extra_mysqld_opt,
497
'engine=s' => \$opt_engine,
491
499
# Run test on running server
492
500
'extern' => \$opt_extern,
503
'subunit' => \$opt_subunit,
495
506
'gdb' => \$opt_gdb,
496
508
'client-gdb' => \$opt_client_gdb,
509
'client-dbx' => \$opt_client_dbx,
497
510
'manual-gdb' => \$opt_manual_gdb,
511
'manual-dbx' => \$opt_manual_dbx,
498
512
'manual-debug' => \$opt_manual_debug,
499
513
'ddd' => \$opt_ddd,
500
514
'client-ddd' => \$opt_client_ddd,
526
540
'valgrind-option=s' => \@valgrind_args,
527
541
'valgrind-path=s' => \$opt_valgrind_path,
528
542
'callgrind' => \$opt_callgrind,
543
'massif' => \$opt_massif,
531
546
'stress' => \$opt_stress,
542
557
'tmpdir=s' => \$opt_tmpdir,
543
558
'vardir=s' => \$opt_vardir,
559
'suitepath=s' => \$opt_suitepath,
560
'testdir=s' => \$opt_testdir,
544
561
'benchdir=s' => \$glob_mysql_bench_dir,
545
562
'mem' => \$opt_mem,
562
579
'testcase-timeout=i' => \$opt_testcase_timeout,
563
580
'suite-timeout=i' => \$opt_suite_timeout,
564
581
'warnings|log-warnings' => \$opt_warnings,
582
'repeat-test=i' => \$opt_repeat_test,
566
584
# Options which are no longer used
567
585
(map { $_ => \&warn_about_removed_option } @removed_options),
572
590
usage("") if $opt_usage;
592
usage("you cannot specify --gdb and --dbx both!") if
593
($opt_gdb && $opt_dbx) ||
594
($opt_manual_gdb && $opt_manual_dbx);
574
596
$glob_scriptname= basename($0);
576
598
if ($opt_mtr_build_thread != 0)
582
604
$opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'};
585
# We require that we are in the "mysql-test" directory
586
# to run drizzle-test-run
587
if (! -f $glob_scriptname)
589
mtr_error("Can't find the location for the drizzle-test-run script\n" .
590
"Go to to the mysql-test directory and execute the script " .
591
"as follows:\n./$glob_scriptname");
594
607
if ( -d "../drizzled" )
599
612
# Find the absolute path to the test directory
600
$glob_mysql_test_dir= cwd();
613
if ( ! $opt_testdir )
615
$glob_mysql_test_dir= cwd();
619
$glob_mysql_test_dir= $opt_testdir;
601
621
$default_vardir= "$glob_mysql_test_dir/var";
623
if ( ! $opt_suitepath )
625
$glob_suite_path= "$glob_mysql_test_dir/../plugin";
629
$glob_suite_path= $opt_suitepath;
603
631
# In most cases, the base directory we find everything relative to,
604
632
# is the parent directory of the "mysql-test" directory. For source
605
633
# distributions, TAR binary distributions and some other packages.
615
643
$glob_basedir= dirname($glob_basedir);
646
if ( $opt_testdir and -d $opt_testdir and $opt_vardir and -d $opt_vardir
647
and -f "$opt_vardir/../../drizzled/drizzled")
649
# probably in a VPATH build
650
$glob_builddir= "$opt_vardir/../..";
618
657
# Expect mysql-bench to be located adjacent to the source tree, by default
619
658
$glob_mysql_bench_dir= "$glob_basedir/../mysql-bench"
620
659
unless defined $glob_mysql_bench_dir;
634
673
# Look for the client binaries directory
635
$path_client_bindir= mtr_path_exists("$glob_basedir/client",
674
$path_client_bindir= mtr_path_exists("$glob_builddir/client",
675
"$glob_basedir/client",
636
676
"$glob_basedir/bin");
638
# Look for charsetsdir, use same share
639
$path_share= mtr_path_exists("$glob_basedir/share/mysql",
640
"$glob_basedir/drizzled/share",
641
"$glob_basedir/share");
643
$path_charsetsdir= mtr_path_exists("$path_share/charsets");
647
678
if (!$opt_extern)
649
680
$exe_drizzled= mtr_exe_exists ("$glob_basedir/drizzled/drizzled",
650
681
"$path_client_bindir/drizzled",
651
682
"$glob_basedir/libexec/drizzled",
652
683
"$glob_basedir/bin/drizzled",
653
"$glob_basedir/sbin/drizzled");
684
"$glob_basedir/sbin/drizzled",
685
"$glob_builddir/drizzled/drizzled");
655
687
# Use the mysqld found above to find out what features are available
656
688
collect_mysqld_features();
693
730
# --------------------------------------------------------------------------
694
# Find out type of logging that are being used
695
# --------------------------------------------------------------------------
696
if (!$opt_extern && $mysql_version_id >= 50100 )
698
foreach my $arg ( @opt_extra_mysqld_opt )
700
if ( $arg =~ /binlog[-_]format=(\S+)/ )
702
$used_binlog_format= $1;
705
if (defined $used_binlog_format)
707
mtr_report("Using binlog format '$used_binlog_format'");
711
mtr_report("Using dynamic switching of binlog format");
716
# --------------------------------------------------------------------------
717
731
# Find out default storage engine being used(if any)
718
732
# --------------------------------------------------------------------------
719
733
foreach my $arg ( @opt_extra_mysqld_opt )
761
775
$opt_vardir= $default_vardir;
763
elsif ( $mysql_version_id < 50000 and
764
$opt_vardir ne $default_vardir)
766
# Version 4.1 and --vardir was specified
767
# Only supported as a symlink from var/
768
# by setting up $opt_mem that symlink will be created
770
# Only platforms that have native symlinks can use the vardir trick
771
$opt_mem= $opt_vardir;
772
mtr_report("Using 4.1 vardir trick");
775
$opt_vardir= $default_vardir;
778
778
$path_vardir_trace= $opt_vardir;
779
779
# Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
780
780
$path_vardir_trace=~ s/^\w://;
782
# We make the path absolute, as the server will do a chdir() before usage
783
unless ( $opt_vardir =~ m,^/,)
785
# Make absolute path, relative test dir
786
$opt_vardir= "$glob_mysql_test_dir/$opt_vardir";
782
$opt_vardir= collapse_path($opt_vardir);
789
784
# --------------------------------------------------------------------------
816
811
# --------------------------------------------------------------------------
818
# --------------------------------------------------------------------------
824
# --------------------------------------------------------------------------
826
813
# --------------------------------------------------------------------------
827
814
if ( $opt_gcov and ! $source_dist )
834
821
# --------------------------------------------------------------------------
835
822
if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd ||
836
823
$opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug ||
837
$opt_debugger || $opt_client_debugger )
824
$opt_debugger || $opt_client_debugger || $opt_gdb || $opt_manual_gdb)
839
826
# Indicate that we are using debugger
840
827
$glob_debugger= 1;
937
931
path_pid => "$opt_vardir/run/master.pid",
938
932
path_sock => "$sockdir/master.sock",
939
933
port => $opt_master_myport,
934
mysql_port => $opt_master_myport + $mysql_port_offset,
940
935
start_timeout => 400, # enough time create innodb tables
941
936
cluster => 0, # index in clusters list
942
937
start_opts => [],
952
947
path_pid => "$opt_vardir/run/master1.pid",
953
948
path_sock => "$sockdir/master1.sock",
954
949
port => $opt_master_myport + 1,
950
mysql_port => $opt_master_myport + 1 + $mysql_port_offset,
955
951
start_timeout => 400, # enough time create innodb tables
956
952
cluster => 0, # index in clusters list
957
953
start_opts => [],
965
961
path_myddir => "$opt_vardir/slave-data",
966
962
path_myerr => "$opt_vardir/log/slave.err",
967
path_pid => "$opt_vardir/run/slave.pid",
968
path_sock => "$sockdir/slave.sock",
969
port => $opt_slave_myport,
963
path_pid => "$opt_vardir/run/slave.pid",
964
path_sock => "$sockdir/slave.sock",
965
port => $opt_slave_myport,
966
mysql_port => $opt_slave_myport + $mysql_port_offset,
970
967
start_timeout => 400,
972
969
cluster => 1, # index in clusters list
981
978
path_myddir => "$opt_vardir/slave1-data",
982
979
path_myerr => "$opt_vardir/log/slave1.err",
983
path_pid => "$opt_vardir/run/slave1.pid",
984
path_sock => "$sockdir/slave1.sock",
985
port => $opt_slave_myport + 1,
980
path_pid => "$opt_vardir/run/slave1.pid",
981
path_sock => "$sockdir/slave1.sock",
982
port => $opt_slave_myport + 1,
983
mysql_port => $opt_slave_myport + 1 + $mysql_port_offset,
986
984
start_timeout => 300,
987
985
cluster => -1, # index in clusters list
988
986
start_opts => [],
996
994
path_myddir => "$opt_vardir/slave2-data",
997
995
path_myerr => "$opt_vardir/log/slave2.err",
998
path_pid => "$opt_vardir/run/slave2.pid",
999
path_sock => "$sockdir/slave2.sock",
1000
port => $opt_slave_myport + 2,
996
path_pid => "$opt_vardir/run/slave2.pid",
997
path_sock => "$sockdir/slave2.sock",
998
port => $opt_slave_myport + 2,
999
mysql_port => $opt_slave_myport + 2 + $mysql_port_offset,
1001
1000
start_timeout => 300,
1002
1001
cluster => -1, # index in clusters list
1003
1002
start_opts => [],
1069
1068
print "got ".$mtr_build_thread."\n";
1071
$mtr_build_thread= (($mtr_build_thread * 10) % 2000) - 1000;
1072
1073
# Up to two masters, up to three slaves
1073
1074
# A magic value in command_line_setup depends on these equations.
1074
$opt_master_myport= $mtr_build_thread * 10 + 10000; # and 1
1075
$opt_master_myport= $mtr_build_thread + 9000; # and 1
1075
1076
$opt_slave_myport= $opt_master_myport + 2; # and 3 4
1077
$opt_memc_myport= $opt_master_myport + 10;
1077
1079
if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 )
1187
1189
mtr_init_args(\$args);
1189
1191
mtr_add_arg($args, "--no-defaults");
1192
mtr_add_arg($args, "--skip-stack-trace");
1190
1193
mtr_add_arg($args, "--user=%s", $opt_user);
1191
1194
mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
1192
1195
mtr_add_arg($args, "--silent"); # Tab separated output
1234
1237
$exe_my_print_defaults=
1235
1238
mtr_exe_exists(
1236
1239
"$path_client_bindir/my_print_defaults",
1237
"$glob_basedir/extra/my_print_defaults");
1240
"$glob_basedir/extra/my_print_defaults",
1241
"$glob_builddir/extra/my_print_defaults");
1239
1243
# Look for perror
1240
1244
$exe_perror= "perror";
1242
1246
# Look for the client binaries
1243
$exe_drizzlecheck= mtr_exe_exists("$path_client_bindir/drizzlecheck");
1244
1247
$exe_drizzledump= mtr_exe_exists("$path_client_bindir/drizzledump");
1245
1248
$exe_drizzleimport= mtr_exe_exists("$path_client_bindir/drizzleimport");
1246
$exe_drizzlebinlog= mtr_exe_exists("$path_client_bindir/drizzlebinlog");
1247
$exe_drizzleadmin= mtr_exe_exists("$path_client_bindir/drizzleadmin");
1248
1249
$exe_drizzle= mtr_exe_exists("$path_client_bindir/drizzle");
1250
1251
if (!$opt_extern)
1252
1253
# Look for SQL scripts directory
1253
if ( $mysql_version_id >= 50100 )
1255
$exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap");
1254
if ( $mysql_version_id >= 50100 )
1256
$exe_drizzleslap= mtr_exe_exists("$path_client_bindir/drizzleslap");
1259
1260
# Look for drizzletest executable
1340
1341
# --------------------------------------------------------------------------
1341
1342
if ( $source_dist )
1343
push(@ld_library_paths, "$glob_basedir/libmysql/.libs/",
1344
"$glob_basedir/libmysql_r/.libs/",
1345
"$glob_basedir/zlib.libs/");
1344
push(@ld_library_paths, "$glob_basedir/libdrizzleclient/.libs/",
1345
"$glob_basedir/mysys/.libs/",
1346
"$glob_basedir/mystrings/.libs/",
1347
"$glob_basedir/drizzled/.libs/",
1369
1372
push(@ld_library_paths, $debug_libraries_path);
1372
$ENV{'LD_LIBRARY_PATH'}= join(":", @ld_library_paths,
1375
$ENV{'LD_LIBRARY_PATH'}= join(":",
1373
1376
$ENV{'LD_LIBRARY_PATH'} ?
1374
split(':', $ENV{'LD_LIBRARY_PATH'}) : ());
1377
split(':', $ENV{'LD_LIBRARY_PATH'}) : (),
1375
1379
mtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}");
1377
1381
$ENV{'DYLD_LIBRARY_PATH'}= join(":", @ld_library_paths,
1395
1399
# Also command lines in .opt files may contain env vars
1396
1400
# --------------------------------------------------------------------------
1398
$ENV{'CHARSETSDIR'}= $path_charsetsdir;
1402
$ENV{'CHARSETSDIR'}= "";
1399
1403
$ENV{'UMASK'}= "0660"; # The octal *string*
1400
1404
$ENV{'UMASK_DIR'}= "0770"; # The octal *string*
1413
1417
$ENV{'LC_COLLATE'}= "C";
1414
1418
$ENV{'USE_RUNNING_SERVER'}= $opt_extern;
1415
$ENV{'DRIZZLE_TEST_DIR'}= $glob_mysql_test_dir;
1419
$ENV{'DRIZZLE_TEST_DIR'}= collapse_path($glob_mysql_test_dir);
1416
1420
$ENV{'MYSQLTEST_VARDIR'}= $opt_vardir;
1417
1421
$ENV{'DRIZZLE_TMP_DIR'}= $opt_tmpdir;
1418
1422
$ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_sock'};
1423
1427
$ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
1424
1428
$ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
1425
1429
$ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
1430
$ENV{'MC_PORT'}= $opt_memc_myport;
1426
1431
$ENV{'DRIZZLE_TCP_PORT'}= $mysqld_variables{'port'};
1428
$ENV{MTR_BUILD_THREAD}= $opt_mtr_build_thread;
1433
$ENV{'MTR_BUILD_THREAD'}= $opt_mtr_build_thread;
1430
1435
$ENV{'EXE_MYSQL'}= $exe_drizzle;
1432
# ----------------------------------------------------
1433
# Setup env so childs can execute mysqlcheck
1434
# ----------------------------------------------------
1435
my $cmdline_mysqlcheck=
1436
mtr_native_path($exe_drizzlecheck) .
1437
" --no-defaults --debug-check -uroot " .
1438
"--port=$master->[0]->{'port'} ";
1442
$cmdline_mysqlcheck .=
1443
" --debug=d:t:A,$path_vardir_trace/log/mysqlcheck.trace";
1445
$ENV{'DRIZZLE_CHECK'}= $cmdline_mysqlcheck;
1447
1438
# ----------------------------------------------------
1448
1439
# Setup env to childs can execute myqldump
1449
1440
# ----------------------------------------------------
1450
1441
my $cmdline_mysqldump= generate_cmdline_mysqldump($master->[0]);
1451
1442
my $cmdline_mysqldumpslave= generate_cmdline_mysqldump($slave->[0]);
1443
my $cmdline_mysqldumpmysql= mtr_native_path($exe_drizzledump) .
1444
" --no-defaults -uroot " .
1445
"--mysql --port=$master->[0]->{'mysql_port'} ";
1453
1447
if ( $opt_debug )
1456
1450
" --debug=d:t:A,$path_vardir_trace/log/mysqldump-master.trace";
1457
1451
$cmdline_mysqldumpslave .=
1458
1452
" --debug=d:t:A,$path_vardir_trace/log/mysqldump-slave.trace";
1453
$cmdline_mysqldumpmysql .=
1454
" --debug=d:t:A,$path_vardir_trace/log/mysqldump-mysql.trace";
1460
1456
$ENV{'DRIZZLE_DUMP'}= $cmdline_mysqldump;
1461
1457
$ENV{'DRIZZLE_DUMP_SLAVE'}= $cmdline_mysqldumpslave;
1458
$ENV{'DRIZZLE_DUMP_MYSQL'}= $cmdline_mysqldumpmysql;
1464
1460
# ----------------------------------------------------
1465
1461
# Setup env so childs can execute mysqlslap
1466
1462
# ----------------------------------------------------
1467
if ( $exe_mysqlslap )
1463
if ( $exe_drizzleslap )
1469
my $cmdline_mysqlslap=
1470
mtr_native_path($exe_mysqlslap) .
1465
my $cmdline_drizzleslap=
1466
mtr_native_path($exe_drizzleslap) .
1472
1468
"--port=$master->[0]->{'port'} ";
1469
my $cmdline_drizzleslapmysql=
1470
mtr_native_path($exe_drizzleslap) .
1472
"--mysql --port=$master->[0]->{'mysql_port'} ";
1474
1474
if ( $opt_debug )
1476
$cmdline_mysqlslap .=
1477
" --debug=d:t:A,$path_vardir_trace/log/mysqlslap.trace";
1476
$cmdline_drizzleslap .=
1477
" --debug=d:t:A,$path_vardir_trace/log/drizzleslap.trace";
1478
$cmdline_drizzleslapmysql .=
1479
" --debug=d:t:A,$path_vardir_trace/log/drizzleslap.trace";
1479
$ENV{'DRIZZLE_SLAP'}= $cmdline_mysqlslap;
1481
$ENV{'DRIZZLE_SLAP'}= $cmdline_drizzleslap;
1482
$ENV{'DRIZZLE_SLAP_MYSQL'}= $cmdline_drizzleslapmysql;
1482
1487
# ----------------------------------------------------
1483
1488
# Setup env so childs can execute mysqlimport
1484
1489
# ----------------------------------------------------
1485
1490
my $cmdline_mysqlimport=
1486
1491
mtr_native_path($exe_drizzleimport) .
1487
" -uroot --debug-check " .
1488
1493
"--port=$master->[0]->{'port'} ";
1490
1495
if ( $opt_debug )
1498
1503
# ----------------------------------------------------
1499
# Setup env so childs can execute mysqlbinlog
1500
# ----------------------------------------------------
1501
my $cmdline_mysqlbinlog=
1502
mtr_native_path($exe_drizzlebinlog) .
1503
" --no-defaults --disable-force-if-open --debug-check";
1504
if ( !$opt_extern && $mysql_version_id >= 50000 )
1506
$cmdline_mysqlbinlog .=" --character-sets-dir=$path_charsetsdir";
1511
$cmdline_mysqlbinlog .=
1512
" --debug=d:t:A,$path_vardir_trace/log/mysqlbinlog.trace";
1514
$ENV{'DRIZZLE_BINLOG'}= $cmdline_mysqlbinlog;
1516
# ----------------------------------------------------
1517
1504
# Setup env so childs can execute mysql
1518
1505
# ----------------------------------------------------
1519
1506
my $cmdline_mysql=
1520
1507
mtr_native_path($exe_drizzle) .
1521
" --no-defaults --debug-check --host=localhost --user=root --password= " .
1522
"--port=$master->[0]->{'port'} " .
1523
"--character-sets-dir=$path_charsetsdir";
1508
" --no-defaults --host=localhost --user=root --password= " .
1509
"--port=$master->[0]->{'port'} ";
1510
my $cmdline_drizzlemysql=
1511
mtr_native_path($exe_drizzle) .
1512
" --no-defaults --host=localhost --user=root --password= " .
1513
"--mysql --port=$master->[0]->{'mysql_port'} ";
1525
1515
$ENV{'MYSQL'}= $cmdline_mysql;
1516
$ENV{'DRIZZLE_MYSQL'}= $cmdline_drizzlemysql;
1527
1518
# ----------------------------------------------------
1528
1519
# Setup env so childs can execute bug25714
1556
1547
$ENV{'DRIZZLE_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
1558
1549
# ----------------------------------------------------
1559
# Setup env so childs can execute mysqladmin
1550
# Setup env so childs can shutdown the server
1560
1551
# ----------------------------------------------------
1561
$ENV{'MYSQLADMIN'}= mtr_native_path($exe_drizzleadmin);
1552
$ENV{'DRIZZLED_SHUTDOWN'}= mtr_native_path($exe_drizzle);
1563
1554
# ----------------------------------------------------
1564
1555
# Setup env so childs can execute perror
1596
1587
print "Using SLAVE_MYPORT = $ENV{SLAVE_MYPORT}\n";
1597
1588
print "Using SLAVE_MYPORT1 = $ENV{SLAVE_MYPORT1}\n";
1598
1589
print "Using SLAVE_MYPORT2 = $ENV{SLAVE_MYPORT2}\n";
1590
print "Using MC_PORT = $ENV{MC_PORT}\n";
1601
1593
# Create an environment variable to make it possible
1791
1783
# Make a link std_data_ln in var/ that points to std_data
1792
symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
1784
symlink(collapse_path("$glob_mysql_test_dir/std_data"),
1785
"$opt_vardir/std_data_ln");
1794
1787
# Remove old log files
1795
1788
foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
1792
system("chmod -R ugo+r $opt_vardir");
1793
system("chmod -R ugo+r $opt_vardir/std_data_ln/*");
1887
1882
if ( ! $benchmark )
1889
mtr_add_arg($args, "--log");
1890
1884
mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", "");
1891
1885
# FIXME check result code?!
1928
1922
foreach my $tinfo ( @$tests )
1930
if (run_testcase_check_skip_test($tinfo))
1924
foreach(1..$opt_repeat_test)
1926
if (run_testcase_check_skip_test($tinfo))
1931
mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
1932
run_testcase($tinfo);
1933
mtr_timer_stop($glob_timers,"testcase");
1935
mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
1936
run_testcase($tinfo);
1937
mtr_timer_stop($glob_timers,"testcase");
1940
1937
mtr_print_line();
2092
2089
unlink("$base_file.log");
2093
2090
unlink("$base_file.warnings");
2097
if (defined $tinfo->{binlog_format} and $mysql_version_id > 50100 )
2099
# Dynamically switch binlog format of
2100
# master, slave is always restarted
2101
foreach my $server ( @$master )
2103
next unless ($server->{'pid'});
2105
mtr_init_args(\$args);
2106
mtr_add_arg($args, "--no-defaults");
2107
mtr_add_arg($args, "--user=root");
2108
mtr_add_arg($args, "--port=$server->{'port'}");
2110
my $sql= "include/set_binlog_format_".$tinfo->{binlog_format}.".sql";
2111
mtr_verbose("Setting binlog format:", $tinfo->{binlog_format});
2112
if (mtr_run($exe_drizzle, $args, $sql, "", "", "") != 0)
2114
mtr_error("Failed to switch binlog format");
2121
2094
sub do_after_run_drizzletest($)
2489
2462
mtr_add_arg($args, "%s--no-defaults", $prefix);
2464
$path_my_basedir= collapse_path($path_my_basedir);
2491
2465
mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir);
2492
mtr_add_arg($args, "%s--character-sets-dir=%s", $prefix, $path_charsetsdir);
2469
mtr_add_arg($args, "%s--default-storage-engine=%s", $prefix, $opt_engine);
2494
2472
if ( $mysql_version_id >= 50036)
2497
2475
mtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir);
2500
if ( $mysql_version_id >= 50000 )
2502
mtr_add_arg($args, "%s--log-bin-trust-function-creators", $prefix);
2505
mtr_add_arg($args, "%s--default-character-set=latin1", $prefix);
2506
2478
mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
2508
2480
# Increase default connect_timeout to avoid intermittent
2509
2481
# disconnects when test servers are put under load
2510
2482
# see BUG#28359
2511
mtr_add_arg($args, "%s--connect-timeout=60", $prefix);
2483
mtr_add_arg($args, "%s--drizzle-protocol-connect-timeout=60", $prefix);
2514
2486
# When mysqld is run by a root user(euid is 0), it will fail
2521
2493
mtr_add_arg($args, "%s--pid-file=%s", $prefix,
2522
2494
$mysqld->{'path_pid'});
2524
mtr_add_arg($args, "%s--port=%d", $prefix,
2496
mtr_add_arg($args, "%s--drizzle-protocol-port=%d", $prefix,
2499
mtr_add_arg($args, "%s--mysql-protocol-port=%d", $prefix,
2500
$mysqld->{'mysql_port'});
2527
2502
mtr_add_arg($args, "%s--datadir=%s", $prefix,
2528
2503
$mysqld->{'path_myddir'});
2530
my $log_base_path= "$opt_vardir/log/$mysqld->{'type'}$sidx";
2531
mtr_add_arg($args, "%s--log=%s.log", $prefix, $log_base_path);
2533
"%s--log-slow-queries=%s-slow.log", $prefix, $log_base_path);
2535
2505
# Check if "extra_opt" contains --skip-log-bin
2536
my $skip_binlog= grep(/^--skip-log-bin/, @$extra_opt, @opt_extra_mysqld_opt);
2537
2506
if ( $mysqld->{'type'} eq 'master' )
2539
if (! ($opt_skip_master_binlog || $skip_binlog) )
2541
mtr_add_arg($args, "%s--log-bin=%s/log/master-bin%s", $prefix,
2542
$opt_vardir, $sidx);
2545
2508
mtr_add_arg($args, "%s--server-id=%d", $prefix,
2546
2509
$idx > 0 ? $idx + 101 : 1);
2548
2511
mtr_add_arg($args, "%s--loose-innodb_data_file_path=ibdata1:10M:autoextend",
2551
mtr_add_arg($args, "%s--local-infile", $prefix);
2514
mtr_add_arg($args, "%s--loose-innodb-lock-wait-timeout=5", $prefix);
2553
2516
if ( $idx > 0 or !$use_innodb)
2560
2523
mtr_error("unknown mysqld type")
2561
2524
unless $mysqld->{'type'} eq 'slave';
2563
#mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
2564
if (! ( $opt_skip_slave_binlog || $skip_binlog ))
2566
mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
2567
$opt_vardir, $sidx); # FIXME use own dir for binlogs
2568
mtr_add_arg($args, "%s--log-slave-updates", $prefix);
2571
mtr_add_arg($args, "%s--master-retry-count=10", $prefix);
2573
mtr_add_arg($args, "%s--relay-log=%s/log/slave%s-relay-bin", $prefix,
2574
$opt_vardir, $sidx);
2575
mtr_add_arg($args, "%s--report-host=127.0.0.1", $prefix);
2576
mtr_add_arg($args, "%s--report-port=%d", $prefix,
2578
# mtr_add_arg($args, "%s--report-user=root", $prefix);
2579
mtr_add_arg($args, "%s--loose-skip-innodb", $prefix);
2580
mtr_add_arg($args, "%s--skip-slave-start", $prefix);
2582
2526
# Directory where slaves find the dumps generated by "load data"
2583
2527
# on the server. The path need to have constant length otherwise
2584
2528
# test results will vary, thus a relative path is used.
2585
2529
my $slave_load_path= "../tmp";
2586
mtr_add_arg($args, "%s--slave-load-tmpdir=%s", $prefix,
2588
mtr_add_arg($args, "%s--set-variable=slave_net_timeout=120", $prefix);
2590
2531
if ( @$slave_master_info )
2599
2540
my $slave_server_id= 2 + $idx;
2600
2541
my $slave_rpl_rank= $slave_server_id;
2601
2542
mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
2602
# mtr_add_arg($args, "%s--rpl-recovery-rank=%d", $prefix, $slave_rpl_rank);
2609
2549
$prefix, $path_vardir_trace, $mysqld->{'type'}, $sidx);
2612
mtr_add_arg($args, "%s--key_buffer_size=1M", $prefix);
2552
mtr_add_arg($args, "%s--myisam_key_cache_size=1M", $prefix);
2613
2553
mtr_add_arg($args, "%s--sort_buffer=256K", $prefix);
2614
2554
mtr_add_arg($args, "%s--max_heap_table_size=1M", $prefix);
2633
2573
$found_skip_core= 1;
2635
elsif ($skip_binlog and mtr_match_prefix($arg, "--binlog-format"))
2637
; # Dont add --binlog-format when running without binlog
2641
2577
mtr_add_arg($args, "%s%s", $prefix, $arg);
2646
2582
mtr_add_arg($args, "%s%s", $prefix, "--core-file");
2651
#mtr_add_arg($args, "%s--rpl-recovery-rank=1", $prefix);
2652
#mtr_add_arg($args, "%s--init-rpl-role=master", $prefix);
2654
elsif ( $mysqld->{'type'} eq 'master' )
2656
mtr_add_arg($args, "%s--open-files-limit=1024", $prefix);
2710
2636
ddd_arguments(\$args, \$exe, "$type"."_$idx");
2638
if ( $opt_dbx || $opt_manual_dbx)
2640
dbx_arguments(\$args, \$exe, "$type"."_$idx");
2712
2642
elsif ( $opt_debugger )
2714
2644
debugger_arguments(\$args, \$exe, "$type"."_$idx");
2936
2866
if ( $mysqld->{'pid'} )
2938
$pid= mtr_mysqladmin_start($mysqld, "shutdown", 20);
2940
$admin_pids{$pid}= 1;
2943
pid => $mysqld->{'pid'},
2944
real_pid => $mysqld->{'real_pid'},
2945
pidfile => $mysqld->{'path_pid'},
2946
sockfile => $mysqld->{'path_sock'},
2947
port => $mysqld->{'port'},
2948
errfile => $mysqld->{'path_myerr'},
2951
$mysqld->{'pid'}= 0; # Assume we are done with it
2868
$pid= mtr_server_shutdown($mysqld);
2870
$admin_pids{$pid}= 1;
2873
pid => $mysqld->{'pid'},
2874
real_pid => $mysqld->{'real_pid'},
2875
pidfile => $mysqld->{'path_pid'},
2876
sockfile => $mysqld->{'path_sock'},
2877
port => $mysqld->{'port'},
2878
errfile => $mysqld->{'path_myerr'},
2881
$mysqld->{'pid'}= 0; # Assume we are done with it
2964
2894
if ( $mysqld->{'pid'} )
2966
$pid= mtr_mysqladmin_start($mysqld, "shutdown", 20);
2968
$admin_pids{$pid}= 1;
2971
pid => $mysqld->{'pid'},
2972
real_pid => $mysqld->{'real_pid'},
2973
pidfile => $mysqld->{'path_pid'},
2974
sockfile => $mysqld->{'path_sock'},
2975
port => $mysqld->{'port'},
2976
errfile => $mysqld->{'path_myerr'},
2980
$mysqld->{'pid'}= 0; # Assume we are done with it
2896
$pid= mtr_server_shutdown($mysqld);
2898
$admin_pids{$pid}= 1;
2901
pid => $mysqld->{'pid'},
2902
real_pid => $mysqld->{'real_pid'},
2903
pidfile => $mysqld->{'path_pid'},
2904
sockfile => $mysqld->{'path_sock'},
2905
port => $mysqld->{'port'},
2906
errfile => $mysqld->{'path_myerr'},
2909
$mysqld->{'pid'}= 0; # Assume we are done with it
3087
3016
mtr_add_arg($args, "--no-defaults");
3088
3017
mtr_add_arg($args, "--silent");
3089
3018
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
3090
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
3092
3020
mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
3093
3021
mtr_add_arg($args, "--database=test");
3102
3030
mtr_add_arg($args, "--record");
3035
mtr_add_arg($args, "--testdir=%s", $opt_testdir);
3105
3038
my $res = mtr_run_test($exe_drizzletest,$args,
3106
3039
"include/check-testcase.test", "", "", "");
3166
3099
mtr_add_arg($args, "--no-defaults");
3167
3100
mtr_add_arg($args, "--silent");
3168
3101
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
3169
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
3170
3102
mtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
3172
3104
# Log line number and time for each line in .test file
3209
3141
$path_vardir_trace);
3146
mtr_add_arg($args, "--testdir=%s", $opt_testdir);
3212
3150
# ----------------------------------------------------------------------
3213
3151
# export DRIZZLE_TEST variable containing <path>/drizzletest <args>
3214
3152
# ----------------------------------------------------------------------
3231
# Modify the exe and args so that program is run in gdb in xterm
3238
# Write $args to gdb init file
3239
my $str= join(" ", @$$args);
3240
my $dbx_init_file= "$opt_tmpdir/dbxinit.$type";
3242
# Remove the old gdbinit file
3243
unlink($dbx_init_file);
3244
if ( $type eq "client" )
3246
# write init file for client
3247
mtr_tofile($dbx_init_file,
3253
# write init file for drizzled
3254
mtr_tofile($dbx_init_file,
3255
"stop in mysql_parse\n" .
3261
if ( $opt_manual_dbx )
3263
print "\nTo start dbx for $type, type in another window:\n";
3264
print "dbx -c 'source $dbx_init_file' $$exe\n";
3266
# Indicate the exe should not be started
3272
mtr_add_arg($$args, "-title");
3273
mtr_add_arg($$args, "$type");
3274
mtr_add_arg($$args, "-e");
3276
mtr_add_arg($$args, "dbx");
3277
mtr_add_arg($$args, "-c");
3278
mtr_add_arg($$args, "source $dbx_init_file");
3279
mtr_add_arg($$args, "$$exe");
3294
3285
# Modify the exe and args so that program is run in gdb in xterm
3435
3426
$$exe= $debugger;
3438
elsif ( $debugger eq "dbx" )
3440
# xterm -e dbx -r exe arg1 .. argn
3442
unshift(@$$args, $$exe);
3443
unshift(@$$args, "-r");
3444
unshift(@$$args, $debugger);
3445
unshift(@$$args, "-e");
3429
#elsif ( $debugger eq "dbx" )
3431
# # xterm -e dbx -r exe arg1 .. argn
3433
# unshift(@$$args, $$exe);
3434
# unshift(@$$args, "-r");
3435
# unshift(@$$args, $debugger);
3436
# unshift(@$$args, "-e");
3452
3443
mtr_error("Unknown argument \"$debugger\" passed to --debugger");
3466
3457
mtr_add_arg($args, "--tool=callgrind");
3467
3458
mtr_add_arg($args, "--base=$opt_vardir/log");
3462
mtr_add_arg($args, "--tool=massif");
3471
3466
mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
3472
mtr_add_arg($args, "--alignment=8");
3473
3467
mtr_add_arg($args, "--leak-check=yes");
3474
3468
mtr_add_arg($args, "--num-callers=16");
3475
3469
mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
3508
sub collapse_path ($) {
3510
my $c_path= rel2abs(shift);
3511
my $updir = updir($c_path);
3512
my $curdir = curdir($c_path);
3514
my($vol, $dirs, $file) = splitpath($c_path);
3515
my @dirs = splitdir($dirs);
3518
foreach my $dir (@dirs) {
3519
if( $dir eq $updir and # if we have an updir
3520
@collapsed and # and something to collapse
3521
length $collapsed[-1] and # and its not the rootdir
3522
$collapsed[-1] ne $updir and # nor another updir
3523
$collapsed[-1] ne $curdir # nor the curdir
3526
pop @collapsed; # collapse
3529
push @collapsed, $dir; # just hang onto it
3533
return catpath($vol, catdir(@collapsed), $file);
3515
3536
##############################################################################
3565
3586
list of suite names.
3566
3587
The default is: "$opt_suites_default"
3567
3588
skip-rpl Skip the replication test cases.
3568
big-test Set the environment variable BIG_TEST, which can be
3569
checked from test cases.
3570
3589
combination="ARG1 .. ARG2" Specify a set of "mysqld" arguments for one
3572
3591
skip-combination Skip any combination options and combinations files
3592
repeat-test=n How many times to repeat each test (default: 1)
3574
3594
Options that specify ports