~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2008-07-07 22:22:20 UTC
  • Revision ID: brian@tangent.org-20080707222220-zhd4bs2ob43wvpqv
More cleanup in mysql-test-run

Show diffs side-by-side

added added

removed removed

Lines of Context:
149
149
our $exe_mysqlshow;
150
150
our $exe_mysql_fix_system_tables;
151
151
our $exe_mysqltest;
152
 
our $exe_ndbd;
153
 
our $exe_ndb_mgmd;
154
152
our $exe_slave_mysqld;
155
153
our $exe_my_print_defaults;
156
154
our $exe_perror;
168
166
our @opt_extra_mysqld_opt;
169
167
 
170
168
our $opt_compress;
171
 
our $opt_ssl;
172
 
our $opt_skip_ssl;
173
 
our $opt_ssl_supported;
174
169
our $opt_ps_protocol;
175
170
our $opt_sp_protocol;
176
171
our $opt_cursor_protocol;
217
212
 
218
213
our $opt_master_myport;
219
214
our $opt_slave_myport;
220
 
our $opt_ndbcluster_port;
221
 
our $opt_ndbconnectstring;
222
 
our $opt_ndbcluster_port_slave;
223
 
our $opt_ndbconnectstring_slave;
224
 
 
225
215
our $opt_record;
226
216
my $opt_report_features;
227
217
our $opt_check_testcases;
270
260
 
271
261
our $opt_warnings;
272
262
 
273
 
our $opt_skip_ndbcluster= 0;
274
 
our $opt_skip_ndbcluster_slave= 0;
275
 
our $opt_with_ndbcluster= 0;
276
 
our $opt_with_ndbcluster_only= 0;
277
 
our $glob_ndbcluster_supported= 0;
278
 
our $opt_ndb_extra_test= 0;
279
263
our $opt_skip_master_binlog= 0;
280
264
our $opt_skip_slave_binlog= 0;
281
265
 
282
 
our $exe_ndb_mgm;
283
 
our $exe_ndb_waiter;
284
 
our $path_ndb_tools_dir;
285
 
our $path_ndb_examples_dir;
286
 
our $exe_ndb_example;
287
 
our $path_ndb_testrun_log;
288
 
 
289
266
our $path_sql_dir;
290
267
 
291
268
our @data_dir_lst;
317
294
sub kill_running_servers ();
318
295
sub remove_stale_vardir ();
319
296
sub setup_vardir ();
320
 
sub check_ssl_support ($);
321
297
sub check_running_as_root();
322
 
sub check_ndbcluster_support ($);
323
 
sub rm_ndbcluster_tables ($);
324
 
sub ndbcluster_start_install ($);
325
 
sub ndbcluster_start ($$);
326
 
sub ndbcluster_wait_started ($$);
327
298
sub mysqld_wait_started($);
328
299
sub run_benchmarks ($);
329
300
sub initialize_servers ();
337
308
sub report_failure_and_restart ($);
338
309
sub do_before_start_master ($);
339
310
sub do_before_start_slave ($);
340
 
sub ndbd_start ($$$);
341
 
sub ndb_mgmd_start ($);
342
311
sub mysqld_start ($$$);
343
312
sub mysqld_arguments ($$$$);
344
313
sub stop_all_servers ();
393
362
      $opt_suites= $opt_suites_default;
394
363
 
395
364
      # Check for any extra suites to enable based on the path name
396
 
      my %extra_suites=
397
 
        (
398
 
         "mysql-5.1-new-ndb"              => "ndb_team",
399
 
         "mysql-5.1-new-ndb-merge"        => "ndb_team",
400
 
         "mysql-5.1-telco-6.2"            => "ndb_team",
401
 
         "mysql-5.1-telco-6.2-merge"      => "ndb_team",
402
 
         "mysql-5.1-telco-6.3"            => "ndb_team",
403
 
         "mysql-6.0-ndb"                  => "ndb_team",
404
 
        );
 
365
      my %extra_suites= ();
405
366
 
406
367
      foreach my $dir ( reverse splitdir($glob_basedir) )
407
368
      {
417
378
    my $tests= collect_test_cases($opt_suites);
418
379
 
419
380
    # Turn off NDB and other similar options if no tests use it
420
 
    my ($need_ndbcluster);
421
381
    foreach my $test (@$tests)
422
382
    {
423
383
      next if $test->{skip};
424
384
 
425
385
      if (!$opt_extern)
426
386
      {
427
 
        $need_ndbcluster||= $test->{ndb_test};
428
 
 
429
387
        # Count max number of slaves used by a test case
430
388
        if ( $test->{slave_num} > $max_slave_num) {
431
389
          $max_slave_num= $test->{slave_num};
442
400
      $use_innodb||= $test->{'innodb_test'};
443
401
    }
444
402
 
445
 
    # Check if cluster can be skipped
446
 
    if ( !$need_ndbcluster )
447
 
    {
448
 
      $opt_skip_ndbcluster= 1;
449
 
      $opt_skip_ndbcluster_slave= 1;
450
 
    }
451
 
 
452
 
    # Check if slave cluster can be skipped
453
 
    if ($max_slave_num == 0)
454
 
    {
455
 
      $opt_skip_ndbcluster_slave= 1;
456
 
    }
457
 
 
458
403
    initialize_servers();
459
404
 
460
405
    if ( $opt_report_features ) {
535
480
             'sp-protocol'              => \$opt_sp_protocol,
536
481
             'view-protocol'            => \$opt_view_protocol,
537
482
             'cursor-protocol'          => \$opt_cursor_protocol,
538
 
             'ssl|with-openssl'         => \$opt_ssl,
539
 
             'skip-ssl'                 => \$opt_skip_ssl,
540
483
             'compress'                 => \$opt_compress,
541
484
             'bench'                    => \$opt_bench,
542
485
             'small-bench'              => \$opt_small_bench,
543
 
             'with-ndbcluster|ndb'      => \$opt_with_ndbcluster,
544
486
             'vs-config'            => \$opt_vs_config,
545
487
 
546
488
             # Control what test suites or cases to run
547
489
             'force'                    => \$opt_force,
548
 
             'with-ndbcluster-only'     => \$opt_with_ndbcluster_only,
549
 
             'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster,
550
 
             'skip-ndbcluster-slave|skip-ndb-slave'
551
 
                                        => \$opt_skip_ndbcluster_slave,
552
 
             'ndb-extra-test'           => \$opt_ndb_extra_test,
553
490
             'skip-master-binlog'       => \$opt_skip_master_binlog,
554
491
             'skip-slave-binlog'        => \$opt_skip_slave_binlog,
555
492
             'do-test=s'                => \$opt_do_test,
564
501
             # Specify ports
565
502
             'master_port=i'            => \$opt_master_myport,
566
503
             'slave_port=i'             => \$opt_slave_myport,
567
 
             'ndbcluster-port|ndbcluster_port=i' => \$opt_ndbcluster_port,
568
 
             'ndbcluster-port-slave=i'  => \$opt_ndbcluster_port_slave,
569
504
             'mtr-build-thread=i'       => \$opt_mtr_build_thread,
570
505
 
571
506
             # Test case authoring
578
513
 
579
514
             # Run test on running server
580
515
             'extern'                   => \$opt_extern,
581
 
             'ndb-connectstring=s'       => \$opt_ndbconnectstring,
582
 
             'ndb-connectstring-slave=s' => \$opt_ndbconnectstring_slave,
583
516
 
584
517
             # Debugging
585
518
             'gdb'                      => \$opt_gdb,
816
749
  # --------------------------------------------------------------------------
817
750
  # Find out default storage engine being used(if any)
818
751
  # --------------------------------------------------------------------------
819
 
  if ( $opt_with_ndbcluster )
820
 
  {
821
 
    # --ndb or --with-ndbcluster turns on --default-storage-engine=ndbcluster
822
 
    push(@opt_extra_mysqld_opt, "--default-storage-engine=ndbcluster");
823
 
  }
824
 
 
825
752
  foreach my $arg ( @opt_extra_mysqld_opt )
826
753
  {
827
754
    if ( $arg =~ /default-storage-engine=(\S+)/ )
1118
1045
  };
1119
1046
 
1120
1047
 
1121
 
  my $data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port";
1122
 
  $clusters->[0]=
1123
 
  {
1124
 
   name            => "Master",
1125
 
   nodes           => 2,
1126
 
   port            => "$opt_ndbcluster_port",
1127
 
   data_dir        => "$data_dir",
1128
 
   connect_string  => "host=localhost:$opt_ndbcluster_port",
1129
 
   path_pid        => "$data_dir/ndb_3.pid", # Nodes + 1
1130
 
   pid             => 0, # pid of ndb_mgmd
1131
 
   installed_ok    => 0,
1132
 
  };
1133
 
 
1134
 
  $data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port_slave";
1135
 
  $clusters->[1]=
1136
 
  {
1137
 
   name            => "Slave",
1138
 
   nodes           => 1,
1139
 
   port            => "$opt_ndbcluster_port_slave",
1140
 
   data_dir        => "$data_dir",
1141
 
   connect_string  => "host=localhost:$opt_ndbcluster_port_slave",
1142
 
   path_pid        => "$data_dir/ndb_2.pid", # Nodes + 1
1143
 
   pid             => 0, # pid of ndb_mgmd
1144
 
   installed_ok    => 0,
1145
 
  };
1146
 
 
1147
 
  # Init pids of ndbd's
1148
 
  foreach my $cluster ( @{$clusters} )
1149
 
  {
1150
 
    for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ )
1151
 
    {
1152
 
      my $nodeid= $idx+1;
1153
 
      $cluster->{'ndbds'}->[$idx]=
1154
 
        {
1155
 
         pid      => 0,
1156
 
         nodeid => $nodeid,
1157
 
         path_pid => "$cluster->{'data_dir'}/ndb_${nodeid}.pid",
1158
 
         path_fs => "$cluster->{'data_dir'}/ndb_${nodeid}_fs",
1159
 
        };
1160
 
    }
1161
 
  }
1162
 
 
1163
1048
  # --------------------------------------------------------------------------
1164
1049
  # extern
1165
1050
  # --------------------------------------------------------------------------
1167
1052
  {
1168
1053
    # Turn off features not supported when running with extern server
1169
1054
    $opt_skip_rpl= 1;
1170
 
    $opt_skip_ndbcluster= 1;
1171
1055
    warn("Currenty broken --extern");
1172
1056
 
1173
1057
    # Setup master->[0] with the settings for the extern server
1181
1065
  }
1182
1066
 
1183
1067
 
1184
 
  # --------------------------------------------------------------------------
1185
 
  # ndbconnectstring and ndbconnectstring_slave
1186
 
  # --------------------------------------------------------------------------
1187
 
  if ( $opt_ndbconnectstring )
1188
 
  {
1189
 
    # ndbconnectstring was supplied by user, the tests shoudl be run
1190
 
    # against an already started cluster, change settings
1191
 
    my $cluster= $clusters->[0]; # Master cluster
1192
 
    $cluster->{'connect_string'}= $opt_ndbconnectstring;
1193
 
    $cluster->{'use_running'}= 1;
1194
 
 
1195
 
    mtr_error("Can't specify --ndb-connectstring and --skip-ndbcluster")
1196
 
      if $opt_skip_ndbcluster;
1197
 
  }
1198
 
  $ENV{'NDB_CONNECTSTRING'}= $clusters->[0]->{'connect_string'};
1199
 
 
1200
 
 
1201
 
  if ( $opt_ndbconnectstring_slave )
1202
 
  {
1203
 
    # ndbconnectstring-slave was supplied by user, the tests should be run
1204
 
    # agains an already started slave cluster, change settings
1205
 
    my $cluster= $clusters->[1]; # Slave cluster
1206
 
    $cluster->{'connect_string'}= $opt_ndbconnectstring_slave;
1207
 
    $cluster->{'use_running'}= 1;
1208
 
 
1209
 
    mtr_error("Can't specify ndb-connectstring_slave and " .
1210
 
              "--skip-ndbcluster-slave")
1211
 
      if $opt_skip_ndbcluster_slave;
1212
 
  }
1213
 
 
1214
 
 
1215
1068
  $path_timefile=  "$opt_vardir/log/mysqltest-time";
1216
1069
  $path_mysqltest_log=  "$opt_vardir/log/mysqltest.log";
1217
1070
  $path_current_test_log= "$opt_vardir/log/current_test";
1218
 
  $path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
1219
1071
 
1220
1072
  $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
1221
1073
 
1262
1114
  # A magic value in command_line_setup depends on these equations.
1263
1115
  $opt_master_myport=         $mtr_build_thread * 10 + 10000; # and 1
1264
1116
  $opt_slave_myport=          $opt_master_myport + 2;  # and 3 4
1265
 
  $opt_ndbcluster_port=       $opt_master_myport + 5;
1266
 
  $opt_ndbcluster_port_slave= $opt_master_myport + 6;
1267
1117
 
1268
1118
  if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 )
1269
1119
  {
1404
1254
  }
1405
1255
}
1406
1256
 
1407
 
 
1408
 
sub executable_setup_ndb () {
1409
 
 
1410
 
  # Look for ndb tols and binaries
1411
 
  my $ndb_path= mtr_file_exists("$glob_basedir/ndb",
1412
 
                                "$glob_basedir/storage/ndb",
1413
 
                                "$glob_basedir/bin");
1414
 
 
1415
 
  $exe_ndbd=
1416
 
    mtr_exe_maybe_exists("$ndb_path/src/kernel/ndbd",
1417
 
                         "$ndb_path/ndbd");
1418
 
  $exe_ndb_mgm=
1419
 
    mtr_exe_maybe_exists("$ndb_path/src/mgmclient/ndb_mgm",
1420
 
                         "$ndb_path/ndb_mgm");
1421
 
  $exe_ndb_mgmd=
1422
 
    mtr_exe_maybe_exists("$ndb_path/src/mgmsrv/ndb_mgmd",
1423
 
                         "$ndb_path/ndb_mgmd");
1424
 
  $exe_ndb_waiter=
1425
 
    mtr_exe_maybe_exists("$ndb_path/tools/ndb_waiter",
1426
 
                         "$ndb_path/ndb_waiter");
1427
 
 
1428
 
  # May not exist
1429
 
  $path_ndb_tools_dir= mtr_file_exists("$ndb_path/tools",
1430
 
                                       "$ndb_path");
1431
 
  # May not exist
1432
 
  $path_ndb_examples_dir=
1433
 
    mtr_file_exists("$ndb_path/ndbapi-examples",
1434
 
                    "$ndb_path/examples");
1435
 
  # May not exist
1436
 
  $exe_ndb_example=
1437
 
    mtr_file_exists("$path_ndb_examples_dir/ndbapi_simple/ndbapi_simple");
1438
 
 
1439
 
  return ( $exe_ndbd eq "" or
1440
 
           $exe_ndb_mgm eq "" or
1441
 
           $exe_ndb_mgmd eq "" or
1442
 
           $exe_ndb_waiter eq "");
1443
 
}
1444
 
 
1445
1257
sub executable_setup () {
1446
1258
 
1447
1259
  #
1484
1296
    {
1485
1297
      $exe_mysqlslap=    mtr_exe_exists("$path_client_bindir/mysqlslap");
1486
1298
    }
1487
 
 
1488
 
 
1489
 
    if ( ! $opt_skip_ndbcluster and executable_setup_ndb())
1490
 
    {
1491
 
      mtr_warning("Could not find all required ndb binaries, " .
1492
 
                "all ndb tests will fail, use --skip-ndbcluster to " .
1493
 
                "skip testing it.");
1494
 
 
1495
 
      foreach my $cluster (@{$clusters})
1496
 
      {
1497
 
        $cluster->{"executable_setup_failed"}= 1;
1498
 
      }
1499
 
    }
1500
 
 
1501
 
 
1502
 
    # Look for the udf_example library
1503
 
    $lib_udf_example=
1504
 
      mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'),
1505
 
                      "$glob_basedir/sql/.libs/udf_example.so",);
1506
 
 
1507
 
    # Look for the ha_example library
1508
 
    $lib_example_plugin=
1509
 
      mtr_file_exists(vs_config_dirs('storage/example', 'ha_example.dll'),
1510
 
                      "$glob_basedir/storage/example/.libs/ha_example.so",);
1511
 
 
1512
1299
  }
1513
1300
 
1514
1301
  # Look for mysqltest executable
1629
1416
    push(@ld_library_paths, "$glob_basedir/lib");
1630
1417
  }
1631
1418
 
1632
 
 # --------------------------------------------------------------------------
1633
 
  # Add the path where libndbclient can be found
1634
 
  # --------------------------------------------------------------------------
1635
 
  if ( $glob_ndbcluster_supported )
1636
 
  {
1637
 
    push(@ld_library_paths,  "$glob_basedir/storage/ndb/src/.libs");
1638
 
  }
1639
 
 
1640
1419
  # --------------------------------------------------------------------------
1641
1420
  # Valgrind need to be run with debug libraries otherwise it's almost
1642
1421
  # impossible to add correct supressions, that means if "/usr/lib/debug"
1717
1496
 
1718
1497
  $ENV{'EXE_MYSQL'}=          $exe_mysql;
1719
1498
 
1720
 
 
1721
 
  # ----------------------------------------------------
1722
 
  # Setup env for NDB
1723
 
  # ----------------------------------------------------
1724
 
  if ( ! $opt_skip_ndbcluster )
1725
 
  {
1726
 
    $ENV{'NDB_MGM'}=                  $exe_ndb_mgm;
1727
 
 
1728
 
    $ENV{'NDBCLUSTER_PORT'}=          $opt_ndbcluster_port;
1729
 
    $ENV{'NDBCLUSTER_PORT_SLAVE'}=    $opt_ndbcluster_port_slave;
1730
 
 
1731
 
    $ENV{'NDB_EXTRA_TEST'}=           $opt_ndb_extra_test;
1732
 
 
1733
 
    $ENV{'NDB_BACKUP_DIR'}=           $clusters->[0]->{'data_dir'};
1734
 
    $ENV{'NDB_DATA_DIR'}=             $clusters->[0]->{'data_dir'};
1735
 
    $ENV{'NDB_TOOLS_DIR'}=            $path_ndb_tools_dir;
1736
 
    $ENV{'NDB_TOOLS_OUTPUT'}=         $path_ndb_testrun_log;
1737
 
 
1738
 
    if ( $mysql_version_id >= 50000 )
1739
 
    {
1740
 
      $ENV{'NDB_EXAMPLES_DIR'}=         $path_ndb_examples_dir;
1741
 
      $ENV{'MY_NDB_EXAMPLES_BINARY'}=   $exe_ndb_example;
1742
 
    }
1743
 
    $ENV{'NDB_EXAMPLES_OUTPUT'}=      $path_ndb_testrun_log;
1744
 
  }
1745
 
 
1746
1499
  # ----------------------------------------------------
1747
1500
  # Setup env so childs can execute mysqlcheck
1748
1501
  # ----------------------------------------------------
2185
1938
}
2186
1939
 
2187
1940
 
2188
 
sub check_ssl_support ($) {
2189
 
  my $mysqld_variables= shift;
2190
 
 
2191
 
  if ($opt_skip_ssl || $opt_extern)
2192
 
  {
2193
 
    if (!$opt_extern)
2194
 
    {
2195
 
      mtr_report("Skipping SSL");
2196
 
    }
2197
 
    $opt_ssl_supported= 0;
2198
 
    $opt_ssl= 0;
2199
 
    return;
2200
 
  }
2201
 
 
2202
 
  if ( ! $mysqld_variables->{'ssl'} )
2203
 
  {
2204
 
    if ( $opt_ssl)
2205
 
    {
2206
 
      mtr_error("Couldn't find support for SSL");
2207
 
      return;
2208
 
    }
2209
 
    mtr_report("Skipping SSL, mysqld not compiled with SSL");
2210
 
    $opt_ssl_supported= 0;
2211
 
    $opt_ssl= 0;
2212
 
    return;
2213
 
  }
2214
 
  mtr_report("Setting mysqld to support SSL connections");
2215
 
  $opt_ssl_supported= 1;
2216
 
}
2217
 
 
2218
 
 
2219
1941
sub check_debug_support ($) {
2220
1942
  my $mysqld_variables= shift;
2221
1943
 
2290
2012
    mtr_add_arg($args, "--small-tables");
2291
2013
  }
2292
2014
 
2293
 
  if ( $opt_with_ndbcluster )
2294
 
  {
2295
 
    mtr_add_arg($args, "--create-options=TYPE=ndb");
2296
 
  }
2297
 
 
2298
2015
  chdir($glob_mysql_bench_dir)
2299
2016
    or mtr_error("Couldn't chdir to '$glob_mysql_bench_dir': $!");
2300
2017
 
2439
2156
    copy_install_db("slave".($idx+1), $slave->[$idx]->{'path_myddir'});
2440
2157
  }
2441
2158
 
2442
 
  my $cluster_started_ok= 1; # Assume it can be started
2443
 
 
2444
 
  my $cluster= $clusters->[0]; # Master cluster
2445
 
  if ($opt_skip_ndbcluster ||
2446
 
      $cluster->{'use_running'} ||
2447
 
      $cluster->{executable_setup_failed})
2448
 
  {
2449
 
    # Don't install master cluster
2450
 
  }
2451
 
  elsif (ndbcluster_start_install($cluster))
2452
 
  {
2453
 
    mtr_warning("Failed to start install of $cluster->{name}");
2454
 
    $cluster_started_ok= 0;
2455
 
  }
2456
 
 
2457
 
  $cluster= $clusters->[1]; # Slave cluster
2458
 
  if ($max_slave_num == 0 ||
2459
 
      $opt_skip_ndbcluster_slave ||
2460
 
      $cluster->{'use_running'} ||
2461
 
      $cluster->{executable_setup_failed})
2462
 
  {
2463
 
    # Don't install slave cluster
2464
 
  }
2465
 
  elsif (ndbcluster_start_install($cluster))
2466
 
  {
2467
 
    mtr_warning("Failed to start install of $cluster->{name}");
2468
 
    $cluster_started_ok= 0;
2469
 
  }
2470
 
 
2471
 
  foreach $cluster (@{$clusters})
2472
 
  {
2473
 
 
2474
 
    next if !$cluster->{'pid'};
2475
 
 
2476
 
    $cluster->{'installed_ok'}= 1; # Assume install suceeds
2477
 
 
2478
 
    if (ndbcluster_wait_started($cluster, ""))
2479
 
    {
2480
 
      # failed to install, disable usage and flag that its no ok
2481
 
      mtr_report("ndbcluster_install of $cluster->{'name'} failed");
2482
 
      $cluster->{"installed_ok"}= 0;
2483
 
 
2484
 
      $cluster_started_ok= 0;
2485
 
    }
2486
 
  }
2487
 
 
2488
 
  if ( ! $cluster_started_ok )
2489
 
  {
2490
 
    if ( $opt_force)
2491
 
    {
2492
 
      # Continue without cluster
2493
 
    }
2494
 
    else
2495
 
    {
2496
 
      mtr_error("To continue, re-run with '--force'.");
2497
 
    }
2498
 
  }
2499
 
 
2500
2159
  return 0;
2501
2160
}
2502
2161
 
2594
2253
    return 1;
2595
2254
  }
2596
2255
 
2597
 
  if ($tinfo->{'ndb_test'})
2598
 
  {
2599
 
    foreach my $cluster (@{$clusters})
2600
 
    {
2601
 
      # Slave cluster is skipped and thus not
2602
 
      # installed, no need to perform checks
2603
 
      last if ($opt_skip_ndbcluster_slave and
2604
 
               $cluster->{'name'} eq 'Slave');
2605
 
 
2606
 
      # Using running cluster - no need
2607
 
      # to check if test should be skipped
2608
 
      # will be done by test itself
2609
 
      last if ($cluster->{'use_running'});
2610
 
 
2611
 
      # If test needs this cluster, check binaries was found ok
2612
 
      if ( $cluster->{'executable_setup_failed'} )
2613
 
      {
2614
 
        mtr_report_test_name($tinfo);
2615
 
        $tinfo->{comment}=
2616
 
          "Failed to find cluster binaries";
2617
 
        mtr_report_test_failed($tinfo);
2618
 
        return 1;
2619
 
      }
2620
 
 
2621
 
      # If test needs this cluster, check it was installed ok
2622
 
      if ( !$cluster->{'installed_ok'} )
2623
 
      {
2624
 
        mtr_report_test_name($tinfo);
2625
 
        $tinfo->{comment}=
2626
 
          "Cluster $cluster->{'name'} was not installed ok";
2627
 
        mtr_report_test_failed($tinfo);
2628
 
        return 1;
2629
 
      }
2630
 
 
2631
 
    }
2632
 
  }
2633
 
 
2634
2256
  return 0;
2635
2257
}
2636
2258
 
2710
2332
    mtr_tofile($mysqld->{path_myerr}, $log_msg);
2711
2333
  }
2712
2334
 
2713
 
  # ndbcluster log file
2714
 
  mtr_tofile($path_ndb_testrun_log, $log_msg);
2715
 
 
2716
2335
}
2717
2336
 
2718
2337
sub find_testcase_skipped_reason($)
2922
2541
      mtr_rmtree("$data_dir");
2923
2542
      mtr_copy_dir("$path_snapshot/$name", "$data_dir");
2924
2543
    }
2925
 
 
2926
 
    # Remove the ndb_*_fs dirs for all ndbd nodes
2927
 
    # forcing a clean start of ndb
2928
 
    foreach my $cluster (@{$clusters})
2929
 
    {
2930
 
      foreach my $ndbd (@{$cluster->{'ndbds'}})
2931
 
      {
2932
 
        mtr_rmtree("$ndbd->{'path_fs'}" );
2933
 
      }
2934
 
    }
2935
2544
  }
2936
2545
  else
2937
2546
  {
3150
2759
    {
3151
2760
      mtr_add_arg($args, "%s--loose-skip-innodb", $prefix);
3152
2761
    }
3153
 
 
3154
 
    my $cluster= $clusters->[$mysqld->{'cluster'}];
3155
 
    if ( $cluster->{'pid'} ||           # Cluster is started
3156
 
         $cluster->{'use_running'} )    # Using running cluster
3157
 
    {
3158
 
      mtr_add_arg($args, "%s--ndbcluster", $prefix);
3159
 
      mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
3160
 
                  $cluster->{'connect_string'});
3161
 
      mtr_add_arg($args, "%s--ndb-wait-connected=20", $prefix);
3162
 
      mtr_add_arg($args, "%s--ndb-cluster-connection-pool=3", $prefix);
3163
 
      mtr_add_arg($args, "%s--slave-allow-batching", $prefix);
3164
 
      if ( $mysql_version_id >= 50100 )
3165
 
      {
3166
 
        mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
3167
 
        mtr_add_arg($args, "%s--ndb-log-orig", $prefix);
3168
 
      }
3169
 
    }
3170
 
    else
3171
 
    {
3172
 
      mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
3173
 
    }
3174
2762
  }
3175
2763
  else
3176
2764
  {
3218
2806
      mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
3219
2807
#      mtr_add_arg($args, "%s--rpl-recovery-rank=%d", $prefix, $slave_rpl_rank);
3220
2808
    }
3221
 
 
3222
 
   my $cluster= $clusters->[$mysqld->{'cluster'}];
3223
 
   if ( $cluster->{'pid'} ||         # Slave cluster is started
3224
 
        $cluster->{'use_running'} )  # Using running slave cluster
3225
 
    {
3226
 
      mtr_add_arg($args, "%s--ndbcluster", $prefix);
3227
 
      mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
3228
 
                  $cluster->{'connect_string'});
3229
 
      mtr_add_arg($args, "%s--ndb-wait-connected=20", $prefix);
3230
 
      mtr_add_arg($args, "%s--ndb-cluster-connection-pool=3", $prefix);
3231
 
      mtr_add_arg($args, "%s--slave-allow-batching", $prefix);
3232
 
      if ( $mysql_version_id >= 50100 )
3233
 
      {
3234
 
        mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
3235
 
        mtr_add_arg($args, "%s--ndb-log-orig", $prefix);
3236
 
      }
3237
 
    }
3238
 
    else
3239
 
    {
3240
 
      mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
3241
 
    }
3242
2809
  } # end slave
3243
2810
 
3244
2811
  if ( $opt_debug )
3251
2818
  mtr_add_arg($args, "%s--sort_buffer=256K", $prefix);
3252
2819
  mtr_add_arg($args, "%s--max_heap_table_size=1M", $prefix);
3253
2820
 
3254
 
  if ( $opt_ssl_supported )
3255
 
  {
3256
 
    mtr_add_arg($args, "%s--ssl-ca=%s/std_data/cacert.pem", $prefix,
3257
 
                $glob_mysql_test_dir);
3258
 
    mtr_add_arg($args, "%s--ssl-cert=%s/std_data/server-cert.pem", $prefix,
3259
 
                $glob_mysql_test_dir);
3260
 
    mtr_add_arg($args, "%s--ssl-key=%s/std_data/server-key.pem", $prefix,
3261
 
                $glob_mysql_test_dir);
3262
 
  }
3263
 
 
3264
2821
  if ( $opt_warnings )
3265
2822
  {
3266
2823
    mtr_add_arg($args, "%s--log-warnings", $prefix);
3444
3001
    }
3445
3002
  }
3446
3003
 
3447
 
  # Start shutdown of clusters
3448
 
  foreach my $cluster (@{$clusters})
3449
 
  {
3450
 
    if ( $cluster->{'pid'} )
3451
 
    {
3452
 
      $pid= mtr_ndbmgm_start($cluster, "shutdown");
3453
 
      $admin_pids{$pid}= 1;
3454
 
 
3455
 
      push(@kill_pids,{
3456
 
                       pid      => $cluster->{'pid'},
3457
 
                       pidfile  => $cluster->{'path_pid'}
3458
 
                      });
3459
 
 
3460
 
      $cluster->{'pid'}= 0; # Assume we are done with it
3461
 
 
3462
 
      foreach my $ndbd (@{$cluster->{'ndbds'}})
3463
 
      {
3464
 
        if ( $ndbd->{'pid'} )
3465
 
        {
3466
 
          push(@kill_pids,{
3467
 
                           pid      => $ndbd->{'pid'},
3468
 
                           pidfile  => $ndbd->{'path_pid'},
3469
 
                          });
3470
 
          $ndbd->{'pid'}= 0;
3471
 
        }
3472
 
      }
3473
 
    }
3474
 
  }
3475
 
 
3476
3004
  # Wait blocking until all shutdown processes has completed
3477
3005
  mtr_wait_blocking(\%admin_pids);
3478
3006
 
3503
3031
    $do_restart= 1; # Always restart if --force-restart in -opt file
3504
3032
    mtr_verbose("Restart master: Restart forced with --force-restart");
3505
3033
  }
3506
 
  elsif ( ! $opt_skip_ndbcluster and
3507
 
          !$tinfo->{'ndb_test'} and
3508
 
          $clusters->[0]->{'pid'} != 0 )
3509
 
  {
3510
 
    $do_restart= 1;           # Restart without cluster
3511
 
    mtr_verbose("Restart master: Test does not need cluster");
3512
 
  }
3513
 
  elsif ( ! $opt_skip_ndbcluster and
3514
 
          $tinfo->{'ndb_test'} and
3515
 
          $clusters->[0]->{'pid'} == 0 )
3516
 
  {
3517
 
    $do_restart= 1;           # Restart with cluster
3518
 
    mtr_verbose("Restart master: Test need cluster");
3519
 
  }
3520
3034
  elsif( $tinfo->{'component_id'} eq 'im' )
3521
3035
  {
3522
3036
    $do_restart= 1;
3655
3169
        $mysqld->{'pid'}= 0; # Assume we are done with it
3656
3170
      }
3657
3171
    }
3658
 
 
3659
 
    # Start shutdown of master cluster
3660
 
    my $cluster= $clusters->[0];
3661
 
    if ( $cluster->{'pid'} )
3662
 
    {
3663
 
      $pid= mtr_ndbmgm_start($cluster, "shutdown");
3664
 
      $admin_pids{$pid}= 1;
3665
 
 
3666
 
      push(@kill_pids,{
3667
 
                       pid      => $cluster->{'pid'},
3668
 
                       pidfile  => $cluster->{'path_pid'}
3669
 
                      });
3670
 
 
3671
 
      $cluster->{'pid'}= 0; # Assume we are done with it
3672
 
 
3673
 
      foreach my $ndbd (@{$cluster->{'ndbds'}})
3674
 
      {
3675
 
        push(@kill_pids,{
3676
 
                         pid      => $ndbd->{'pid'},
3677
 
                         pidfile  => $ndbd->{'path_pid'},
3678
 
                        });
3679
 
        $ndbd->{'pid'}= 0; # Assume we are done with it
3680
 
      }
3681
 
    }
3682
3172
  }
3683
3173
 
3684
3174
  if ( $do_restart || $do_slave_restart )
3708
3198
        $mysqld->{'pid'}= 0; # Assume we are done with it
3709
3199
      }
3710
3200
    }
3711
 
 
3712
 
    # Start shutdown of slave cluster
3713
 
    my $cluster= $clusters->[1];
3714
 
    if ( $cluster->{'pid'} )
3715
 
    {
3716
 
      $pid= mtr_ndbmgm_start($cluster, "shutdown");
3717
 
 
3718
 
      $admin_pids{$pid}= 1;
3719
 
 
3720
 
      push(@kill_pids,{
3721
 
                       pid      => $cluster->{'pid'},
3722
 
                       pidfile  => $cluster->{'path_pid'}
3723
 
                      });
3724
 
 
3725
 
      $cluster->{'pid'}= 0; # Assume we are done with it
3726
 
 
3727
 
      foreach my $ndbd (@{$cluster->{'ndbds'}} )
3728
 
      {
3729
 
        push(@kill_pids,{
3730
 
                         pid      => $ndbd->{'pid'},
3731
 
                         pidfile  => $ndbd->{'path_pid'},
3732
 
                        });
3733
 
        $ndbd->{'pid'}= 0; # Assume we are done with it
3734
 
      }
3735
 
    }
3736
3201
  }
3737
3202
 
3738
3203
  # ----------------------------------------------------------------------
3765
3230
 
3766
3231
  if ( $tinfo->{'component_id'} eq 'mysqld' )
3767
3232
  {
3768
 
    if ( ! $opt_skip_ndbcluster and
3769
 
         !$clusters->[0]->{'pid'} and
3770
 
         $tinfo->{'ndb_test'} )
3771
 
    {
3772
 
      # Test need cluster, cluster is not started, start it
3773
 
      ndbcluster_start($clusters->[0], "");
3774
 
    }
3775
 
 
3776
3233
    if ( !$master->[0]->{'pid'} )
3777
3234
    {
3778
3235
      # Master mysqld is not started
3782
3239
 
3783
3240
    }
3784
3241
 
3785
 
    if ( $clusters->[0]->{'pid'} || $clusters->[0]->{'use_running'}
3786
 
         and ! $master->[1]->{'pid'} and
3787
 
         $tinfo->{'master_num'} > 1 )
3788
 
    {
3789
 
      # Test needs cluster, start an extra mysqld connected to cluster
3790
 
 
3791
 
      if ( $mysql_version_id >= 50100 )
3792
 
      {
3793
 
        # First wait for first mysql server to have created ndb system
3794
 
        # tables ok FIXME This is a workaround so that only one mysqld
3795
 
        # create the tables
3796
 
        if ( ! sleep_until_file_created(
3797
 
                  "$master->[0]->{'path_myddir'}/mysql/ndb_apply_status.ndb",
3798
 
                                        $master->[0]->{'start_timeout'},
3799
 
                                        $master->[0]->{'pid'}))
3800
 
        {
3801
 
 
3802
 
          $tinfo->{'comment'}= "Failed to create 'mysql/ndb_apply_status' table";
3803
 
          return 1;
3804
 
        }
3805
 
      }
3806
 
      mysqld_start($master->[1],$tinfo->{'master_opt'},[]);
3807
 
    }
3808
 
 
3809
3242
    # Save this test case information, so next can examine it
3810
3243
    $master->[0]->{'running_master_options'}= $tinfo;
3811
3244
  }
3819
3252
 
3820
3253
    do_before_start_slave($tinfo);
3821
3254
 
3822
 
    if ( ! $opt_skip_ndbcluster_slave and
3823
 
         !$clusters->[1]->{'pid'} and
3824
 
         $tinfo->{'ndb_test'} )
3825
 
    {
3826
 
      # Test need slave cluster, cluster is not started, start it
3827
 
      ndbcluster_start($clusters->[1], "");
3828
 
    }
3829
 
 
3830
3255
    for ( my $idx= 0; $idx <  $tinfo->{'slave_num'}; $idx++ )
3831
3256
    {
3832
3257
      if ( ! $slave->[$idx]->{'pid'} )
3841
3266
    $slave->[0]->{'running_slave_options'}= $tinfo;
3842
3267
  }
3843
3268
 
3844
 
  # Wait for clusters to start
3845
 
  foreach my $cluster (@{$clusters})
3846
 
  {
3847
 
 
3848
 
    next if !$cluster->{'pid'};
3849
 
 
3850
 
    if (ndbcluster_wait_started($cluster, ""))
3851
 
    {
3852
 
      # failed to start
3853
 
      $tinfo->{'comment'}= "Start of $cluster->{'name'} cluster failed";
3854
 
      return 1;
3855
 
    }
3856
 
  }
3857
 
 
3858
3269
  # Wait for mysqld's to start
3859
3270
  foreach my $mysqld (@{$master},@{$slave})
3860
3271
  {
4038
3449
                $path_vardir_trace);
4039
3450
  }
4040
3451
 
4041
 
  if ( $opt_ssl_supported )
4042
 
  {
4043
 
    mtr_add_arg($args, "--ssl-ca=%s/std_data/cacert.pem",
4044
 
                $glob_mysql_test_dir);
4045
 
    mtr_add_arg($args, "--ssl-cert=%s/std_data/client-cert.pem",
4046
 
                $glob_mysql_test_dir);
4047
 
    mtr_add_arg($args, "--ssl-key=%s/std_data/client-key.pem",
4048
 
                $glob_mysql_test_dir);
4049
 
  }
4050
 
 
4051
 
  if ( $opt_ssl )
4052
 
  {
4053
 
    # Turn on SSL for _all_ test cases if option --ssl was used
4054
 
    mtr_add_arg($args, "--ssl");
4055
 
  }
4056
 
  elsif ( $opt_ssl_supported )
4057
 
  {
4058
 
    mtr_add_arg($args, "--skip-ssl");
4059
 
  }
4060
 
 
4061
3452
  # ----------------------------------------------------------------------
4062
3453
  # If embedded server, we create server args to give mysqltest to pass on
4063
3454
  # ----------------------------------------------------------------------
4408
3799
  view-protocol         Create a view to execute all non updating queries
4409
3800
  sp-protocol           Create a stored procedure to execute all queries
4410
3801
  compress              Use the compressed protocol between client and server
4411
 
  ssl                   Use ssl protocol between client and server
4412
 
  skip-ssl              Dont start server with support for ssl connections
4413
3802
  bench                 Run the benchmark suite
4414
3803
  small-bench           Run the benchmarks with --small-tests --small-tables
4415
3804
  ndb|with-ndbcluster   Use cluster as default table type
4540
3929
 
4541
3930
  sleep=SECONDS         Passed to mysqltest, will be used as fixed sleep time
4542
3931
 
4543
 
Deprecated options
4544
 
  with-openssl          Deprecated option for ssl
4545
 
 
4546
 
 
4547
3932
HERE
4548
3933
  mtr_exit(1);
4549
3934