534
465
Getopt::Long::Configure("pass_through");
536
467
# Control what engine/variation to run
537
'embedded-server' => \$opt_embedded_server,
538
'ps-protocol' => \$opt_ps_protocol,
539
'sp-protocol' => \$opt_sp_protocol,
540
'view-protocol' => \$opt_view_protocol,
541
'cursor-protocol' => \$opt_cursor_protocol,
542
'ssl|with-openssl' => \$opt_ssl,
543
'skip-ssl' => \$opt_skip_ssl,
544
468
'compress' => \$opt_compress,
545
469
'bench' => \$opt_bench,
546
470
'small-bench' => \$opt_small_bench,
547
'with-ndbcluster|ndb' => \$opt_with_ndbcluster,
548
471
'vs-config' => \$opt_vs_config,
550
473
# Control what test suites or cases to run
551
474
'force' => \$opt_force,
552
'with-ndbcluster-only' => \$opt_with_ndbcluster_only,
553
'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster,
554
'skip-ndbcluster-slave|skip-ndb-slave'
555
=> \$opt_skip_ndbcluster_slave,
556
'ndb-extra-test' => \$opt_ndb_extra_test,
557
475
'skip-master-binlog' => \$opt_skip_master_binlog,
558
476
'skip-slave-binlog' => \$opt_skip_slave_binlog,
559
477
'do-test=s' => \$opt_do_test,
781
658
if (!$opt_extern)
783
$exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'),
784
vs_config_dirs('sql', 'mysqld-debug'),
785
"$glob_basedir/sql/mysqld",
786
"$path_client_bindir/mysqld-max-nt",
787
"$path_client_bindir/mysqld-max",
788
"$path_client_bindir/mysqld-nt",
789
"$path_client_bindir/mysqld",
790
"$path_client_bindir/mysqld-debug",
791
"$path_client_bindir/mysqld-max",
792
"$glob_basedir/libexec/mysqld",
793
"$glob_basedir/bin/mysqld",
794
"$glob_basedir/sbin/mysqld");
660
$exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'drizzled'),
661
"$glob_basedir/sql/drizzled",
662
"$path_client_bindir/drizzled",
663
"$glob_basedir/libexec/drizzled",
664
"$glob_basedir/bin/drizzled",
665
"$glob_basedir/sbin/drizzled");
796
667
# Use the mysqld found above to find out what features are available
797
668
collect_mysqld_features();
1229
# --------------------------------------------------------------------------
1230
# ndbconnectstring and ndbconnectstring_slave
1231
# --------------------------------------------------------------------------
1232
if ( $opt_ndbconnectstring )
1234
# ndbconnectstring was supplied by user, the tests shoudl be run
1235
# against an already started cluster, change settings
1236
my $cluster= $clusters->[0]; # Master cluster
1237
$cluster->{'connect_string'}= $opt_ndbconnectstring;
1238
$cluster->{'use_running'}= 1;
1240
mtr_error("Can't specify --ndb-connectstring and --skip-ndbcluster")
1241
if $opt_skip_ndbcluster;
1243
$ENV{'NDB_CONNECTSTRING'}= $clusters->[0]->{'connect_string'};
1246
if ( $opt_ndbconnectstring_slave )
1248
# ndbconnectstring-slave was supplied by user, the tests should be run
1249
# agains an already started slave cluster, change settings
1250
my $cluster= $clusters->[1]; # Slave cluster
1251
$cluster->{'connect_string'}= $opt_ndbconnectstring_slave;
1252
$cluster->{'use_running'}= 1;
1254
mtr_error("Can't specify ndb-connectstring_slave and " .
1255
"--skip-ndbcluster-slave")
1256
if $opt_skip_ndbcluster_slave;
1260
1039
$path_timefile= "$opt_vardir/log/mysqltest-time";
1261
1040
$path_mysqltest_log= "$opt_vardir/log/mysqltest.log";
1262
1041
$path_current_test_log= "$opt_vardir/log/current_test";
1263
$path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
1265
1043
$path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
1453
sub executable_setup_ndb () {
1455
# Look for ndb tols and binaries
1456
my $ndb_path= mtr_file_exists("$glob_basedir/ndb",
1457
"$glob_basedir/storage/ndb",
1458
"$glob_basedir/bin");
1461
mtr_exe_maybe_exists("$ndb_path/src/kernel/ndbd",
1464
mtr_exe_maybe_exists("$ndb_path/src/mgmclient/ndb_mgm",
1465
"$ndb_path/ndb_mgm");
1467
mtr_exe_maybe_exists("$ndb_path/src/mgmsrv/ndb_mgmd",
1468
"$ndb_path/ndb_mgmd");
1470
mtr_exe_maybe_exists("$ndb_path/tools/ndb_waiter",
1471
"$ndb_path/ndb_waiter");
1474
$path_ndb_tools_dir= mtr_file_exists("$ndb_path/tools",
1477
$path_ndb_examples_dir=
1478
mtr_file_exists("$ndb_path/ndbapi-examples",
1479
"$ndb_path/examples");
1482
mtr_file_exists("$path_ndb_examples_dir/ndbapi_simple/ndbapi_simple");
1484
return ( $exe_ndbd eq "" or
1485
$exe_ndb_mgm eq "" or
1486
$exe_ndb_mgmd eq "" or
1487
$exe_ndb_waiter eq "");
1490
1228
sub executable_setup () {
1493
# Check if libtool is available in this distribution/clone
1494
# we need it when valgrinding or debugging non installed binary
1495
# Otherwise valgrind will valgrind the libtool wrapper or bash
1496
# and gdb will not find the real executable to debug
1231
# Check if libtool is available in this distribution/clone
1232
# we need it when valgrinding or debugging non installed binary
1233
# Otherwise valgrind will valgrind the libtool wrapper or bash
1234
# and gdb will not find the real executable to debug
1498
1236
if ( -x "../libtool")
1500
1238
$exe_libtool= "../libtool";
1507
# Look for my_print_defaults
1245
# Look for my_print_defaults
1508
1246
$exe_my_print_defaults=
1509
1247
mtr_exe_exists(vs_config_dirs('extra', 'my_print_defaults'),
1510
"$path_client_bindir/my_print_defaults",
1511
"$glob_basedir/extra/my_print_defaults");
1248
"$path_client_bindir/my_print_defaults",
1249
"$glob_basedir/extra/my_print_defaults");
1514
1252
$exe_perror= "perror";
1516
# Look for the client binaries
1517
$exe_mysqlcheck= mtr_exe_exists("$path_client_bindir/mysqlcheck");
1518
$exe_mysqldump= mtr_exe_exists("$path_client_bindir/mysqldump");
1519
$exe_mysqlimport= mtr_exe_exists("$path_client_bindir/mysqlimport");
1520
$exe_mysqlshow= mtr_exe_exists("$path_client_bindir/mysqlshow");
1521
$exe_mysqlbinlog= mtr_exe_exists("$path_client_bindir/mysqlbinlog");
1522
$exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin");
1254
# Look for the client binaries
1255
$exe_mysqlcheck= mtr_exe_exists("$path_client_bindir/mysqlcheck");
1256
$exe_mysqldump= mtr_exe_exists("$path_client_bindir/mysqldump");
1257
$exe_mysqlimport= mtr_exe_exists("$path_client_bindir/mysqlimport");
1258
$exe_mysqlshow= mtr_exe_exists("$path_client_bindir/mysqlshow");
1259
$exe_mysqlbinlog= mtr_exe_exists("$path_client_bindir/mysqlbinlog");
1260
$exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin");
1523
1261
$exe_mysql= mtr_exe_exists("$path_client_bindir/mysql");
1525
1263
if (!$opt_extern)
1527
# Look for SQL scripts directory
1265
# Look for SQL scripts directory
1528
1266
if ( $mysql_version_id >= 50100 )
1530
$exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap");
1534
if ( ! $opt_skip_ndbcluster and executable_setup_ndb())
1536
mtr_warning("Could not find all required ndb binaries, " .
1537
"all ndb tests will fail, use --skip-ndbcluster to " .
1538
"skip testing it.");
1540
foreach my $cluster (@{$clusters})
1542
$cluster->{"executable_setup_failed"}= 1;
1547
# Look for the udf_example library
1549
mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'),
1550
"$glob_basedir/sql/.libs/udf_example.so",);
1552
# Look for the ha_example library
1553
$lib_example_plugin=
1554
mtr_file_exists(vs_config_dirs('storage/example', 'ha_example.dll'),
1555
"$glob_basedir/storage/example/.libs/ha_example.so",);
1559
# Look for mysqltest executable
1560
if ( $glob_use_embedded_server )
1563
mtr_exe_exists(vs_config_dirs('libmysqld/examples','mysqltest_embedded'),
1564
"$glob_basedir/libmysqld/examples/mysqltest_embedded",
1565
"$path_client_bindir/mysqltest_embedded");
1268
$exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap");
1272
# Look for mysqltest executable
1569
1274
$exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
1572
# Look for mysql_client_test executable which may _not_ exist in
1573
# some versions, test using it should be skipped
1574
if ( $glob_use_embedded_server )
1576
$exe_mysql_client_test=
1577
mtr_exe_maybe_exists(
1578
vs_config_dirs('libmysqld/examples', 'mysql_client_test_embedded'),
1579
"$glob_basedir/libmysqld/examples/mysql_client_test_embedded");
1277
# Look for mysql_client_test executable which may _not_ exist in
1278
# some versions, test using it should be skipped
1583
1280
$exe_mysql_client_test=
1584
1281
mtr_exe_maybe_exists(vs_config_dirs('tests', 'mysql_client_test'),
1585
"$glob_basedir/tests/mysql_client_test",
1586
"$glob_basedir/bin/mysql_client_test");
1282
"$glob_basedir/tests/mysql_client_test",
1283
"$glob_basedir/bin/mysql_client_test");
1589
# Look for bug25714 executable which may _not_ exist in
1590
# some versions, test using it should be skipped
1286
# Look for bug25714 executable which may _not_ exist in
1287
# some versions, test using it should be skipped
1592
mtr_exe_maybe_exists(vs_config_dirs('tests', 'bug25714'),
1593
"$glob_basedir/tests/bug25714");
1289
mtr_exe_maybe_exists(vs_config_dirs('tests', 'bug25714'),
1290
"$glob_basedir/tests/bug25714");
1597
1295
sub generate_cmdline_mysqldump ($) {
1598
1296
my($mysqld) = @_;
2331
1912
##############################################################################
2333
# Start the ndb cluster
2335
##############################################################################
2337
sub check_ndbcluster_support ($) {
2338
my $mysqld_variables= shift;
2340
if ($opt_skip_ndbcluster || $opt_extern)
2344
mtr_report("Skipping ndbcluster");
2346
$opt_skip_ndbcluster_slave= 1;
2350
if ( ! $mysqld_variables->{'ndb-connectstring'} )
2352
mtr_report("Skipping ndbcluster, mysqld not compiled with ndbcluster");
2353
$opt_skip_ndbcluster= 1;
2354
$opt_skip_ndbcluster_slave= 1;
2357
$glob_ndbcluster_supported= 1;
2358
mtr_report("Using ndbcluster when necessary, mysqld supports it");
2360
if ( $mysql_version_id < 50100 )
2362
# Slave cluster is not supported until 5.1
2363
$opt_skip_ndbcluster_slave= 1;
2371
sub ndbcluster_start_install ($) {
2374
mtr_report("Installing $cluster->{'name'} Cluster");
2376
mkdir($cluster->{'data_dir'});
2378
# Create a config file from template
2380
my $ndb_no_attr=2048;
2381
my $ndb_con_op=105000;
2384
my $ndb_pbmem="32M";
2385
my $nodes= $cluster->{'nodes'};
2386
my $ndb_host= "localhost";
2387
my $ndb_diskless= 0;
2391
# Use a smaller configuration
2392
if ( $mysql_version_id < 50100 )
2394
# 4.1 and 5.0 is using a "larger" --small configuration
2410
my $config_file_template= "ndb/ndb_config_${nodes}_node.ini";
2411
my $config_file= "$cluster->{'data_dir'}/config.ini";
2413
open(IN, $config_file_template)
2414
or mtr_error("Can't open $config_file_template: $!");
2415
open(OUT, ">", $config_file)
2416
or mtr_error("Can't write to $config_file: $!");
2421
s/CHOOSE_MaxNoOfAttributes/$ndb_no_attr/;
2422
s/CHOOSE_MaxNoOfOrderedIndexes/$ndb_no_ord/;
2423
s/CHOOSE_MaxNoOfConcurrentOperations/$ndb_con_op/;
2424
s/CHOOSE_DataMemory/$ndb_dmem/;
2425
s/CHOOSE_IndexMemory/$ndb_imem/;
2426
s/CHOOSE_Diskless/$ndb_diskless/;
2427
s/CHOOSE_HOSTNAME_.*/$ndb_host/;
2428
s/CHOOSE_FILESYSTEM/$cluster->{'data_dir'}/;
2429
s/CHOOSE_PORT_MGM/$cluster->{'port'}/;
2430
if ( $mysql_version_id < 50000 )
2432
my $base_port= $cluster->{'port'} + 1;
2433
s/CHOOSE_PORT_TRANSPORTER/$base_port/;
2435
s/CHOOSE_DiskPageBufferMemory/$ndb_pbmem/;
2443
# Start cluster with "--initial"
2445
ndbcluster_start($cluster, "--initial");
2451
sub ndbcluster_wait_started($$){
2453
my $ndb_waiter_extra_opt= shift;
2454
my $path_waiter_log= "$cluster->{'data_dir'}/ndb_waiter.log";
2457
mtr_init_args(\$args);
2459
mtr_add_arg($args, "--no-defaults");
2460
mtr_add_arg($args, "--core");
2461
mtr_add_arg($args, "--ndb-connectstring=%s", $cluster->{'connect_string'});
2462
mtr_add_arg($args, "--timeout=60");
2464
if ($ndb_waiter_extra_opt)
2466
mtr_add_arg($args, "$ndb_waiter_extra_opt");
2469
# Start the ndb_waiter which will connect to the ndb_mgmd
2470
# and poll it for state of the ndbd's, will return when
2471
# all nodes in the cluster is started
2472
my $res= mtr_run($exe_ndb_waiter, $args,
2473
"", $path_waiter_log, $path_waiter_log, "");
2474
mtr_verbose("ndbcluster_wait_started, returns: $res") if $res;
2480
sub mysqld_wait_started($){
2483
if (sleep_until_file_created($mysqld->{'path_pid'},
2484
$mysqld->{'start_timeout'},
2485
$mysqld->{'pid'}) == 0)
2487
# Failed to wait for pid file
2491
# Get the "real pid" of the process, it will be used for killing
2492
# the process in ActiveState's perl on windows
2493
$mysqld->{'real_pid'}= mtr_get_pid_from_file($mysqld->{'path_pid'});
2499
sub ndb_mgmd_wait_started($) {
2503
while (ndbcluster_wait_started($cluster, "--no-contact") and
2506
# Millisceond sleep emulated with select
2507
select(undef, undef, undef, (0.1));
2512
return $retries == 0;
2516
sub ndb_mgmd_start ($) {
2519
my $args; # Arg vector
2522
mtr_init_args(\$args);
2523
mtr_add_arg($args, "--no-defaults");
2524
mtr_add_arg($args, "--core");
2525
mtr_add_arg($args, "--nodaemon");
2526
mtr_add_arg($args, "--config-file=%s", "$cluster->{'data_dir'}/config.ini");
2529
my $path_ndb_mgmd_log= "$cluster->{'data_dir'}/\l$cluster->{'name'}_ndb_mgmd.log";
2530
$pid= mtr_spawn($exe_ndb_mgmd, $args, "",
2534
{ append_log_file => 1 });
2536
# FIXME Should not be needed
2537
# Unfortunately the cluster nodes will fail to start
2538
# if ndb_mgmd has not started properly
2539
if (ndb_mgmd_wait_started($cluster))
2541
mtr_error("Failed to wait for start of ndb_mgmd");
2544
# Remember pid of ndb_mgmd
2545
$cluster->{'pid'}= $pid;
2547
mtr_verbose("ndb_mgmd_start, pid: $pid");
2553
sub ndbd_start ($$$) {
2556
my $extra_args= shift;
2558
my $args; # Arg vector
2561
mtr_init_args(\$args);
2562
mtr_add_arg($args, "--no-defaults");
2563
mtr_add_arg($args, "--core");
2564
mtr_add_arg($args, "--ndb-connectstring=%s", "$cluster->{'connect_string'}");
2565
if ( $mysql_version_id >= 50000)
2567
mtr_add_arg($args, "--character-sets-dir=%s", "$path_charsetsdir");
2569
mtr_add_arg($args, "--nodaemon");
2570
mtr_add_arg($args, "$extra_args");
2572
my $nodeid= $cluster->{'ndbds'}->[$idx]->{'nodeid'};
2573
my $path_ndbd_log= "$cluster->{'data_dir'}/ndb_${nodeid}.log";
2574
$pid= mtr_spawn($exe_ndbd, $args, "",
2578
{ append_log_file => 1 });
2580
# Add pid to list of pids for this cluster
2581
$cluster->{'ndbds'}->[$idx]->{'pid'}= $pid;
2583
# Rememeber options used when starting
2584
$cluster->{'ndbds'}->[$idx]->{'start_extra_args'}= $extra_args;
2585
$cluster->{'ndbds'}->[$idx]->{'idx'}= $idx;
2587
mtr_verbose("ndbd_start, pid: $pid");
2593
sub ndbcluster_start ($$) {
2595
my $extra_args= shift;
2597
mtr_verbose("ndbcluster_start '$cluster->{'name'}'");
2599
if ( $cluster->{'use_running'} )
2604
if ( $cluster->{'pid'} )
2606
mtr_error("Cluster '$cluster->{'name'}' already started");
2609
ndb_mgmd_start($cluster);
2611
for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ )
2613
ndbd_start($cluster, $idx, $extra_args);
2620
sub rm_ndbcluster_tables ($) {
2622
foreach my $bin ( glob("$dir/mysql/ndb_apply_status*"),
2623
glob("$dir/mysql/ndb_schema*"))
2630
##############################################################################
2632
1914
# Run the benchmark suite
2634
1916
##############################################################################
2806
2078
copy_install_db("slave".($idx+1), $slave->[$idx]->{'path_myddir'});
2809
my $cluster_started_ok= 1; # Assume it can be started
2811
my $cluster= $clusters->[0]; # Master cluster
2812
if ($opt_skip_ndbcluster ||
2813
$cluster->{'use_running'} ||
2814
$cluster->{executable_setup_failed})
2816
# Don't install master cluster
2818
elsif (ndbcluster_start_install($cluster))
2820
mtr_warning("Failed to start install of $cluster->{name}");
2821
$cluster_started_ok= 0;
2824
$cluster= $clusters->[1]; # Slave cluster
2825
if ($max_slave_num == 0 ||
2826
$opt_skip_ndbcluster_slave ||
2827
$cluster->{'use_running'} ||
2828
$cluster->{executable_setup_failed})
2830
# Don't install slave cluster
2832
elsif (ndbcluster_start_install($cluster))
2834
mtr_warning("Failed to start install of $cluster->{name}");
2835
$cluster_started_ok= 0;
2838
foreach $cluster (@{$clusters})
2841
next if !$cluster->{'pid'};
2843
$cluster->{'installed_ok'}= 1; # Assume install suceeds
2845
if (ndbcluster_wait_started($cluster, ""))
2847
# failed to install, disable usage and flag that its no ok
2848
mtr_report("ndbcluster_install of $cluster->{'name'} failed");
2849
$cluster->{"installed_ok"}= 0;
2851
$cluster_started_ok= 0;
2855
if ( ! $cluster_started_ok )
2859
# Continue without cluster
2863
mtr_error("To continue, re-run with '--force'.");
2883
sub install_db ($$) {
2885
my $data_dir= shift;
2887
mtr_report("Installing \u$type Database");
2891
mtr_init_args(\$args);
2892
mtr_add_arg($args, "--no-defaults");
2893
mtr_add_arg($args, "--bootstrap");
2894
mtr_add_arg($args, "--basedir=%s", $path_my_basedir);
2895
mtr_add_arg($args, "--datadir=%s", $data_dir);
2896
mtr_add_arg($args, "--loose-skip-innodb");
2897
mtr_add_arg($args, "--tmpdir=.");
2898
mtr_add_arg($args, "--core-file");
2902
mtr_add_arg($args, "--debug=d:t:i:A,%s/log/bootstrap_%s.trace",
2903
$path_vardir_trace, $type);
2906
if ( ! $glob_netware )
2908
mtr_add_arg($args, "--language=%s", $path_language);
2909
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
2912
# If DISABLE_GRANT_OPTIONS is defined when the server is compiled (e.g.,
2913
# configure --disable-grant-options), mysqld will not recognize the
2914
# --bootstrap or --skip-grant-tables options. The user can set
2915
# MYSQLD_BOOTSTRAP to the full path to a mysqld which does accept
2916
# --bootstrap, to accommodate this.
2917
my $exe_mysqld_bootstrap = $ENV{'MYSQLD_BOOTSTRAP'} || $exe_mysqld;
2919
# ----------------------------------------------------------------------
2920
# export MYSQLD_BOOTSTRAP_CMD variable containing <path>/mysqld <args>
2921
# ----------------------------------------------------------------------
2922
$ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args);
2927
2098
# Restore snapshot of the installed slave databases
2928
2099
# if the snapshot exists
3586
2666
mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
3587
2667
# mtr_add_arg($args, "%s--rpl-recovery-rank=%d", $prefix, $slave_rpl_rank);
3590
my $cluster= $clusters->[$mysqld->{'cluster'}];
3591
if ( $cluster->{'pid'} || # Slave cluster is started
3592
$cluster->{'use_running'} ) # Using running slave cluster
3594
mtr_add_arg($args, "%s--ndbcluster", $prefix);
3595
mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
3596
$cluster->{'connect_string'});
3597
mtr_add_arg($args, "%s--ndb-wait-connected=20", $prefix);
3598
mtr_add_arg($args, "%s--ndb-cluster-connection-pool=3", $prefix);
3599
mtr_add_arg($args, "%s--slave-allow-batching", $prefix);
3600
if ( $mysql_version_id >= 50100 )
3602
mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
3603
mtr_add_arg($args, "%s--ndb-log-orig", $prefix);
3608
mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
3612
2671
if ( $opt_debug )