~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/perl
2
2
# -*- cperl -*-
3
3
 
4
 
use utf8;
5
 
 
6
4
#
7
5
##############################################################################
8
6
#
9
 
#  drizzle-test-run.pl
 
7
#  mysql-test-run.pl
10
8
#
11
9
#  Tool used for executing a suite of .test file
12
10
#
13
 
#  For now, see the "MySQL Test framework manual" for more information
 
11
#  See the "MySQL Test framework manual" for more information
14
12
#  http://dev.mysql.com/doc/mysqltest/en/index.html
15
 
#  (as the Drizzle test environment is currently still fairly similar)
16
13
#
17
14
#  Please keep the test framework tools identical in all versions!
18
15
#
52
49
# A nice way to trace the execution of this script while debugging
53
50
# is to use the Devel::Trace package found at
54
51
# "http://www.plover.com/~mjd/perl/Trace/" and run this script like
55
 
# "perl -d:Trace drizzle-test-run.pl"
 
52
# "perl -d:Trace mysql-test-run.pl"
56
53
#
57
54
 
58
55
 
65
62
use File::Basename;
66
63
use File::Copy;
67
64
use File::Temp qw /tempdir/;
68
 
use File::Spec::Functions qw /splitdir catpath catdir
69
 
                              updir curdir splitpath rel2abs/;
 
65
use File::Spec::Functions qw /splitdir/;
70
66
use Cwd;
71
67
use Getopt::Long;
72
68
use IO::Socket;
77
73
select(STDOUT);
78
74
$| = 1; # Automatically flush STDOUT
79
75
 
80
 
require "mtr_cases.pl";
81
 
require "mtr_process.pl";
82
 
require "mtr_timer.pl";
83
 
require "mtr_io.pl";
84
 
require "mtr_gcov.pl";
85
 
require "mtr_gprof.pl";
86
 
require "mtr_report.pl";
87
 
require "mtr_match.pl";
88
 
require "mtr_misc.pl";
89
 
require "mtr_stress.pl";
90
 
require "mtr_unique.pl";
 
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
require "lib/mtr_cases.pl";
 
82
require "lib/mtr_process.pl";
 
83
require "lib/mtr_timer.pl";
 
84
require "lib/mtr_io.pl";
 
85
require "lib/mtr_gcov.pl";
 
86
require "lib/mtr_gprof.pl";
 
87
require "lib/mtr_report.pl";
 
88
require "lib/mtr_match.pl";
 
89
require "lib/mtr_misc.pl";
 
90
require "lib/mtr_stress.pl";
 
91
require "lib/mtr_unique.pl";
91
92
 
92
93
$Devel::Trace::TRACE= 1;
93
94
 
99
100
 
100
101
# Misc global variables
101
102
our $mysql_version_id;
102
 
our $glob_suite_path=             undef;
103
103
our $glob_mysql_test_dir=         undef;
104
104
our $glob_mysql_bench_dir=        undef;
105
105
our $glob_scriptname=             undef;
106
106
our $glob_timers=                 undef;
 
107
our $glob_use_embedded_server=    0;
107
108
our @glob_test_mode;
108
109
 
109
 
our $glob_builddir;
110
 
 
111
110
our $glob_basedir;
112
111
 
 
112
our $path_charsetsdir;
113
113
our $path_client_bindir;
 
114
our $path_share;
 
115
our $path_language;
114
116
our $path_timefile;
115
117
our $path_snapshot;
116
 
our $path_drizzletest_log;
 
118
our $path_mysqltest_log;
117
119
our $path_current_test_log;
118
120
our $path_my_basedir;
119
121
 
120
122
our $opt_vardir;                 # A path but set directly on cmd line
121
123
our $path_vardir_trace;          # unix formatted opt_vardir for trace files
122
124
our $opt_tmpdir;                 # A path but set directly on cmd line
123
 
our $opt_suitepath;
124
 
our $opt_testdir;
125
125
 
126
 
our $opt_subunit;
 
126
# Visual Studio produces executables in different sub-directories based on the
 
127
# configuration used to build them.  To make life easier, an environment
 
128
# variable or command-line option may be specified to control which set of
 
129
# executables will be used by the test suite.
 
130
our $opt_vs_config = $ENV{'MTR_VS_CONFIG'};
127
131
 
128
132
our $default_vardir;
129
133
 
130
134
our $opt_usage;
131
135
our $opt_suites;
132
 
our $opt_suites_default= "main"; # Default suites to run
 
136
our $opt_suites_default= "main,binlog,rpl"; # Default suites to run
133
137
our $opt_script_debug= 0;  # Script debugging, enable with --script-debug
134
138
our $opt_verbose= 0;  # Verbose output, enable with --verbose
135
139
 
136
 
our $opt_repeat_test= 1;
137
 
 
138
140
our $exe_master_mysqld;
139
 
our $exe_drizzle;
140
 
our $exe_drizzle_client_test;
 
141
our $exe_mysql;
 
142
our $exe_mysqladmin;
 
143
our $exe_mysql_upgrade;
 
144
our $exe_mysqlbinlog;
 
145
our $exe_mysql_client_test;
141
146
our $exe_bug25714;
142
 
our $exe_drizzled;
143
 
our $exe_drizzledump;
144
 
our $exe_drizzleslap;
145
 
our $exe_drizzleimport;
146
 
our $exe_drizzle_fix_system_tables;
147
 
our $exe_drizzletest;
 
147
our $exe_mysqld;
 
148
our $exe_mysqlcheck;
 
149
our $exe_mysqldump;
 
150
our $exe_mysqlslap;
 
151
our $exe_mysqlimport;
 
152
our $exe_mysqlshow;
 
153
our $exe_mysql_fix_system_tables;
 
154
our $file_mysql_fix_privilege_tables;
 
155
our $exe_mysqltest;
 
156
our $exe_ndbd;
 
157
our $exe_ndb_mgmd;
148
158
our $exe_slave_mysqld;
149
159
our $exe_my_print_defaults;
150
160
our $exe_perror;
154
164
 
155
165
our $opt_bench= 0;
156
166
our $opt_small_bench= 0;
 
167
our $opt_big_test= 0;
157
168
 
158
169
our @opt_combinations;
159
170
our $opt_skip_combination;
161
172
our @opt_extra_mysqld_opt;
162
173
 
163
174
our $opt_compress;
 
175
our $opt_ssl;
 
176
our $opt_skip_ssl;
 
177
our $opt_ssl_supported;
 
178
our $opt_ps_protocol;
 
179
our $opt_sp_protocol;
 
180
our $opt_cursor_protocol;
 
181
our $opt_view_protocol;
164
182
 
165
183
our $opt_debug;
166
184
our $opt_do_test;
167
185
our @opt_cases;                  # The test cases names in argv
168
 
our $opt_engine;
 
186
our $opt_embedded_server;
169
187
 
170
188
our $opt_extern= 0;
171
189
our $opt_socket;
182
200
 
183
201
our $glob_debugger= 0;
184
202
our $opt_gdb;
185
 
our $opt_dbx;
186
203
our $opt_client_gdb;
187
 
our $opt_client_dbx;
188
 
our $opt_dbx_gdb;
189
204
our $opt_ddd;
190
205
our $opt_client_ddd;
191
206
our $opt_manual_gdb;
192
 
our $opt_manual_dbx;
193
207
our $opt_manual_ddd;
194
208
our $opt_manual_debug;
195
 
# Magic number -69.4 results in traditional test ports starting from 9306.
196
 
our $opt_mtr_build_thread=-69.4;
 
209
our $opt_mtr_build_thread=0;
197
210
our $opt_debugger;
198
211
our $opt_client_debugger;
199
212
 
208
221
 
209
222
our $opt_master_myport;
210
223
our $opt_slave_myport;
211
 
our $opt_memc_myport;
 
224
our $opt_ndbcluster_port;
 
225
our $opt_ndbconnectstring;
 
226
our $opt_ndbcluster_port_slave;
 
227
our $opt_ndbconnectstring_slave;
 
228
 
212
229
our $opt_record;
213
230
my $opt_report_features;
214
231
our $opt_check_testcases;
215
232
our $opt_mark_progress;
216
233
 
217
 
our $opt_skip_rpl= 1;
 
234
our $opt_skip_rpl;
218
235
our $max_slave_num= 0;
219
236
our $max_master_num= 1;
220
237
our $use_innodb;
239
256
 
240
257
my $opt_valgrind= 0;
241
258
my $opt_valgrind_mysqld= 0;
242
 
my $opt_valgrind_drizzletest= 0;
 
259
my $opt_valgrind_mysqltest= 0;
243
260
my @default_valgrind_args= ("--show-reachable=yes");
244
261
my @valgrind_args;
245
262
my $opt_valgrind_path;
246
263
my $opt_callgrind;
247
 
my $opt_massif;
248
264
 
249
265
our $opt_stress=               "";
250
266
our $opt_stress_suite=     "main";
258
274
 
259
275
our $opt_warnings;
260
276
 
 
277
our $opt_skip_ndbcluster= 0;
 
278
our $opt_skip_ndbcluster_slave= 0;
 
279
our $opt_with_ndbcluster= 0;
 
280
our $opt_with_ndbcluster_only= 0;
 
281
our $glob_ndbcluster_supported= 0;
 
282
our $opt_ndb_extra_test= 0;
 
283
our $opt_skip_master_binlog= 0;
 
284
our $opt_skip_slave_binlog= 0;
 
285
 
 
286
our $exe_ndb_mgm;
 
287
our $exe_ndb_waiter;
 
288
our $path_ndb_tools_dir;
 
289
our $path_ndb_examples_dir;
 
290
our $exe_ndb_example;
 
291
our $path_ndb_testrun_log;
 
292
 
261
293
our $path_sql_dir;
262
294
 
263
295
our @data_dir_lst;
264
296
 
 
297
our $used_binlog_format;
265
298
our $used_default_engine;
266
299
our $debug_compiled_binaries;
267
300
 
288
321
sub kill_running_servers ();
289
322
sub remove_stale_vardir ();
290
323
sub setup_vardir ();
 
324
sub check_ssl_support ($);
291
325
sub check_running_as_root();
 
326
sub check_ndbcluster_support ($);
 
327
sub rm_ndbcluster_tables ($);
 
328
sub ndbcluster_start_install ($);
 
329
sub ndbcluster_start ($$);
 
330
sub ndbcluster_wait_started ($$);
292
331
sub mysqld_wait_started($);
293
332
sub run_benchmarks ($);
294
333
sub initialize_servers ();
295
334
sub mysql_install_db ();
 
335
sub install_db ($$);
296
336
sub copy_install_db ($$);
297
337
sub run_testcase ($);
298
338
sub run_testcase_stop_servers ($$$);
301
341
sub report_failure_and_restart ($);
302
342
sub do_before_start_master ($);
303
343
sub do_before_start_slave ($);
 
344
sub ndbd_start ($$$);
 
345
sub ndb_mgmd_start ($);
304
346
sub mysqld_start ($$$);
305
347
sub mysqld_arguments ($$$$);
306
348
sub stop_all_servers ();
307
 
sub run_drizzletest ($);
308
 
sub collapse_path ($);
 
349
sub run_mysqltest ($);
309
350
sub usage ($);
310
351
 
311
352
 
321
362
 
322
363
  command_line_setup();
323
364
 
 
365
  check_ndbcluster_support(\%mysqld_variables);
 
366
  check_ssl_support(\%mysqld_variables);
324
367
  check_debug_support(\%mysqld_variables);
325
368
 
326
369
  executable_setup();
356
399
      $opt_suites= $opt_suites_default;
357
400
 
358
401
      # Check for any extra suites to enable based on the path name
359
 
      my %extra_suites= ();
 
402
      my %extra_suites=
 
403
        (
 
404
         "mysql-5.1-new-ndb"              => "ndb_team",
 
405
         "mysql-5.1-new-ndb-merge"        => "ndb_team",
 
406
         "mysql-5.1-telco-6.2"            => "ndb_team",
 
407
         "mysql-5.1-telco-6.2-merge"      => "ndb_team",
 
408
         "mysql-5.1-telco-6.3"            => "ndb_team",
 
409
         "mysql-6.0-ndb"                  => "ndb_team",
 
410
        );
360
411
 
361
412
      foreach my $dir ( reverse splitdir($glob_basedir) )
362
413
      {
372
423
    my $tests= collect_test_cases($opt_suites);
373
424
 
374
425
    # Turn off NDB and other similar options if no tests use it
 
426
    my ($need_ndbcluster);
375
427
    foreach my $test (@$tests)
376
428
    {
377
429
      next if $test->{skip};
378
430
 
379
431
      if (!$opt_extern)
380
432
      {
 
433
        $need_ndbcluster||= $test->{ndb_test};
 
434
 
381
435
        # Count max number of slaves used by a test case
382
436
        if ( $test->{slave_num} > $max_slave_num) {
383
437
          $max_slave_num= $test->{slave_num};
394
448
      $use_innodb||= $test->{'innodb_test'};
395
449
    }
396
450
 
 
451
    # Check if cluster can be skipped
 
452
    if ( !$need_ndbcluster )
 
453
    {
 
454
      $opt_skip_ndbcluster= 1;
 
455
      $opt_skip_ndbcluster_slave= 1;
 
456
    }
 
457
 
 
458
    # Check if slave cluster can be skipped
 
459
    if ($max_slave_num == 0)
 
460
    {
 
461
      $opt_skip_ndbcluster_slave= 1;
 
462
    }
 
463
 
397
464
    initialize_servers();
398
465
 
399
466
    if ( $opt_report_features ) {
431
498
 
432
499
  my $opt_comment;
433
500
 
 
501
  # Magic number -69.4 results in traditional test ports starting from 9306.
 
502
  set_mtr_build_thread_ports(-69.4);
 
503
 
434
504
  # If so requested, we try to avail ourselves of a unique build thread number.
435
505
  if ( $ENV{'MTR_BUILD_THREAD'} ) {
436
506
    if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) {
466
536
  Getopt::Long::Configure("pass_through");
467
537
  GetOptions(
468
538
             # Control what engine/variation to run
 
539
             'embedded-server'          => \$opt_embedded_server,
 
540
             'ps-protocol'              => \$opt_ps_protocol,
 
541
             'sp-protocol'              => \$opt_sp_protocol,
 
542
             'view-protocol'            => \$opt_view_protocol,
 
543
             'cursor-protocol'          => \$opt_cursor_protocol,
 
544
             'ssl|with-openssl'         => \$opt_ssl,
 
545
             'skip-ssl'                 => \$opt_skip_ssl,
469
546
             'compress'                 => \$opt_compress,
470
547
             'bench'                    => \$opt_bench,
471
548
             'small-bench'              => \$opt_small_bench,
 
549
             'with-ndbcluster|ndb'      => \$opt_with_ndbcluster,
 
550
             'vs-config'            => \$opt_vs_config,
472
551
 
473
552
             # Control what test suites or cases to run
474
553
             'force'                    => \$opt_force,
 
554
             'with-ndbcluster-only'     => \$opt_with_ndbcluster_only,
 
555
             'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster,
 
556
             'skip-ndbcluster-slave|skip-ndb-slave'
 
557
                                        => \$opt_skip_ndbcluster_slave,
 
558
             'ndb-extra-test'           => \$opt_ndb_extra_test,
 
559
             'skip-master-binlog'       => \$opt_skip_master_binlog,
 
560
             'skip-slave-binlog'        => \$opt_skip_slave_binlog,
475
561
             'do-test=s'                => \$opt_do_test,
476
562
             'start-from=s'             => \$opt_start_from,
477
563
             'suite|suites=s'           => \$opt_suites,
478
564
             'skip-rpl'                 => \$opt_skip_rpl,
479
565
             'skip-test=s'              => \$opt_skip_test,
 
566
             'big-test'                 => \$opt_big_test,
480
567
             'combination=s'            => \@opt_combinations,
481
568
             'skip-combination'         => \$opt_skip_combination,
482
569
 
483
570
             # Specify ports
484
571
             'master_port=i'            => \$opt_master_myport,
485
572
             'slave_port=i'             => \$opt_slave_myport,
486
 
             'memc_port=i'              => \$opt_memc_myport,
 
573
             'ndbcluster-port|ndbcluster_port=i' => \$opt_ndbcluster_port,
 
574
             'ndbcluster-port-slave=i'  => \$opt_ndbcluster_port_slave,
487
575
             'mtr-build-thread=i'       => \$opt_mtr_build_thread,
488
576
 
489
577
             # Test case authoring
493
581
 
494
582
             # Extra options used when starting mysqld
495
583
             'mysqld=s'                 => \@opt_extra_mysqld_opt,
496
 
             'engine=s'                 => \$opt_engine,
497
584
 
498
585
             # Run test on running server
499
586
             'extern'                   => \$opt_extern,
500
 
 
501
 
             # Output format
502
 
             'subunit'                  => \$opt_subunit,
 
587
             'ndb-connectstring=s'       => \$opt_ndbconnectstring,
 
588
             'ndb-connectstring-slave=s' => \$opt_ndbconnectstring_slave,
503
589
 
504
590
             # Debugging
505
591
             'gdb'                      => \$opt_gdb,
506
 
             'dbx'                      => \$opt_dbx,
507
592
             'client-gdb'               => \$opt_client_gdb,
508
 
             'client-dbx'               => \$opt_client_dbx,
509
593
             'manual-gdb'               => \$opt_manual_gdb,
510
 
             'manual-dbx'               => \$opt_manual_dbx,
511
594
             'manual-debug'             => \$opt_manual_debug,
512
595
             'ddd'                      => \$opt_ddd,
513
596
             'client-ddd'               => \$opt_client_ddd,
523
606
             'gcov'                     => \$opt_gcov,
524
607
             'gprof'                    => \$opt_gprof,
525
608
             'valgrind|valgrind-all'    => \$opt_valgrind,
526
 
             'valgrind-drizzletest'       => \$opt_valgrind_drizzletest,
 
609
             'valgrind-mysqltest'       => \$opt_valgrind_mysqltest,
527
610
             'valgrind-mysqld'          => \$opt_valgrind_mysqld,
528
611
             'valgrind-options=s'       => sub {
529
612
               my ($opt, $value)= @_;
539
622
             'valgrind-option=s'        => \@valgrind_args,
540
623
             'valgrind-path=s'          => \$opt_valgrind_path,
541
624
             'callgrind'                => \$opt_callgrind,
542
 
             'massif'                   => \$opt_massif,
543
625
 
544
626
             # Stress testing 
545
627
             'stress'                   => \$opt_stress,
555
637
             # Directories
556
638
             'tmpdir=s'                 => \$opt_tmpdir,
557
639
             'vardir=s'                 => \$opt_vardir,
558
 
             'suitepath=s'              => \$opt_suitepath,
559
 
             'testdir=s'                => \$opt_testdir,
560
640
             'benchdir=s'               => \$glob_mysql_bench_dir,
561
641
             'mem'                      => \$opt_mem,
562
642
 
578
658
             'testcase-timeout=i'       => \$opt_testcase_timeout,
579
659
             'suite-timeout=i'          => \$opt_suite_timeout,
580
660
             'warnings|log-warnings'    => \$opt_warnings,
581
 
             'repeat-test=i'            => \$opt_repeat_test,
582
661
 
583
662
             # Options which are no longer used
584
663
             (map { $_ => \&warn_about_removed_option } @removed_options),
588
667
 
589
668
  usage("") if $opt_usage;
590
669
 
591
 
  usage("you cannot specify --gdb and --dbx both!") if 
592
 
        ($opt_gdb && $opt_dbx) ||
593
 
        ($opt_manual_gdb && $opt_manual_dbx);
594
 
 
595
670
  $glob_scriptname=  basename($0);
596
671
 
597
672
  if ($opt_mtr_build_thread != 0)
603
678
    $opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'};
604
679
  }
605
680
 
606
 
  if ( -d "../drizzled" )
 
681
  # We require that we are in the "mysql-test" directory
 
682
  # to run mysql-test-run
 
683
  if (! -f $glob_scriptname)
 
684
  {
 
685
    mtr_error("Can't find the location for the mysql-test-run script\n" .
 
686
              "Go to to the mysql-test directory and execute the script " .
 
687
              "as follows:\n./$glob_scriptname");
 
688
  }
 
689
 
 
690
  if ( -d "../sql" )
607
691
  {
608
692
    $source_dist=  1;
609
693
  }
610
694
 
611
695
  # Find the absolute path to the test directory
612
 
  if ( ! $opt_testdir )
613
 
  {
614
 
    $glob_mysql_test_dir=  cwd();
615
 
  } 
616
 
  else
617
 
  {
618
 
    $glob_mysql_test_dir= $opt_testdir;
 
696
  $glob_mysql_test_dir=  cwd();
 
697
  if ( $glob_cygwin_perl )
 
698
  {
 
699
    # Windows programs like 'mysqld' needs Windows paths
 
700
    $glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`;
 
701
    chomp($glob_mysql_test_dir);
619
702
  }
620
703
  $default_vardir= "$glob_mysql_test_dir/var";
621
704
 
622
 
  if ( ! $opt_suitepath )
623
 
  {
624
 
    $glob_suite_path= "$glob_mysql_test_dir/../plugin";
625
 
  }
626
 
  else
627
 
  {
628
 
    $glob_suite_path= $opt_suitepath;
629
 
  }
630
705
  # In most cases, the base directory we find everything relative to,
631
706
  # is the parent directory of the "mysql-test" directory. For source
632
707
  # distributions, TAR binary distributions and some other packages.
642
717
    $glob_basedir= dirname($glob_basedir);
643
718
  }
644
719
 
645
 
  if ( $opt_testdir and -d $opt_testdir and $opt_vardir and -d $opt_vardir
646
 
         and -f "$opt_vardir/../../drizzled/drizzled")
647
 
  {
648
 
    # probably in a VPATH build
649
 
    $glob_builddir= "$opt_vardir/../..";
650
 
  }
651
 
  else
652
 
  {
653
 
    $glob_builddir="..";
654
 
  }
655
 
 
656
720
  # Expect mysql-bench to be located adjacent to the source tree, by default
657
721
  $glob_mysql_bench_dir= "$glob_basedir/../mysql-bench"
658
722
    unless defined $glob_mysql_bench_dir;
664
728
 
665
729
  $glob_timers= mtr_init_timers();
666
730
 
 
731
  # --------------------------------------------------------------------------
 
732
  # Embedded server flag
 
733
  # --------------------------------------------------------------------------
 
734
  if ( $opt_embedded_server )
 
735
  {
 
736
    $glob_use_embedded_server= 1;
 
737
    # Add the location for libmysqld.dll to the path.
 
738
    if ( $glob_win32 )
 
739
    {
 
740
      my $lib_mysqld=
 
741
        mtr_path_exists(vs_config_dirs('libmysqld',''));
 
742
          $lib_mysqld= $glob_cygwin_perl ? ":".`cygpath "$lib_mysqld"` 
 
743
                                     : ";".$lib_mysqld;
 
744
      chomp($lib_mysqld);
 
745
      $ENV{'PATH'}="$ENV{'PATH'}".$lib_mysqld;
 
746
    }
 
747
 
 
748
    push(@glob_test_mode, "embedded");
 
749
    $opt_skip_rpl= 1;              # We never run replication with embedded
 
750
    $opt_skip_ndbcluster= 1;       # Turn off use of NDB cluster
 
751
    $opt_skip_ssl= 1;              # Turn off use of SSL
 
752
 
 
753
    # Turn off use of bin log
 
754
    push(@opt_extra_mysqld_opt, "--skip-log-bin");
 
755
 
 
756
    if ( $opt_extern )
 
757
    {
 
758
      mtr_error("Can't use --extern with --embedded-server");
 
759
    }
 
760
  }
 
761
 
667
762
  #
668
763
  # Find the mysqld executable to be able to find the mysqld version
669
764
  # number as early as possible
670
765
  #
671
766
 
672
767
  # Look for the client binaries directory
673
 
  $path_client_bindir= mtr_path_exists("$glob_builddir/client",
674
 
                                       "$glob_basedir/client",
 
768
  $path_client_bindir= mtr_path_exists("$glob_basedir/client_release",
 
769
                                       "$glob_basedir/client_debug",
 
770
                                       vs_config_dirs('client', ''),
 
771
                                       "$glob_basedir/client",
675
772
                                       "$glob_basedir/bin");
676
773
 
 
774
  # Look for language files and charsetsdir, use same share
 
775
  $path_share=      mtr_path_exists("$glob_basedir/share/mysql",
 
776
                                    "$glob_basedir/sql/share",
 
777
                                    "$glob_basedir/share");
 
778
 
 
779
  $path_language=      mtr_path_exists("$path_share/english");
 
780
  $path_charsetsdir=   mtr_path_exists("$path_share/charsets");
 
781
 
 
782
 
677
783
  if (!$opt_extern)
678
784
  {
679
 
    $exe_drizzled=       mtr_exe_exists ("$glob_basedir/drizzled/drizzled",
680
 
                                       "$path_client_bindir/drizzled",
681
 
                                       "$glob_basedir/libexec/drizzled",
682
 
                                       "$glob_basedir/bin/drizzled",
683
 
                                       "$glob_basedir/sbin/drizzled",
684
 
                                       "$glob_builddir/drizzled/drizzled");
 
785
    $exe_mysqld=       mtr_exe_exists (vs_config_dirs('sql', 'mysqld'),
 
786
                                       vs_config_dirs('sql', 'mysqld-debug'),
 
787
                                       "$glob_basedir/sql/mysqld",
 
788
                                       "$path_client_bindir/mysqld-max-nt",
 
789
                                       "$path_client_bindir/mysqld-max",
 
790
                                       "$path_client_bindir/mysqld-nt",
 
791
                                       "$path_client_bindir/mysqld",
 
792
                                       "$path_client_bindir/mysqld-debug",
 
793
                                       "$path_client_bindir/mysqld-max",
 
794
                                       "$glob_basedir/libexec/mysqld",
 
795
                                       "$glob_basedir/bin/mysqld",
 
796
                                       "$glob_basedir/sbin/mysqld");
685
797
 
686
798
    # Use the mysqld found above to find out what features are available
687
799
    collect_mysqld_features();
688
800
  }
689
801
  else
690
802
  {
691
 
    $mysqld_variables{'port'}= 4427;
692
 
  }
693
 
 
694
 
  if (!$opt_engine)
695
 
  {
696
 
    $opt_engine= "innodb";
 
803
    $mysqld_variables{'port'}= 3306;
697
804
  }
698
805
 
699
806
  if ( $opt_comment )
727
834
  }
728
835
 
729
836
  # --------------------------------------------------------------------------
 
837
  # Find out type of logging that are being used
 
838
  # --------------------------------------------------------------------------
 
839
  if (!$opt_extern && $mysql_version_id >= 50100 )
 
840
  {
 
841
    foreach my $arg ( @opt_extra_mysqld_opt )
 
842
    {
 
843
      if ( $arg =~ /binlog[-_]format=(\S+)/ )
 
844
      {
 
845
        $used_binlog_format= $1;
 
846
      }
 
847
    }
 
848
    if (defined $used_binlog_format) 
 
849
    {
 
850
      mtr_report("Using binlog format '$used_binlog_format'");
 
851
    }
 
852
    else
 
853
    {
 
854
      mtr_report("Using dynamic switching of binlog format");
 
855
    }
 
856
  }
 
857
 
 
858
 
 
859
  # --------------------------------------------------------------------------
730
860
  # Find out default storage engine being used(if any)
731
861
  # --------------------------------------------------------------------------
 
862
  if ( $opt_with_ndbcluster )
 
863
  {
 
864
    # --ndb or --with-ndbcluster turns on --default-storage-engine=ndbcluster
 
865
    push(@opt_extra_mysqld_opt, "--default-storage-engine=ndbcluster");
 
866
  }
 
867
 
732
868
  foreach my $arg ( @opt_extra_mysqld_opt )
733
869
  {
734
870
    if ( $arg =~ /default-storage-engine=(\S+)/ )
773
909
  {
774
910
    $opt_vardir= $default_vardir;
775
911
  }
 
912
  elsif ( $mysql_version_id < 50000 and
 
913
          $opt_vardir ne $default_vardir)
 
914
  {
 
915
    # Version 4.1 and --vardir was specified
 
916
    # Only supported as a symlink from var/
 
917
    # by setting up $opt_mem that symlink will be created
 
918
    if ( ! $glob_win32 )
 
919
    {
 
920
      # Only platforms that have native symlinks can use the vardir trick
 
921
      $opt_mem= $opt_vardir;
 
922
      mtr_report("Using 4.1 vardir trick");
 
923
    }
 
924
 
 
925
    $opt_vardir= $default_vardir;
 
926
  }
776
927
 
777
928
  $path_vardir_trace= $opt_vardir;
778
929
  # Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
779
930
  $path_vardir_trace=~ s/^\w://;
780
931
 
781
 
  $opt_vardir= collapse_path($opt_vardir);
 
932
  # We make the path absolute, as the server will do a chdir() before usage
 
933
  unless ( $opt_vardir =~ m,^/, or
 
934
           ($glob_win32 and $opt_vardir =~ m,^[a-z]:/,i) )
 
935
  {
 
936
    # Make absolute path, relative test dir
 
937
    $opt_vardir= "$glob_mysql_test_dir/$opt_vardir";
 
938
  }
782
939
 
783
940
  # --------------------------------------------------------------------------
784
941
  # Set tmpdir
800
957
  }
801
958
 
802
959
  # --------------------------------------------------------------------------
 
960
  # ps protcol flag
 
961
  # --------------------------------------------------------------------------
 
962
  if ( $opt_ps_protocol )
 
963
  {
 
964
    push(@glob_test_mode, "ps-protocol");
 
965
  }
 
966
 
 
967
  # --------------------------------------------------------------------------
803
968
  # Bench flags
804
969
  # --------------------------------------------------------------------------
805
970
  if ( $opt_small_bench )
808
973
  }
809
974
 
810
975
  # --------------------------------------------------------------------------
 
976
  # Big test flags
 
977
  # --------------------------------------------------------------------------
 
978
   if ( $opt_big_test )
 
979
   {
 
980
     $ENV{'BIG_TEST'}= 1;
 
981
   }
 
982
 
 
983
  # --------------------------------------------------------------------------
811
984
  # Gcov flag
812
985
  # --------------------------------------------------------------------------
813
986
  if ( $opt_gcov and ! $source_dist )
820
993
  # --------------------------------------------------------------------------
821
994
  if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd ||
822
995
       $opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug ||
823
 
       $opt_debugger || $opt_client_debugger || $opt_gdb || $opt_manual_gdb)
 
996
       $opt_debugger || $opt_client_debugger )
824
997
  {
825
998
    # Indicate that we are using debugger
826
999
    $glob_debugger= 1;
833
1006
  # --------------------------------------------------------------------------
834
1007
  # Check if special exe was selected for master or slave
835
1008
  # --------------------------------------------------------------------------
836
 
  $exe_master_mysqld= $exe_master_mysqld || $exe_drizzled;
837
 
  $exe_slave_mysqld=  $exe_slave_mysqld  || $exe_drizzled;
 
1009
  $exe_master_mysqld= $exe_master_mysqld || $exe_mysqld;
 
1010
  $exe_slave_mysqld=  $exe_slave_mysqld  || $exe_mysqld;
838
1011
 
839
1012
  # --------------------------------------------------------------------------
840
1013
  # Check valgrind arguments
844
1017
    mtr_report("Turning on valgrind for all executables");
845
1018
    $opt_valgrind= 1;
846
1019
    $opt_valgrind_mysqld= 1;
847
 
    $opt_valgrind_drizzletest= 1;
 
1020
    $opt_valgrind_mysqltest= 1;
848
1021
  }
849
1022
  elsif ( $opt_valgrind_mysqld )
850
1023
  {
851
1024
    mtr_report("Turning on valgrind for mysqld(s) only");
852
1025
    $opt_valgrind= 1;
853
1026
  }
854
 
  elsif ( $opt_valgrind_drizzletest )
 
1027
  elsif ( $opt_valgrind_mysqltest )
855
1028
  {
856
 
    mtr_report("Turning on valgrind for drizzletest and drizzle_client_test only");
 
1029
    mtr_report("Turning on valgrind for mysqltest and mysql_client_test only");
857
1030
    $opt_valgrind= 1;
858
1031
  }
859
1032
 
868
1041
      unless @valgrind_args;
869
1042
  }
870
1043
 
871
 
  if ( $opt_massif )
872
 
  {
873
 
    mtr_report("Valgrind with Massif tool for drizzled(s)");
874
 
    $opt_valgrind= 1;
875
 
    $opt_valgrind_mysqld= 1;
876
 
  }
877
 
 
878
1044
  if ( $opt_valgrind )
879
1045
  {
880
1046
    # Set valgrind_options to default unless already defined
889
1055
  {
890
1056
    $opt_testcase_timeout= $default_testcase_timeout;
891
1057
    $opt_testcase_timeout*= 10 if $opt_valgrind;
 
1058
    $opt_testcase_timeout*= 10 if ($opt_debug and $glob_win32);
892
1059
  }
893
1060
 
894
1061
  if ( ! $opt_suite_timeout )
895
1062
  {
896
1063
    $opt_suite_timeout= $default_suite_timeout;
897
1064
    $opt_suite_timeout*= 6 if $opt_valgrind;
 
1065
    $opt_suite_timeout*= 6 if ($opt_debug and $glob_win32);
898
1066
  }
899
1067
 
900
1068
  if ( ! $opt_user )
997
1165
  };
998
1166
 
999
1167
 
 
1168
  my $data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port";
 
1169
  $clusters->[0]=
 
1170
  {
 
1171
   name            => "Master",
 
1172
   nodes           => 2,
 
1173
   port            => "$opt_ndbcluster_port",
 
1174
   data_dir        => "$data_dir",
 
1175
   connect_string  => "host=localhost:$opt_ndbcluster_port",
 
1176
   path_pid        => "$data_dir/ndb_3.pid", # Nodes + 1
 
1177
   pid             => 0, # pid of ndb_mgmd
 
1178
   installed_ok    => 0,
 
1179
  };
 
1180
 
 
1181
  $data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port_slave";
 
1182
  $clusters->[1]=
 
1183
  {
 
1184
   name            => "Slave",
 
1185
   nodes           => 1,
 
1186
   port            => "$opt_ndbcluster_port_slave",
 
1187
   data_dir        => "$data_dir",
 
1188
   connect_string  => "host=localhost:$opt_ndbcluster_port_slave",
 
1189
   path_pid        => "$data_dir/ndb_2.pid", # Nodes + 1
 
1190
   pid             => 0, # pid of ndb_mgmd
 
1191
   installed_ok    => 0,
 
1192
  };
 
1193
 
 
1194
  # Init pids of ndbd's
 
1195
  foreach my $cluster ( @{$clusters} )
 
1196
  {
 
1197
    for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ )
 
1198
    {
 
1199
      my $nodeid= $idx+1;
 
1200
      $cluster->{'ndbds'}->[$idx]=
 
1201
        {
 
1202
         pid      => 0,
 
1203
         nodeid => $nodeid,
 
1204
         path_pid => "$cluster->{'data_dir'}/ndb_${nodeid}.pid",
 
1205
         path_fs => "$cluster->{'data_dir'}/ndb_${nodeid}_fs",
 
1206
        };
 
1207
    }
 
1208
  }
 
1209
 
1000
1210
  # --------------------------------------------------------------------------
1001
1211
  # extern
1002
1212
  # --------------------------------------------------------------------------
1004
1214
  {
1005
1215
    # Turn off features not supported when running with extern server
1006
1216
    $opt_skip_rpl= 1;
 
1217
    $opt_skip_ndbcluster= 1;
1007
1218
    warn("Currenty broken --extern");
1008
1219
 
1009
1220
    # Setup master->[0] with the settings for the extern server
1017
1228
  }
1018
1229
 
1019
1230
 
1020
 
  $path_timefile=  "$opt_vardir/log/drizzletest-time";
1021
 
  $path_drizzletest_log=  "$opt_vardir/log/drizzletest.log";
 
1231
  # --------------------------------------------------------------------------
 
1232
  # ndbconnectstring and ndbconnectstring_slave
 
1233
  # --------------------------------------------------------------------------
 
1234
  if ( $opt_ndbconnectstring )
 
1235
  {
 
1236
    # ndbconnectstring was supplied by user, the tests shoudl be run
 
1237
    # against an already started cluster, change settings
 
1238
    my $cluster= $clusters->[0]; # Master cluster
 
1239
    $cluster->{'connect_string'}= $opt_ndbconnectstring;
 
1240
    $cluster->{'use_running'}= 1;
 
1241
 
 
1242
    mtr_error("Can't specify --ndb-connectstring and --skip-ndbcluster")
 
1243
      if $opt_skip_ndbcluster;
 
1244
  }
 
1245
  $ENV{'NDB_CONNECTSTRING'}= $clusters->[0]->{'connect_string'};
 
1246
 
 
1247
 
 
1248
  if ( $opt_ndbconnectstring_slave )
 
1249
  {
 
1250
    # ndbconnectstring-slave was supplied by user, the tests should be run
 
1251
    # agains an already started slave cluster, change settings
 
1252
    my $cluster= $clusters->[1]; # Slave cluster
 
1253
    $cluster->{'connect_string'}= $opt_ndbconnectstring_slave;
 
1254
    $cluster->{'use_running'}= 1;
 
1255
 
 
1256
    mtr_error("Can't specify ndb-connectstring_slave and " .
 
1257
              "--skip-ndbcluster-slave")
 
1258
      if $opt_skip_ndbcluster_slave;
 
1259
  }
 
1260
 
 
1261
 
 
1262
  $path_timefile=  "$opt_vardir/log/mysqltest-time";
 
1263
  $path_mysqltest_log=  "$opt_vardir/log/mysqltest.log";
1022
1264
  $path_current_test_log= "$opt_vardir/log/current_test";
 
1265
  $path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
1023
1266
 
1024
1267
  $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
1025
1268
 
1062
1305
    print "got ".$mtr_build_thread."\n";
1063
1306
  }
1064
1307
 
1065
 
  $mtr_build_thread= (($mtr_build_thread * 10) % 2000) - 1000;
1066
 
 
1067
1308
  # Up to two masters, up to three slaves
1068
1309
  # A magic value in command_line_setup depends on these equations.
1069
 
  $opt_master_myport=         $mtr_build_thread + 9000; # and 1
 
1310
  $opt_master_myport=         $mtr_build_thread * 10 + 10000; # and 1
1070
1311
  $opt_slave_myport=          $opt_master_myport + 2;  # and 3 4
1071
 
  $opt_memc_myport= $opt_master_myport + 10;
 
1312
  $opt_ndbcluster_port=       $opt_master_myport + 5;
 
1313
  $opt_ndbcluster_port_slave= $opt_master_myport + 6;
1072
1314
 
1073
1315
  if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 )
1074
1316
  {
1114
1356
  #
1115
1357
  # --datadir must exist, mysqld will chdir into it
1116
1358
  #
1117
 
  my $list= `$exe_drizzled --no-defaults --datadir=$tmpdir --skip-grant-tables --verbose --help`;
 
1359
  my $list= `$exe_mysqld --no-defaults --datadir=$tmpdir --language=$path_language --skip-grant-tables --verbose --help`;
1118
1360
 
1119
1361
  foreach my $line (split('\n', $list))
1120
1362
  {
1122
1364
    if ( !$mysql_version_id )
1123
1365
    {
1124
1366
      # Look for version
1125
 
      my $exe_name= basename($exe_drizzled);
 
1367
      my $exe_name= basename($exe_mysqld);
1126
1368
      mtr_verbose("exe_name: $exe_name");
1127
1369
      if ( $line =~ /^\S*$exe_name\s\sVer\s([0-9]*)\.([0-9]*)\.([0-9]*)/ )
1128
1370
      {
1183
1425
  mtr_init_args(\$args);
1184
1426
 
1185
1427
  mtr_add_arg($args, "--no-defaults");
1186
 
  mtr_add_arg($args, "--skip-stack-trace");
1187
1428
  mtr_add_arg($args, "--user=%s", $opt_user);
1188
1429
  mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
1189
1430
  mtr_add_arg($args, "--silent"); # Tab separated output
1190
1431
  mtr_add_arg($args, "-e '%s'", $query);
1191
1432
 
1192
 
  my $cmd= "$exe_drizzle " . join(' ', @$args);
 
1433
  my $cmd= "$exe_mysql " . join(' ', @$args);
1193
1434
  mtr_verbose("cmd: $cmd");
1194
1435
  return `$cmd`;
1195
1436
}
1210
1451
  }
1211
1452
}
1212
1453
 
 
1454
 
 
1455
sub executable_setup_ndb () {
 
1456
 
 
1457
  # Look for ndb tols and binaries
 
1458
  my $ndb_path= mtr_file_exists("$glob_basedir/ndb",
 
1459
                                "$glob_basedir/storage/ndb",
 
1460
                                "$glob_basedir/bin");
 
1461
 
 
1462
  $exe_ndbd=
 
1463
    mtr_exe_maybe_exists("$ndb_path/src/kernel/ndbd",
 
1464
                         "$ndb_path/ndbd");
 
1465
  $exe_ndb_mgm=
 
1466
    mtr_exe_maybe_exists("$ndb_path/src/mgmclient/ndb_mgm",
 
1467
                         "$ndb_path/ndb_mgm");
 
1468
  $exe_ndb_mgmd=
 
1469
    mtr_exe_maybe_exists("$ndb_path/src/mgmsrv/ndb_mgmd",
 
1470
                         "$ndb_path/ndb_mgmd");
 
1471
  $exe_ndb_waiter=
 
1472
    mtr_exe_maybe_exists("$ndb_path/tools/ndb_waiter",
 
1473
                         "$ndb_path/ndb_waiter");
 
1474
 
 
1475
  # May not exist
 
1476
  $path_ndb_tools_dir= mtr_file_exists("$ndb_path/tools",
 
1477
                                       "$ndb_path");
 
1478
  # May not exist
 
1479
  $path_ndb_examples_dir=
 
1480
    mtr_file_exists("$ndb_path/ndbapi-examples",
 
1481
                    "$ndb_path/examples");
 
1482
  # May not exist
 
1483
  $exe_ndb_example=
 
1484
    mtr_file_exists("$path_ndb_examples_dir/ndbapi_simple/ndbapi_simple");
 
1485
 
 
1486
  return ( $exe_ndbd eq "" or
 
1487
           $exe_ndb_mgm eq "" or
 
1488
           $exe_ndb_mgmd eq "" or
 
1489
           $exe_ndb_waiter eq "");
 
1490
}
 
1491
 
1213
1492
sub executable_setup () {
1214
1493
 
1215
 
#
1216
 
# Check if libtool is available in this distribution/clone
1217
 
# we need it when valgrinding or debugging non installed binary
1218
 
# Otherwise valgrind will valgrind the libtool wrapper or bash
1219
 
# and gdb will not find the real executable to debug
1220
 
#
 
1494
  #
 
1495
  # Check if libtool is available in this distribution/clone
 
1496
  # we need it when valgrinding or debugging non installed binary
 
1497
  # Otherwise valgrind will valgrind the libtool wrapper or bash
 
1498
  # and gdb will not find the real executable to debug
 
1499
  #
1221
1500
  if ( -x "../libtool")
1222
1501
  {
1223
1502
    $exe_libtool= "../libtool";
1227
1506
    }
1228
1507
  }
1229
1508
 
1230
 
# Look for my_print_defaults
 
1509
  # Look for my_print_defaults
1231
1510
  $exe_my_print_defaults=
1232
 
    mtr_exe_exists(
1233
 
        "$path_client_bindir/my_print_defaults",
1234
 
        "$glob_basedir/extra/my_print_defaults",
1235
 
        "$glob_builddir/extra/my_print_defaults");
1236
 
 
1237
 
# Look for perror
1238
 
  $exe_perror= "perror";
1239
 
 
1240
 
# Look for the client binaries
1241
 
  $exe_drizzledump= mtr_exe_exists("$path_client_bindir/drizzledump");
1242
 
  $exe_drizzleimport= mtr_exe_exists("$path_client_bindir/drizzleimport");
1243
 
  $exe_drizzle=          mtr_exe_exists("$path_client_bindir/drizzle");
 
1511
    mtr_exe_exists(vs_config_dirs('extra', 'my_print_defaults'),
 
1512
                           "$path_client_bindir/my_print_defaults",
 
1513
                           "$glob_basedir/extra/my_print_defaults");
 
1514
 
 
1515
  # Look for perror
 
1516
  $exe_perror= mtr_exe_exists(vs_config_dirs('extra', 'perror'),
 
1517
                                          "$glob_basedir/extra/perror",
 
1518
                                          "$path_client_bindir/perror");
 
1519
 
 
1520
  # Look for the client binaries
 
1521
  $exe_mysqlcheck=     mtr_exe_exists("$path_client_bindir/mysqlcheck");
 
1522
  $exe_mysqldump=      mtr_exe_exists("$path_client_bindir/mysqldump");
 
1523
  $exe_mysqlimport=    mtr_exe_exists("$path_client_bindir/mysqlimport");
 
1524
  $exe_mysqlshow=      mtr_exe_exists("$path_client_bindir/mysqlshow");
 
1525
  $exe_mysqlbinlog=    mtr_exe_exists("$path_client_bindir/mysqlbinlog");
 
1526
  $exe_mysqladmin=     mtr_exe_exists("$path_client_bindir/mysqladmin");
 
1527
  $exe_mysql=          mtr_exe_exists("$path_client_bindir/mysql");
1244
1528
 
1245
1529
  if (!$opt_extern)
1246
1530
  {
1247
 
# Look for SQL scripts directory
1248
 
     if ( $mysql_version_id >= 50100 )
1249
 
     {
1250
 
         $exe_drizzleslap= mtr_exe_exists("$path_client_bindir/drizzleslap");
1251
 
     }
1252
 
  }
1253
 
 
1254
 
# Look for drizzletest executable
1255
 
  {
1256
 
    $exe_drizzletest= mtr_exe_exists("$path_client_bindir/drizzletest");
1257
 
  }
1258
 
 
1259
 
# Look for drizzle_client_test executable which may _not_ exist in
1260
 
# some versions, test using it should be skipped
1261
 
  {
1262
 
    $exe_drizzle_client_test=
 
1531
  # Look for SQL scripts directory
 
1532
    if ( mtr_file_exists("$path_share/mysql_system_tables.sql") ne "")
 
1533
    {
 
1534
      # The SQL scripts are in path_share
 
1535
      $path_sql_dir= $path_share;
 
1536
    }
 
1537
    else
 
1538
    {
 
1539
  $path_sql_dir= mtr_path_exists("$glob_basedir/share",
 
1540
                                 "$glob_basedir/scripts");
 
1541
    }
 
1542
 
 
1543
    if ( $mysql_version_id >= 50100 )
 
1544
    {
 
1545
      $exe_mysqlslap=    mtr_exe_exists("$path_client_bindir/mysqlslap");
 
1546
    }
 
1547
    if ( $mysql_version_id >= 50000 and !$glob_use_embedded_server )
 
1548
    {
 
1549
      $exe_mysql_upgrade= mtr_exe_exists("$path_client_bindir/mysql_upgrade")
 
1550
    }
 
1551
    else
 
1552
    {
 
1553
      $exe_mysql_upgrade= "";
 
1554
    }
 
1555
 
 
1556
    if ( ! $glob_win32 )
 
1557
    {
 
1558
      # Look for mysql_fix_system_table script
 
1559
      $exe_mysql_fix_system_tables=
 
1560
        mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables",
 
1561
                        "$path_client_bindir/mysql_fix_privilege_tables");
 
1562
    }
 
1563
 
 
1564
    # Look for mysql_fix_privilege_tables.sql script
 
1565
    $file_mysql_fix_privilege_tables=
 
1566
      mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql",
 
1567
                    "$glob_basedir/share/mysql_fix_privilege_tables.sql");
 
1568
 
 
1569
    if ( ! $opt_skip_ndbcluster and executable_setup_ndb())
 
1570
    {
 
1571
      mtr_warning("Could not find all required ndb binaries, " .
 
1572
                "all ndb tests will fail, use --skip-ndbcluster to " .
 
1573
                "skip testing it.");
 
1574
 
 
1575
      foreach my $cluster (@{$clusters})
 
1576
      {
 
1577
        $cluster->{"executable_setup_failed"}= 1;
 
1578
      }
 
1579
    }
 
1580
 
 
1581
 
 
1582
    # Look for the udf_example library
 
1583
    $lib_udf_example=
 
1584
      mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'),
 
1585
                      "$glob_basedir/sql/.libs/udf_example.so",);
 
1586
 
 
1587
    # Look for the ha_example library
 
1588
    $lib_example_plugin=
 
1589
      mtr_file_exists(vs_config_dirs('storage/example', 'ha_example.dll'),
 
1590
                      "$glob_basedir/storage/example/.libs/ha_example.so",);
 
1591
 
 
1592
  }
 
1593
 
 
1594
  # Look for mysqltest executable
 
1595
  if ( $glob_use_embedded_server )
 
1596
  {
 
1597
    $exe_mysqltest=
 
1598
      mtr_exe_exists(vs_config_dirs('libmysqld/examples','mysqltest_embedded'),
 
1599
                     "$glob_basedir/libmysqld/examples/mysqltest_embedded",
 
1600
                     "$path_client_bindir/mysqltest_embedded");
 
1601
  }
 
1602
  else
 
1603
  {
 
1604
    $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
 
1605
  }
 
1606
 
 
1607
  # Look for mysql_client_test executable which may _not_ exist in
 
1608
  # some versions, test using it should be skipped
 
1609
  if ( $glob_use_embedded_server )
 
1610
  {
 
1611
    $exe_mysql_client_test=
1263
1612
      mtr_exe_maybe_exists(
1264
 
          "$glob_basedir/tests/drizzle_client_test",
1265
 
          "$glob_basedir/bin/drizzle_client_test");
 
1613
        vs_config_dirs('libmysqld/examples', 'mysql_client_test_embedded'),
 
1614
        "$glob_basedir/libmysqld/examples/mysql_client_test_embedded");
 
1615
  }
 
1616
  else
 
1617
  {
 
1618
    $exe_mysql_client_test=
 
1619
      mtr_exe_maybe_exists(vs_config_dirs('tests', 'mysql_client_test'),
 
1620
                           "$glob_basedir/tests/mysql_client_test",
 
1621
                           "$glob_basedir/bin/mysql_client_test");
1266
1622
  }
1267
1623
 
1268
 
# Look for bug25714 executable which may _not_ exist in
1269
 
# some versions, test using it should be skipped
 
1624
  # Look for bug25714 executable which may _not_ exist in
 
1625
  # some versions, test using it should be skipped
1270
1626
  $exe_bug25714=
1271
 
    mtr_exe_maybe_exists(
1272
 
        "$glob_basedir/tests/bug25714");
 
1627
      mtr_exe_maybe_exists(vs_config_dirs('tests', 'bug25714'),
 
1628
                           "$glob_basedir/tests/bug25714");
1273
1629
}
1274
1630
 
1275
1631
 
1276
 
 
1277
1632
sub generate_cmdline_mysqldump ($) {
1278
1633
  my($mysqld) = @_;
1279
1634
  return
1280
 
    mtr_native_path($exe_drizzledump) .
1281
 
      " --no-defaults -uroot " .
 
1635
    mtr_native_path($exe_mysqldump) .
 
1636
      " --no-defaults -uroot --debug-check " .
1282
1637
      "--port=$mysqld->{'port'} ";
1283
1638
}
1284
1639
 
1286
1641
##############################################################################
1287
1642
#
1288
1643
#  Set environment to be used by childs of this process for
1289
 
#  things that are constant duting the whole lifetime of drizzle-test-run.pl
 
1644
#  things that are constant duting the whole lifetime of mysql-test-run.pl
1290
1645
#
1291
1646
##############################################################################
1292
1647
 
1293
 
sub drizzle_client_test_arguments()
 
1648
sub mysql_client_test_arguments()
1294
1649
{
1295
 
  my $exe= $exe_drizzle_client_test;
 
1650
  my $exe= $exe_mysql_client_test;
1296
1651
 
1297
1652
  my $args;
1298
1653
  mtr_init_args(\$args);
1299
 
  if ( $opt_valgrind_drizzletest )
 
1654
  if ( $opt_valgrind_mysqltest )
1300
1655
  {
1301
1656
    valgrind_arguments($args, \$exe);
1302
1657
  }
1314
1669
  if ( $opt_debug )
1315
1670
  {
1316
1671
    mtr_add_arg($args,
1317
 
      "--debug=d:t:A,$path_vardir_trace/log/drizzle_client_test.trace");
1318
 
  }
1319
 
 
1320
 
  return join(" ", $exe, @$args);
1321
 
}
1322
 
 
 
1672
      "--debug=d:t:A,$path_vardir_trace/log/mysql_client_test.trace");
 
1673
  }
 
1674
 
 
1675
  if ( $glob_use_embedded_server )
 
1676
  {
 
1677
    mtr_add_arg($args,
 
1678
      " -A --language=$path_language");
 
1679
    mtr_add_arg($args,
 
1680
      " -A --datadir=$slave->[0]->{'path_myddir'}");
 
1681
    mtr_add_arg($args,
 
1682
      " -A --character-sets-dir=$path_charsetsdir");
 
1683
  }
 
1684
 
 
1685
  return join(" ", $exe, @$args);
 
1686
}
 
1687
 
 
1688
sub mysql_upgrade_arguments()
 
1689
{
 
1690
  my $exe= $exe_mysql_upgrade;
 
1691
 
 
1692
  my $args;
 
1693
  mtr_init_args(\$args);
 
1694
#  if ( $opt_valgrind_mysql_ugrade )
 
1695
#  {
 
1696
#    valgrind_arguments($args, \$exe);
 
1697
#  }
 
1698
 
 
1699
  mtr_add_arg($args, "--no-defaults");
 
1700
  mtr_add_arg($args, "--user=root");
 
1701
  mtr_add_arg($args, "--port=$master->[0]->{'port'}");
 
1702
  mtr_add_arg($args, "--datadir=$master->[0]->{'path_myddir'}");
 
1703
  mtr_add_arg($args, "--basedir=$glob_basedir");
 
1704
 
 
1705
  if ( $opt_debug )
 
1706
  {
 
1707
    mtr_add_arg($args,
 
1708
      "--debug=d:t:A,$path_vardir_trace/log/mysql_upgrade.trace");
 
1709
  }
 
1710
 
 
1711
  return join(" ", $exe, @$args);
 
1712
}
1323
1713
 
1324
1714
# Note that some env is setup in spawn/run, in "mtr_process.pl"
1325
1715
 
1335
1725
  # --------------------------------------------------------------------------
1336
1726
  if ( $source_dist )
1337
1727
  {
1338
 
    push(@ld_library_paths, "$glob_basedir/libdrizzleclient/.libs/",
1339
 
                            "$glob_basedir/mysys/.libs/",
1340
 
                            "$glob_basedir/mystrings/.libs/",
1341
 
                            "$glob_basedir/drizzled/.libs/",
1342
 
                            "/usr/local/lib");
 
1728
    push(@ld_library_paths, "$glob_basedir/libmysql/.libs/",
 
1729
                            "$glob_basedir/libmysql_r/.libs/",
 
1730
                            "$glob_basedir/zlib.libs/");
1343
1731
  }
1344
1732
  else
1345
1733
  {
1346
1734
    push(@ld_library_paths, "$glob_basedir/lib");
1347
1735
  }
1348
1736
 
 
1737
 # --------------------------------------------------------------------------
 
1738
  # Add the path where libndbclient can be found
 
1739
  # --------------------------------------------------------------------------
 
1740
  if ( $glob_ndbcluster_supported )
 
1741
  {
 
1742
    push(@ld_library_paths,  "$glob_basedir/storage/ndb/src/.libs");
 
1743
  }
 
1744
 
1349
1745
  # --------------------------------------------------------------------------
1350
1746
  # Valgrind need to be run with debug libraries otherwise it's almost
1351
1747
  # impossible to add correct supressions, that means if "/usr/lib/debug"
1366
1762
    push(@ld_library_paths, $debug_libraries_path);
1367
1763
  }
1368
1764
 
1369
 
  $ENV{'LD_LIBRARY_PATH'}= join(":", 
 
1765
  $ENV{'LD_LIBRARY_PATH'}= join(":", @ld_library_paths,
1370
1766
                                $ENV{'LD_LIBRARY_PATH'} ?
1371
 
                                split(':', $ENV{'LD_LIBRARY_PATH'}) : (),
1372
 
                                @ld_library_paths);
 
1767
                                split(':', $ENV{'LD_LIBRARY_PATH'}) : ());
1373
1768
  mtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}");
1374
1769
 
1375
1770
  $ENV{'DYLD_LIBRARY_PATH'}= join(":", @ld_library_paths,
1393
1788
  # Also command lines in .opt files may contain env vars
1394
1789
  # --------------------------------------------------------------------------
1395
1790
 
1396
 
  $ENV{'CHARSETSDIR'}=              "";
 
1791
  $ENV{'CHARSETSDIR'}=              $path_charsetsdir;
1397
1792
  $ENV{'UMASK'}=              "0660"; # The octal *string*
1398
1793
  $ENV{'UMASK_DIR'}=          "0770"; # The octal *string*
1399
1794
  
1410
1805
  
1411
1806
  $ENV{'LC_COLLATE'}=         "C";
1412
1807
  $ENV{'USE_RUNNING_SERVER'}= $opt_extern;
1413
 
  $ENV{'DRIZZLE_TEST_DIR'}=     collapse_path($glob_mysql_test_dir);
 
1808
  $ENV{'MYSQL_TEST_DIR'}=     $glob_mysql_test_dir;
1414
1809
  $ENV{'MYSQLTEST_VARDIR'}=   $opt_vardir;
1415
 
  $ENV{'DRIZZLE_TMP_DIR'}=      $opt_tmpdir;
 
1810
  $ENV{'MYSQL_TMP_DIR'}=      $opt_tmpdir;
1416
1811
  $ENV{'MASTER_MYSOCK'}=      $master->[0]->{'path_sock'};
1417
1812
  $ENV{'MASTER_MYSOCK1'}=     $master->[1]->{'path_sock'};
1418
1813
  $ENV{'MASTER_MYPORT'}=      $master->[0]->{'port'};
1421
1816
  $ENV{'SLAVE_MYPORT'}=       $slave->[0]->{'port'};
1422
1817
  $ENV{'SLAVE_MYPORT1'}=      $slave->[1]->{'port'};
1423
1818
  $ENV{'SLAVE_MYPORT2'}=      $slave->[2]->{'port'};
1424
 
  $ENV{'MC_PORT'}=            $opt_memc_myport;
1425
 
  $ENV{'DRIZZLE_TCP_PORT'}=     $mysqld_variables{'port'};
1426
 
 
1427
 
  $ENV{'MTR_BUILD_THREAD'}=      $opt_mtr_build_thread;
1428
 
 
1429
 
  $ENV{'EXE_MYSQL'}=          $exe_drizzle;
1430
 
 
 
1819
  $ENV{'MYSQL_TCP_PORT'}=     $mysqld_variables{'port'};
 
1820
 
 
1821
  $ENV{MTR_BUILD_THREAD}=      $opt_mtr_build_thread;
 
1822
 
 
1823
  $ENV{'EXE_MYSQL'}=          $exe_mysql;
 
1824
 
 
1825
 
 
1826
  # ----------------------------------------------------
 
1827
  # Setup env for NDB
 
1828
  # ----------------------------------------------------
 
1829
  if ( ! $opt_skip_ndbcluster )
 
1830
  {
 
1831
    $ENV{'NDB_MGM'}=                  $exe_ndb_mgm;
 
1832
 
 
1833
    $ENV{'NDBCLUSTER_PORT'}=          $opt_ndbcluster_port;
 
1834
    $ENV{'NDBCLUSTER_PORT_SLAVE'}=    $opt_ndbcluster_port_slave;
 
1835
 
 
1836
    $ENV{'NDB_EXTRA_TEST'}=           $opt_ndb_extra_test;
 
1837
 
 
1838
    $ENV{'NDB_BACKUP_DIR'}=           $clusters->[0]->{'data_dir'};
 
1839
    $ENV{'NDB_DATA_DIR'}=             $clusters->[0]->{'data_dir'};
 
1840
    $ENV{'NDB_TOOLS_DIR'}=            $path_ndb_tools_dir;
 
1841
    $ENV{'NDB_TOOLS_OUTPUT'}=         $path_ndb_testrun_log;
 
1842
 
 
1843
    if ( $mysql_version_id >= 50000 )
 
1844
    {
 
1845
      $ENV{'NDB_EXAMPLES_DIR'}=         $path_ndb_examples_dir;
 
1846
      $ENV{'MY_NDB_EXAMPLES_BINARY'}=   $exe_ndb_example;
 
1847
    }
 
1848
    $ENV{'NDB_EXAMPLES_OUTPUT'}=      $path_ndb_testrun_log;
 
1849
  }
 
1850
 
 
1851
  # ----------------------------------------------------
 
1852
  # Setup env so childs can execute mysqlcheck
 
1853
  # ----------------------------------------------------
 
1854
  my $cmdline_mysqlcheck=
 
1855
    mtr_native_path($exe_mysqlcheck) .
 
1856
    " --no-defaults --debug-check -uroot " .
 
1857
    "--port=$master->[0]->{'port'} ";
 
1858
 
 
1859
  if ( $opt_debug )
 
1860
  {
 
1861
    $cmdline_mysqlcheck .=
 
1862
      " --debug=d:t:A,$path_vardir_trace/log/mysqlcheck.trace";
 
1863
  }
 
1864
  $ENV{'MYSQL_CHECK'}=              $cmdline_mysqlcheck;
1431
1865
 
1432
1866
  # ----------------------------------------------------
1433
1867
  # Setup env to childs can execute myqldump
1442
1876
    $cmdline_mysqldumpslave .=
1443
1877
      " --debug=d:t:A,$path_vardir_trace/log/mysqldump-slave.trace";
1444
1878
  }
1445
 
  $ENV{'DRIZZLE_DUMP'}= $cmdline_mysqldump;
1446
 
  $ENV{'DRIZZLE_DUMP_SLAVE'}= $cmdline_mysqldumpslave;
 
1879
  $ENV{'MYSQL_DUMP'}= $cmdline_mysqldump;
 
1880
  $ENV{'MYSQL_DUMP_SLAVE'}= $cmdline_mysqldumpslave;
 
1881
 
1447
1882
 
1448
1883
  # ----------------------------------------------------
1449
1884
  # Setup env so childs can execute mysqlslap
1450
1885
  # ----------------------------------------------------
1451
 
  if ( $exe_drizzleslap )
 
1886
  if ( $exe_mysqlslap )
1452
1887
  {
1453
 
    my $cmdline_drizzleslap=
1454
 
      mtr_native_path($exe_drizzleslap) .
 
1888
    my $cmdline_mysqlslap=
 
1889
      mtr_native_path($exe_mysqlslap) .
1455
1890
      " -uroot " .
1456
1891
      "--port=$master->[0]->{'port'} ";
1457
1892
 
1458
1893
    if ( $opt_debug )
1459
1894
   {
1460
 
      $cmdline_drizzleslap .=
1461
 
        " --debug=d:t:A,$path_vardir_trace/log/drizzleslap.trace";
 
1895
      $cmdline_mysqlslap .=
 
1896
        " --debug=d:t:A,$path_vardir_trace/log/mysqlslap.trace";
1462
1897
    }
1463
 
    $ENV{'DRIZZLE_SLAP'}= $cmdline_drizzleslap;
 
1898
    $ENV{'MYSQL_SLAP'}= $cmdline_mysqlslap;
1464
1899
  }
1465
1900
 
1466
 
 
1467
 
 
1468
1901
  # ----------------------------------------------------
1469
1902
  # Setup env so childs can execute mysqlimport
1470
1903
  # ----------------------------------------------------
1471
1904
  my $cmdline_mysqlimport=
1472
 
    mtr_native_path($exe_drizzleimport) .
1473
 
    " -uroot " .
 
1905
    mtr_native_path($exe_mysqlimport) .
 
1906
    " -uroot --debug-check " .
1474
1907
    "--port=$master->[0]->{'port'} ";
1475
1908
 
1476
1909
  if ( $opt_debug )
1478
1911
    $cmdline_mysqlimport .=
1479
1912
      " --debug=d:t:A,$path_vardir_trace/log/mysqlimport.trace";
1480
1913
  }
1481
 
  $ENV{'DRIZZLE_IMPORT'}= $cmdline_mysqlimport;
1482
 
 
 
1914
  $ENV{'MYSQL_IMPORT'}= $cmdline_mysqlimport;
 
1915
 
 
1916
 
 
1917
  # ----------------------------------------------------
 
1918
  # Setup env so childs can execute mysqlshow
 
1919
  # ----------------------------------------------------
 
1920
  my $cmdline_mysqlshow=
 
1921
    mtr_native_path($exe_mysqlshow) .
 
1922
    " -uroot --debug-check " .
 
1923
    "--port=$master->[0]->{'port'} ";
 
1924
 
 
1925
  if ( $opt_debug )
 
1926
  {
 
1927
    $cmdline_mysqlshow .=
 
1928
      " --debug=d:t:A,$path_vardir_trace/log/mysqlshow.trace";
 
1929
  }
 
1930
  $ENV{'MYSQL_SHOW'}= $cmdline_mysqlshow;
 
1931
 
 
1932
  # ----------------------------------------------------
 
1933
  # Setup env so childs can execute mysqlbinlog
 
1934
  # ----------------------------------------------------
 
1935
  my $cmdline_mysqlbinlog=
 
1936
    mtr_native_path($exe_mysqlbinlog) .
 
1937
      " --no-defaults --disable-force-if-open --debug-check";
 
1938
  if ( !$opt_extern && $mysql_version_id >= 50000 )
 
1939
  {
 
1940
    $cmdline_mysqlbinlog .=" --character-sets-dir=$path_charsetsdir";
 
1941
  }
 
1942
 
 
1943
  if ( $opt_debug )
 
1944
  {
 
1945
    $cmdline_mysqlbinlog .=
 
1946
      " --debug=d:t:A,$path_vardir_trace/log/mysqlbinlog.trace";
 
1947
  }
 
1948
  $ENV{'MYSQL_BINLOG'}= $cmdline_mysqlbinlog;
1483
1949
 
1484
1950
  # ----------------------------------------------------
1485
1951
  # Setup env so childs can execute mysql
1486
1952
  # ----------------------------------------------------
1487
1953
  my $cmdline_mysql=
1488
 
    mtr_native_path($exe_drizzle) .
1489
 
    " --no-defaults --host=localhost  --user=root --password= " .
1490
 
    "--port=$master->[0]->{'port'} ";
 
1954
    mtr_native_path($exe_mysql) .
 
1955
    " --no-defaults --debug-check --host=localhost  --user=root --password= " .
 
1956
    "--port=$master->[0]->{'port'} " .
 
1957
    "--character-sets-dir=$path_charsetsdir";
1491
1958
 
1492
1959
  $ENV{'MYSQL'}= $cmdline_mysql;
1493
1960
 
1494
1961
  # ----------------------------------------------------
1495
1962
  # Setup env so childs can execute bug25714
1496
1963
  # ----------------------------------------------------
1497
 
  $ENV{'DRIZZLE_BUG25714'}=  $exe_bug25714;
1498
 
 
1499
 
  # ----------------------------------------------------
1500
 
  # Setup env so childs can execute drizzle_client_test
1501
 
  # ----------------------------------------------------
1502
 
  $ENV{'DRIZZLE_CLIENT_TEST'}=  drizzle_client_test_arguments();
1503
 
 
 
1964
  $ENV{'MYSQL_BUG25714'}=  $exe_bug25714;
 
1965
 
 
1966
  # ----------------------------------------------------
 
1967
  # Setup env so childs can execute mysql_client_test
 
1968
  # ----------------------------------------------------
 
1969
  $ENV{'MYSQL_CLIENT_TEST'}=  mysql_client_test_arguments();
 
1970
 
 
1971
  # ----------------------------------------------------
 
1972
  # Setup env so childs can execute mysql_upgrade
 
1973
  # ----------------------------------------------------
 
1974
  if ( !$opt_extern && $mysql_version_id >= 50000 )
 
1975
  {
 
1976
    $ENV{'MYSQL_UPGRADE'}= mysql_upgrade_arguments();
 
1977
  }
1504
1978
 
1505
1979
  # ----------------------------------------------------
1506
1980
  # Setup env so childs can execute mysql_fix_system_tables
1507
1981
  # ----------------------------------------------------
1508
 
  #if ( !$opt_extern)
1509
 
  if ( 0 )
 
1982
  if ( !$opt_extern && ! $glob_win32 )
1510
1983
  {
1511
1984
    my $cmdline_mysql_fix_system_tables=
1512
 
      "$exe_drizzle_fix_system_tables --no-defaults --host=localhost " .
 
1985
      "$exe_mysql_fix_system_tables --no-defaults --host=localhost " .
1513
1986
      "--user=root --password= " .
1514
1987
      "--basedir=$glob_basedir --bindir=$path_client_bindir --verbose " .
1515
1988
      "--port=$master->[0]->{'port'} ";
1516
 
    $ENV{'DRIZZLE_FIX_SYSTEM_TABLES'}=  $cmdline_mysql_fix_system_tables;
 
1989
    $ENV{'MYSQL_FIX_SYSTEM_TABLES'}=  $cmdline_mysql_fix_system_tables;
1517
1990
 
1518
1991
  }
 
1992
    $ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}=  $file_mysql_fix_privilege_tables;
1519
1993
 
1520
1994
  # ----------------------------------------------------
1521
1995
  # Setup env so childs can execute my_print_defaults
1522
1996
  # ----------------------------------------------------
1523
 
  $ENV{'DRIZZLE_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
 
1997
  $ENV{'MYSQL_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
1524
1998
 
1525
1999
  # ----------------------------------------------------
1526
 
  # Setup env so childs can shutdown the server
 
2000
  # Setup env so childs can execute mysqladmin
1527
2001
  # ----------------------------------------------------
1528
 
  $ENV{'DRIZZLED_SHUTDOWN'}= mtr_native_path($exe_drizzle);
 
2002
  $ENV{'MYSQLADMIN'}= mtr_native_path($exe_mysqladmin);
1529
2003
 
1530
2004
  # ----------------------------------------------------
1531
2005
  # Setup env so childs can execute perror  
1533
2007
  $ENV{'MY_PERROR'}= mtr_native_path($exe_perror);
1534
2008
 
1535
2009
  # ----------------------------------------------------
 
2010
  # Add the path where mysqld will find udf_example.so
 
2011
  # ----------------------------------------------------
 
2012
  $ENV{'UDF_EXAMPLE_LIB'}=
 
2013
    ($lib_udf_example ? basename($lib_udf_example) : "");
 
2014
  $ENV{'UDF_EXAMPLE_LIB_OPT'}=
 
2015
    ($lib_udf_example ? "--plugin_dir=" . dirname($lib_udf_example) : "");
 
2016
 
 
2017
  # ----------------------------------------------------
1536
2018
  # Add the path where mysqld will find ha_example.so
1537
2019
  # ----------------------------------------------------
1538
2020
  $ENV{'EXAMPLE_PLUGIN'}=
1543
2025
  # ----------------------------------------------------
1544
2026
  # Setup env so childs can execute myisampack and myisamchk
1545
2027
  # ----------------------------------------------------
1546
 
#  $ENV{'MYISAMCHK'}= mtr_native_path(mtr_exe_exists(
1547
 
#                       "$path_client_bindir/myisamchk",
1548
 
#                       "$glob_basedir/storage/myisam/myisamchk",
1549
 
#                       "$glob_basedir/myisam/myisamchk"));
1550
 
#  $ENV{'MYISAMPACK'}= mtr_native_path(mtr_exe_exists(
1551
 
#                        "$path_client_bindir/myisampack",
1552
 
#                        "$glob_basedir/storage/myisam/myisampack",
1553
 
#                        "$glob_basedir/myisam/myisampack"));
 
2028
  $ENV{'MYISAMCHK'}= mtr_native_path(mtr_exe_exists(
 
2029
                       vs_config_dirs('storage/myisam', 'myisamchk'),
 
2030
                       vs_config_dirs('myisam', 'myisamchk'),
 
2031
                       "$path_client_bindir/myisamchk",
 
2032
                       "$glob_basedir/storage/myisam/myisamchk",
 
2033
                       "$glob_basedir/myisam/myisamchk"));
 
2034
  $ENV{'MYISAMPACK'}= mtr_native_path(mtr_exe_exists(
 
2035
                        vs_config_dirs('storage/myisam', 'myisampack'),
 
2036
                        vs_config_dirs('myisam', 'myisampack'),
 
2037
                        "$path_client_bindir/myisampack",
 
2038
                        "$glob_basedir/storage/myisam/myisampack",
 
2039
                        "$glob_basedir/myisam/myisampack"));
1554
2040
 
1555
2041
  # ----------------------------------------------------
1556
2042
  # We are nice and report a bit about our settings
1563
2049
    print "Using SLAVE_MYPORT          = $ENV{SLAVE_MYPORT}\n";
1564
2050
    print "Using SLAVE_MYPORT1         = $ENV{SLAVE_MYPORT1}\n";
1565
2051
    print "Using SLAVE_MYPORT2         = $ENV{SLAVE_MYPORT2}\n";
1566
 
    print "Using MC_PORT               = $ENV{MC_PORT}\n";
 
2052
    if ( ! $opt_skip_ndbcluster )
 
2053
    {
 
2054
      print "Using NDBCLUSTER_PORT       = $ENV{NDBCLUSTER_PORT}\n";
 
2055
      if ( ! $opt_skip_ndbcluster_slave )
 
2056
      {
 
2057
        print "Using NDBCLUSTER_PORT_SLAVE = $ENV{NDBCLUSTER_PORT_SLAVE}\n";
 
2058
      }
 
2059
    }
1567
2060
  }
1568
2061
 
1569
2062
  # Create an environment variable to make it possible
1600
2093
##############################################################################
1601
2094
 
1602
2095
sub kill_running_servers () {
 
2096
 
 
2097
  if ( $opt_fast or $glob_use_embedded_server )
 
2098
  {
 
2099
    # FIXME is embedded server really using PID files?!
 
2100
    unlink($master->[0]->{'path_pid'});
 
2101
    unlink($master->[1]->{'path_pid'});
 
2102
    unlink($slave->[0]->{'path_pid'});
 
2103
    unlink($slave->[1]->{'path_pid'});
 
2104
    unlink($slave->[2]->{'path_pid'});
 
2105
  }
 
2106
  else
1603
2107
  {
1604
2108
    # Ensure that no old mysqld test servers are running
1605
2109
    # This is different from terminating processes we have
1757
2261
  }
1758
2262
 
1759
2263
  # Make a link std_data_ln in var/ that points to std_data
1760
 
  symlink(collapse_path("$glob_mysql_test_dir/std_data"),
1761
 
          "$opt_vardir/std_data_ln");
 
2264
  if ( ! $glob_win32 )
 
2265
  {
 
2266
    symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
 
2267
  }
 
2268
  else
 
2269
  {
 
2270
    # on windows, copy all files from std_data into var/std_data_ln
 
2271
    mkpath("$opt_vardir/std_data_ln");
 
2272
    opendir(DIR, "$glob_mysql_test_dir/std_data")
 
2273
      or mtr_error("Can't find the std_data directory: $!");
 
2274
    for(readdir(DIR)) {
 
2275
      next if -d "$glob_mysql_test_dir/std_data/$_";
 
2276
      copy("$glob_mysql_test_dir/std_data/$_", "$opt_vardir/std_data_ln/$_");
 
2277
    }
 
2278
    closedir(DIR);
 
2279
  }
1762
2280
 
1763
2281
  # Remove old log files
1764
2282
  foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
1765
2283
  {
1766
2284
    unlink($name);
1767
2285
  }
1768
 
  system("chmod -R ugo+r $opt_vardir");
1769
 
  system("chmod -R ugo+r $opt_vardir/std_data_ln/*");
1770
2286
}
1771
2287
 
1772
2288
 
1789
2305
  # the file will not return 0000
1790
2306
  my $file_mode= (stat($test_file))[2] & 07777;
1791
2307
 
1792
 
  $ENV{'DRIZZLE_TEST_ROOT'}= "NO";
 
2308
  $ENV{'MYSQL_TEST_ROOT'}= "NO";
1793
2309
  mtr_verbose("result: $result, file_mode: $file_mode");
1794
2310
  if ($result eq "MySQL" && $file_mode == 0)
1795
2311
  {
1796
2312
    mtr_warning("running this script as _root_ will cause some " .
1797
2313
                "tests to be skipped");
1798
 
    $ENV{'DRIZZLE_TEST_ROOT'}= "YES";
 
2314
    $ENV{'MYSQL_TEST_ROOT'}= "YES";
1799
2315
  }
1800
2316
 
1801
2317
  chmod(oct("0755"), $test_file);
1804
2320
}
1805
2321
 
1806
2322
 
 
2323
sub check_ssl_support ($) {
 
2324
  my $mysqld_variables= shift;
 
2325
 
 
2326
  if ($opt_skip_ssl || $opt_extern)
 
2327
  {
 
2328
    if (!$opt_extern)
 
2329
    {
 
2330
      mtr_report("Skipping SSL");
 
2331
    }
 
2332
    $opt_ssl_supported= 0;
 
2333
    $opt_ssl= 0;
 
2334
    return;
 
2335
  }
 
2336
 
 
2337
  if ( ! $mysqld_variables->{'ssl'} )
 
2338
  {
 
2339
    if ( $opt_ssl)
 
2340
    {
 
2341
      mtr_error("Couldn't find support for SSL");
 
2342
      return;
 
2343
    }
 
2344
    mtr_report("Skipping SSL, mysqld not compiled with SSL");
 
2345
    $opt_ssl_supported= 0;
 
2346
    $opt_ssl= 0;
 
2347
    return;
 
2348
  }
 
2349
  mtr_report("Setting mysqld to support SSL connections");
 
2350
  $opt_ssl_supported= 1;
 
2351
}
 
2352
 
 
2353
 
1807
2354
sub check_debug_support ($) {
1808
2355
  my $mysqld_variables= shift;
1809
2356
 
1822
2369
  $debug_compiled_binaries= 1;
1823
2370
}
1824
2371
 
 
2372
##############################################################################
 
2373
#
 
2374
# Helper function to handle configuration-based subdirectories which Visual
 
2375
# Studio uses for storing binaries.  If opt_vs_config is set, this returns
 
2376
# a path based on that setting; if not, it returns paths for the default
 
2377
# /release/ and /debug/ subdirectories.
 
2378
#
 
2379
# $exe can be undefined, if the directory itself will be used
 
2380
#
 
2381
###############################################################################
 
2382
 
 
2383
sub vs_config_dirs ($$) {
 
2384
  my ($path_part, $exe) = @_;
 
2385
 
 
2386
  $exe = "" if not defined $exe;
 
2387
 
 
2388
  if ($opt_vs_config)
 
2389
  {
 
2390
    return ("$glob_basedir/$path_part/$opt_vs_config/$exe");
 
2391
  }
 
2392
 
 
2393
  return ("$glob_basedir/$path_part/release/$exe",
 
2394
          "$glob_basedir/$path_part/relwithdebinfo/$exe",
 
2395
          "$glob_basedir/$path_part/debug/$exe");
 
2396
}
 
2397
 
 
2398
##############################################################################
 
2399
#
 
2400
#  Start the ndb cluster
 
2401
#
 
2402
##############################################################################
 
2403
 
 
2404
sub check_ndbcluster_support ($) {
 
2405
  my $mysqld_variables= shift;
 
2406
 
 
2407
  if ($opt_skip_ndbcluster || $opt_extern)
 
2408
  {
 
2409
    if (!$opt_extern)
 
2410
    {
 
2411
      mtr_report("Skipping ndbcluster");
 
2412
    }
 
2413
    $opt_skip_ndbcluster_slave= 1;
 
2414
    return;
 
2415
  }
 
2416
 
 
2417
  if ( ! $mysqld_variables->{'ndb-connectstring'} )
 
2418
  {
 
2419
    mtr_report("Skipping ndbcluster, mysqld not compiled with ndbcluster");
 
2420
    $opt_skip_ndbcluster= 1;
 
2421
    $opt_skip_ndbcluster_slave= 1;
 
2422
    return;
 
2423
  }
 
2424
  $glob_ndbcluster_supported= 1;
 
2425
  mtr_report("Using ndbcluster when necessary, mysqld supports it");
 
2426
 
 
2427
  if ( $mysql_version_id < 50100 )
 
2428
  {
 
2429
    # Slave cluster is not supported until 5.1
 
2430
    $opt_skip_ndbcluster_slave= 1;
 
2431
 
 
2432
  }
 
2433
 
 
2434
  return;
 
2435
}
 
2436
 
 
2437
 
 
2438
sub ndbcluster_start_install ($) {
 
2439
  my $cluster= shift;
 
2440
 
 
2441
  mtr_report("Installing $cluster->{'name'} Cluster");
 
2442
 
 
2443
  mkdir($cluster->{'data_dir'});
 
2444
 
 
2445
  # Create a config file from template
 
2446
  my $ndb_no_ord=512;
 
2447
  my $ndb_no_attr=2048;
 
2448
  my $ndb_con_op=105000;
 
2449
  my $ndb_dmem="80M";
 
2450
  my $ndb_imem="24M";
 
2451
  my $ndb_pbmem="32M";
 
2452
  my $nodes= $cluster->{'nodes'};
 
2453
  my $ndb_host= "localhost";
 
2454
  my $ndb_diskless= 0;
 
2455
 
 
2456
  if (!$opt_bench)
 
2457
  {
 
2458
    # Use a smaller configuration
 
2459
    if (  $mysql_version_id < 50100 )
 
2460
    {
 
2461
      # 4.1 and 5.0 is using a "larger" --small configuration
 
2462
      $ndb_no_ord=128;
 
2463
      $ndb_con_op=10000;
 
2464
      $ndb_dmem="40M";
 
2465
      $ndb_imem="12M";
 
2466
    }
 
2467
    else
 
2468
    {
 
2469
      $ndb_no_ord=32;
 
2470
      $ndb_con_op=10000;
 
2471
      $ndb_dmem="20M";
 
2472
      $ndb_imem="1M";
 
2473
      $ndb_pbmem="4M";
 
2474
    }
 
2475
  }
 
2476
 
 
2477
  my $config_file_template=     "ndb/ndb_config_${nodes}_node.ini";
 
2478
  my $config_file= "$cluster->{'data_dir'}/config.ini";
 
2479
 
 
2480
  open(IN, $config_file_template)
 
2481
    or mtr_error("Can't open $config_file_template: $!");
 
2482
  open(OUT, ">", $config_file)
 
2483
    or mtr_error("Can't write to $config_file: $!");
 
2484
  while (<IN>)
 
2485
  {
 
2486
    chomp;
 
2487
 
 
2488
    s/CHOOSE_MaxNoOfAttributes/$ndb_no_attr/;
 
2489
    s/CHOOSE_MaxNoOfOrderedIndexes/$ndb_no_ord/;
 
2490
    s/CHOOSE_MaxNoOfConcurrentOperations/$ndb_con_op/;
 
2491
    s/CHOOSE_DataMemory/$ndb_dmem/;
 
2492
    s/CHOOSE_IndexMemory/$ndb_imem/;
 
2493
    s/CHOOSE_Diskless/$ndb_diskless/;
 
2494
    s/CHOOSE_HOSTNAME_.*/$ndb_host/;
 
2495
    s/CHOOSE_FILESYSTEM/$cluster->{'data_dir'}/;
 
2496
    s/CHOOSE_PORT_MGM/$cluster->{'port'}/;
 
2497
    if ( $mysql_version_id < 50000 )
 
2498
    {
 
2499
      my $base_port= $cluster->{'port'} + 1;
 
2500
      s/CHOOSE_PORT_TRANSPORTER/$base_port/;
 
2501
    }
 
2502
    s/CHOOSE_DiskPageBufferMemory/$ndb_pbmem/;
 
2503
 
 
2504
    print OUT "$_ \n";
 
2505
  }
 
2506
  close OUT;
 
2507
  close IN;
 
2508
 
 
2509
 
 
2510
  # Start cluster with "--initial"
 
2511
 
 
2512
  ndbcluster_start($cluster, "--initial");
 
2513
 
 
2514
  return 0;
 
2515
}
 
2516
 
 
2517
 
 
2518
sub ndbcluster_wait_started($$){
 
2519
  my $cluster= shift;
 
2520
  my $ndb_waiter_extra_opt= shift;
 
2521
  my $path_waiter_log= "$cluster->{'data_dir'}/ndb_waiter.log";
 
2522
  my $args;
 
2523
 
 
2524
  mtr_init_args(\$args);
 
2525
 
 
2526
  mtr_add_arg($args, "--no-defaults");
 
2527
  mtr_add_arg($args, "--core");
 
2528
  mtr_add_arg($args, "--ndb-connectstring=%s", $cluster->{'connect_string'});
 
2529
  mtr_add_arg($args, "--timeout=60");
 
2530
 
 
2531
  if ($ndb_waiter_extra_opt)
 
2532
  {
 
2533
    mtr_add_arg($args, "$ndb_waiter_extra_opt");
 
2534
  }
 
2535
 
 
2536
  # Start the ndb_waiter which will connect to the ndb_mgmd
 
2537
  # and poll it for state of the ndbd's, will return when
 
2538
  # all nodes in the cluster is started
 
2539
  my $res= mtr_run($exe_ndb_waiter, $args,
 
2540
                   "", $path_waiter_log, $path_waiter_log, "");
 
2541
  mtr_verbose("ndbcluster_wait_started, returns: $res") if $res;
 
2542
  return $res;
 
2543
}
 
2544
 
 
2545
 
 
2546
 
 
2547
sub mysqld_wait_started($){
 
2548
  my $mysqld= shift;
 
2549
 
 
2550
  if (sleep_until_file_created($mysqld->{'path_pid'},
 
2551
                               $mysqld->{'start_timeout'},
 
2552
                               $mysqld->{'pid'}) == 0)
 
2553
  {
 
2554
    # Failed to wait for pid file
 
2555
    return 1;
 
2556
  }
 
2557
 
 
2558
  # Get the "real pid" of the process, it will be used for killing
 
2559
  # the process in ActiveState's perl on windows
 
2560
  $mysqld->{'real_pid'}= mtr_get_pid_from_file($mysqld->{'path_pid'});
 
2561
 
 
2562
  return 0;
 
2563
}
 
2564
 
 
2565
 
 
2566
sub ndb_mgmd_wait_started($) {
 
2567
  my ($cluster)= @_;
 
2568
 
 
2569
  my $retries= 100;
 
2570
  while (ndbcluster_wait_started($cluster, "--no-contact") and
 
2571
         $retries)
 
2572
  {
 
2573
    # Millisceond sleep emulated with select
 
2574
    select(undef, undef, undef, (0.1));
 
2575
 
 
2576
    $retries--;
 
2577
  }
 
2578
 
 
2579
  return $retries == 0;
 
2580
 
 
2581
}
 
2582
 
 
2583
sub ndb_mgmd_start ($) {
 
2584
  my $cluster= shift;
 
2585
 
 
2586
  my $args;                             # Arg vector
 
2587
  my $pid= -1;
 
2588
 
 
2589
  mtr_init_args(\$args);
 
2590
  mtr_add_arg($args, "--no-defaults");
 
2591
  mtr_add_arg($args, "--core");
 
2592
  mtr_add_arg($args, "--nodaemon");
 
2593
  mtr_add_arg($args, "--config-file=%s", "$cluster->{'data_dir'}/config.ini");
 
2594
 
 
2595
 
 
2596
  my $path_ndb_mgmd_log= "$cluster->{'data_dir'}/\l$cluster->{'name'}_ndb_mgmd.log";
 
2597
  $pid= mtr_spawn($exe_ndb_mgmd, $args, "",
 
2598
                  $path_ndb_mgmd_log,
 
2599
                  $path_ndb_mgmd_log,
 
2600
                  "",
 
2601
                  { append_log_file => 1 });
 
2602
 
 
2603
  # FIXME Should not be needed
 
2604
  # Unfortunately the cluster nodes will fail to start
 
2605
  # if ndb_mgmd has not started properly
 
2606
  if (ndb_mgmd_wait_started($cluster))
 
2607
  {
 
2608
    mtr_error("Failed to wait for start of ndb_mgmd");
 
2609
  }
 
2610
 
 
2611
  # Remember pid of ndb_mgmd
 
2612
  $cluster->{'pid'}= $pid;
 
2613
 
 
2614
  mtr_verbose("ndb_mgmd_start, pid: $pid");
 
2615
 
 
2616
  return $pid;
 
2617
}
 
2618
 
 
2619
 
 
2620
sub ndbd_start ($$$) {
 
2621
  my $cluster= shift;
 
2622
  my $idx= shift;
 
2623
  my $extra_args= shift;
 
2624
 
 
2625
  my $args;                             # Arg vector
 
2626
  my $pid= -1;
 
2627
 
 
2628
  mtr_init_args(\$args);
 
2629
  mtr_add_arg($args, "--no-defaults");
 
2630
  mtr_add_arg($args, "--core");
 
2631
  mtr_add_arg($args, "--ndb-connectstring=%s", "$cluster->{'connect_string'}");
 
2632
  if ( $mysql_version_id >= 50000)
 
2633
  {
 
2634
    mtr_add_arg($args, "--character-sets-dir=%s", "$path_charsetsdir");
 
2635
  }
 
2636
  mtr_add_arg($args, "--nodaemon");
 
2637
  mtr_add_arg($args, "$extra_args");
 
2638
 
 
2639
  my $nodeid= $cluster->{'ndbds'}->[$idx]->{'nodeid'};
 
2640
  my $path_ndbd_log= "$cluster->{'data_dir'}/ndb_${nodeid}.log";
 
2641
  $pid= mtr_spawn($exe_ndbd, $args, "",
 
2642
                  $path_ndbd_log,
 
2643
                  $path_ndbd_log,
 
2644
                  "",
 
2645
                  { append_log_file => 1 });
 
2646
 
 
2647
  # Add pid to list of pids for this cluster
 
2648
  $cluster->{'ndbds'}->[$idx]->{'pid'}= $pid;
 
2649
 
 
2650
  # Rememeber options used when starting
 
2651
  $cluster->{'ndbds'}->[$idx]->{'start_extra_args'}= $extra_args;
 
2652
  $cluster->{'ndbds'}->[$idx]->{'idx'}= $idx;
 
2653
 
 
2654
  mtr_verbose("ndbd_start, pid: $pid");
 
2655
 
 
2656
  return $pid;
 
2657
}
 
2658
 
 
2659
 
 
2660
sub ndbcluster_start ($$) {
 
2661
  my $cluster= shift;
 
2662
  my $extra_args= shift;
 
2663
 
 
2664
  mtr_verbose("ndbcluster_start '$cluster->{'name'}'");
 
2665
 
 
2666
  if ( $cluster->{'use_running'} )
 
2667
  {
 
2668
    return 0;
 
2669
  }
 
2670
 
 
2671
  if ( $cluster->{'pid'} )
 
2672
  {
 
2673
    mtr_error("Cluster '$cluster->{'name'}' already started");
 
2674
  }
 
2675
 
 
2676
  ndb_mgmd_start($cluster);
 
2677
 
 
2678
  for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ )
 
2679
  {
 
2680
    ndbd_start($cluster, $idx, $extra_args);
 
2681
  }
 
2682
 
 
2683
  return 0;
 
2684
}
 
2685
 
 
2686
 
 
2687
sub rm_ndbcluster_tables ($) {
 
2688
  my $dir=       shift;
 
2689
  foreach my $bin ( glob("$dir/mysql/ndb_apply_status*"),
 
2690
                    glob("$dir/mysql/ndb_schema*"))
 
2691
  {
 
2692
    unlink($bin);
 
2693
  }
 
2694
}
 
2695
 
1825
2696
 
1826
2697
##############################################################################
1827
2698
#
1834
2705
 
1835
2706
  my $args;
1836
2707
 
 
2708
  if ( ! $glob_use_embedded_server )
1837
2709
  {
1838
2710
    mysqld_start($master->[0],[],[]);
1839
2711
    if ( ! $master->[0]->{'pid'} )
1852
2724
    mtr_add_arg($args, "--small-tables");
1853
2725
  }
1854
2726
 
 
2727
  if ( $opt_with_ndbcluster )
 
2728
  {
 
2729
    mtr_add_arg($args, "--create-options=TYPE=ndb");
 
2730
  }
 
2731
 
1855
2732
  chdir($glob_mysql_bench_dir)
1856
2733
    or mtr_error("Couldn't chdir to '$glob_mysql_bench_dir': $!");
1857
2734
 
1858
2735
  if ( ! $benchmark )
1859
2736
  {
 
2737
    mtr_add_arg($args, "--log");
1860
2738
    mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", "");
1861
2739
    # FIXME check result code?!
1862
2740
  }
1872
2750
 
1873
2751
  chdir($glob_mysql_test_dir);          # Go back
1874
2752
 
 
2753
  if ( ! $glob_use_embedded_server )
1875
2754
  {
1876
2755
    stop_masters();
1877
2756
  }
1897
2776
 
1898
2777
  foreach my $tinfo ( @$tests )
1899
2778
  {
1900
 
    foreach(1..$opt_repeat_test)
 
2779
    if (run_testcase_check_skip_test($tinfo))
1901
2780
    {
1902
 
      if (run_testcase_check_skip_test($tinfo))
1903
 
        {
1904
 
          next;
1905
 
        }
1906
 
 
1907
 
      mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
1908
 
      run_testcase($tinfo);
1909
 
      mtr_timer_stop($glob_timers,"testcase");
 
2781
      next;
1910
2782
    }
 
2783
 
 
2784
    mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
 
2785
    run_testcase($tinfo);
 
2786
    mtr_timer_stop($glob_timers,"testcase");
1911
2787
  }
1912
2788
 
1913
2789
  mtr_print_line();
1914
2790
 
1915
2791
  if ( ! $glob_debugger and
1916
 
       ! $opt_extern )
 
2792
       ! $opt_extern and
 
2793
       ! $glob_use_embedded_server )
1917
2794
  {
1918
2795
    stop_all_servers();
1919
2796
  }
1977
2854
  }
1978
2855
  check_running_as_root();
1979
2856
 
1980
 
  mtr_log_init("$opt_vardir/log/drizzle-test-run.log");
 
2857
  mtr_log_init("$opt_vardir/log/mysql-test-run.log");
1981
2858
 
1982
2859
}
1983
2860
 
1984
2861
sub mysql_install_db () {
1985
2862
 
 
2863
  install_db('master', $master->[0]->{'path_myddir'});
 
2864
 
1986
2865
  if ($max_master_num > 1)
1987
2866
  {
1988
2867
    copy_install_db('master', $master->[1]->{'path_myddir'});
1994
2873
    copy_install_db("slave".($idx+1), $slave->[$idx]->{'path_myddir'});
1995
2874
  }
1996
2875
 
 
2876
  my $cluster_started_ok= 1; # Assume it can be started
 
2877
 
 
2878
  my $cluster= $clusters->[0]; # Master cluster
 
2879
  if ($opt_skip_ndbcluster ||
 
2880
      $cluster->{'use_running'} ||
 
2881
      $cluster->{executable_setup_failed})
 
2882
  {
 
2883
    # Don't install master cluster
 
2884
  }
 
2885
  elsif (ndbcluster_start_install($cluster))
 
2886
  {
 
2887
    mtr_warning("Failed to start install of $cluster->{name}");
 
2888
    $cluster_started_ok= 0;
 
2889
  }
 
2890
 
 
2891
  $cluster= $clusters->[1]; # Slave cluster
 
2892
  if ($max_slave_num == 0 ||
 
2893
      $opt_skip_ndbcluster_slave ||
 
2894
      $cluster->{'use_running'} ||
 
2895
      $cluster->{executable_setup_failed})
 
2896
  {
 
2897
    # Don't install slave cluster
 
2898
  }
 
2899
  elsif (ndbcluster_start_install($cluster))
 
2900
  {
 
2901
    mtr_warning("Failed to start install of $cluster->{name}");
 
2902
    $cluster_started_ok= 0;
 
2903
  }
 
2904
 
 
2905
  foreach $cluster (@{$clusters})
 
2906
  {
 
2907
 
 
2908
    next if !$cluster->{'pid'};
 
2909
 
 
2910
    $cluster->{'installed_ok'}= 1; # Assume install suceeds
 
2911
 
 
2912
    if (ndbcluster_wait_started($cluster, ""))
 
2913
    {
 
2914
      # failed to install, disable usage and flag that its no ok
 
2915
      mtr_report("ndbcluster_install of $cluster->{'name'} failed");
 
2916
      $cluster->{"installed_ok"}= 0;
 
2917
 
 
2918
      $cluster_started_ok= 0;
 
2919
    }
 
2920
  }
 
2921
 
 
2922
  if ( ! $cluster_started_ok )
 
2923
  {
 
2924
    if ( $opt_force)
 
2925
    {
 
2926
      # Continue without cluster
 
2927
    }
 
2928
    else
 
2929
    {
 
2930
      mtr_error("To continue, re-run with '--force'.");
 
2931
    }
 
2932
  }
 
2933
 
1997
2934
  return 0;
1998
2935
}
1999
2936
 
2010
2947
}
2011
2948
 
2012
2949
 
 
2950
sub install_db ($$) {
 
2951
  my $type=      shift;
 
2952
  my $data_dir=  shift;
 
2953
 
 
2954
  mtr_report("Installing \u$type Database");
 
2955
 
 
2956
 
 
2957
  my $args;
 
2958
  mtr_init_args(\$args);
 
2959
  mtr_add_arg($args, "--no-defaults");
 
2960
  mtr_add_arg($args, "--bootstrap");
 
2961
  mtr_add_arg($args, "--basedir=%s", $path_my_basedir);
 
2962
  mtr_add_arg($args, "--datadir=%s", $data_dir);
 
2963
  mtr_add_arg($args, "--loose-skip-innodb");
 
2964
  mtr_add_arg($args, "--tmpdir=.");
 
2965
  mtr_add_arg($args, "--core-file");
 
2966
 
 
2967
  if ( $opt_debug )
 
2968
  {
 
2969
    mtr_add_arg($args, "--debug=d:t:i:A,%s/log/bootstrap_%s.trace",
 
2970
                $path_vardir_trace, $type);
 
2971
  }
 
2972
 
 
2973
  if ( ! $glob_netware )
 
2974
  {
 
2975
    mtr_add_arg($args, "--language=%s", $path_language);
 
2976
    mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
 
2977
  }
 
2978
 
 
2979
  # If DISABLE_GRANT_OPTIONS is defined when the server is compiled (e.g.,
 
2980
  # configure --disable-grant-options), mysqld will not recognize the
 
2981
  # --bootstrap or --skip-grant-tables options.  The user can set
 
2982
  # MYSQLD_BOOTSTRAP to the full path to a mysqld which does accept
 
2983
  # --bootstrap, to accommodate this.
 
2984
  my $exe_mysqld_bootstrap = $ENV{'MYSQLD_BOOTSTRAP'} || $exe_mysqld;
 
2985
 
 
2986
  # ----------------------------------------------------------------------
 
2987
  # export MYSQLD_BOOTSTRAP_CMD variable containing <path>/mysqld <args>
 
2988
  # ----------------------------------------------------------------------
 
2989
  $ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args);
 
2990
 
 
2991
  # ----------------------------------------------------------------------
 
2992
  # Create the bootstrap.sql file
 
2993
  # ----------------------------------------------------------------------
 
2994
  my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql";
 
2995
 
 
2996
  # Use the mysql database for system tables
 
2997
  mtr_tofile($bootstrap_sql_file, "use mysql");
 
2998
 
 
2999
  # Add the offical mysql system tables
 
3000
  # for a production system
 
3001
  mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables.sql",
 
3002
                         $bootstrap_sql_file);
 
3003
 
 
3004
  # Add the mysql system tables initial data
 
3005
  # for a production system
 
3006
  mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables_data.sql",
 
3007
                         $bootstrap_sql_file);
 
3008
 
 
3009
  # Add test data for timezone - this is just a subset, on a real
 
3010
  # system these tables will be populated either by mysql_tzinfo_to_sql
 
3011
  # or by downloading the timezone table package from our website
 
3012
  mtr_appendfile_to_file("$path_sql_dir/mysql_test_data_timezone.sql",
 
3013
                         $bootstrap_sql_file);
 
3014
 
 
3015
  # Remove anonymous users
 
3016
  mtr_tofile($bootstrap_sql_file,
 
3017
             "DELETE FROM mysql.user where user= '';");
 
3018
 
 
3019
  # Log bootstrap command
 
3020
  my $path_bootstrap_log= "$opt_vardir/log/bootstrap.log";
 
3021
  mtr_tofile($path_bootstrap_log,
 
3022
             "$exe_mysqld_bootstrap " . join(" ", @$args) . "\n");
 
3023
 
 
3024
 
 
3025
  if ( mtr_run($exe_mysqld_bootstrap, $args, $bootstrap_sql_file,
 
3026
               $path_bootstrap_log, $path_bootstrap_log,
 
3027
               "", { append_log_file => 1 }) != 0 )
 
3028
 
 
3029
  {
 
3030
    mtr_error("Error executing mysqld --bootstrap\n" .
 
3031
              "Could not install system database from $bootstrap_sql_file\n" .
 
3032
              "see $path_bootstrap_log for errors");
 
3033
  }
 
3034
}
 
3035
 
 
3036
 
2013
3037
#
2014
3038
# Restore snapshot of the installed slave databases
2015
3039
# if the snapshot exists
2038
3062
  # If marked to skip, just print out and return.
2039
3063
  # Note that a test case not marked as 'skip' can still be
2040
3064
  # skipped later, because of the test case itself in cooperation
2041
 
  # with the drizzletest program tells us so.
 
3065
  # with the mysqltest program tells us so.
2042
3066
  # ----------------------------------------------------------------------
2043
3067
 
2044
3068
  if ( $tinfo->{'skip'} )
2048
3072
    return 1;
2049
3073
  }
2050
3074
 
 
3075
  if ($tinfo->{'ndb_test'})
 
3076
  {
 
3077
    foreach my $cluster (@{$clusters})
 
3078
    {
 
3079
      # Slave cluster is skipped and thus not
 
3080
      # installed, no need to perform checks
 
3081
      last if ($opt_skip_ndbcluster_slave and
 
3082
               $cluster->{'name'} eq 'Slave');
 
3083
 
 
3084
      # Using running cluster - no need
 
3085
      # to check if test should be skipped
 
3086
      # will be done by test itself
 
3087
      last if ($cluster->{'use_running'});
 
3088
 
 
3089
      # If test needs this cluster, check binaries was found ok
 
3090
      if ( $cluster->{'executable_setup_failed'} )
 
3091
      {
 
3092
        mtr_report_test_name($tinfo);
 
3093
        $tinfo->{comment}=
 
3094
          "Failed to find cluster binaries";
 
3095
        mtr_report_test_failed($tinfo);
 
3096
        return 1;
 
3097
      }
 
3098
 
 
3099
      # If test needs this cluster, check it was installed ok
 
3100
      if ( !$cluster->{'installed_ok'} )
 
3101
      {
 
3102
        mtr_report_test_name($tinfo);
 
3103
        $tinfo->{comment}=
 
3104
          "Cluster $cluster->{'name'} was not installed ok";
 
3105
        mtr_report_test_failed($tinfo);
 
3106
        return 1;
 
3107
      }
 
3108
 
 
3109
    }
 
3110
  }
 
3111
 
2051
3112
  return 0;
2052
3113
}
2053
3114
 
2054
3115
 
2055
 
sub do_before_run_drizzletest($)
 
3116
sub do_before_run_mysqltest($)
2056
3117
{
2057
3118
  my $tinfo= shift;
2058
3119
  my $args;
2059
3120
 
2060
 
  # Remove old files produced by drizzletest
 
3121
  # Remove old files produced by mysqltest
2061
3122
  my $base_file= mtr_match_extension($tinfo->{'result_file'},
2062
3123
                                    "result"); # Trim extension
2063
3124
  unlink("$base_file.reject");
2065
3126
  unlink("$base_file.log");
2066
3127
  unlink("$base_file.warnings");
2067
3128
 
 
3129
  if (!$opt_extern)
 
3130
  {
 
3131
    if ( $mysql_version_id < 50000 ) {
 
3132
      # Set environment variable NDB_STATUS_OK to 1
 
3133
      # if script decided to run mysqltest cluster _is_ installed ok
 
3134
      $ENV{'NDB_STATUS_OK'} = "1";
 
3135
    } elsif ( $mysql_version_id < 50100 ) {
 
3136
      # Set environment variable NDB_STATUS_OK to YES
 
3137
      # if script decided to run mysqltest cluster _is_ installed ok
 
3138
      $ENV{'NDB_STATUS_OK'} = "YES";
 
3139
    }
 
3140
    if (defined $tinfo->{binlog_format} and  $mysql_version_id > 50100 )
 
3141
    {
 
3142
      # Dynamically switch binlog format of
 
3143
      # master, slave is always restarted
 
3144
      foreach my $server ( @$master )
 
3145
      {
 
3146
        next unless ($server->{'pid'});
 
3147
 
 
3148
        mtr_init_args(\$args);
 
3149
        mtr_add_arg($args, "--no-defaults");
 
3150
        mtr_add_arg($args, "--user=root");
 
3151
        mtr_add_arg($args, "--port=$server->{'port'}");
 
3152
 
 
3153
        my $sql= "include/set_binlog_format_".$tinfo->{binlog_format}.".sql";
 
3154
        mtr_verbose("Setting binlog format:", $tinfo->{binlog_format});
 
3155
        if (mtr_run($exe_mysql, $args, $sql, "", "", "") != 0)
 
3156
        {
 
3157
          mtr_error("Failed to switch binlog format");
 
3158
        }
 
3159
      }
 
3160
    }
 
3161
  }
2068
3162
}
2069
3163
 
2070
 
sub do_after_run_drizzletest($)
 
3164
sub do_after_run_mysqltest($)
2071
3165
{
2072
3166
  my $tinfo= shift;
2073
3167
 
2074
 
  # Save info from this testcase run to drizzletest.log
2075
 
  mtr_appendfile_to_file($path_current_test_log, $path_drizzletest_log)
 
3168
  # Save info from this testcase run to mysqltest.log
 
3169
  mtr_appendfile_to_file($path_current_test_log, $path_mysqltest_log)
2076
3170
    if -f $path_current_test_log;
2077
 
  mtr_appendfile_to_file($path_timefile, $path_drizzletest_log)
 
3171
  mtr_appendfile_to_file($path_timefile, $path_mysqltest_log)
2078
3172
    if -f $path_timefile;
2079
3173
}
2080
3174
 
2094
3188
    mtr_tofile($mysqld->{path_myerr}, $log_msg);
2095
3189
  }
2096
3190
 
 
3191
  # ndbcluster log file
 
3192
  mtr_tofile($path_ndb_testrun_log, $log_msg);
 
3193
 
2097
3194
}
2098
3195
 
2099
3196
sub find_testcase_skipped_reason($)
2103
3200
  # Set default message
2104
3201
  $tinfo->{'comment'}= "Detected by testcase(no log file)";
2105
3202
 
2106
 
  # Open drizzletest-time(the drizzletest log file)
 
3203
  # Open mysqltest-time(the mysqltest log file)
2107
3204
  my $F= IO::File->new($path_timefile)
2108
3205
    or return;
2109
3206
  my $reason;
2182
3279
      return 1;
2183
3280
    }
2184
3281
  }
 
3282
  elsif ($glob_use_embedded_server)
 
3283
  {
 
3284
    run_master_init_script($tinfo);
 
3285
  }
 
3286
 
2185
3287
  # ----------------------------------------------------------------------
2186
3288
  # If --start-and-exit or --start-dirty given, stop here to let user manually
2187
3289
  # run tests
2194
3296
  }
2195
3297
 
2196
3298
  {
2197
 
    do_before_run_drizzletest($tinfo);
 
3299
    do_before_run_mysqltest($tinfo);
2198
3300
 
2199
 
    my $res= run_drizzletest($tinfo);
 
3301
    my $res= run_mysqltest($tinfo);
2200
3302
    mtr_report_test_name($tinfo);
2201
3303
 
2202
 
    do_after_run_drizzletest($tinfo);
 
3304
    do_after_run_mysqltest($tinfo);
2203
3305
 
2204
3306
    if ( $res == 0 )
2205
3307
    {
2209
3311
    {
2210
3312
      # Testcase itself tell us to skip this one
2211
3313
 
2212
 
      # Try to get reason from drizzletest.log
 
3314
      # Try to get reason from mysqltest.log
2213
3315
      find_testcase_skipped_reason($tinfo);
2214
3316
      mtr_report_test_skipped($tinfo);
2215
3317
    }
2220
3322
    }
2221
3323
    elsif ( $res == 1 )
2222
3324
    {
2223
 
      # Test case failure reported by drizzletest
 
3325
      # Test case failure reported by mysqltest
2224
3326
      report_failure_and_restart($tinfo);
2225
3327
    }
2226
3328
    else
2227
3329
    {
2228
 
      # drizzletest failed, probably crashed
 
3330
      # mysqltest failed, probably crashed
2229
3331
      $tinfo->{comment}=
2230
 
        "drizzletest returned unexpected code $res, it has probably crashed";
 
3332
        "mysqltest returned unexpected code $res, it has probably crashed";
2231
3333
      report_failure_and_restart($tinfo);
2232
3334
    }
2233
3335
  }
2234
3336
 
2235
 
  # Remove the file that drizzletest writes info to
 
3337
  # Remove the file that mysqltest writes info to
2236
3338
  unlink($path_timefile);
2237
3339
 
2238
3340
  # ----------------------------------------------------------------------
2298
3400
      mtr_rmtree("$data_dir");
2299
3401
      mtr_copy_dir("$path_snapshot/$name", "$data_dir");
2300
3402
    }
 
3403
 
 
3404
    # Remove the ndb_*_fs dirs for all ndbd nodes
 
3405
    # forcing a clean start of ndb
 
3406
    foreach my $cluster (@{$clusters})
 
3407
    {
 
3408
      foreach my $ndbd (@{$cluster->{'ndbds'}})
 
3409
      {
 
3410
        mtr_rmtree("$ndbd->{'path_fs'}" );
 
3411
      }
 
3412
    }
2301
3413
  }
2302
3414
  else
2303
3415
  {
2326
3438
  mtr_report("Aborting: $tinfo->{'name'} failed in $test_mode mode. ");
2327
3439
  mtr_report("To continue, re-run with '--force'.");
2328
3440
  if ( ! $glob_debugger and
2329
 
       ! $opt_extern )
 
3441
       ! $opt_extern and
 
3442
       ! $glob_use_embedded_server )
2330
3443
  {
2331
3444
    stop_all_servers();
2332
3445
  }
2433
3546
    $sidx= $idx;
2434
3547
  }
2435
3548
 
2436
 
  my $prefix= "";               # If drizzletest server arg
 
3549
  my $prefix= "";               # If mysqltest server arg
 
3550
  if ( $glob_use_embedded_server )
 
3551
  {
 
3552
    $prefix= "--server-arg=";
 
3553
  }
2437
3554
 
2438
3555
  mtr_add_arg($args, "%s--no-defaults", $prefix);
2439
3556
 
2440
 
  $path_my_basedir= collapse_path($path_my_basedir);
2441
3557
  mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir);
2442
 
 
2443
 
  if ($opt_engine)
2444
 
  {
2445
 
    mtr_add_arg($args, "%s--default-storage-engine=%s", $prefix, $opt_engine);
2446
 
  }
 
3558
  mtr_add_arg($args, "%s--character-sets-dir=%s", $prefix, $path_charsetsdir);
2447
3559
 
2448
3560
  if ( $mysql_version_id >= 50036)
2449
3561
  {
2451
3563
    mtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir);
2452
3564
  }
2453
3565
 
 
3566
  if ( $mysql_version_id >= 50000 )
 
3567
  {
 
3568
    mtr_add_arg($args, "%s--log-bin-trust-function-creators", $prefix);
 
3569
  }
 
3570
 
 
3571
  mtr_add_arg($args, "%s--default-character-set=latin1", $prefix);
 
3572
  mtr_add_arg($args, "%s--language=%s", $prefix, $path_language);
2454
3573
  mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
2455
3574
 
2456
3575
  # Increase default connect_timeout to avoid intermittent
2457
3576
  # disconnects when test servers are put under load
2458
3577
  # see BUG#28359
2459
 
  mtr_add_arg($args, "%s--drizzle-protocol-connect-timeout=60", $prefix);
 
3578
  mtr_add_arg($args, "%s--connect-timeout=60", $prefix);
2460
3579
 
2461
3580
 
2462
3581
  # When mysqld is run by a root user(euid is 0), it will fail
2463
3582
  # to start unless we specify what user to run as, see BUG#30630
2464
3583
  my $euid= $>;
2465
 
  if (grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt) == 0) {
 
3584
  if (!$glob_win32 and $euid == 0 and
 
3585
      grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt) == 0) {
2466
3586
    mtr_add_arg($args, "%s--user=root", $prefix);
2467
3587
  }
2468
3588
 
2469
3589
  mtr_add_arg($args, "%s--pid-file=%s", $prefix,
2470
3590
              $mysqld->{'path_pid'});
2471
3591
 
2472
 
  mtr_add_arg($args, "%s--drizzle-protocol-port=%d", $prefix,
 
3592
  mtr_add_arg($args, "%s--port=%d", $prefix,
2473
3593
                $mysqld->{'port'});
2474
3594
 
2475
 
  mtr_add_arg($args, "%s--mysql-protocol-port=%d", $prefix,
2476
 
                $mysqld->{'port'} + 50);
2477
 
 
2478
3595
  mtr_add_arg($args, "%s--datadir=%s", $prefix,
2479
3596
              $mysqld->{'path_myddir'});
2480
3597
 
 
3598
 
 
3599
  if ( $mysql_version_id >= 50106 )
 
3600
  {
 
3601
    # Turn on logging to bothe tables and file
 
3602
    mtr_add_arg($args, "%s--log-output=table,file", $prefix);
 
3603
  }
 
3604
 
 
3605
  my $log_base_path= "$opt_vardir/log/$mysqld->{'type'}$sidx";
 
3606
  mtr_add_arg($args, "%s--log=%s.log", $prefix, $log_base_path);
 
3607
  mtr_add_arg($args,
 
3608
              "%s--log-slow-queries=%s-slow.log", $prefix, $log_base_path);
 
3609
 
2481
3610
  # Check if "extra_opt" contains --skip-log-bin
 
3611
  my $skip_binlog= grep(/^--skip-log-bin/, @$extra_opt, @opt_extra_mysqld_opt);
2482
3612
  if ( $mysqld->{'type'} eq 'master' )
2483
3613
  {
 
3614
    if (! ($opt_skip_master_binlog || $skip_binlog) )
 
3615
    {
 
3616
      mtr_add_arg($args, "%s--log-bin=%s/log/master-bin%s", $prefix,
 
3617
                  $opt_vardir, $sidx);
 
3618
    }
 
3619
 
2484
3620
    mtr_add_arg($args, "%s--server-id=%d", $prefix,
2485
3621
               $idx > 0 ? $idx + 101 : 1);
2486
3622
 
2487
3623
    mtr_add_arg($args, "%s--loose-innodb_data_file_path=ibdata1:10M:autoextend",
2488
3624
                $prefix);
2489
3625
 
2490
 
    mtr_add_arg($args, "%s--loose-innodb-lock-wait-timeout=5", $prefix);
 
3626
    mtr_add_arg($args, "%s--local-infile", $prefix);
2491
3627
 
2492
3628
    if ( $idx > 0 or !$use_innodb)
2493
3629
    {
2494
3630
      mtr_add_arg($args, "%s--loose-skip-innodb", $prefix);
2495
3631
    }
 
3632
 
 
3633
    my $cluster= $clusters->[$mysqld->{'cluster'}];
 
3634
    if ( $cluster->{'pid'} ||           # Cluster is started
 
3635
         $cluster->{'use_running'} )    # Using running cluster
 
3636
    {
 
3637
      mtr_add_arg($args, "%s--ndbcluster", $prefix);
 
3638
      mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
 
3639
                  $cluster->{'connect_string'});
 
3640
      mtr_add_arg($args, "%s--ndb-wait-connected=20", $prefix);
 
3641
      mtr_add_arg($args, "%s--ndb-cluster-connection-pool=3", $prefix);
 
3642
      mtr_add_arg($args, "%s--slave-allow-batching", $prefix);
 
3643
      if ( $mysql_version_id >= 50100 )
 
3644
      {
 
3645
        mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
 
3646
        mtr_add_arg($args, "%s--ndb-log-orig", $prefix);
 
3647
      }
 
3648
    }
 
3649
    else
 
3650
    {
 
3651
      mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
 
3652
    }
2496
3653
  }
2497
3654
  else
2498
3655
  {
2499
3656
    mtr_error("unknown mysqld type")
2500
3657
      unless $mysqld->{'type'} eq 'slave';
2501
3658
 
 
3659
    #mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
 
3660
    if (! ( $opt_skip_slave_binlog || $skip_binlog ))
 
3661
    {
 
3662
      mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
 
3663
                  $opt_vardir, $sidx); # FIXME use own dir for binlogs
 
3664
      mtr_add_arg($args, "%s--log-slave-updates", $prefix);
 
3665
    }
 
3666
 
 
3667
    mtr_add_arg($args, "%s--master-retry-count=10", $prefix);
 
3668
 
 
3669
    mtr_add_arg($args, "%s--relay-log=%s/log/slave%s-relay-bin", $prefix,
 
3670
                $opt_vardir, $sidx);
 
3671
    mtr_add_arg($args, "%s--report-host=127.0.0.1", $prefix);
 
3672
    mtr_add_arg($args, "%s--report-port=%d", $prefix,
 
3673
                $mysqld->{'port'});
 
3674
#    mtr_add_arg($args, "%s--report-user=root", $prefix);
 
3675
    mtr_add_arg($args, "%s--loose-skip-innodb", $prefix);
 
3676
    mtr_add_arg($args, "%s--skip-slave-start", $prefix);
 
3677
 
2502
3678
    # Directory where slaves find the dumps generated by "load data"
2503
3679
    # on the server. The path need to have constant length otherwise
2504
3680
    # test results will vary, thus a relative path is used.
2505
3681
    my $slave_load_path= "../tmp";
 
3682
    mtr_add_arg($args, "%s--slave-load-tmpdir=%s", $prefix,
 
3683
                $slave_load_path);
 
3684
    mtr_add_arg($args, "%s--set-variable=slave_net_timeout=120", $prefix);
2506
3685
 
2507
3686
    if ( @$slave_master_info )
2508
3687
    {
2516
3695
      my $slave_server_id=  2 + $idx;
2517
3696
      my $slave_rpl_rank= $slave_server_id;
2518
3697
      mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
 
3698
#      mtr_add_arg($args, "%s--rpl-recovery-rank=%d", $prefix, $slave_rpl_rank);
 
3699
    }
 
3700
 
 
3701
   my $cluster= $clusters->[$mysqld->{'cluster'}];
 
3702
   if ( $cluster->{'pid'} ||         # Slave cluster is started
 
3703
        $cluster->{'use_running'} )  # Using running slave cluster
 
3704
    {
 
3705
      mtr_add_arg($args, "%s--ndbcluster", $prefix);
 
3706
      mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
 
3707
                  $cluster->{'connect_string'});
 
3708
      mtr_add_arg($args, "%s--ndb-wait-connected=20", $prefix);
 
3709
      mtr_add_arg($args, "%s--ndb-cluster-connection-pool=3", $prefix);
 
3710
      mtr_add_arg($args, "%s--slave-allow-batching", $prefix);
 
3711
      if ( $mysql_version_id >= 50100 )
 
3712
      {
 
3713
        mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
 
3714
        mtr_add_arg($args, "%s--ndb-log-orig", $prefix);
 
3715
      }
 
3716
    }
 
3717
    else
 
3718
    {
 
3719
      mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
2519
3720
    }
2520
3721
  } # end slave
2521
3722
 
2529
3730
  mtr_add_arg($args, "%s--sort_buffer=256K", $prefix);
2530
3731
  mtr_add_arg($args, "%s--max_heap_table_size=1M", $prefix);
2531
3732
 
 
3733
  if ( $opt_ssl_supported )
 
3734
  {
 
3735
    mtr_add_arg($args, "%s--ssl-ca=%s/std_data/cacert.pem", $prefix,
 
3736
                $glob_mysql_test_dir);
 
3737
    mtr_add_arg($args, "%s--ssl-cert=%s/std_data/server-cert.pem", $prefix,
 
3738
                $glob_mysql_test_dir);
 
3739
    mtr_add_arg($args, "%s--ssl-key=%s/std_data/server-key.pem", $prefix,
 
3740
                $glob_mysql_test_dir);
 
3741
  }
 
3742
 
2532
3743
  if ( $opt_warnings )
2533
3744
  {
2534
3745
    mtr_add_arg($args, "%s--log-warnings", $prefix);
2548
3759
    {
2549
3760
      $found_skip_core= 1;
2550
3761
    }
 
3762
    elsif ($skip_binlog and mtr_match_prefix($arg, "--binlog-format"))
 
3763
    {
 
3764
      ; # Dont add --binlog-format when running without binlog
 
3765
    }
2551
3766
    else
2552
3767
    {
2553
3768
      mtr_add_arg($args, "%s%s", $prefix, $arg);
2558
3773
    mtr_add_arg($args, "%s%s", $prefix, "--core-file");
2559
3774
  }
2560
3775
 
 
3776
  if ( $opt_bench )
 
3777
  {
 
3778
    #mtr_add_arg($args, "%s--rpl-recovery-rank=1", $prefix);
 
3779
    #mtr_add_arg($args, "%s--init-rpl-role=master", $prefix);
 
3780
  }
 
3781
  elsif ( $mysqld->{'type'} eq 'master' )
 
3782
  {
 
3783
    mtr_add_arg($args, "%s--open-files-limit=1024", $prefix);
 
3784
  }
 
3785
 
2561
3786
  return $args;
2562
3787
}
2563
3788
 
2581
3806
  my $type= $mysqld->{'type'};
2582
3807
  my $idx= $mysqld->{'idx'};
2583
3808
 
 
3809
  mtr_error("Internal error: mysqld should never be started for embedded")
 
3810
    if $glob_use_embedded_server;
 
3811
 
2584
3812
  if ( $type eq 'master' )
2585
3813
  {
2586
3814
    $exe= $exe_master_mysqld;
2611
3839
  {
2612
3840
    ddd_arguments(\$args, \$exe, "$type"."_$idx");
2613
3841
  }
2614
 
  if ( $opt_dbx || $opt_manual_dbx)
2615
 
  {
2616
 
    dbx_arguments(\$args, \$exe, "$type"."_$idx");
2617
 
  }
2618
3842
  elsif ( $opt_debugger )
2619
3843
  {
2620
3844
    debugger_arguments(\$args, \$exe, "$type"."_$idx");
2683
3907
  {
2684
3908
    if ( $mysqld->{'pid'} )
2685
3909
    {
2686
 
      $pid= mtr_server_shutdown($mysqld);
 
3910
      $pid= mtr_mysqladmin_start($mysqld, "shutdown", 70);
2687
3911
      $admin_pids{$pid}= 1;
2688
3912
 
2689
3913
      push(@kill_pids,{
2699
3923
    }
2700
3924
  }
2701
3925
 
 
3926
  # Start shutdown of clusters
 
3927
  foreach my $cluster (@{$clusters})
 
3928
  {
 
3929
    if ( $cluster->{'pid'} )
 
3930
    {
 
3931
      $pid= mtr_ndbmgm_start($cluster, "shutdown");
 
3932
      $admin_pids{$pid}= 1;
 
3933
 
 
3934
      push(@kill_pids,{
 
3935
                       pid      => $cluster->{'pid'},
 
3936
                       pidfile  => $cluster->{'path_pid'}
 
3937
                      });
 
3938
 
 
3939
      $cluster->{'pid'}= 0; # Assume we are done with it
 
3940
 
 
3941
      foreach my $ndbd (@{$cluster->{'ndbds'}})
 
3942
      {
 
3943
        if ( $ndbd->{'pid'} )
 
3944
        {
 
3945
          push(@kill_pids,{
 
3946
                           pid      => $ndbd->{'pid'},
 
3947
                           pidfile  => $ndbd->{'path_pid'},
 
3948
                          });
 
3949
          $ndbd->{'pid'}= 0;
 
3950
        }
 
3951
      }
 
3952
    }
 
3953
  }
 
3954
 
2702
3955
  # Wait blocking until all shutdown processes has completed
2703
3956
  mtr_wait_blocking(\%admin_pids);
2704
3957
 
2705
3958
  # Make sure that process has shutdown else try to kill them
2706
3959
  mtr_check_stop_servers(\@kill_pids);
 
3960
 
 
3961
  foreach my $mysqld (@{$master}, @{$slave})
 
3962
  {
 
3963
    rm_ndbcluster_tables($mysqld->{'path_myddir'});
 
3964
  }
2707
3965
}
2708
3966
 
2709
3967
 
2714
3972
  # We try to find out if we are to restart the master(s)
2715
3973
  my $do_restart= 0;          # Assumes we don't have to
2716
3974
 
2717
 
  if ( $tinfo->{'master_sh'} )
 
3975
  if ( $glob_use_embedded_server )
 
3976
  {
 
3977
    mtr_verbose("Never start or restart for embedded server");
 
3978
    return $do_restart;
 
3979
  }
 
3980
  elsif ( $tinfo->{'master_sh'} )
2718
3981
  {
2719
3982
    $do_restart= 1;           # Always restart if script to run
2720
3983
    mtr_verbose("Restart master: Always restart if script to run");
2724
3987
    $do_restart= 1; # Always restart if --force-restart in -opt file
2725
3988
    mtr_verbose("Restart master: Restart forced with --force-restart");
2726
3989
  }
 
3990
  elsif ( ! $opt_skip_ndbcluster and
 
3991
          !$tinfo->{'ndb_test'} and
 
3992
          $clusters->[0]->{'pid'} != 0 )
 
3993
  {
 
3994
    $do_restart= 1;           # Restart without cluster
 
3995
    mtr_verbose("Restart master: Test does not need cluster");
 
3996
  }
 
3997
  elsif ( ! $opt_skip_ndbcluster and
 
3998
          $tinfo->{'ndb_test'} and
 
3999
          $clusters->[0]->{'pid'} == 0 )
 
4000
  {
 
4001
    $do_restart= 1;           # Restart with cluster
 
4002
    mtr_verbose("Restart master: Test need cluster");
 
4003
  }
2727
4004
  elsif( $tinfo->{'component_id'} eq 'im' )
2728
4005
  {
2729
4006
    $do_restart= 1;
2745
4022
    my $diff_opts= mtr_diff_opts($master->[0]->{'start_opts'},$tinfo->{'master_opt'});
2746
4023
    if (scalar(@$diff_opts) eq 2) 
2747
4024
    {
2748
 
      $do_restart= 1;
 
4025
      $do_restart= 1 unless ($diff_opts->[0] =~/^--binlog-format=/ and $diff_opts->[1] =~/^--binlog-format=/);
2749
4026
    }
2750
4027
    else
2751
4028
    {
2778
4055
  # We try to find out if we are to restart the slaves
2779
4056
  my $do_slave_restart= 0;     # Assumes we don't have to
2780
4057
 
2781
 
  if ( $max_slave_num == 0)
 
4058
  if ( $glob_use_embedded_server )
 
4059
  {
 
4060
    mtr_verbose("Never start or restart for embedded server");
 
4061
    return $do_slave_restart;
 
4062
  }
 
4063
  elsif ( $max_slave_num == 0)
2782
4064
  {
2783
4065
    mtr_verbose("Skip slave restart: No testcase use slaves");
2784
4066
  }
2841
4123
    {
2842
4124
      if ( $mysqld->{'pid'} )
2843
4125
      {
2844
 
        $pid= mtr_server_shutdown($mysqld);
2845
 
 
2846
 
        $admin_pids{$pid}= 1;
2847
 
 
2848
 
        push(@kill_pids,{
2849
 
              pid      => $mysqld->{'pid'},
2850
 
              real_pid => $mysqld->{'real_pid'},
2851
 
              pidfile  => $mysqld->{'path_pid'},
2852
 
              sockfile => $mysqld->{'path_sock'},
2853
 
              port     => $mysqld->{'port'},
2854
 
              errfile   => $mysqld->{'path_myerr'},
2855
 
        });
2856
 
 
2857
 
        $mysqld->{'pid'}= 0; # Assume we are done with it
 
4126
        $pid= mtr_mysqladmin_start($mysqld, "shutdown", 20);
 
4127
 
 
4128
        $admin_pids{$pid}= 1;
 
4129
 
 
4130
        push(@kill_pids,{
 
4131
                         pid      => $mysqld->{'pid'},
 
4132
                         real_pid => $mysqld->{'real_pid'},
 
4133
                         pidfile  => $mysqld->{'path_pid'},
 
4134
                         sockfile => $mysqld->{'path_sock'},
 
4135
                         port     => $mysqld->{'port'},
 
4136
                         errfile   => $mysqld->{'path_myerr'},
 
4137
                        });
 
4138
 
 
4139
        $mysqld->{'pid'}= 0; # Assume we are done with it
 
4140
      }
 
4141
    }
 
4142
 
 
4143
    # Start shutdown of master cluster
 
4144
    my $cluster= $clusters->[0];
 
4145
    if ( $cluster->{'pid'} )
 
4146
    {
 
4147
      $pid= mtr_ndbmgm_start($cluster, "shutdown");
 
4148
      $admin_pids{$pid}= 1;
 
4149
 
 
4150
      push(@kill_pids,{
 
4151
                       pid      => $cluster->{'pid'},
 
4152
                       pidfile  => $cluster->{'path_pid'}
 
4153
                      });
 
4154
 
 
4155
      $cluster->{'pid'}= 0; # Assume we are done with it
 
4156
 
 
4157
      foreach my $ndbd (@{$cluster->{'ndbds'}})
 
4158
      {
 
4159
        push(@kill_pids,{
 
4160
                         pid      => $ndbd->{'pid'},
 
4161
                         pidfile  => $ndbd->{'path_pid'},
 
4162
                        });
 
4163
        $ndbd->{'pid'}= 0; # Assume we are done with it
2858
4164
      }
2859
4165
    }
2860
4166
  }
2869
4175
    {
2870
4176
      if ( $mysqld->{'pid'} )
2871
4177
      {
2872
 
        $pid= mtr_server_shutdown($mysqld);
2873
 
 
2874
 
        $admin_pids{$pid}= 1;
2875
 
 
2876
 
        push(@kill_pids,{
2877
 
              pid      => $mysqld->{'pid'},
2878
 
              real_pid => $mysqld->{'real_pid'},
2879
 
              pidfile  => $mysqld->{'path_pid'},
2880
 
              sockfile => $mysqld->{'path_sock'},
2881
 
              port     => $mysqld->{'port'},
2882
 
              errfile  => $mysqld->{'path_myerr'},
2883
 
        });
2884
 
 
2885
 
        $mysqld->{'pid'}= 0; # Assume we are done with it
 
4178
        $pid= mtr_mysqladmin_start($mysqld, "shutdown", 20);
 
4179
 
 
4180
        $admin_pids{$pid}= 1;
 
4181
 
 
4182
        push(@kill_pids,{
 
4183
                         pid      => $mysqld->{'pid'},
 
4184
                         real_pid => $mysqld->{'real_pid'},
 
4185
                         pidfile  => $mysqld->{'path_pid'},
 
4186
                         sockfile => $mysqld->{'path_sock'},
 
4187
                         port     => $mysqld->{'port'},
 
4188
                         errfile   => $mysqld->{'path_myerr'},
 
4189
                        });
 
4190
 
 
4191
 
 
4192
        $mysqld->{'pid'}= 0; # Assume we are done with it
 
4193
      }
 
4194
    }
 
4195
 
 
4196
    # Start shutdown of slave cluster
 
4197
    my $cluster= $clusters->[1];
 
4198
    if ( $cluster->{'pid'} )
 
4199
    {
 
4200
      $pid= mtr_ndbmgm_start($cluster, "shutdown");
 
4201
 
 
4202
      $admin_pids{$pid}= 1;
 
4203
 
 
4204
      push(@kill_pids,{
 
4205
                       pid      => $cluster->{'pid'},
 
4206
                       pidfile  => $cluster->{'path_pid'}
 
4207
                      });
 
4208
 
 
4209
      $cluster->{'pid'}= 0; # Assume we are done with it
 
4210
 
 
4211
      foreach my $ndbd (@{$cluster->{'ndbds'}} )
 
4212
      {
 
4213
        push(@kill_pids,{
 
4214
                         pid      => $ndbd->{'pid'},
 
4215
                         pidfile  => $ndbd->{'path_pid'},
 
4216
                        });
 
4217
        $ndbd->{'pid'}= 0; # Assume we are done with it
2886
4218
      }
2887
4219
    }
2888
4220
  }
2898
4230
 
2899
4231
  # Make sure that process has shutdown else try to kill them
2900
4232
  mtr_check_stop_servers(\@kill_pids);
 
4233
 
 
4234
  foreach my $mysqld (@{$master}, @{$slave})
 
4235
  {
 
4236
    if ( ! $mysqld->{'pid'} )
 
4237
    {
 
4238
      # Remove ndbcluster tables if server is stopped
 
4239
      rm_ndbcluster_tables($mysqld->{'path_myddir'});
 
4240
    }
 
4241
  }
2901
4242
}
2902
4243
 
2903
4244
 
2917
4258
 
2918
4259
  if ( $tinfo->{'component_id'} eq 'mysqld' )
2919
4260
  {
 
4261
    if ( ! $opt_skip_ndbcluster and
 
4262
         !$clusters->[0]->{'pid'} and
 
4263
         $tinfo->{'ndb_test'} )
 
4264
    {
 
4265
      # Test need cluster, cluster is not started, start it
 
4266
      ndbcluster_start($clusters->[0], "");
 
4267
    }
 
4268
 
2920
4269
    if ( !$master->[0]->{'pid'} )
2921
4270
    {
2922
4271
      # Master mysqld is not started
2926
4275
 
2927
4276
    }
2928
4277
 
 
4278
    if ( $clusters->[0]->{'pid'} || $clusters->[0]->{'use_running'}
 
4279
         and ! $master->[1]->{'pid'} and
 
4280
         $tinfo->{'master_num'} > 1 )
 
4281
    {
 
4282
      # Test needs cluster, start an extra mysqld connected to cluster
 
4283
 
 
4284
      if ( $mysql_version_id >= 50100 )
 
4285
      {
 
4286
        # First wait for first mysql server to have created ndb system
 
4287
        # tables ok FIXME This is a workaround so that only one mysqld
 
4288
        # create the tables
 
4289
        if ( ! sleep_until_file_created(
 
4290
                  "$master->[0]->{'path_myddir'}/mysql/ndb_apply_status.ndb",
 
4291
                                        $master->[0]->{'start_timeout'},
 
4292
                                        $master->[0]->{'pid'}))
 
4293
        {
 
4294
 
 
4295
          $tinfo->{'comment'}= "Failed to create 'mysql/ndb_apply_status' table";
 
4296
          return 1;
 
4297
        }
 
4298
      }
 
4299
      mysqld_start($master->[1],$tinfo->{'master_opt'},[]);
 
4300
    }
 
4301
 
2929
4302
    # Save this test case information, so next can examine it
2930
4303
    $master->[0]->{'running_master_options'}= $tinfo;
2931
4304
  }
2939
4312
 
2940
4313
    do_before_start_slave($tinfo);
2941
4314
 
 
4315
    if ( ! $opt_skip_ndbcluster_slave and
 
4316
         !$clusters->[1]->{'pid'} and
 
4317
         $tinfo->{'ndb_test'} )
 
4318
    {
 
4319
      # Test need slave cluster, cluster is not started, start it
 
4320
      ndbcluster_start($clusters->[1], "");
 
4321
    }
 
4322
 
2942
4323
    for ( my $idx= 0; $idx <  $tinfo->{'slave_num'}; $idx++ )
2943
4324
    {
2944
4325
      if ( ! $slave->[$idx]->{'pid'} )
2953
4334
    $slave->[0]->{'running_slave_options'}= $tinfo;
2954
4335
  }
2955
4336
 
 
4337
  # Wait for clusters to start
 
4338
  foreach my $cluster (@{$clusters})
 
4339
  {
 
4340
 
 
4341
    next if !$cluster->{'pid'};
 
4342
 
 
4343
    if (ndbcluster_wait_started($cluster, ""))
 
4344
    {
 
4345
      # failed to start
 
4346
      $tinfo->{'comment'}= "Start of $cluster->{'name'} cluster failed";
 
4347
      return 1;
 
4348
    }
 
4349
  }
 
4350
 
2956
4351
  # Wait for mysqld's to start
2957
4352
  foreach my $mysqld (@{$master},@{$slave})
2958
4353
  {
2992
4387
  mtr_add_arg($args, "--no-defaults");
2993
4388
  mtr_add_arg($args, "--silent");
2994
4389
  mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
 
4390
  mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
2995
4391
 
2996
4392
  mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
2997
4393
  mtr_add_arg($args, "--database=test");
3006
4402
    mtr_add_arg($args, "--record");
3007
4403
  }
3008
4404
 
3009
 
  if ( $opt_testdir )
3010
 
  {
3011
 
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
3012
 
  }
3013
 
 
3014
 
  my $res = mtr_run_test($exe_drizzletest,$args,
 
4405
  my $res = mtr_run_test($exe_mysqltest,$args,
3015
4406
                "include/check-testcase.test", "", "", "");
3016
4407
 
3017
4408
  if ( $res == 1  and $mode eq "after")
3037
4428
sub run_report_features () {
3038
4429
  my $args;
3039
4430
 
 
4431
  if ( ! $glob_use_embedded_server )
3040
4432
  {
3041
4433
    mysqld_start($master->[0],[],[]);
3042
4434
    if ( ! $master->[0]->{'pid'} )
3057
4449
  $tinfo->{'slave_opt'} = [];
3058
4450
  $tinfo->{'slave_mi'} = [];
3059
4451
  $tinfo->{'comment'} = 'report server features';
3060
 
  run_drizzletest($tinfo);
 
4452
  run_mysqltest($tinfo);
3061
4453
 
 
4454
  if ( ! $glob_use_embedded_server )
3062
4455
  {
3063
4456
    stop_all_servers();
3064
4457
  }
3065
4458
}
3066
4459
 
3067
4460
 
3068
 
sub run_drizzletest ($) {
 
4461
sub run_mysqltest ($) {
3069
4462
  my ($tinfo)= @_;
3070
 
  my $exe= $exe_drizzletest;
 
4463
  my $exe= $exe_mysqltest;
3071
4464
  my $args;
3072
4465
 
3073
4466
  mtr_init_args(\$args);
3075
4468
  mtr_add_arg($args, "--no-defaults");
3076
4469
  mtr_add_arg($args, "--silent");
3077
4470
  mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
 
4471
  mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
3078
4472
  mtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
3079
4473
 
3080
4474
  # Log line number and time  for each line in .test file
3088
4482
    mtr_add_arg($args, "--password=");
3089
4483
  }
3090
4484
 
 
4485
  if ( $opt_ps_protocol )
 
4486
  {
 
4487
    mtr_add_arg($args, "--ps-protocol");
 
4488
  }
 
4489
 
 
4490
  if ( $opt_sp_protocol )
 
4491
  {
 
4492
    mtr_add_arg($args, "--sp-protocol");
 
4493
  }
 
4494
 
 
4495
  if ( $opt_view_protocol )
 
4496
  {
 
4497
    mtr_add_arg($args, "--view-protocol");
 
4498
  }
 
4499
 
 
4500
  if ( $opt_cursor_protocol )
 
4501
  {
 
4502
    mtr_add_arg($args, "--cursor-protocol");
 
4503
  }
 
4504
 
3091
4505
  if ( $opt_strace_client )
3092
4506
  {
3093
4507
    $exe=  "strace";            # FIXME there are ktrace, ....
3094
4508
    mtr_add_arg($args, "-o");
3095
 
    mtr_add_arg($args, "%s/log/drizzletest.strace", $opt_vardir);
3096
 
    mtr_add_arg($args, "$exe_drizzletest");
 
4509
    mtr_add_arg($args, "%s/log/mysqltest.strace", $opt_vardir);
 
4510
    mtr_add_arg($args, "$exe_mysqltest");
3097
4511
  }
3098
4512
 
3099
4513
  if ( $opt_timer )
3113
4527
 
3114
4528
  if ( $opt_debug )
3115
4529
  {
3116
 
    mtr_add_arg($args, "--debug=d:t:A,%s/log/drizzletest.trace",
 
4530
    mtr_add_arg($args, "--debug=d:t:A,%s/log/mysqltest.trace",
3117
4531
                $path_vardir_trace);
3118
4532
  }
3119
4533
 
3120
 
  if ( $opt_testdir )
3121
 
  {
3122
 
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
3123
 
  }
3124
 
 
3125
 
 
3126
 
  # ----------------------------------------------------------------------
3127
 
  # export DRIZZLE_TEST variable containing <path>/drizzletest <args>
3128
 
  # ----------------------------------------------------------------------
3129
 
  $ENV{'DRIZZLE_TEST'}=
3130
 
    mtr_native_path($exe_drizzletest) . " " . join(" ", @$args);
3131
 
 
3132
 
  # ----------------------------------------------------------------------
3133
 
  # Add arguments that should not go into the DRIZZLE_TEST env var
3134
 
  # ----------------------------------------------------------------------
3135
 
 
3136
 
  if ( $opt_valgrind_drizzletest )
 
4534
  if ( $opt_ssl_supported )
 
4535
  {
 
4536
    mtr_add_arg($args, "--ssl-ca=%s/std_data/cacert.pem",
 
4537
                $glob_mysql_test_dir);
 
4538
    mtr_add_arg($args, "--ssl-cert=%s/std_data/client-cert.pem",
 
4539
                $glob_mysql_test_dir);
 
4540
    mtr_add_arg($args, "--ssl-key=%s/std_data/client-key.pem",
 
4541
                $glob_mysql_test_dir);
 
4542
  }
 
4543
 
 
4544
  if ( $opt_ssl )
 
4545
  {
 
4546
    # Turn on SSL for _all_ test cases if option --ssl was used
 
4547
    mtr_add_arg($args, "--ssl");
 
4548
  }
 
4549
  elsif ( $opt_ssl_supported )
 
4550
  {
 
4551
    mtr_add_arg($args, "--skip-ssl");
 
4552
  }
 
4553
 
 
4554
  # ----------------------------------------------------------------------
 
4555
  # If embedded server, we create server args to give mysqltest to pass on
 
4556
  # ----------------------------------------------------------------------
 
4557
 
 
4558
  if ( $glob_use_embedded_server )
 
4559
  {
 
4560
    mysqld_arguments($args,$master->[0],$tinfo->{'master_opt'},[]);
 
4561
  }
 
4562
 
 
4563
  # ----------------------------------------------------------------------
 
4564
  # export MYSQL_TEST variable containing <path>/mysqltest <args>
 
4565
  # ----------------------------------------------------------------------
 
4566
  $ENV{'MYSQL_TEST'}=
 
4567
    mtr_native_path($exe_mysqltest) . " " . join(" ", @$args);
 
4568
 
 
4569
  # ----------------------------------------------------------------------
 
4570
  # Add arguments that should not go into the MYSQL_TEST env var
 
4571
  # ----------------------------------------------------------------------
 
4572
 
 
4573
  if ( $opt_valgrind_mysqltest )
3137
4574
  {
3138
4575
    # Prefix the Valgrind options to the argument list.
3139
4576
    # We do this here, since we do not want to Valgrind the nested invocations
3140
 
    # of drizzletest; that would mess up the stderr output causing test failure.
 
4577
    # of mysqltest; that would mess up the stderr output causing test failure.
3141
4578
    my @args_saved = @$args;
3142
4579
    mtr_init_args(\$args);
3143
4580
    valgrind_arguments($args, \$exe);
3203
4640
 
3204
4641
}
3205
4642
 
3206
 
#
3207
 
# Modify the exe and args so that program is run in gdb in xterm
3208
 
#
3209
 
sub dbx_arguments {
3210
 
  my $args= shift;
3211
 
  my $exe=  shift;
3212
 
  my $type= shift;
3213
 
 
3214
 
  # Write $args to gdb init file
3215
 
  my $str= join(" ", @$$args);
3216
 
  my $dbx_init_file= "$opt_tmpdir/dbxinit.$type";
3217
 
 
3218
 
  # Remove the old gdbinit file
3219
 
  unlink($dbx_init_file);
3220
 
  if ( $type eq "client" )
3221
 
  {
3222
 
    # write init file for client
3223
 
    mtr_tofile($dbx_init_file,
3224
 
               "runargs $str\n" .
3225
 
               "run\n");
3226
 
  }
3227
 
  else
3228
 
  {
3229
 
    # write init file for drizzled
3230
 
    mtr_tofile($dbx_init_file,
3231
 
               "stop in mysql_parse\n" .
3232
 
               "runargs $str\n" .
3233
 
               "run\n" .
3234
 
               "\n");
3235
 
  }
3236
 
 
3237
 
  if ( $opt_manual_dbx )
3238
 
  {
3239
 
     print "\nTo start dbx for $type, type in another window:\n";
3240
 
     print "dbx -c 'source $dbx_init_file' $$exe\n";
3241
 
 
3242
 
     # Indicate the exe should not be started
3243
 
     $$exe= undef;
3244
 
     return;
3245
 
  }
3246
 
 
3247
 
  $$args= [];
3248
 
  mtr_add_arg($$args, "-title");
3249
 
  mtr_add_arg($$args, "$type");
3250
 
  mtr_add_arg($$args, "-e");
3251
 
 
3252
 
  mtr_add_arg($$args, "dbx");
3253
 
  mtr_add_arg($$args, "-c");
3254
 
  mtr_add_arg($$args, "source $dbx_init_file");
3255
 
  mtr_add_arg($$args, "$$exe");
3256
 
 
3257
 
  $$exe= "xterm";
3258
 
}
3259
4643
 
3260
4644
#
3261
4645
# Modify the exe and args so that program is run in gdb in xterm
3402
4786
    $$exe= $debugger;
3403
4787
 
3404
4788
  }
3405
 
  #elsif ( $debugger eq "dbx" )
3406
 
  #{
3407
 
  #  # xterm -e dbx -r exe arg1 .. argn
3408
 
#
3409
 
#    unshift(@$$args, $$exe);
3410
 
#    unshift(@$$args, "-r");
3411
 
#    unshift(@$$args, $debugger);
3412
 
#    unshift(@$$args, "-e");
3413
 
#
3414
 
#    $$exe= "xterm";
3415
 
#
3416
 
#  }
 
4789
  elsif ( $debugger =~ /windbg/ )
 
4790
  {
 
4791
    # windbg exe arg1 .. argn
 
4792
 
 
4793
    # Add name of the exe before args
 
4794
    unshift(@$$args, "$$exe");
 
4795
 
 
4796
    # Set exe to debuggername
 
4797
    $$exe= $debugger;
 
4798
 
 
4799
  }
 
4800
  elsif ( $debugger eq "dbx" )
 
4801
  {
 
4802
    # xterm -e dbx -r exe arg1 .. argn
 
4803
 
 
4804
    unshift(@$$args, $$exe);
 
4805
    unshift(@$$args, "-r");
 
4806
    unshift(@$$args, $debugger);
 
4807
    unshift(@$$args, "-e");
 
4808
 
 
4809
    $$exe= "xterm";
 
4810
 
 
4811
  }
3417
4812
  else
3418
4813
  {
3419
4814
    mtr_error("Unknown argument \"$debugger\" passed to --debugger");
3433
4828
    mtr_add_arg($args, "--tool=callgrind");
3434
4829
    mtr_add_arg($args, "--base=$opt_vardir/log");
3435
4830
  }
3436
 
  elsif ($opt_massif)
3437
 
  {
3438
 
    mtr_add_arg($args, "--tool=massif");
3439
 
  }
3440
4831
  else
3441
4832
  {
3442
4833
    mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
 
4834
    mtr_add_arg($args, "--alignment=8");
3443
4835
    mtr_add_arg($args, "--leak-check=yes");
3444
4836
    mtr_add_arg($args, "--num-callers=16");
3445
4837
    mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
3463
4855
}
3464
4856
 
3465
4857
 
3466
 
sub mysqld_wait_started($){
3467
 
  my $mysqld= shift;
3468
 
 
3469
 
  if (sleep_until_file_created($mysqld->{'path_pid'},
3470
 
            $mysqld->{'start_timeout'},
3471
 
            $mysqld->{'pid'}) == 0)
3472
 
  {
3473
 
    # Failed to wait for pid file
3474
 
    return 1;
3475
 
  }
3476
 
 
3477
 
  # Get the "real pid" of the process, it will be used for killing
3478
 
  # the process in ActiveState's perl on windows
3479
 
  $mysqld->{'real_pid'}= mtr_get_pid_from_file($mysqld->{'path_pid'});
3480
 
 
3481
 
  return 0;
3482
 
}
3483
 
 
3484
 
sub collapse_path ($) {
3485
 
 
3486
 
    my $c_path= rel2abs(shift);
3487
 
    my $updir  = updir($c_path);
3488
 
    my $curdir = curdir($c_path);
3489
 
 
3490
 
    my($vol, $dirs, $file) = splitpath($c_path);
3491
 
    my @dirs = splitdir($dirs);
3492
 
 
3493
 
    my @collapsed;
3494
 
    foreach my $dir (@dirs) {
3495
 
        if( $dir eq $updir              and   # if we have an updir
3496
 
            @collapsed                  and   # and something to collapse
3497
 
            length $collapsed[-1]       and   # and its not the rootdir
3498
 
            $collapsed[-1] ne $updir    and   # nor another updir
3499
 
            $collapsed[-1] ne $curdir         # nor the curdir
3500
 
          )
3501
 
        {                                     # then
3502
 
            pop @collapsed;                   # collapse
3503
 
        }
3504
 
        else {                                # else
3505
 
            push @collapsed, $dir;            # just hang onto it
3506
 
        }
3507
 
    }
3508
 
 
3509
 
    return catpath($vol, catdir(@collapsed), $file);
3510
 
}
3511
 
 
3512
4858
##############################################################################
3513
4859
#
3514
4860
#  Usage
3529
4875
 
3530
4876
Options to control what engine/variation to run
3531
4877
 
 
4878
  embedded-server       Use the embedded server, i.e. no mysqld daemons
 
4879
  ps-protocol           Use the binary protocol between client and server
 
4880
  cursor-protocol       Use the cursor protocol between client and server
 
4881
                        (implies --ps-protocol)
 
4882
  view-protocol         Create a view to execute all non updating queries
 
4883
  sp-protocol           Create a stored procedure to execute all queries
3532
4884
  compress              Use the compressed protocol between client and server
 
4885
  ssl                   Use ssl protocol between client and server
 
4886
  skip-ssl              Dont start server with support for ssl connections
3533
4887
  bench                 Run the benchmark suite
3534
4888
  small-bench           Run the benchmarks with --small-tests --small-tables
 
4889
  ndb|with-ndbcluster   Use cluster as default table type
 
4890
  vs-config             Visual Studio configuration used to create executables
 
4891
                        (default: MTR_VS_CONFIG environment variable)
3535
4892
 
3536
4893
Options to control directories to use
3537
4894
  benchdir=DIR          The directory where the benchmark suite is stored
3551
4908
Options to control what test suites or cases to run
3552
4909
 
3553
4910
  force                 Continue to run the suite after failure
 
4911
  with-ndbcluster-only  Run only tests that include "ndb" in the filename
 
4912
  skip-ndb[cluster]     Skip all tests that need cluster
 
4913
  skip-ndb[cluster]-slave Skip all tests that need a slave cluster
 
4914
  ndb-extra             Run extra tests from ndb directory
3554
4915
  do-test=PREFIX or REGEX
3555
4916
                        Run test cases which name are prefixed with PREFIX
3556
4917
                        or fulfills REGEX
3562
4923
                        list of suite names.
3563
4924
                        The default is: "$opt_suites_default"
3564
4925
  skip-rpl              Skip the replication test cases.
 
4926
  big-test              Set the environment variable BIG_TEST, which can be
 
4927
                        checked from test cases.
3565
4928
  combination="ARG1 .. ARG2" Specify a set of "mysqld" arguments for one
3566
4929
                        combination.
3567
4930
  skip-combination      Skip any combination options and combinations files
3568
 
  repeat-test=n         How many times to repeat each test (default: 1)
3569
4931
 
3570
4932
Options that specify ports
3571
4933
 
3572
4934
  master_port=PORT      Specify the port number used by the first master
3573
4935
  slave_port=PORT       Specify the port number used by the first slave
 
4936
  ndbcluster-port=PORT  Specify the port number used by cluster
 
4937
  ndbcluster-port-slave=PORT  Specify the port number used by slave cluster
3574
4938
  mtr-build-thread=#    Specify unique collection of ports. Can also be set by
3575
4939
                        setting the environment variable MTR_BUILD_THREAD.
3576
4940
 
3587
4951
Options to run test on running server
3588
4952
 
3589
4953
  extern                Use running server for tests
 
4954
  ndb-connectstring=STR Use running cluster, and connect using STR
 
4955
  ndb-connectstring-slave=STR Use running slave cluster, and connect using STR
3590
4956
  user=USER             User for connection to extern server
 
4957
  socket=PATH           Socket for connection to extern server
3591
4958
 
3592
4959
Options for debugging the product
3593
4960
 
3594
 
  client-ddd            Start drizzletest client in ddd
3595
 
  client-debugger=NAME  Start drizzletest in the selected debugger
3596
 
  client-gdb            Start drizzletest client in gdb
 
4961
  client-ddd            Start mysqltest client in ddd
 
4962
  client-debugger=NAME  Start mysqltest in the selected debugger
 
4963
  client-gdb            Start mysqltest client in gdb
3597
4964
  ddd                   Start mysqld in ddd
3598
4965
  debug                 Dump trace output for all servers and client programs
3599
4966
  debugger=NAME         Start mysqld in the selected debugger
3606
4973
                        test(s)
3607
4974
  master-binary=PATH    Specify the master "mysqld" to use
3608
4975
  slave-binary=PATH     Specify the slave "mysqld" to use
3609
 
  strace-client         Create strace output for drizzletest client
 
4976
  strace-client         Create strace output for mysqltest client
3610
4977
  max-save-core         Limit the number of core files saved (to avoid filling
3611
4978
                        up disks for heavily crashing server). Defaults to
3612
4979
                        $opt_max_save_core, set to 0 for no limit.
3614
4981
Options for coverage, profiling etc
3615
4982
 
3616
4983
  gcov                  FIXME
3617
 
  gprof                 See online documentation on how to use it.
3618
 
  valgrind              Run the "drizzletest" and "mysqld" executables using
 
4984
  gprof                 FIXME
 
4985
  valgrind              Run the "mysqltest" and "mysqld" executables using
3619
4986
                        valgrind with default options
3620
4987
  valgrind-all          Synonym for --valgrind
3621
 
  valgrind-drizzletest    Run the "drizzletest" and "drizzle_client_test" executable
 
4988
  valgrind-mysqltest    Run the "mysqltest" and "mysql_client_test" executable
3622
4989
                        with valgrind
3623
4990
  valgrind-mysqld       Run the "mysqld" executable with valgrind
3624
4991
  valgrind-options=ARGS Deprecated, use --valgrind-option
3626
4993
                        can be specified more then once
3627
4994
  valgrind-path=[EXE]   Path to the valgrind executable
3628
4995
  callgrind             Instruct valgrind to use callgrind
3629
 
  massif                Instruct valgrind to use massif
3630
4996
 
3631
4997
Misc options
3632
4998
 
3646
5012
  suite-timeout=MINUTES Max test suite run time (default $default_suite_timeout)
3647
5013
  warnings | log-warnings Pass --log-warnings to mysqld
3648
5014
 
3649
 
  sleep=SECONDS         Passed to drizzletest, will be used as fixed sleep time
 
5015
  sleep=SECONDS         Passed to mysqltest, will be used as fixed sleep time
 
5016
 
 
5017
Deprecated options
 
5018
  with-openssl          Deprecated option for ssl
 
5019
 
3650
5020
 
3651
5021
HERE
3652
5022
  mtr_exit(1);