457
534
Getopt::Long::Configure("pass_through");
459
536
# 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,
460
544
'compress' => \$opt_compress,
461
545
'bench' => \$opt_bench,
462
546
'small-bench' => \$opt_small_bench,
547
'with-ndbcluster|ndb' => \$opt_with_ndbcluster,
548
'vs-config' => \$opt_vs_config,
464
550
# Control what test suites or cases to run
465
551
'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,
466
557
'skip-master-binlog' => \$opt_skip_master_binlog,
467
558
'skip-slave-binlog' => \$opt_skip_slave_binlog,
468
559
'do-test=s' => \$opt_do_test,
627
727
$glob_timers= mtr_init_timers();
729
# --------------------------------------------------------------------------
730
# Embedded server flag
731
# --------------------------------------------------------------------------
732
if ( $opt_embedded_server )
734
$glob_use_embedded_server= 1;
735
# Add the location for libmysqld.dll to the path.
739
mtr_path_exists(vs_config_dirs('libmysqld',''));
740
$lib_mysqld= $glob_cygwin_perl ? ":".`cygpath "$lib_mysqld"`
743
$ENV{'PATH'}="$ENV{'PATH'}".$lib_mysqld;
746
push(@glob_test_mode, "embedded");
747
$opt_skip_rpl= 1; # We never run replication with embedded
748
$opt_skip_ndbcluster= 1; # Turn off use of NDB cluster
749
$opt_skip_ssl= 1; # Turn off use of SSL
751
# Turn off use of bin log
752
push(@opt_extra_mysqld_opt, "--skip-log-bin");
756
mtr_error("Can't use --extern with --embedded-server");
630
761
# Find the mysqld executable to be able to find the mysqld version
631
762
# number as early as possible
634
765
# Look for the client binaries directory
635
$path_client_bindir= mtr_path_exists("$glob_basedir/client",
766
$path_client_bindir= mtr_path_exists("$glob_basedir/client_release",
767
"$glob_basedir/client_debug",
768
vs_config_dirs('client', ''),
769
"$glob_basedir/client",
636
770
"$glob_basedir/bin");
772
# Look for language files and charsetsdir, use same share
773
$path_share= mtr_path_exists("$glob_basedir/share/mysql",
774
"$glob_basedir/sql/share",
775
"$glob_basedir/share");
777
$path_language= mtr_path_exists("$path_share/english");
778
$path_charsetsdir= mtr_path_exists("$path_share/charsets");
638
781
if (!$opt_extern)
640
$exe_drizzled= mtr_exe_exists ("$glob_basedir/drizzled/drizzled",
641
"$path_client_bindir/drizzled",
642
"$glob_basedir/libexec/drizzled",
643
"$glob_basedir/bin/drizzled",
644
"$glob_basedir/sbin/drizzled");
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");
646
796
# Use the mysqld found above to find out what features are available
647
797
collect_mysqld_features();
651
$mysqld_variables{'port'}= 4427;
656
$opt_engine= "innodb";
801
$mysqld_variables{'port'}= 3306;
659
804
if ( $opt_comment )
1023
$path_timefile= "$opt_vardir/log/drizzletest-time";
1024
$path_drizzletest_log= "$opt_vardir/log/drizzletest.log";
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
$path_timefile= "$opt_vardir/log/mysqltest-time";
1261
$path_mysqltest_log= "$opt_vardir/log/mysqltest.log";
1025
1262
$path_current_test_log= "$opt_vardir/log/current_test";
1263
$path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
1027
1265
$path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
1229
# Look for my_print_defaults
1507
# Look for my_print_defaults
1230
1508
$exe_my_print_defaults=
1232
"$path_client_bindir/my_print_defaults",
1233
"$glob_basedir/extra/my_print_defaults");
1509
mtr_exe_exists(vs_config_dirs('extra', 'my_print_defaults'),
1510
"$path_client_bindir/my_print_defaults",
1511
"$glob_basedir/extra/my_print_defaults");
1236
1514
$exe_perror= "perror";
1238
# Look for the client binaries
1239
$exe_drizzlecheck= mtr_exe_exists("$path_client_bindir/drizzlecheck");
1240
$exe_drizzledump= mtr_exe_exists("$path_client_bindir/drizzledump");
1241
$exe_drizzleimport= mtr_exe_exists("$path_client_bindir/drizzleimport");
1242
$exe_drizzleadmin= mtr_exe_exists("$path_client_bindir/drizzleadmin");
1243
$exe_drizzle= mtr_exe_exists("$path_client_bindir/drizzle");
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");
1523
$exe_mysql= mtr_exe_exists("$path_client_bindir/mysql");
1245
1525
if (!$opt_extern)
1247
# Look for SQL scripts directory
1248
if ( $mysql_version_id >= 50100 )
1250
$exe_drizzleslap= mtr_exe_exists("$path_client_bindir/drizzleslap");
1254
# Look for drizzletest executable
1256
$exe_drizzletest= mtr_exe_exists("$path_client_bindir/drizzletest");
1259
# Look for drizzle_client_test executable which may _not_ exist in
1260
# some versions, test using it should be skipped
1262
$exe_drizzle_client_test=
1527
# Look for SQL scripts directory
1528
if ( mtr_file_exists("$path_share/mysql_system_tables.sql") ne "")
1530
# The SQL scripts are in path_share
1531
$path_sql_dir= $path_share;
1535
$path_sql_dir= mtr_path_exists("$glob_basedir/share",
1536
"$glob_basedir/scripts");
1539
if ( $mysql_version_id >= 50100 )
1541
$exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap");
1545
if ( ! $opt_skip_ndbcluster and executable_setup_ndb())
1547
mtr_warning("Could not find all required ndb binaries, " .
1548
"all ndb tests will fail, use --skip-ndbcluster to " .
1549
"skip testing it.");
1551
foreach my $cluster (@{$clusters})
1553
$cluster->{"executable_setup_failed"}= 1;
1558
# Look for the udf_example library
1560
mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'),
1561
"$glob_basedir/sql/.libs/udf_example.so",);
1563
# Look for the ha_example library
1564
$lib_example_plugin=
1565
mtr_file_exists(vs_config_dirs('storage/example', 'ha_example.dll'),
1566
"$glob_basedir/storage/example/.libs/ha_example.so",);
1570
# Look for mysqltest executable
1571
if ( $glob_use_embedded_server )
1574
mtr_exe_exists(vs_config_dirs('libmysqld/examples','mysqltest_embedded'),
1575
"$glob_basedir/libmysqld/examples/mysqltest_embedded",
1576
"$path_client_bindir/mysqltest_embedded");
1580
$exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
1583
# Look for mysql_client_test executable which may _not_ exist in
1584
# some versions, test using it should be skipped
1585
if ( $glob_use_embedded_server )
1587
$exe_mysql_client_test=
1263
1588
mtr_exe_maybe_exists(
1264
"$glob_basedir/tests/drizzle_client_test",
1265
"$glob_basedir/bin/drizzle_client_test");
1589
vs_config_dirs('libmysqld/examples', 'mysql_client_test_embedded'),
1590
"$glob_basedir/libmysqld/examples/mysql_client_test_embedded");
1594
$exe_mysql_client_test=
1595
mtr_exe_maybe_exists(vs_config_dirs('tests', 'mysql_client_test'),
1596
"$glob_basedir/tests/mysql_client_test",
1597
"$glob_basedir/bin/mysql_client_test");
1268
# Look for bug25714 executable which may _not_ exist in
1269
# some versions, test using it should be skipped
1600
# Look for bug25714 executable which may _not_ exist in
1601
# some versions, test using it should be skipped
1271
mtr_exe_maybe_exists(
1272
"$glob_basedir/tests/bug25714");
1603
mtr_exe_maybe_exists(vs_config_dirs('tests', 'bug25714'),
1604
"$glob_basedir/tests/bug25714");
1277
1608
sub generate_cmdline_mysqldump ($) {
1278
1609
my($mysqld) = @_;
1280
mtr_native_path($exe_drizzledump) .
1611
mtr_native_path($exe_mysqldump) .
1281
1612
" --no-defaults -uroot --debug-check " .
1282
1613
"--port=$mysqld->{'port'} ";
1418
1767
$ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
1419
1768
$ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
1420
1769
$ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
1421
$ENV{'DRIZZLE_TCP_PORT'}= $mysqld_variables{'port'};
1770
$ENV{'MYSQL_TCP_PORT'}= $mysqld_variables{'port'};
1423
1772
$ENV{MTR_BUILD_THREAD}= $opt_mtr_build_thread;
1425
$ENV{'EXE_MYSQL'}= $exe_drizzle;
1774
$ENV{'EXE_MYSQL'}= $exe_mysql;
1777
# ----------------------------------------------------
1779
# ----------------------------------------------------
1780
if ( ! $opt_skip_ndbcluster )
1782
$ENV{'NDB_MGM'}= $exe_ndb_mgm;
1784
$ENV{'NDBCLUSTER_PORT'}= $opt_ndbcluster_port;
1785
$ENV{'NDBCLUSTER_PORT_SLAVE'}= $opt_ndbcluster_port_slave;
1787
$ENV{'NDB_EXTRA_TEST'}= $opt_ndb_extra_test;
1789
$ENV{'NDB_BACKUP_DIR'}= $clusters->[0]->{'data_dir'};
1790
$ENV{'NDB_DATA_DIR'}= $clusters->[0]->{'data_dir'};
1791
$ENV{'NDB_TOOLS_DIR'}= $path_ndb_tools_dir;
1792
$ENV{'NDB_TOOLS_OUTPUT'}= $path_ndb_testrun_log;
1794
if ( $mysql_version_id >= 50000 )
1796
$ENV{'NDB_EXAMPLES_DIR'}= $path_ndb_examples_dir;
1797
$ENV{'MY_NDB_EXAMPLES_BINARY'}= $exe_ndb_example;
1799
$ENV{'NDB_EXAMPLES_OUTPUT'}= $path_ndb_testrun_log;
1427
1802
# ----------------------------------------------------
1428
1803
# Setup env so childs can execute mysqlcheck
1429
1804
# ----------------------------------------------------
1430
1805
my $cmdline_mysqlcheck=
1431
mtr_native_path($exe_drizzlecheck) .
1806
mtr_native_path($exe_mysqlcheck) .
1432
1807
" --no-defaults --debug-check -uroot " .
1433
1808
"--port=$master->[0]->{'port'} ";
1488
1862
$cmdline_mysqlimport .=
1489
1863
" --debug=d:t:A,$path_vardir_trace/log/mysqlimport.trace";
1491
$ENV{'DRIZZLE_IMPORT'}= $cmdline_mysqlimport;
1865
$ENV{'MYSQL_IMPORT'}= $cmdline_mysqlimport;
1868
# ----------------------------------------------------
1869
# Setup env so childs can execute mysqlshow
1870
# ----------------------------------------------------
1871
my $cmdline_mysqlshow=
1872
mtr_native_path($exe_mysqlshow) .
1873
" -uroot --debug-check " .
1874
"--port=$master->[0]->{'port'} ";
1878
$cmdline_mysqlshow .=
1879
" --debug=d:t:A,$path_vardir_trace/log/mysqlshow.trace";
1881
$ENV{'MYSQL_SHOW'}= $cmdline_mysqlshow;
1883
# ----------------------------------------------------
1884
# Setup env so childs can execute mysqlbinlog
1885
# ----------------------------------------------------
1886
my $cmdline_mysqlbinlog=
1887
mtr_native_path($exe_mysqlbinlog) .
1888
" --no-defaults --disable-force-if-open --debug-check";
1889
if ( !$opt_extern && $mysql_version_id >= 50000 )
1891
$cmdline_mysqlbinlog .=" --character-sets-dir=$path_charsetsdir";
1896
$cmdline_mysqlbinlog .=
1897
" --debug=d:t:A,$path_vardir_trace/log/mysqlbinlog.trace";
1899
$ENV{'MYSQL_BINLOG'}= $cmdline_mysqlbinlog;
1494
1901
# ----------------------------------------------------
1495
1902
# Setup env so childs can execute mysql
1496
1903
# ----------------------------------------------------
1497
1904
my $cmdline_mysql=
1498
mtr_native_path($exe_drizzle) .
1905
mtr_native_path($exe_mysql) .
1499
1906
" --no-defaults --debug-check --host=localhost --user=root --password= " .
1500
"--port=$master->[0]->{'port'} ";
1907
"--port=$master->[0]->{'port'} " .
1908
"--character-sets-dir=$path_charsetsdir";
1502
1910
$ENV{'MYSQL'}= $cmdline_mysql;
1504
1912
# ----------------------------------------------------
1505
1913
# Setup env so childs can execute bug25714
1506
1914
# ----------------------------------------------------
1507
$ENV{'DRIZZLE_BUG25714'}= $exe_bug25714;
1915
$ENV{'MYSQL_BUG25714'}= $exe_bug25714;
1509
1917
# ----------------------------------------------------
1510
# Setup env so childs can execute drizzle_client_test
1918
# Setup env so childs can execute mysql_client_test
1511
1919
# ----------------------------------------------------
1512
$ENV{'DRIZZLE_CLIENT_TEST'}= drizzle_client_test_arguments();
1920
$ENV{'MYSQL_CLIENT_TEST'}= mysql_client_test_arguments();
1515
1923
# ----------------------------------------------------
1516
1924
# Setup env so childs can execute mysql_fix_system_tables
1517
1925
# ----------------------------------------------------
1926
#if ( !$opt_extern && ! $glob_win32 )
1521
1929
my $cmdline_mysql_fix_system_tables=
1522
"$exe_drizzle_fix_system_tables --no-defaults --host=localhost " .
1930
"$exe_mysql_fix_system_tables --no-defaults --host=localhost " .
1523
1931
"--user=root --password= " .
1524
1932
"--basedir=$glob_basedir --bindir=$path_client_bindir --verbose " .
1525
1933
"--port=$master->[0]->{'port'} ";
1526
$ENV{'DRIZZLE_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables;
1934
$ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables;
1530
1938
# ----------------------------------------------------
1531
1939
# Setup env so childs can execute my_print_defaults
1532
1940
# ----------------------------------------------------
1533
$ENV{'DRIZZLE_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
1941
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
1535
1943
# ----------------------------------------------------
1536
1944
# Setup env so childs can execute mysqladmin
1537
1945
# ----------------------------------------------------
1538
$ENV{'MYSQLADMIN'}= mtr_native_path($exe_drizzleadmin);
1946
$ENV{'MYSQLADMIN'}= mtr_native_path($exe_mysqladmin);
1540
1948
# ----------------------------------------------------
1541
1949
# Setup env so childs can execute perror
1828
2313
$debug_compiled_binaries= 1;
2316
##############################################################################
2318
# Helper function to handle configuration-based subdirectories which Visual
2319
# Studio uses for storing binaries. If opt_vs_config is set, this returns
2320
# a path based on that setting; if not, it returns paths for the default
2321
# /release/ and /debug/ subdirectories.
2323
# $exe can be undefined, if the directory itself will be used
2325
###############################################################################
2327
sub vs_config_dirs ($$) {
2328
my ($path_part, $exe) = @_;
2330
$exe = "" if not defined $exe;
2334
return ("$glob_basedir/$path_part/$opt_vs_config/$exe");
2337
return ("$glob_basedir/$path_part/release/$exe",
2338
"$glob_basedir/$path_part/relwithdebinfo/$exe",
2339
"$glob_basedir/$path_part/debug/$exe");
2342
##############################################################################
2344
# Start the ndb cluster
2346
##############################################################################
2348
sub check_ndbcluster_support ($) {
2349
my $mysqld_variables= shift;
2351
if ($opt_skip_ndbcluster || $opt_extern)
2355
mtr_report("Skipping ndbcluster");
2357
$opt_skip_ndbcluster_slave= 1;
2361
if ( ! $mysqld_variables->{'ndb-connectstring'} )
2363
mtr_report("Skipping ndbcluster, mysqld not compiled with ndbcluster");
2364
$opt_skip_ndbcluster= 1;
2365
$opt_skip_ndbcluster_slave= 1;
2368
$glob_ndbcluster_supported= 1;
2369
mtr_report("Using ndbcluster when necessary, mysqld supports it");
2371
if ( $mysql_version_id < 50100 )
2373
# Slave cluster is not supported until 5.1
2374
$opt_skip_ndbcluster_slave= 1;
2382
sub ndbcluster_start_install ($) {
2385
mtr_report("Installing $cluster->{'name'} Cluster");
2387
mkdir($cluster->{'data_dir'});
2389
# Create a config file from template
2391
my $ndb_no_attr=2048;
2392
my $ndb_con_op=105000;
2395
my $ndb_pbmem="32M";
2396
my $nodes= $cluster->{'nodes'};
2397
my $ndb_host= "localhost";
2398
my $ndb_diskless= 0;
2402
# Use a smaller configuration
2403
if ( $mysql_version_id < 50100 )
2405
# 4.1 and 5.0 is using a "larger" --small configuration
2421
my $config_file_template= "ndb/ndb_config_${nodes}_node.ini";
2422
my $config_file= "$cluster->{'data_dir'}/config.ini";
2424
open(IN, $config_file_template)
2425
or mtr_error("Can't open $config_file_template: $!");
2426
open(OUT, ">", $config_file)
2427
or mtr_error("Can't write to $config_file: $!");
2432
s/CHOOSE_MaxNoOfAttributes/$ndb_no_attr/;
2433
s/CHOOSE_MaxNoOfOrderedIndexes/$ndb_no_ord/;
2434
s/CHOOSE_MaxNoOfConcurrentOperations/$ndb_con_op/;
2435
s/CHOOSE_DataMemory/$ndb_dmem/;
2436
s/CHOOSE_IndexMemory/$ndb_imem/;
2437
s/CHOOSE_Diskless/$ndb_diskless/;
2438
s/CHOOSE_HOSTNAME_.*/$ndb_host/;
2439
s/CHOOSE_FILESYSTEM/$cluster->{'data_dir'}/;
2440
s/CHOOSE_PORT_MGM/$cluster->{'port'}/;
2441
if ( $mysql_version_id < 50000 )
2443
my $base_port= $cluster->{'port'} + 1;
2444
s/CHOOSE_PORT_TRANSPORTER/$base_port/;
2446
s/CHOOSE_DiskPageBufferMemory/$ndb_pbmem/;
2454
# Start cluster with "--initial"
2456
ndbcluster_start($cluster, "--initial");
2462
sub ndbcluster_wait_started($$){
2464
my $ndb_waiter_extra_opt= shift;
2465
my $path_waiter_log= "$cluster->{'data_dir'}/ndb_waiter.log";
2468
mtr_init_args(\$args);
2470
mtr_add_arg($args, "--no-defaults");
2471
mtr_add_arg($args, "--core");
2472
mtr_add_arg($args, "--ndb-connectstring=%s", $cluster->{'connect_string'});
2473
mtr_add_arg($args, "--timeout=60");
2475
if ($ndb_waiter_extra_opt)
2477
mtr_add_arg($args, "$ndb_waiter_extra_opt");
2480
# Start the ndb_waiter which will connect to the ndb_mgmd
2481
# and poll it for state of the ndbd's, will return when
2482
# all nodes in the cluster is started
2483
my $res= mtr_run($exe_ndb_waiter, $args,
2484
"", $path_waiter_log, $path_waiter_log, "");
2485
mtr_verbose("ndbcluster_wait_started, returns: $res") if $res;
2491
sub mysqld_wait_started($){
2494
if (sleep_until_file_created($mysqld->{'path_pid'},
2495
$mysqld->{'start_timeout'},
2496
$mysqld->{'pid'}) == 0)
2498
# Failed to wait for pid file
2502
# Get the "real pid" of the process, it will be used for killing
2503
# the process in ActiveState's perl on windows
2504
$mysqld->{'real_pid'}= mtr_get_pid_from_file($mysqld->{'path_pid'});
2510
sub ndb_mgmd_wait_started($) {
2514
while (ndbcluster_wait_started($cluster, "--no-contact") and
2517
# Millisceond sleep emulated with select
2518
select(undef, undef, undef, (0.1));
2523
return $retries == 0;
2527
sub ndb_mgmd_start ($) {
2530
my $args; # Arg vector
2533
mtr_init_args(\$args);
2534
mtr_add_arg($args, "--no-defaults");
2535
mtr_add_arg($args, "--core");
2536
mtr_add_arg($args, "--nodaemon");
2537
mtr_add_arg($args, "--config-file=%s", "$cluster->{'data_dir'}/config.ini");
2540
my $path_ndb_mgmd_log= "$cluster->{'data_dir'}/\l$cluster->{'name'}_ndb_mgmd.log";
2541
$pid= mtr_spawn($exe_ndb_mgmd, $args, "",
2545
{ append_log_file => 1 });
2547
# FIXME Should not be needed
2548
# Unfortunately the cluster nodes will fail to start
2549
# if ndb_mgmd has not started properly
2550
if (ndb_mgmd_wait_started($cluster))
2552
mtr_error("Failed to wait for start of ndb_mgmd");
2555
# Remember pid of ndb_mgmd
2556
$cluster->{'pid'}= $pid;
2558
mtr_verbose("ndb_mgmd_start, pid: $pid");
2564
sub ndbd_start ($$$) {
2567
my $extra_args= shift;
2569
my $args; # Arg vector
2572
mtr_init_args(\$args);
2573
mtr_add_arg($args, "--no-defaults");
2574
mtr_add_arg($args, "--core");
2575
mtr_add_arg($args, "--ndb-connectstring=%s", "$cluster->{'connect_string'}");
2576
if ( $mysql_version_id >= 50000)
2578
mtr_add_arg($args, "--character-sets-dir=%s", "$path_charsetsdir");
2580
mtr_add_arg($args, "--nodaemon");
2581
mtr_add_arg($args, "$extra_args");
2583
my $nodeid= $cluster->{'ndbds'}->[$idx]->{'nodeid'};
2584
my $path_ndbd_log= "$cluster->{'data_dir'}/ndb_${nodeid}.log";
2585
$pid= mtr_spawn($exe_ndbd, $args, "",
2589
{ append_log_file => 1 });
2591
# Add pid to list of pids for this cluster
2592
$cluster->{'ndbds'}->[$idx]->{'pid'}= $pid;
2594
# Rememeber options used when starting
2595
$cluster->{'ndbds'}->[$idx]->{'start_extra_args'}= $extra_args;
2596
$cluster->{'ndbds'}->[$idx]->{'idx'}= $idx;
2598
mtr_verbose("ndbd_start, pid: $pid");
2604
sub ndbcluster_start ($$) {
2606
my $extra_args= shift;
2608
mtr_verbose("ndbcluster_start '$cluster->{'name'}'");
2610
if ( $cluster->{'use_running'} )
2615
if ( $cluster->{'pid'} )
2617
mtr_error("Cluster '$cluster->{'name'}' already started");
2620
ndb_mgmd_start($cluster);
2622
for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ )
2624
ndbd_start($cluster, $idx, $extra_args);
2631
sub rm_ndbcluster_tables ($) {
2633
foreach my $bin ( glob("$dir/mysql/ndb_apply_status*"),
2634
glob("$dir/mysql/ndb_schema*"))
1832
2641
##############################################################################
1998
2817
copy_install_db("slave".($idx+1), $slave->[$idx]->{'path_myddir'});
2820
my $cluster_started_ok= 1; # Assume it can be started
2822
my $cluster= $clusters->[0]; # Master cluster
2823
if ($opt_skip_ndbcluster ||
2824
$cluster->{'use_running'} ||
2825
$cluster->{executable_setup_failed})
2827
# Don't install master cluster
2829
elsif (ndbcluster_start_install($cluster))
2831
mtr_warning("Failed to start install of $cluster->{name}");
2832
$cluster_started_ok= 0;
2835
$cluster= $clusters->[1]; # Slave cluster
2836
if ($max_slave_num == 0 ||
2837
$opt_skip_ndbcluster_slave ||
2838
$cluster->{'use_running'} ||
2839
$cluster->{executable_setup_failed})
2841
# Don't install slave cluster
2843
elsif (ndbcluster_start_install($cluster))
2845
mtr_warning("Failed to start install of $cluster->{name}");
2846
$cluster_started_ok= 0;
2849
foreach $cluster (@{$clusters})
2852
next if !$cluster->{'pid'};
2854
$cluster->{'installed_ok'}= 1; # Assume install suceeds
2856
if (ndbcluster_wait_started($cluster, ""))
2858
# failed to install, disable usage and flag that its no ok
2859
mtr_report("ndbcluster_install of $cluster->{'name'} failed");
2860
$cluster->{"installed_ok"}= 0;
2862
$cluster_started_ok= 0;
2866
if ( ! $cluster_started_ok )
2870
# Continue without cluster
2874
mtr_error("To continue, re-run with '--force'.");
2894
sub install_db ($$) {
2896
my $data_dir= shift;
2898
mtr_report("Installing \u$type Database");
2902
mtr_init_args(\$args);
2903
mtr_add_arg($args, "--no-defaults");
2904
mtr_add_arg($args, "--bootstrap");
2905
mtr_add_arg($args, "--basedir=%s", $path_my_basedir);
2906
mtr_add_arg($args, "--datadir=%s", $data_dir);
2907
mtr_add_arg($args, "--loose-skip-innodb");
2908
mtr_add_arg($args, "--tmpdir=.");
2909
mtr_add_arg($args, "--core-file");
2913
mtr_add_arg($args, "--debug=d:t:i:A,%s/log/bootstrap_%s.trace",
2914
$path_vardir_trace, $type);
2917
if ( ! $glob_netware )
2919
mtr_add_arg($args, "--language=%s", $path_language);
2920
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
2923
# If DISABLE_GRANT_OPTIONS is defined when the server is compiled (e.g.,
2924
# configure --disable-grant-options), mysqld will not recognize the
2925
# --bootstrap or --skip-grant-tables options. The user can set
2926
# MYSQLD_BOOTSTRAP to the full path to a mysqld which does accept
2927
# --bootstrap, to accommodate this.
2928
my $exe_mysqld_bootstrap = $ENV{'MYSQLD_BOOTSTRAP'} || $exe_mysqld;
2930
# ----------------------------------------------------------------------
2931
# export MYSQLD_BOOTSTRAP_CMD variable containing <path>/mysqld <args>
2932
# ----------------------------------------------------------------------
2933
$ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args);
2935
# ----------------------------------------------------------------------
2936
# Create the bootstrap.sql file
2937
# ----------------------------------------------------------------------
2938
my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql";
2940
# Use the mysql database for system tables
2941
mtr_tofile($bootstrap_sql_file, "use mysql");
2943
# Add the offical mysql system tables
2944
# for a production system
2945
mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables.sql",
2946
$bootstrap_sql_file);
2949
# Add test data for timezone - this is just a subset, on a real
2950
# system these tables will be populated either by mysql_tzinfo_to_sql
2951
# or by downloading the timezone table package from our website
2952
mtr_appendfile_to_file("$path_sql_dir/mysql_test_data_timezone.sql",
2953
$bootstrap_sql_file);
2955
# Remove anonymous users
2956
mtr_tofile($bootstrap_sql_file,
2957
"DELETE FROM mysql.user where user= '';");
2959
# Log bootstrap command
2960
my $path_bootstrap_log= "$opt_vardir/log/bootstrap.log";
2961
mtr_tofile($path_bootstrap_log,
2962
"$exe_mysqld_bootstrap " . join(" ", @$args) . "\n");
2965
if ( mtr_run($exe_mysqld_bootstrap, $args, $bootstrap_sql_file,
2966
$path_bootstrap_log, $path_bootstrap_log,
2967
"", { append_log_file => 1 }) != 0 )
2970
mtr_error("Error executing mysqld --bootstrap\n" .
2971
"Could not install system database from $bootstrap_sql_file\n" .
2972
"see $path_bootstrap_log for errors");
2018
2978
# Restore snapshot of the installed slave databases
2019
2979
# if the snapshot exists
3015
if ($tinfo->{'ndb_test'})
3017
foreach my $cluster (@{$clusters})
3019
# Slave cluster is skipped and thus not
3020
# installed, no need to perform checks
3021
last if ($opt_skip_ndbcluster_slave and
3022
$cluster->{'name'} eq 'Slave');
3024
# Using running cluster - no need
3025
# to check if test should be skipped
3026
# will be done by test itself
3027
last if ($cluster->{'use_running'});
3029
# If test needs this cluster, check binaries was found ok
3030
if ( $cluster->{'executable_setup_failed'} )
3032
mtr_report_test_name($tinfo);
3034
"Failed to find cluster binaries";
3035
mtr_report_test_failed($tinfo);
3039
# If test needs this cluster, check it was installed ok
3040
if ( !$cluster->{'installed_ok'} )
3042
mtr_report_test_name($tinfo);
3044
"Cluster $cluster->{'name'} was not installed ok";
3045
mtr_report_test_failed($tinfo);
2059
sub do_before_run_drizzletest($)
3056
sub do_before_run_mysqltest($)
2061
3058
my $tinfo= shift;
2064
# Remove old files produced by drizzletest
3061
# Remove old files produced by mysqltest
2065
3062
my $base_file= mtr_match_extension($tinfo->{'result_file'},
2066
3063
"result"); # Trim extension
2067
3064
unlink("$base_file.reject");
3177
4468
if ( $opt_debug )
3179
mtr_add_arg($args, "--debug=d:t:A,%s/log/drizzletest.trace",
4470
mtr_add_arg($args, "--debug=d:t:A,%s/log/mysqltest.trace",
3180
4471
$path_vardir_trace);
3183
# ----------------------------------------------------------------------
3184
# export DRIZZLE_TEST variable containing <path>/drizzletest <args>
3185
# ----------------------------------------------------------------------
3186
$ENV{'DRIZZLE_TEST'}=
3187
mtr_native_path($exe_drizzletest) . " " . join(" ", @$args);
3189
# ----------------------------------------------------------------------
3190
# Add arguments that should not go into the DRIZZLE_TEST env var
3191
# ----------------------------------------------------------------------
3193
if ( $opt_valgrind_drizzletest )
4474
if ( $opt_ssl_supported )
4476
mtr_add_arg($args, "--ssl-ca=%s/std_data/cacert.pem",
4477
$glob_mysql_test_dir);
4478
mtr_add_arg($args, "--ssl-cert=%s/std_data/client-cert.pem",
4479
$glob_mysql_test_dir);
4480
mtr_add_arg($args, "--ssl-key=%s/std_data/client-key.pem",
4481
$glob_mysql_test_dir);
4486
# Turn on SSL for _all_ test cases if option --ssl was used
4487
mtr_add_arg($args, "--ssl");
4489
elsif ( $opt_ssl_supported )
4491
mtr_add_arg($args, "--skip-ssl");
4494
# ----------------------------------------------------------------------
4495
# If embedded server, we create server args to give mysqltest to pass on
4496
# ----------------------------------------------------------------------
4498
if ( $glob_use_embedded_server )
4500
mysqld_arguments($args,$master->[0],$tinfo->{'master_opt'},[]);
4503
# ----------------------------------------------------------------------
4504
# export MYSQL_TEST variable containing <path>/mysqltest <args>
4505
# ----------------------------------------------------------------------
4507
mtr_native_path($exe_mysqltest) . " " . join(" ", @$args);
4509
# ----------------------------------------------------------------------
4510
# Add arguments that should not go into the MYSQL_TEST env var
4511
# ----------------------------------------------------------------------
4513
if ( $opt_valgrind_mysqltest )
3195
4515
# Prefix the Valgrind options to the argument list.
3196
4516
# We do this here, since we do not want to Valgrind the nested invocations
3197
# of drizzletest; that would mess up the stderr output causing test failure.
4517
# of mysqltest; that would mess up the stderr output causing test failure.
3198
4518
my @args_saved = @$args;
3199
4519
mtr_init_args(\$args);
3200
4520
valgrind_arguments($args, \$exe);