~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/mysql-test-run.pl

Merged from trunk. 
Moved resolve_stack_dump to mysql-test. 
Removed perl-sub cruft in mysql-test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
select(STDOUT);
74
74
$| = 1; # Automatically flush STDOUT
75
75
 
76
 
our $glob_win32_perl=  ($^O eq "MSWin32"); # ActiveState Win32 Perl
77
 
our $glob_cygwin_perl= ($^O eq "cygwin");  # Cygwin Perl
78
 
our $glob_win32=       ($glob_win32_perl or $glob_cygwin_perl);
79
 
our $glob_netware=     ($^O eq "NetWare"); # NetWare
80
 
 
81
76
require "lib/mtr_cases.pl";
82
77
require "lib/mtr_process.pl";
83
78
require "lib/mtr_timer.pl";
104
99
our $glob_mysql_bench_dir=        undef;
105
100
our $glob_scriptname=             undef;
106
101
our $glob_timers=                 undef;
107
 
our $glob_use_embedded_server=    0;
108
102
our @glob_test_mode;
109
103
 
110
104
our $glob_basedir;
151
145
our $exe_mysqlshow;
152
146
our $exe_mysql_fix_system_tables;
153
147
our $exe_mysqltest;
154
 
our $exe_ndbd;
155
 
our $exe_ndb_mgmd;
156
148
our $exe_slave_mysqld;
157
149
our $exe_my_print_defaults;
158
150
our $exe_perror;
170
162
our @opt_extra_mysqld_opt;
171
163
 
172
164
our $opt_compress;
173
 
our $opt_ssl;
174
 
our $opt_skip_ssl;
175
 
our $opt_ssl_supported;
176
 
our $opt_ps_protocol;
177
 
our $opt_sp_protocol;
178
 
our $opt_cursor_protocol;
179
 
our $opt_view_protocol;
180
165
 
181
166
our $opt_debug;
182
167
our $opt_do_test;
183
168
our @opt_cases;                  # The test cases names in argv
184
 
our $opt_embedded_server;
185
169
 
186
170
our $opt_extern= 0;
187
171
our $opt_socket;
219
203
 
220
204
our $opt_master_myport;
221
205
our $opt_slave_myport;
222
 
our $opt_ndbcluster_port;
223
 
our $opt_ndbconnectstring;
224
 
our $opt_ndbcluster_port_slave;
225
 
our $opt_ndbconnectstring_slave;
226
 
 
227
206
our $opt_record;
228
207
my $opt_report_features;
229
208
our $opt_check_testcases;
272
251
 
273
252
our $opt_warnings;
274
253
 
275
 
our $opt_skip_ndbcluster= 0;
276
 
our $opt_skip_ndbcluster_slave= 0;
277
 
our $opt_with_ndbcluster= 0;
278
 
our $opt_with_ndbcluster_only= 0;
279
 
our $glob_ndbcluster_supported= 0;
280
 
our $opt_ndb_extra_test= 0;
281
254
our $opt_skip_master_binlog= 0;
282
255
our $opt_skip_slave_binlog= 0;
283
256
 
284
 
our $exe_ndb_mgm;
285
 
our $exe_ndb_waiter;
286
 
our $path_ndb_tools_dir;
287
 
our $path_ndb_examples_dir;
288
 
our $exe_ndb_example;
289
 
our $path_ndb_testrun_log;
290
 
 
291
257
our $path_sql_dir;
292
258
 
293
259
our @data_dir_lst;
319
285
sub kill_running_servers ();
320
286
sub remove_stale_vardir ();
321
287
sub setup_vardir ();
322
 
sub check_ssl_support ($);
323
288
sub check_running_as_root();
324
 
sub check_ndbcluster_support ($);
325
 
sub rm_ndbcluster_tables ($);
326
 
sub ndbcluster_start_install ($);
327
 
sub ndbcluster_start ($$);
328
 
sub ndbcluster_wait_started ($$);
329
289
sub mysqld_wait_started($);
330
290
sub run_benchmarks ($);
331
291
sub initialize_servers ();
332
292
sub mysql_install_db ();
333
 
sub install_db ($$);
334
293
sub copy_install_db ($$);
335
294
sub run_testcase ($);
336
295
sub run_testcase_stop_servers ($$$);
339
298
sub report_failure_and_restart ($);
340
299
sub do_before_start_master ($);
341
300
sub do_before_start_slave ($);
342
 
sub ndbd_start ($$$);
343
 
sub ndb_mgmd_start ($);
344
301
sub mysqld_start ($$$);
345
302
sub mysqld_arguments ($$$$);
346
303
sub stop_all_servers ();
360
317
 
361
318
  command_line_setup();
362
319
 
363
 
  check_ndbcluster_support(\%mysqld_variables);
364
 
  check_ssl_support(\%mysqld_variables);
365
320
  check_debug_support(\%mysqld_variables);
366
321
 
367
322
  executable_setup();
397
352
      $opt_suites= $opt_suites_default;
398
353
 
399
354
      # Check for any extra suites to enable based on the path name
400
 
      my %extra_suites=
401
 
        (
402
 
         "mysql-5.1-new-ndb"              => "ndb_team",
403
 
         "mysql-5.1-new-ndb-merge"        => "ndb_team",
404
 
         "mysql-5.1-telco-6.2"            => "ndb_team",
405
 
         "mysql-5.1-telco-6.2-merge"      => "ndb_team",
406
 
         "mysql-5.1-telco-6.3"            => "ndb_team",
407
 
         "mysql-6.0-ndb"                  => "ndb_team",
408
 
        );
 
355
      my %extra_suites= ();
409
356
 
410
357
      foreach my $dir ( reverse splitdir($glob_basedir) )
411
358
      {
421
368
    my $tests= collect_test_cases($opt_suites);
422
369
 
423
370
    # Turn off NDB and other similar options if no tests use it
424
 
    my ($need_ndbcluster);
425
371
    foreach my $test (@$tests)
426
372
    {
427
373
      next if $test->{skip};
428
374
 
429
375
      if (!$opt_extern)
430
376
      {
431
 
        $need_ndbcluster||= $test->{ndb_test};
432
 
 
433
377
        # Count max number of slaves used by a test case
434
378
        if ( $test->{slave_num} > $max_slave_num) {
435
379
          $max_slave_num= $test->{slave_num};
446
390
      $use_innodb||= $test->{'innodb_test'};
447
391
    }
448
392
 
449
 
    # Check if cluster can be skipped
450
 
    if ( !$need_ndbcluster )
451
 
    {
452
 
      $opt_skip_ndbcluster= 1;
453
 
      $opt_skip_ndbcluster_slave= 1;
454
 
    }
455
 
 
456
 
    # Check if slave cluster can be skipped
457
 
    if ($max_slave_num == 0)
458
 
    {
459
 
      $opt_skip_ndbcluster_slave= 1;
460
 
    }
461
 
 
462
393
    initialize_servers();
463
394
 
464
395
    if ( $opt_report_features ) {
534
465
  Getopt::Long::Configure("pass_through");
535
466
  GetOptions(
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,
549
472
 
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,
568
486
             # Specify ports
569
487
             'master_port=i'            => \$opt_master_myport,
570
488
             'slave_port=i'             => \$opt_slave_myport,
571
 
             'ndbcluster-port|ndbcluster_port=i' => \$opt_ndbcluster_port,
572
 
             'ndbcluster-port-slave=i'  => \$opt_ndbcluster_port_slave,
573
489
             'mtr-build-thread=i'       => \$opt_mtr_build_thread,
574
490
 
575
491
             # Test case authoring
582
498
 
583
499
             # Run test on running server
584
500
             'extern'                   => \$opt_extern,
585
 
             'ndb-connectstring=s'       => \$opt_ndbconnectstring,
586
 
             'ndb-connectstring-slave=s' => \$opt_ndbconnectstring_slave,
587
501
 
588
502
             # Debugging
589
503
             'gdb'                      => \$opt_gdb,
692
606
 
693
607
  # Find the absolute path to the test directory
694
608
  $glob_mysql_test_dir=  cwd();
695
 
  if ( $glob_cygwin_perl )
696
 
  {
697
 
    # Windows programs like 'mysqld' needs Windows paths
698
 
    $glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`;
699
 
    chomp($glob_mysql_test_dir);
700
 
  }
701
609
  $default_vardir= "$glob_mysql_test_dir/var";
702
610
 
703
611
  # In most cases, the base directory we find everything relative to,
726
634
 
727
635
  $glob_timers= mtr_init_timers();
728
636
 
729
 
  # --------------------------------------------------------------------------
730
 
  # Embedded server flag
731
 
  # --------------------------------------------------------------------------
732
 
  if ( $opt_embedded_server )
733
 
  {
734
 
    $glob_use_embedded_server= 1;
735
 
    # Add the location for libmysqld.dll to the path.
736
 
    if ( $glob_win32 )
737
 
    {
738
 
      my $lib_mysqld=
739
 
        mtr_path_exists(vs_config_dirs('libmysqld',''));
740
 
          $lib_mysqld= $glob_cygwin_perl ? ":".`cygpath "$lib_mysqld"` 
741
 
                                     : ";".$lib_mysqld;
742
 
      chomp($lib_mysqld);
743
 
      $ENV{'PATH'}="$ENV{'PATH'}".$lib_mysqld;
744
 
    }
745
 
 
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
750
 
 
751
 
    # Turn off use of bin log
752
 
    push(@opt_extra_mysqld_opt, "--skip-log-bin");
753
 
 
754
 
    if ( $opt_extern )
755
 
    {
756
 
      mtr_error("Can't use --extern with --embedded-server");
757
 
    }
758
 
  }
759
 
 
760
637
  #
761
638
  # Find the mysqld executable to be able to find the mysqld version
762
639
  # number as early as possible
780
657
 
781
658
  if (!$opt_extern)
782
659
  {
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");
795
666
 
796
667
    # Use the mysqld found above to find out what features are available
797
668
    collect_mysqld_features();
857
728
  # --------------------------------------------------------------------------
858
729
  # Find out default storage engine being used(if any)
859
730
  # --------------------------------------------------------------------------
860
 
  if ( $opt_with_ndbcluster )
861
 
  {
862
 
    # --ndb or --with-ndbcluster turns on --default-storage-engine=ndbcluster
863
 
    push(@opt_extra_mysqld_opt, "--default-storage-engine=ndbcluster");
864
 
  }
865
 
 
866
731
  foreach my $arg ( @opt_extra_mysqld_opt )
867
732
  {
868
733
    if ( $arg =~ /default-storage-engine=(\S+)/ )
913
778
    # Version 4.1 and --vardir was specified
914
779
    # Only supported as a symlink from var/
915
780
    # by setting up $opt_mem that symlink will be created
916
 
    if ( ! $glob_win32 )
917
781
    {
918
782
      # Only platforms that have native symlinks can use the vardir trick
919
783
      $opt_mem= $opt_vardir;
928
792
  $path_vardir_trace=~ s/^\w://;
929
793
 
930
794
  # We make the path absolute, as the server will do a chdir() before usage
931
 
  unless ( $opt_vardir =~ m,^/, or
932
 
           ($glob_win32 and $opt_vardir =~ m,^[a-z]:/,i) )
 
795
  unless ( $opt_vardir =~ m,^/,)
933
796
  {
934
797
    # Make absolute path, relative test dir
935
798
    $opt_vardir= "$glob_mysql_test_dir/$opt_vardir";
955
818
  }
956
819
 
957
820
  # --------------------------------------------------------------------------
958
 
  # ps protcol flag
959
 
  # --------------------------------------------------------------------------
960
 
  if ( $opt_ps_protocol )
961
 
  {
962
 
    push(@glob_test_mode, "ps-protocol");
963
 
  }
964
 
 
965
 
  # --------------------------------------------------------------------------
966
821
  # Bench flags
967
822
  # --------------------------------------------------------------------------
968
823
  if ( $opt_small_bench )
1053
908
  {
1054
909
    $opt_testcase_timeout= $default_testcase_timeout;
1055
910
    $opt_testcase_timeout*= 10 if $opt_valgrind;
1056
 
    $opt_testcase_timeout*= 10 if ($opt_debug and $glob_win32);
1057
911
  }
1058
912
 
1059
913
  if ( ! $opt_suite_timeout )
1060
914
  {
1061
915
    $opt_suite_timeout= $default_suite_timeout;
1062
916
    $opt_suite_timeout*= 6 if $opt_valgrind;
1063
 
    $opt_suite_timeout*= 6 if ($opt_debug and $glob_win32);
1064
917
  }
1065
918
 
1066
919
  if ( ! $opt_user )
1163
1016
  };
1164
1017
 
1165
1018
 
1166
 
  my $data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port";
1167
 
  $clusters->[0]=
1168
 
  {
1169
 
   name            => "Master",
1170
 
   nodes           => 2,
1171
 
   port            => "$opt_ndbcluster_port",
1172
 
   data_dir        => "$data_dir",
1173
 
   connect_string  => "host=localhost:$opt_ndbcluster_port",
1174
 
   path_pid        => "$data_dir/ndb_3.pid", # Nodes + 1
1175
 
   pid             => 0, # pid of ndb_mgmd
1176
 
   installed_ok    => 0,
1177
 
  };
1178
 
 
1179
 
  $data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port_slave";
1180
 
  $clusters->[1]=
1181
 
  {
1182
 
   name            => "Slave",
1183
 
   nodes           => 1,
1184
 
   port            => "$opt_ndbcluster_port_slave",
1185
 
   data_dir        => "$data_dir",
1186
 
   connect_string  => "host=localhost:$opt_ndbcluster_port_slave",
1187
 
   path_pid        => "$data_dir/ndb_2.pid", # Nodes + 1
1188
 
   pid             => 0, # pid of ndb_mgmd
1189
 
   installed_ok    => 0,
1190
 
  };
1191
 
 
1192
 
  # Init pids of ndbd's
1193
 
  foreach my $cluster ( @{$clusters} )
1194
 
  {
1195
 
    for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ )
1196
 
    {
1197
 
      my $nodeid= $idx+1;
1198
 
      $cluster->{'ndbds'}->[$idx]=
1199
 
        {
1200
 
         pid      => 0,
1201
 
         nodeid => $nodeid,
1202
 
         path_pid => "$cluster->{'data_dir'}/ndb_${nodeid}.pid",
1203
 
         path_fs => "$cluster->{'data_dir'}/ndb_${nodeid}_fs",
1204
 
        };
1205
 
    }
1206
 
  }
1207
 
 
1208
1019
  # --------------------------------------------------------------------------
1209
1020
  # extern
1210
1021
  # --------------------------------------------------------------------------
1212
1023
  {
1213
1024
    # Turn off features not supported when running with extern server
1214
1025
    $opt_skip_rpl= 1;
1215
 
    $opt_skip_ndbcluster= 1;
1216
1026
    warn("Currenty broken --extern");
1217
1027
 
1218
1028
    # Setup master->[0] with the settings for the extern server
1226
1036
  }
1227
1037
 
1228
1038
 
1229
 
  # --------------------------------------------------------------------------
1230
 
  # ndbconnectstring and ndbconnectstring_slave
1231
 
  # --------------------------------------------------------------------------
1232
 
  if ( $opt_ndbconnectstring )
1233
 
  {
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;
1239
 
 
1240
 
    mtr_error("Can't specify --ndb-connectstring and --skip-ndbcluster")
1241
 
      if $opt_skip_ndbcluster;
1242
 
  }
1243
 
  $ENV{'NDB_CONNECTSTRING'}= $clusters->[0]->{'connect_string'};
1244
 
 
1245
 
 
1246
 
  if ( $opt_ndbconnectstring_slave )
1247
 
  {
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;
1253
 
 
1254
 
    mtr_error("Can't specify ndb-connectstring_slave and " .
1255
 
              "--skip-ndbcluster-slave")
1256
 
      if $opt_skip_ndbcluster_slave;
1257
 
  }
1258
 
 
1259
 
 
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";
1264
1042
 
1265
1043
  $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
1266
1044
 
1307
1085
  # A magic value in command_line_setup depends on these equations.
1308
1086
  $opt_master_myport=         $mtr_build_thread * 10 + 10000; # and 1
1309
1087
  $opt_slave_myport=          $opt_master_myport + 2;  # and 3 4
1310
 
  $opt_ndbcluster_port=       $opt_master_myport + 5;
1311
 
  $opt_ndbcluster_port_slave= $opt_master_myport + 6;
1312
1088
 
1313
1089
  if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 )
1314
1090
  {
1449
1225
  }
1450
1226
}
1451
1227
 
1452
 
 
1453
 
sub executable_setup_ndb () {
1454
 
 
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");
1459
 
 
1460
 
  $exe_ndbd=
1461
 
    mtr_exe_maybe_exists("$ndb_path/src/kernel/ndbd",
1462
 
                         "$ndb_path/ndbd");
1463
 
  $exe_ndb_mgm=
1464
 
    mtr_exe_maybe_exists("$ndb_path/src/mgmclient/ndb_mgm",
1465
 
                         "$ndb_path/ndb_mgm");
1466
 
  $exe_ndb_mgmd=
1467
 
    mtr_exe_maybe_exists("$ndb_path/src/mgmsrv/ndb_mgmd",
1468
 
                         "$ndb_path/ndb_mgmd");
1469
 
  $exe_ndb_waiter=
1470
 
    mtr_exe_maybe_exists("$ndb_path/tools/ndb_waiter",
1471
 
                         "$ndb_path/ndb_waiter");
1472
 
 
1473
 
  # May not exist
1474
 
  $path_ndb_tools_dir= mtr_file_exists("$ndb_path/tools",
1475
 
                                       "$ndb_path");
1476
 
  # May not exist
1477
 
  $path_ndb_examples_dir=
1478
 
    mtr_file_exists("$ndb_path/ndbapi-examples",
1479
 
                    "$ndb_path/examples");
1480
 
  # May not exist
1481
 
  $exe_ndb_example=
1482
 
    mtr_file_exists("$path_ndb_examples_dir/ndbapi_simple/ndbapi_simple");
1483
 
 
1484
 
  return ( $exe_ndbd eq "" or
1485
 
           $exe_ndb_mgm eq "" or
1486
 
           $exe_ndb_mgmd eq "" or
1487
 
           $exe_ndb_waiter eq "");
1488
 
}
1489
 
 
1490
1228
sub executable_setup () {
1491
1229
 
1492
 
  #
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
1497
 
  #
 
1230
#
 
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
 
1235
#
1498
1236
  if ( -x "../libtool")
1499
1237
  {
1500
1238
    $exe_libtool= "../libtool";
1504
1242
    }
1505
1243
  }
1506
1244
 
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");
1512
1250
 
1513
 
  # Look for perror
 
1251
# Look for perror
1514
1252
  $exe_perror= "perror";
1515
1253
 
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");
1524
1262
 
1525
1263
  if (!$opt_extern)
1526
1264
  {
1527
 
  # Look for SQL scripts directory
 
1265
# Look for SQL scripts directory
1528
1266
    if ( $mysql_version_id >= 50100 )
1529
1267
    {
1530
 
      $exe_mysqlslap=    mtr_exe_exists("$path_client_bindir/mysqlslap");
1531
 
    }
1532
 
 
1533
 
 
1534
 
    if ( ! $opt_skip_ndbcluster and executable_setup_ndb())
1535
 
    {
1536
 
      mtr_warning("Could not find all required ndb binaries, " .
1537
 
                "all ndb tests will fail, use --skip-ndbcluster to " .
1538
 
                "skip testing it.");
1539
 
 
1540
 
      foreach my $cluster (@{$clusters})
1541
 
      {
1542
 
        $cluster->{"executable_setup_failed"}= 1;
1543
 
      }
1544
 
    }
1545
 
 
1546
 
 
1547
 
    # Look for the udf_example library
1548
 
    $lib_udf_example=
1549
 
      mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'),
1550
 
                      "$glob_basedir/sql/.libs/udf_example.so",);
1551
 
 
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",);
1556
 
 
1557
 
  }
1558
 
 
1559
 
  # Look for mysqltest executable
1560
 
  if ( $glob_use_embedded_server )
1561
 
  {
1562
 
    $exe_mysqltest=
1563
 
      mtr_exe_exists(vs_config_dirs('libmysqld/examples','mysqltest_embedded'),
1564
 
                     "$glob_basedir/libmysqld/examples/mysqltest_embedded",
1565
 
                     "$path_client_bindir/mysqltest_embedded");
1566
 
  }
1567
 
  else
 
1268
      $exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap");
 
1269
    }
 
1270
  }
 
1271
 
 
1272
# Look for mysqltest executable
1568
1273
  {
1569
1274
    $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
1570
1275
  }
1571
1276
 
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 )
1575
 
  {
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");
1580
 
  }
1581
 
  else
 
1277
# Look for mysql_client_test executable which may _not_ exist in
 
1278
# some versions, test using it should be skipped
1582
1279
  {
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");
1587
1284
  }
1588
1285
 
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
1591
1288
  $exe_bug25714=
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");
1594
1291
}
1595
1292
 
1596
1293
 
 
1294
 
1597
1295
sub generate_cmdline_mysqldump ($) {
1598
1296
  my($mysqld) = @_;
1599
1297
  return
1637
1335
      "--debug=d:t:A,$path_vardir_trace/log/mysql_client_test.trace");
1638
1336
  }
1639
1337
 
1640
 
  if ( $glob_use_embedded_server )
1641
 
  {
1642
 
    mtr_add_arg($args,
1643
 
      " -A --language=$path_language");
1644
 
    mtr_add_arg($args,
1645
 
      " -A --datadir=$slave->[0]->{'path_myddir'}");
1646
 
    mtr_add_arg($args,
1647
 
      " -A --character-sets-dir=$path_charsetsdir");
1648
 
  }
1649
 
 
1650
1338
  return join(" ", $exe, @$args);
1651
1339
}
1652
1340
 
1674
1362
    push(@ld_library_paths, "$glob_basedir/lib");
1675
1363
  }
1676
1364
 
1677
 
 # --------------------------------------------------------------------------
1678
 
  # Add the path where libndbclient can be found
1679
 
  # --------------------------------------------------------------------------
1680
 
  if ( $glob_ndbcluster_supported )
1681
 
  {
1682
 
    push(@ld_library_paths,  "$glob_basedir/storage/ndb/src/.libs");
1683
 
  }
1684
 
 
1685
1365
  # --------------------------------------------------------------------------
1686
1366
  # Valgrind need to be run with debug libraries otherwise it's almost
1687
1367
  # impossible to add correct supressions, that means if "/usr/lib/debug"
1762
1442
 
1763
1443
  $ENV{'EXE_MYSQL'}=          $exe_mysql;
1764
1444
 
1765
 
 
1766
 
  # ----------------------------------------------------
1767
 
  # Setup env for NDB
1768
 
  # ----------------------------------------------------
1769
 
  if ( ! $opt_skip_ndbcluster )
1770
 
  {
1771
 
    $ENV{'NDB_MGM'}=                  $exe_ndb_mgm;
1772
 
 
1773
 
    $ENV{'NDBCLUSTER_PORT'}=          $opt_ndbcluster_port;
1774
 
    $ENV{'NDBCLUSTER_PORT_SLAVE'}=    $opt_ndbcluster_port_slave;
1775
 
 
1776
 
    $ENV{'NDB_EXTRA_TEST'}=           $opt_ndb_extra_test;
1777
 
 
1778
 
    $ENV{'NDB_BACKUP_DIR'}=           $clusters->[0]->{'data_dir'};
1779
 
    $ENV{'NDB_DATA_DIR'}=             $clusters->[0]->{'data_dir'};
1780
 
    $ENV{'NDB_TOOLS_DIR'}=            $path_ndb_tools_dir;
1781
 
    $ENV{'NDB_TOOLS_OUTPUT'}=         $path_ndb_testrun_log;
1782
 
 
1783
 
    if ( $mysql_version_id >= 50000 )
1784
 
    {
1785
 
      $ENV{'NDB_EXAMPLES_DIR'}=         $path_ndb_examples_dir;
1786
 
      $ENV{'MY_NDB_EXAMPLES_BINARY'}=   $exe_ndb_example;
1787
 
    }
1788
 
    $ENV{'NDB_EXAMPLES_OUTPUT'}=      $path_ndb_testrun_log;
1789
 
  }
1790
 
 
1791
1445
  # ----------------------------------------------------
1792
1446
  # Setup env so childs can execute mysqlcheck
1793
1447
  # ----------------------------------------------------
1912
1566
  # ----------------------------------------------------
1913
1567
  # Setup env so childs can execute mysql_fix_system_tables
1914
1568
  # ----------------------------------------------------
1915
 
  #if ( !$opt_extern && ! $glob_win32 )
 
1569
  #if ( !$opt_extern)
1916
1570
  if ( 0 )
1917
1571
  {
1918
1572
    my $cmdline_mysql_fix_system_tables=
1940
1594
  $ENV{'MY_PERROR'}= mtr_native_path($exe_perror);
1941
1595
 
1942
1596
  # ----------------------------------------------------
1943
 
  # Add the path where mysqld will find udf_example.so
1944
 
  # ----------------------------------------------------
1945
 
  $ENV{'UDF_EXAMPLE_LIB'}=
1946
 
    ($lib_udf_example ? basename($lib_udf_example) : "");
1947
 
  $ENV{'UDF_EXAMPLE_LIB_OPT'}=
1948
 
    ($lib_udf_example ? "--plugin_dir=" . dirname($lib_udf_example) : "");
1949
 
 
1950
 
  # ----------------------------------------------------
1951
1597
  # Add the path where mysqld will find ha_example.so
1952
1598
  # ----------------------------------------------------
1953
1599
  $ENV{'EXAMPLE_PLUGIN'}=
1982
1628
    print "Using SLAVE_MYPORT          = $ENV{SLAVE_MYPORT}\n";
1983
1629
    print "Using SLAVE_MYPORT1         = $ENV{SLAVE_MYPORT1}\n";
1984
1630
    print "Using SLAVE_MYPORT2         = $ENV{SLAVE_MYPORT2}\n";
1985
 
    if ( ! $opt_skip_ndbcluster )
1986
 
    {
1987
 
      print "Using NDBCLUSTER_PORT       = $ENV{NDBCLUSTER_PORT}\n";
1988
 
      if ( ! $opt_skip_ndbcluster_slave )
1989
 
      {
1990
 
        print "Using NDBCLUSTER_PORT_SLAVE = $ENV{NDBCLUSTER_PORT_SLAVE}\n";
1991
 
      }
1992
 
    }
1993
1631
  }
1994
1632
 
1995
1633
  # Create an environment variable to make it possible
2026
1664
##############################################################################
2027
1665
 
2028
1666
sub kill_running_servers () {
2029
 
 
2030
 
  if ( $opt_fast or $glob_use_embedded_server )
2031
 
  {
2032
 
    # FIXME is embedded server really using PID files?!
2033
 
    unlink($master->[0]->{'path_pid'});
2034
 
    unlink($master->[1]->{'path_pid'});
2035
 
    unlink($slave->[0]->{'path_pid'});
2036
 
    unlink($slave->[1]->{'path_pid'});
2037
 
    unlink($slave->[2]->{'path_pid'});
2038
 
  }
2039
 
  else
2040
1667
  {
2041
1668
    # Ensure that no old mysqld test servers are running
2042
1669
    # This is different from terminating processes we have
2194
1821
  }
2195
1822
 
2196
1823
  # Make a link std_data_ln in var/ that points to std_data
2197
 
  if ( ! $glob_win32 )
2198
 
  {
2199
 
    symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
2200
 
  }
2201
 
  else
2202
 
  {
2203
 
    # on windows, copy all files from std_data into var/std_data_ln
2204
 
    mkpath("$opt_vardir/std_data_ln");
2205
 
    opendir(DIR, "$glob_mysql_test_dir/std_data")
2206
 
      or mtr_error("Can't find the std_data directory: $!");
2207
 
    for(readdir(DIR)) {
2208
 
      next if -d "$glob_mysql_test_dir/std_data/$_";
2209
 
      copy("$glob_mysql_test_dir/std_data/$_", "$opt_vardir/std_data_ln/$_");
2210
 
    }
2211
 
    closedir(DIR);
2212
 
  }
 
1824
  symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
2213
1825
 
2214
1826
  # Remove old log files
2215
1827
  foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
2253
1865
}
2254
1866
 
2255
1867
 
2256
 
sub check_ssl_support ($) {
2257
 
  my $mysqld_variables= shift;
2258
 
 
2259
 
  if ($opt_skip_ssl || $opt_extern)
2260
 
  {
2261
 
    if (!$opt_extern)
2262
 
    {
2263
 
      mtr_report("Skipping SSL");
2264
 
    }
2265
 
    $opt_ssl_supported= 0;
2266
 
    $opt_ssl= 0;
2267
 
    return;
2268
 
  }
2269
 
 
2270
 
  if ( ! $mysqld_variables->{'ssl'} )
2271
 
  {
2272
 
    if ( $opt_ssl)
2273
 
    {
2274
 
      mtr_error("Couldn't find support for SSL");
2275
 
      return;
2276
 
    }
2277
 
    mtr_report("Skipping SSL, mysqld not compiled with SSL");
2278
 
    $opt_ssl_supported= 0;
2279
 
    $opt_ssl= 0;
2280
 
    return;
2281
 
  }
2282
 
  mtr_report("Setting mysqld to support SSL connections");
2283
 
  $opt_ssl_supported= 1;
2284
 
}
2285
 
 
2286
 
 
2287
1868
sub check_debug_support ($) {
2288
1869
  my $mysqld_variables= shift;
2289
1870
 
2330
1911
 
2331
1912
##############################################################################
2332
1913
#
2333
 
#  Start the ndb cluster
2334
 
#
2335
 
##############################################################################
2336
 
 
2337
 
sub check_ndbcluster_support ($) {
2338
 
  my $mysqld_variables= shift;
2339
 
 
2340
 
  if ($opt_skip_ndbcluster || $opt_extern)
2341
 
  {
2342
 
    if (!$opt_extern)
2343
 
    {
2344
 
      mtr_report("Skipping ndbcluster");
2345
 
    }
2346
 
    $opt_skip_ndbcluster_slave= 1;
2347
 
    return;
2348
 
  }
2349
 
 
2350
 
  if ( ! $mysqld_variables->{'ndb-connectstring'} )
2351
 
  {
2352
 
    mtr_report("Skipping ndbcluster, mysqld not compiled with ndbcluster");
2353
 
    $opt_skip_ndbcluster= 1;
2354
 
    $opt_skip_ndbcluster_slave= 1;
2355
 
    return;
2356
 
  }
2357
 
  $glob_ndbcluster_supported= 1;
2358
 
  mtr_report("Using ndbcluster when necessary, mysqld supports it");
2359
 
 
2360
 
  if ( $mysql_version_id < 50100 )
2361
 
  {
2362
 
    # Slave cluster is not supported until 5.1
2363
 
    $opt_skip_ndbcluster_slave= 1;
2364
 
 
2365
 
  }
2366
 
 
2367
 
  return;
2368
 
}
2369
 
 
2370
 
 
2371
 
sub ndbcluster_start_install ($) {
2372
 
  my $cluster= shift;
2373
 
 
2374
 
  mtr_report("Installing $cluster->{'name'} Cluster");
2375
 
 
2376
 
  mkdir($cluster->{'data_dir'});
2377
 
 
2378
 
  # Create a config file from template
2379
 
  my $ndb_no_ord=512;
2380
 
  my $ndb_no_attr=2048;
2381
 
  my $ndb_con_op=105000;
2382
 
  my $ndb_dmem="80M";
2383
 
  my $ndb_imem="24M";
2384
 
  my $ndb_pbmem="32M";
2385
 
  my $nodes= $cluster->{'nodes'};
2386
 
  my $ndb_host= "localhost";
2387
 
  my $ndb_diskless= 0;
2388
 
 
2389
 
  if (!$opt_bench)
2390
 
  {
2391
 
    # Use a smaller configuration
2392
 
    if (  $mysql_version_id < 50100 )
2393
 
    {
2394
 
      # 4.1 and 5.0 is using a "larger" --small configuration
2395
 
      $ndb_no_ord=128;
2396
 
      $ndb_con_op=10000;
2397
 
      $ndb_dmem="40M";
2398
 
      $ndb_imem="12M";
2399
 
    }
2400
 
    else
2401
 
    {
2402
 
      $ndb_no_ord=32;
2403
 
      $ndb_con_op=10000;
2404
 
      $ndb_dmem="20M";
2405
 
      $ndb_imem="1M";
2406
 
      $ndb_pbmem="4M";
2407
 
    }
2408
 
  }
2409
 
 
2410
 
  my $config_file_template=     "ndb/ndb_config_${nodes}_node.ini";
2411
 
  my $config_file= "$cluster->{'data_dir'}/config.ini";
2412
 
 
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: $!");
2417
 
  while (<IN>)
2418
 
  {
2419
 
    chomp;
2420
 
 
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 )
2431
 
    {
2432
 
      my $base_port= $cluster->{'port'} + 1;
2433
 
      s/CHOOSE_PORT_TRANSPORTER/$base_port/;
2434
 
    }
2435
 
    s/CHOOSE_DiskPageBufferMemory/$ndb_pbmem/;
2436
 
 
2437
 
    print OUT "$_ \n";
2438
 
  }
2439
 
  close OUT;
2440
 
  close IN;
2441
 
 
2442
 
 
2443
 
  # Start cluster with "--initial"
2444
 
 
2445
 
  ndbcluster_start($cluster, "--initial");
2446
 
 
2447
 
  return 0;
2448
 
}
2449
 
 
2450
 
 
2451
 
sub ndbcluster_wait_started($$){
2452
 
  my $cluster= shift;
2453
 
  my $ndb_waiter_extra_opt= shift;
2454
 
  my $path_waiter_log= "$cluster->{'data_dir'}/ndb_waiter.log";
2455
 
  my $args;
2456
 
 
2457
 
  mtr_init_args(\$args);
2458
 
 
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");
2463
 
 
2464
 
  if ($ndb_waiter_extra_opt)
2465
 
  {
2466
 
    mtr_add_arg($args, "$ndb_waiter_extra_opt");
2467
 
  }
2468
 
 
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;
2475
 
  return $res;
2476
 
}
2477
 
 
2478
 
 
2479
 
 
2480
 
sub mysqld_wait_started($){
2481
 
  my $mysqld= shift;
2482
 
 
2483
 
  if (sleep_until_file_created($mysqld->{'path_pid'},
2484
 
                               $mysqld->{'start_timeout'},
2485
 
                               $mysqld->{'pid'}) == 0)
2486
 
  {
2487
 
    # Failed to wait for pid file
2488
 
    return 1;
2489
 
  }
2490
 
 
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'});
2494
 
 
2495
 
  return 0;
2496
 
}
2497
 
 
2498
 
 
2499
 
sub ndb_mgmd_wait_started($) {
2500
 
  my ($cluster)= @_;
2501
 
 
2502
 
  my $retries= 100;
2503
 
  while (ndbcluster_wait_started($cluster, "--no-contact") and
2504
 
         $retries)
2505
 
  {
2506
 
    # Millisceond sleep emulated with select
2507
 
    select(undef, undef, undef, (0.1));
2508
 
 
2509
 
    $retries--;
2510
 
  }
2511
 
 
2512
 
  return $retries == 0;
2513
 
 
2514
 
}
2515
 
 
2516
 
sub ndb_mgmd_start ($) {
2517
 
  my $cluster= shift;
2518
 
 
2519
 
  my $args;                             # Arg vector
2520
 
  my $pid= -1;
2521
 
 
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");
2527
 
 
2528
 
 
2529
 
  my $path_ndb_mgmd_log= "$cluster->{'data_dir'}/\l$cluster->{'name'}_ndb_mgmd.log";
2530
 
  $pid= mtr_spawn($exe_ndb_mgmd, $args, "",
2531
 
                  $path_ndb_mgmd_log,
2532
 
                  $path_ndb_mgmd_log,
2533
 
                  "",
2534
 
                  { append_log_file => 1 });
2535
 
 
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))
2540
 
  {
2541
 
    mtr_error("Failed to wait for start of ndb_mgmd");
2542
 
  }
2543
 
 
2544
 
  # Remember pid of ndb_mgmd
2545
 
  $cluster->{'pid'}= $pid;
2546
 
 
2547
 
  mtr_verbose("ndb_mgmd_start, pid: $pid");
2548
 
 
2549
 
  return $pid;
2550
 
}
2551
 
 
2552
 
 
2553
 
sub ndbd_start ($$$) {
2554
 
  my $cluster= shift;
2555
 
  my $idx= shift;
2556
 
  my $extra_args= shift;
2557
 
 
2558
 
  my $args;                             # Arg vector
2559
 
  my $pid= -1;
2560
 
 
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)
2566
 
  {
2567
 
    mtr_add_arg($args, "--character-sets-dir=%s", "$path_charsetsdir");
2568
 
  }
2569
 
  mtr_add_arg($args, "--nodaemon");
2570
 
  mtr_add_arg($args, "$extra_args");
2571
 
 
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, "",
2575
 
                  $path_ndbd_log,
2576
 
                  $path_ndbd_log,
2577
 
                  "",
2578
 
                  { append_log_file => 1 });
2579
 
 
2580
 
  # Add pid to list of pids for this cluster
2581
 
  $cluster->{'ndbds'}->[$idx]->{'pid'}= $pid;
2582
 
 
2583
 
  # Rememeber options used when starting
2584
 
  $cluster->{'ndbds'}->[$idx]->{'start_extra_args'}= $extra_args;
2585
 
  $cluster->{'ndbds'}->[$idx]->{'idx'}= $idx;
2586
 
 
2587
 
  mtr_verbose("ndbd_start, pid: $pid");
2588
 
 
2589
 
  return $pid;
2590
 
}
2591
 
 
2592
 
 
2593
 
sub ndbcluster_start ($$) {
2594
 
  my $cluster= shift;
2595
 
  my $extra_args= shift;
2596
 
 
2597
 
  mtr_verbose("ndbcluster_start '$cluster->{'name'}'");
2598
 
 
2599
 
  if ( $cluster->{'use_running'} )
2600
 
  {
2601
 
    return 0;
2602
 
  }
2603
 
 
2604
 
  if ( $cluster->{'pid'} )
2605
 
  {
2606
 
    mtr_error("Cluster '$cluster->{'name'}' already started");
2607
 
  }
2608
 
 
2609
 
  ndb_mgmd_start($cluster);
2610
 
 
2611
 
  for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ )
2612
 
  {
2613
 
    ndbd_start($cluster, $idx, $extra_args);
2614
 
  }
2615
 
 
2616
 
  return 0;
2617
 
}
2618
 
 
2619
 
 
2620
 
sub rm_ndbcluster_tables ($) {
2621
 
  my $dir=       shift;
2622
 
  foreach my $bin ( glob("$dir/mysql/ndb_apply_status*"),
2623
 
                    glob("$dir/mysql/ndb_schema*"))
2624
 
  {
2625
 
    unlink($bin);
2626
 
  }
2627
 
}
2628
 
 
2629
 
 
2630
 
##############################################################################
2631
 
#
2632
1914
#  Run the benchmark suite
2633
1915
#
2634
1916
##############################################################################
2638
1920
 
2639
1921
  my $args;
2640
1922
 
2641
 
  if ( ! $glob_use_embedded_server )
2642
1923
  {
2643
1924
    mysqld_start($master->[0],[],[]);
2644
1925
    if ( ! $master->[0]->{'pid'} )
2657
1938
    mtr_add_arg($args, "--small-tables");
2658
1939
  }
2659
1940
 
2660
 
  if ( $opt_with_ndbcluster )
2661
 
  {
2662
 
    mtr_add_arg($args, "--create-options=TYPE=ndb");
2663
 
  }
2664
 
 
2665
1941
  chdir($glob_mysql_bench_dir)
2666
1942
    or mtr_error("Couldn't chdir to '$glob_mysql_bench_dir': $!");
2667
1943
 
2683
1959
 
2684
1960
  chdir($glob_mysql_test_dir);          # Go back
2685
1961
 
2686
 
  if ( ! $glob_use_embedded_server )
2687
1962
  {
2688
1963
    stop_masters();
2689
1964
  }
2722
1997
  mtr_print_line();
2723
1998
 
2724
1999
  if ( ! $glob_debugger and
2725
 
       ! $opt_extern and
2726
 
       ! $glob_use_embedded_server )
 
2000
       ! $opt_extern )
2727
2001
  {
2728
2002
    stop_all_servers();
2729
2003
  }
2793
2067
 
2794
2068
sub mysql_install_db () {
2795
2069
 
2796
 
  install_db('master', $master->[0]->{'path_myddir'});
2797
 
 
2798
2070
  if ($max_master_num > 1)
2799
2071
  {
2800
2072
    copy_install_db('master', $master->[1]->{'path_myddir'});
2806
2078
    copy_install_db("slave".($idx+1), $slave->[$idx]->{'path_myddir'});
2807
2079
  }
2808
2080
 
2809
 
  my $cluster_started_ok= 1; # Assume it can be started
2810
 
 
2811
 
  my $cluster= $clusters->[0]; # Master cluster
2812
 
  if ($opt_skip_ndbcluster ||
2813
 
      $cluster->{'use_running'} ||
2814
 
      $cluster->{executable_setup_failed})
2815
 
  {
2816
 
    # Don't install master cluster
2817
 
  }
2818
 
  elsif (ndbcluster_start_install($cluster))
2819
 
  {
2820
 
    mtr_warning("Failed to start install of $cluster->{name}");
2821
 
    $cluster_started_ok= 0;
2822
 
  }
2823
 
 
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})
2829
 
  {
2830
 
    # Don't install slave cluster
2831
 
  }
2832
 
  elsif (ndbcluster_start_install($cluster))
2833
 
  {
2834
 
    mtr_warning("Failed to start install of $cluster->{name}");
2835
 
    $cluster_started_ok= 0;
2836
 
  }
2837
 
 
2838
 
  foreach $cluster (@{$clusters})
2839
 
  {
2840
 
 
2841
 
    next if !$cluster->{'pid'};
2842
 
 
2843
 
    $cluster->{'installed_ok'}= 1; # Assume install suceeds
2844
 
 
2845
 
    if (ndbcluster_wait_started($cluster, ""))
2846
 
    {
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;
2850
 
 
2851
 
      $cluster_started_ok= 0;
2852
 
    }
2853
 
  }
2854
 
 
2855
 
  if ( ! $cluster_started_ok )
2856
 
  {
2857
 
    if ( $opt_force)
2858
 
    {
2859
 
      # Continue without cluster
2860
 
    }
2861
 
    else
2862
 
    {
2863
 
      mtr_error("To continue, re-run with '--force'.");
2864
 
    }
2865
 
  }
2866
 
 
2867
2081
  return 0;
2868
2082
}
2869
2083
 
2880
2094
}
2881
2095
 
2882
2096
 
2883
 
sub install_db ($$) {
2884
 
  my $type=      shift;
2885
 
  my $data_dir=  shift;
2886
 
 
2887
 
  mtr_report("Installing \u$type Database");
2888
 
 
2889
 
 
2890
 
  my $args;
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");
2899
 
 
2900
 
  if ( $opt_debug )
2901
 
  {
2902
 
    mtr_add_arg($args, "--debug=d:t:i:A,%s/log/bootstrap_%s.trace",
2903
 
                $path_vardir_trace, $type);
2904
 
  }
2905
 
 
2906
 
  if ( ! $glob_netware )
2907
 
  {
2908
 
    mtr_add_arg($args, "--language=%s", $path_language);
2909
 
    mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
2910
 
  }
2911
 
 
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;
2918
 
 
2919
 
  # ----------------------------------------------------------------------
2920
 
  # export MYSQLD_BOOTSTRAP_CMD variable containing <path>/mysqld <args>
2921
 
  # ----------------------------------------------------------------------
2922
 
  $ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args);
2923
 
}
2924
 
 
2925
 
 
2926
2097
#
2927
2098
# Restore snapshot of the installed slave databases
2928
2099
# if the snapshot exists
2961
2132
    return 1;
2962
2133
  }
2963
2134
 
2964
 
  if ($tinfo->{'ndb_test'})
2965
 
  {
2966
 
    foreach my $cluster (@{$clusters})
2967
 
    {
2968
 
      # Slave cluster is skipped and thus not
2969
 
      # installed, no need to perform checks
2970
 
      last if ($opt_skip_ndbcluster_slave and
2971
 
               $cluster->{'name'} eq 'Slave');
2972
 
 
2973
 
      # Using running cluster - no need
2974
 
      # to check if test should be skipped
2975
 
      # will be done by test itself
2976
 
      last if ($cluster->{'use_running'});
2977
 
 
2978
 
      # If test needs this cluster, check binaries was found ok
2979
 
      if ( $cluster->{'executable_setup_failed'} )
2980
 
      {
2981
 
        mtr_report_test_name($tinfo);
2982
 
        $tinfo->{comment}=
2983
 
          "Failed to find cluster binaries";
2984
 
        mtr_report_test_failed($tinfo);
2985
 
        return 1;
2986
 
      }
2987
 
 
2988
 
      # If test needs this cluster, check it was installed ok
2989
 
      if ( !$cluster->{'installed_ok'} )
2990
 
      {
2991
 
        mtr_report_test_name($tinfo);
2992
 
        $tinfo->{comment}=
2993
 
          "Cluster $cluster->{'name'} was not installed ok";
2994
 
        mtr_report_test_failed($tinfo);
2995
 
        return 1;
2996
 
      }
2997
 
 
2998
 
    }
2999
 
  }
3000
 
 
3001
2135
  return 0;
3002
2136
}
3003
2137
 
3017
2151
 
3018
2152
  if (!$opt_extern)
3019
2153
  {
3020
 
    if ( $mysql_version_id < 50000 ) {
3021
 
      # Set environment variable NDB_STATUS_OK to 1
3022
 
      # if script decided to run mysqltest cluster _is_ installed ok
3023
 
      $ENV{'NDB_STATUS_OK'} = "1";
3024
 
    } elsif ( $mysql_version_id < 50100 ) {
3025
 
      # Set environment variable NDB_STATUS_OK to YES
3026
 
      # if script decided to run mysqltest cluster _is_ installed ok
3027
 
      $ENV{'NDB_STATUS_OK'} = "YES";
3028
 
    }
3029
2154
    if (defined $tinfo->{binlog_format} and  $mysql_version_id > 50100 )
3030
2155
    {
3031
2156
      # Dynamically switch binlog format of
3077
2202
    mtr_tofile($mysqld->{path_myerr}, $log_msg);
3078
2203
  }
3079
2204
 
3080
 
  # ndbcluster log file
3081
 
  mtr_tofile($path_ndb_testrun_log, $log_msg);
3082
 
 
3083
2205
}
3084
2206
 
3085
2207
sub find_testcase_skipped_reason($)
3168
2290
      return 1;
3169
2291
    }
3170
2292
  }
3171
 
  elsif ($glob_use_embedded_server)
3172
 
  {
3173
 
    run_master_init_script($tinfo);
3174
 
  }
3175
 
 
3176
2293
  # ----------------------------------------------------------------------
3177
2294
  # If --start-and-exit or --start-dirty given, stop here to let user manually
3178
2295
  # run tests
3289
2406
      mtr_rmtree("$data_dir");
3290
2407
      mtr_copy_dir("$path_snapshot/$name", "$data_dir");
3291
2408
    }
3292
 
 
3293
 
    # Remove the ndb_*_fs dirs for all ndbd nodes
3294
 
    # forcing a clean start of ndb
3295
 
    foreach my $cluster (@{$clusters})
3296
 
    {
3297
 
      foreach my $ndbd (@{$cluster->{'ndbds'}})
3298
 
      {
3299
 
        mtr_rmtree("$ndbd->{'path_fs'}" );
3300
 
      }
3301
 
    }
3302
2409
  }
3303
2410
  else
3304
2411
  {
3327
2434
  mtr_report("Aborting: $tinfo->{'name'} failed in $test_mode mode. ");
3328
2435
  mtr_report("To continue, re-run with '--force'.");
3329
2436
  if ( ! $glob_debugger and
3330
 
       ! $opt_extern and
3331
 
       ! $glob_use_embedded_server )
 
2437
       ! $opt_extern )
3332
2438
  {
3333
2439
    stop_all_servers();
3334
2440
  }
3436
2542
  }
3437
2543
 
3438
2544
  my $prefix= "";               # If mysqltest server arg
3439
 
  if ( $glob_use_embedded_server )
3440
 
  {
3441
 
    $prefix= "--server-arg=";
3442
 
  }
3443
2545
 
3444
2546
  mtr_add_arg($args, "%s--no-defaults", $prefix);
3445
2547
 
3470
2572
  # When mysqld is run by a root user(euid is 0), it will fail
3471
2573
  # to start unless we specify what user to run as, see BUG#30630
3472
2574
  my $euid= $>;
3473
 
  if (!$glob_win32 and $euid == 0 and
3474
 
      grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt) == 0) {
 
2575
  if (grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt) == 0) {
3475
2576
    mtr_add_arg($args, "%s--user=root", $prefix);
3476
2577
  }
3477
2578
 
3518
2619
    {
3519
2620
      mtr_add_arg($args, "%s--loose-skip-innodb", $prefix);
3520
2621
    }
3521
 
 
3522
 
    my $cluster= $clusters->[$mysqld->{'cluster'}];
3523
 
    if ( $cluster->{'pid'} ||           # Cluster is started
3524
 
         $cluster->{'use_running'} )    # Using running cluster
3525
 
    {
3526
 
      mtr_add_arg($args, "%s--ndbcluster", $prefix);
3527
 
      mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
3528
 
                  $cluster->{'connect_string'});
3529
 
      mtr_add_arg($args, "%s--ndb-wait-connected=20", $prefix);
3530
 
      mtr_add_arg($args, "%s--ndb-cluster-connection-pool=3", $prefix);
3531
 
      mtr_add_arg($args, "%s--slave-allow-batching", $prefix);
3532
 
      if ( $mysql_version_id >= 50100 )
3533
 
      {
3534
 
        mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
3535
 
        mtr_add_arg($args, "%s--ndb-log-orig", $prefix);
3536
 
      }
3537
 
    }
3538
 
    else
3539
 
    {
3540
 
      mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
3541
 
    }
3542
2622
  }
3543
2623
  else
3544
2624
  {
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);
3588
2668
    }
3589
 
 
3590
 
   my $cluster= $clusters->[$mysqld->{'cluster'}];
3591
 
   if ( $cluster->{'pid'} ||         # Slave cluster is started
3592
 
        $cluster->{'use_running'} )  # Using running slave cluster
3593
 
    {
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 )
3601
 
      {
3602
 
        mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
3603
 
        mtr_add_arg($args, "%s--ndb-log-orig", $prefix);
3604
 
      }
3605
 
    }
3606
 
    else
3607
 
    {
3608
 
      mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
3609
 
    }
3610
2669
  } # end slave
3611
2670
 
3612
2671
  if ( $opt_debug )
3619
2678
  mtr_add_arg($args, "%s--sort_buffer=256K", $prefix);
3620
2679
  mtr_add_arg($args, "%s--max_heap_table_size=1M", $prefix);
3621
2680
 
3622
 
  if ( $opt_ssl_supported )
3623
 
  {
3624
 
    mtr_add_arg($args, "%s--ssl-ca=%s/std_data/cacert.pem", $prefix,
3625
 
                $glob_mysql_test_dir);
3626
 
    mtr_add_arg($args, "%s--ssl-cert=%s/std_data/server-cert.pem", $prefix,
3627
 
                $glob_mysql_test_dir);
3628
 
    mtr_add_arg($args, "%s--ssl-key=%s/std_data/server-key.pem", $prefix,
3629
 
                $glob_mysql_test_dir);
3630
 
  }
3631
 
 
3632
2681
  if ( $opt_warnings )
3633
2682
  {
3634
2683
    mtr_add_arg($args, "%s--log-warnings", $prefix);
3695
2744
  my $type= $mysqld->{'type'};
3696
2745
  my $idx= $mysqld->{'idx'};
3697
2746
 
3698
 
  mtr_error("Internal error: mysqld should never be started for embedded")
3699
 
    if $glob_use_embedded_server;
3700
 
 
3701
2747
  if ( $type eq 'master' )
3702
2748
  {
3703
2749
    $exe= $exe_master_mysqld;
3812
2858
    }
3813
2859
  }
3814
2860
 
3815
 
  # Start shutdown of clusters
3816
 
  foreach my $cluster (@{$clusters})
3817
 
  {
3818
 
    if ( $cluster->{'pid'} )
3819
 
    {
3820
 
      $pid= mtr_ndbmgm_start($cluster, "shutdown");
3821
 
      $admin_pids{$pid}= 1;
3822
 
 
3823
 
      push(@kill_pids,{
3824
 
                       pid      => $cluster->{'pid'},
3825
 
                       pidfile  => $cluster->{'path_pid'}
3826
 
                      });
3827
 
 
3828
 
      $cluster->{'pid'}= 0; # Assume we are done with it
3829
 
 
3830
 
      foreach my $ndbd (@{$cluster->{'ndbds'}})
3831
 
      {
3832
 
        if ( $ndbd->{'pid'} )
3833
 
        {
3834
 
          push(@kill_pids,{
3835
 
                           pid      => $ndbd->{'pid'},
3836
 
                           pidfile  => $ndbd->{'path_pid'},
3837
 
                          });
3838
 
          $ndbd->{'pid'}= 0;
3839
 
        }
3840
 
      }
3841
 
    }
3842
 
  }
3843
 
 
3844
2861
  # Wait blocking until all shutdown processes has completed
3845
2862
  mtr_wait_blocking(\%admin_pids);
3846
2863
 
3847
2864
  # Make sure that process has shutdown else try to kill them
3848
2865
  mtr_check_stop_servers(\@kill_pids);
3849
 
 
3850
 
  foreach my $mysqld (@{$master}, @{$slave})
3851
 
  {
3852
 
    rm_ndbcluster_tables($mysqld->{'path_myddir'});
3853
 
  }
3854
2866
}
3855
2867
 
3856
2868
 
3861
2873
  # We try to find out if we are to restart the master(s)
3862
2874
  my $do_restart= 0;          # Assumes we don't have to
3863
2875
 
3864
 
  if ( $glob_use_embedded_server )
3865
 
  {
3866
 
    mtr_verbose("Never start or restart for embedded server");
3867
 
    return $do_restart;
3868
 
  }
3869
 
  elsif ( $tinfo->{'master_sh'} )
 
2876
  if ( $tinfo->{'master_sh'} )
3870
2877
  {
3871
2878
    $do_restart= 1;           # Always restart if script to run
3872
2879
    mtr_verbose("Restart master: Always restart if script to run");
3876
2883
    $do_restart= 1; # Always restart if --force-restart in -opt file
3877
2884
    mtr_verbose("Restart master: Restart forced with --force-restart");
3878
2885
  }
3879
 
  elsif ( ! $opt_skip_ndbcluster and
3880
 
          !$tinfo->{'ndb_test'} and
3881
 
          $clusters->[0]->{'pid'} != 0 )
3882
 
  {
3883
 
    $do_restart= 1;           # Restart without cluster
3884
 
    mtr_verbose("Restart master: Test does not need cluster");
3885
 
  }
3886
 
  elsif ( ! $opt_skip_ndbcluster and
3887
 
          $tinfo->{'ndb_test'} and
3888
 
          $clusters->[0]->{'pid'} == 0 )
3889
 
  {
3890
 
    $do_restart= 1;           # Restart with cluster
3891
 
    mtr_verbose("Restart master: Test need cluster");
3892
 
  }
3893
2886
  elsif( $tinfo->{'component_id'} eq 'im' )
3894
2887
  {
3895
2888
    $do_restart= 1;
3944
2937
  # We try to find out if we are to restart the slaves
3945
2938
  my $do_slave_restart= 0;     # Assumes we don't have to
3946
2939
 
3947
 
  if ( $glob_use_embedded_server )
3948
 
  {
3949
 
    mtr_verbose("Never start or restart for embedded server");
3950
 
    return $do_slave_restart;
3951
 
  }
3952
 
  elsif ( $max_slave_num == 0)
 
2940
  if ( $max_slave_num == 0)
3953
2941
  {
3954
2942
    mtr_verbose("Skip slave restart: No testcase use slaves");
3955
2943
  }
4028
3016
        $mysqld->{'pid'}= 0; # Assume we are done with it
4029
3017
      }
4030
3018
    }
4031
 
 
4032
 
    # Start shutdown of master cluster
4033
 
    my $cluster= $clusters->[0];
4034
 
    if ( $cluster->{'pid'} )
4035
 
    {
4036
 
      $pid= mtr_ndbmgm_start($cluster, "shutdown");
4037
 
      $admin_pids{$pid}= 1;
4038
 
 
4039
 
      push(@kill_pids,{
4040
 
                       pid      => $cluster->{'pid'},
4041
 
                       pidfile  => $cluster->{'path_pid'}
4042
 
                      });
4043
 
 
4044
 
      $cluster->{'pid'}= 0; # Assume we are done with it
4045
 
 
4046
 
      foreach my $ndbd (@{$cluster->{'ndbds'}})
4047
 
      {
4048
 
        push(@kill_pids,{
4049
 
                         pid      => $ndbd->{'pid'},
4050
 
                         pidfile  => $ndbd->{'path_pid'},
4051
 
                        });
4052
 
        $ndbd->{'pid'}= 0; # Assume we are done with it
4053
 
      }
4054
 
    }
4055
3019
  }
4056
3020
 
4057
3021
  if ( $do_restart || $do_slave_restart )
4081
3045
        $mysqld->{'pid'}= 0; # Assume we are done with it
4082
3046
      }
4083
3047
    }
4084
 
 
4085
 
    # Start shutdown of slave cluster
4086
 
    my $cluster= $clusters->[1];
4087
 
    if ( $cluster->{'pid'} )
4088
 
    {
4089
 
      $pid= mtr_ndbmgm_start($cluster, "shutdown");
4090
 
 
4091
 
      $admin_pids{$pid}= 1;
4092
 
 
4093
 
      push(@kill_pids,{
4094
 
                       pid      => $cluster->{'pid'},
4095
 
                       pidfile  => $cluster->{'path_pid'}
4096
 
                      });
4097
 
 
4098
 
      $cluster->{'pid'}= 0; # Assume we are done with it
4099
 
 
4100
 
      foreach my $ndbd (@{$cluster->{'ndbds'}} )
4101
 
      {
4102
 
        push(@kill_pids,{
4103
 
                         pid      => $ndbd->{'pid'},
4104
 
                         pidfile  => $ndbd->{'path_pid'},
4105
 
                        });
4106
 
        $ndbd->{'pid'}= 0; # Assume we are done with it
4107
 
      }
4108
 
    }
4109
3048
  }
4110
3049
 
4111
3050
  # ----------------------------------------------------------------------
4119
3058
 
4120
3059
  # Make sure that process has shutdown else try to kill them
4121
3060
  mtr_check_stop_servers(\@kill_pids);
4122
 
 
4123
 
  foreach my $mysqld (@{$master}, @{$slave})
4124
 
  {
4125
 
    if ( ! $mysqld->{'pid'} )
4126
 
    {
4127
 
      # Remove ndbcluster tables if server is stopped
4128
 
      rm_ndbcluster_tables($mysqld->{'path_myddir'});
4129
 
    }
4130
 
  }
4131
3061
}
4132
3062
 
4133
3063
 
4147
3077
 
4148
3078
  if ( $tinfo->{'component_id'} eq 'mysqld' )
4149
3079
  {
4150
 
    if ( ! $opt_skip_ndbcluster and
4151
 
         !$clusters->[0]->{'pid'} and
4152
 
         $tinfo->{'ndb_test'} )
4153
 
    {
4154
 
      # Test need cluster, cluster is not started, start it
4155
 
      ndbcluster_start($clusters->[0], "");
4156
 
    }
4157
 
 
4158
3080
    if ( !$master->[0]->{'pid'} )
4159
3081
    {
4160
3082
      # Master mysqld is not started
4164
3086
 
4165
3087
    }
4166
3088
 
4167
 
    if ( $clusters->[0]->{'pid'} || $clusters->[0]->{'use_running'}
4168
 
         and ! $master->[1]->{'pid'} and
4169
 
         $tinfo->{'master_num'} > 1 )
4170
 
    {
4171
 
      # Test needs cluster, start an extra mysqld connected to cluster
4172
 
 
4173
 
      if ( $mysql_version_id >= 50100 )
4174
 
      {
4175
 
        # First wait for first mysql server to have created ndb system
4176
 
        # tables ok FIXME This is a workaround so that only one mysqld
4177
 
        # create the tables
4178
 
        if ( ! sleep_until_file_created(
4179
 
                  "$master->[0]->{'path_myddir'}/mysql/ndb_apply_status.ndb",
4180
 
                                        $master->[0]->{'start_timeout'},
4181
 
                                        $master->[0]->{'pid'}))
4182
 
        {
4183
 
 
4184
 
          $tinfo->{'comment'}= "Failed to create 'mysql/ndb_apply_status' table";
4185
 
          return 1;
4186
 
        }
4187
 
      }
4188
 
      mysqld_start($master->[1],$tinfo->{'master_opt'},[]);
4189
 
    }
4190
 
 
4191
3089
    # Save this test case information, so next can examine it
4192
3090
    $master->[0]->{'running_master_options'}= $tinfo;
4193
3091
  }
4201
3099
 
4202
3100
    do_before_start_slave($tinfo);
4203
3101
 
4204
 
    if ( ! $opt_skip_ndbcluster_slave and
4205
 
         !$clusters->[1]->{'pid'} and
4206
 
         $tinfo->{'ndb_test'} )
4207
 
    {
4208
 
      # Test need slave cluster, cluster is not started, start it
4209
 
      ndbcluster_start($clusters->[1], "");
4210
 
    }
4211
 
 
4212
3102
    for ( my $idx= 0; $idx <  $tinfo->{'slave_num'}; $idx++ )
4213
3103
    {
4214
3104
      if ( ! $slave->[$idx]->{'pid'} )
4223
3113
    $slave->[0]->{'running_slave_options'}= $tinfo;
4224
3114
  }
4225
3115
 
4226
 
  # Wait for clusters to start
4227
 
  foreach my $cluster (@{$clusters})
4228
 
  {
4229
 
 
4230
 
    next if !$cluster->{'pid'};
4231
 
 
4232
 
    if (ndbcluster_wait_started($cluster, ""))
4233
 
    {
4234
 
      # failed to start
4235
 
      $tinfo->{'comment'}= "Start of $cluster->{'name'} cluster failed";
4236
 
      return 1;
4237
 
    }
4238
 
  }
4239
 
 
4240
3116
  # Wait for mysqld's to start
4241
3117
  foreach my $mysqld (@{$master},@{$slave})
4242
3118
  {
4317
3193
sub run_report_features () {
4318
3194
  my $args;
4319
3195
 
4320
 
  if ( ! $glob_use_embedded_server )
4321
3196
  {
4322
3197
    mysqld_start($master->[0],[],[]);
4323
3198
    if ( ! $master->[0]->{'pid'} )
4340
3215
  $tinfo->{'comment'} = 'report server features';
4341
3216
  run_mysqltest($tinfo);
4342
3217
 
4343
 
  if ( ! $glob_use_embedded_server )
4344
3218
  {
4345
3219
    stop_all_servers();
4346
3220
  }
4371
3245
    mtr_add_arg($args, "--password=");
4372
3246
  }
4373
3247
 
4374
 
  if ( $opt_ps_protocol )
4375
 
  {
4376
 
    mtr_add_arg($args, "--ps-protocol");
4377
 
  }
4378
 
 
4379
 
  if ( $opt_sp_protocol )
4380
 
  {
4381
 
    mtr_add_arg($args, "--sp-protocol");
4382
 
  }
4383
 
 
4384
 
  if ( $opt_view_protocol )
4385
 
  {
4386
 
    mtr_add_arg($args, "--view-protocol");
4387
 
  }
4388
 
 
4389
 
  if ( $opt_cursor_protocol )
4390
 
  {
4391
 
    mtr_add_arg($args, "--cursor-protocol");
4392
 
  }
4393
 
 
4394
3248
  if ( $opt_strace_client )
4395
3249
  {
4396
3250
    $exe=  "strace";            # FIXME there are ktrace, ....
4420
3274
                $path_vardir_trace);
4421
3275
  }
4422
3276
 
4423
 
  if ( $opt_ssl_supported )
4424
 
  {
4425
 
    mtr_add_arg($args, "--ssl-ca=%s/std_data/cacert.pem",
4426
 
                $glob_mysql_test_dir);
4427
 
    mtr_add_arg($args, "--ssl-cert=%s/std_data/client-cert.pem",
4428
 
                $glob_mysql_test_dir);
4429
 
    mtr_add_arg($args, "--ssl-key=%s/std_data/client-key.pem",
4430
 
                $glob_mysql_test_dir);
4431
 
  }
4432
 
 
4433
 
  if ( $opt_ssl )
4434
 
  {
4435
 
    # Turn on SSL for _all_ test cases if option --ssl was used
4436
 
    mtr_add_arg($args, "--ssl");
4437
 
  }
4438
 
  elsif ( $opt_ssl_supported )
4439
 
  {
4440
 
    mtr_add_arg($args, "--skip-ssl");
4441
 
  }
4442
 
 
4443
 
  # ----------------------------------------------------------------------
4444
 
  # If embedded server, we create server args to give mysqltest to pass on
4445
 
  # ----------------------------------------------------------------------
4446
 
 
4447
 
  if ( $glob_use_embedded_server )
4448
 
  {
4449
 
    mysqld_arguments($args,$master->[0],$tinfo->{'master_opt'},[]);
4450
 
  }
4451
 
 
4452
3277
  # ----------------------------------------------------------------------
4453
3278
  # export MYSQL_TEST variable containing <path>/mysqltest <args>
4454
3279
  # ----------------------------------------------------------------------
4675
3500
    $$exe= $debugger;
4676
3501
 
4677
3502
  }
4678
 
  elsif ( $debugger =~ /windbg/ )
4679
 
  {
4680
 
    # windbg exe arg1 .. argn
4681
 
 
4682
 
    # Add name of the exe before args
4683
 
    unshift(@$$args, "$$exe");
4684
 
 
4685
 
    # Set exe to debuggername
4686
 
    $$exe= $debugger;
4687
 
 
4688
 
  }
4689
3503
  elsif ( $debugger eq "dbx" )
4690
3504
  {
4691
3505
    # xterm -e dbx -r exe arg1 .. argn
4744
3558
}
4745
3559
 
4746
3560
 
 
3561
sub mysqld_wait_started($){
 
3562
  my $mysqld= shift;
 
3563
 
 
3564
  if (sleep_until_file_created($mysqld->{'path_pid'},
 
3565
            $mysqld->{'start_timeout'},
 
3566
            $mysqld->{'pid'}) == 0)
 
3567
  {
 
3568
    # Failed to wait for pid file
 
3569
    return 1;
 
3570
  }
 
3571
 
 
3572
  # Get the "real pid" of the process, it will be used for killing
 
3573
  # the process in ActiveState's perl on windows
 
3574
  $mysqld->{'real_pid'}= mtr_get_pid_from_file($mysqld->{'path_pid'});
 
3575
 
 
3576
  return 0;
 
3577
}
 
3578
 
 
3579
 
4747
3580
##############################################################################
4748
3581
#
4749
3582
#  Usage
4764
3597
 
4765
3598
Options to control what engine/variation to run
4766
3599
 
4767
 
  embedded-server       Use the embedded server, i.e. no mysqld daemons
4768
3600
  ps-protocol           Use the binary protocol between client and server
4769
3601
  cursor-protocol       Use the cursor protocol between client and server
4770
3602
                        (implies --ps-protocol)
4771
3603
  view-protocol         Create a view to execute all non updating queries
4772
3604
  sp-protocol           Create a stored procedure to execute all queries
4773
3605
  compress              Use the compressed protocol between client and server
4774
 
  ssl                   Use ssl protocol between client and server
4775
 
  skip-ssl              Dont start server with support for ssl connections
4776
3606
  bench                 Run the benchmark suite
4777
3607
  small-bench           Run the benchmarks with --small-tests --small-tables
4778
 
  ndb|with-ndbcluster   Use cluster as default table type
4779
3608
  vs-config             Visual Studio configuration used to create executables
4780
3609
                        (default: MTR_VS_CONFIG environment variable)
4781
3610
 
4797
3626
Options to control what test suites or cases to run
4798
3627
 
4799
3628
  force                 Continue to run the suite after failure
4800
 
  with-ndbcluster-only  Run only tests that include "ndb" in the filename
4801
 
  skip-ndb[cluster]     Skip all tests that need cluster
4802
 
  skip-ndb[cluster]-slave Skip all tests that need a slave cluster
4803
 
  ndb-extra             Run extra tests from ndb directory
4804
3629
  do-test=PREFIX or REGEX
4805
3630
                        Run test cases which name are prefixed with PREFIX
4806
3631
                        or fulfills REGEX
4822
3647
 
4823
3648
  master_port=PORT      Specify the port number used by the first master
4824
3649
  slave_port=PORT       Specify the port number used by the first slave
4825
 
  ndbcluster-port=PORT  Specify the port number used by cluster
4826
 
  ndbcluster-port-slave=PORT  Specify the port number used by slave cluster
4827
3650
  mtr-build-thread=#    Specify unique collection of ports. Can also be set by
4828
3651
                        setting the environment variable MTR_BUILD_THREAD.
4829
3652
 
4840
3663
Options to run test on running server
4841
3664
 
4842
3665
  extern                Use running server for tests
4843
 
  ndb-connectstring=STR Use running cluster, and connect using STR
4844
 
  ndb-connectstring-slave=STR Use running slave cluster, and connect using STR
4845
3666
  user=USER             User for connection to extern server
4846
 
  socket=PATH           Socket for connection to extern server
4847
3667
 
4848
3668
Options for debugging the product
4849
3669
 
4903
3723
 
4904
3724
  sleep=SECONDS         Passed to mysqltest, will be used as fixed sleep time
4905
3725
 
4906
 
Deprecated options
4907
 
  with-openssl          Deprecated option for ssl
4908
 
 
4909
 
 
4910
3726
HERE
4911
3727
  mtr_exit(1);
4912
3728