~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/test_tools/randgen/runall.pl

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-10-29 15:43:40 UTC
  • mfrom: (1.2.12) (2.1.19 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029154340-2gp39el6cv8bwf2o
Tags: 1:7.2.3-2ubuntu1
* Merge from debian, remaining changes:
  - Link against boost_system because of boost_thread.
  - Add required libs to message/include.am
  - Add upstart job and adjust init script to be upstart compatible.
  - Disable -floop-parallelize-all due to gcc-4.8/4.9 compiler ICE
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57732

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
# Copyright (c) 2008, 2011 Oracle and/or its affiliates. All rights reserved.
 
4
# Use is subject to license terms.
 
5
#
 
6
# This program is free software; you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation; version 2 of the License.
 
9
#
 
10
# This program is distributed in the hope that it will be useful, but
 
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
13
# General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 
18
# USA
 
19
 
 
20
#
 
21
# This script executes the following sequence
 
22
#
 
23
# $ mysql-test-run.pl --start-and-exit with replication
 
24
# $ gentest.pl --gendata
 
25
# $ diff master slave
 
26
#
 
27
#
 
28
 
 
29
use lib 'lib';
 
30
use lib "$ENV{RQG_HOME}/lib";
 
31
use strict;
 
32
use GenTest;
 
33
use Carp;
 
34
 
 
35
my $logger;
 
36
eval
 
37
{
 
38
    require Log::Log4perl;
 
39
    Log::Log4perl->import();
 
40
    $logger = Log::Log4perl->get_logger('randgen.gentest');
 
41
};
 
42
 
 
43
use GenTest::BzrInfo;
 
44
 
 
45
$| = 1;
 
46
if (osWindows()) {
 
47
        $SIG{CHLD} = "IGNORE";
 
48
}
 
49
 
 
50
if (defined $ENV{RQG_HOME}) {
 
51
        if (osWindows()) {
 
52
                $ENV{RQG_HOME} = $ENV{RQG_HOME}.'\\';
 
53
        } else {
 
54
                $ENV{RQG_HOME} = $ENV{RQG_HOME}.'/';
 
55
        }
 
56
}
 
57
 
 
58
use Getopt::Long;
 
59
use GenTest::Constants;
 
60
use DBI;
 
61
use Cwd;
 
62
 
 
63
my $database = 'test';
 
64
my @master_dsns;
 
65
 
 
66
my ($gendata, $skip_gendata, @basedirs, @mysqld_options, @vardirs, $rpl_mode,
 
67
    $engine, $help, $debug, $validators, $reporters, $grammar_file, $skip_recursive_rules,
 
68
    $redefine_file, $seed, $mask, $mask_level, $no_mask, $mem, $rows,
 
69
    $varchar_len, $xml_output, $valgrind, $valgrind_xml, $views,
 
70
    $start_dirty, $filter, $build_thread, $testname, $report_xml_tt,
 
71
    $report_xml_tt_type, $report_xml_tt_dest, $notnull, $sqltrace,
 
72
    $lcov, $transformers, $logfile, $logconf, $report_tt_logdir,$querytimeout,
 
73
    $short_column_names, $strict_fields, $freeze_time);
 
74
 
 
75
my $threads = my $default_threads = 10;
 
76
my $queries = my $default_queries = 1000;
 
77
my $duration = my $default_duration = 3600;
 
78
 
 
79
my @ARGV_saved = @ARGV;
 
80
 
 
81
my $opt_result = GetOptions(
 
82
        'mysqld=s@' => \$mysqld_options[0],
 
83
        'mysqld1=s@' => \$mysqld_options[0],
 
84
        'mysqld2=s@' => \$mysqld_options[1],
 
85
        'basedir=s' => \$basedirs[0],
 
86
        'basedir1=s' => \$basedirs[0],
 
87
        'basedir2=s' => \$basedirs[1],
 
88
        'vardir=s' => \$vardirs[0],
 
89
        'vardir1=s' => \$vardirs[0],
 
90
        'vardir2=s' => \$vardirs[1],
 
91
        'rpl_mode=s' => \$rpl_mode,
 
92
        'engine=s' => \$engine,
 
93
        'grammar=s' => \$grammar_file,
 
94
        'skip-recursive-rules' => \$skip_recursive_rules,       
 
95
        'redefine=s' => \$redefine_file,
 
96
        'threads=i' => \$threads,
 
97
        'queries=s' => \$queries,
 
98
        'duration=i' => \$duration,
 
99
        'help' => \$help,
 
100
        'debug' => \$debug,
 
101
        'validators:s@' => \$validators,
 
102
    'transformers:s@' =>\$transformers,
 
103
        'reporters:s@' => \$reporters,
 
104
        'report-xml-tt' => \$report_xml_tt,
 
105
        'report-xml-tt-type=s' => \$report_xml_tt_type,
 
106
        'report-xml-tt-dest=s' => \$report_xml_tt_dest,
 
107
        'gendata:s' => \$gendata,
 
108
        'skip-gendata' => \$skip_gendata,
 
109
        'notnull' => \$notnull,
 
110
        'short_column_names' => \$short_column_names,
 
111
        'strict_fields' => \$strict_fields,
 
112
        'freeze_time' => \$freeze_time,
 
113
        'seed=s' => \$seed,
 
114
        'mask=i' => \$mask,
 
115
    'mask-level=i' => \$mask_level,
 
116
        'no-mask' => \$no_mask,
 
117
        'mem' => \$mem,
 
118
        'rows=s' => \$rows,
 
119
        'varchar-length=i' => \$varchar_len,
 
120
        'xml-output=s'  => \$xml_output,
 
121
        'valgrind'      => \$valgrind,
 
122
        'valgrind-xml'  => \$valgrind_xml,
 
123
        'views:s'       => \$views,
 
124
        'sqltrace:s' => \$sqltrace,
 
125
        'start-dirty'   => \$start_dirty,
 
126
        'filter=s'      => \$filter,
 
127
    'mtr-build-thread=i' => \$build_thread,
 
128
    'testname=s' => \$testname,
 
129
        'lcov' => \$lcov,
 
130
    'logfile=s' => \$logfile,
 
131
    'logconf=s' => \$logconf,
 
132
    'report-tt-logdir=s' => \$report_tt_logdir,
 
133
    'querytimeout=i' => \$querytimeout
 
134
);
 
135
 
 
136
if (defined $logfile && defined $logger) {
 
137
    setLoggingToFile($logfile);
 
138
} else {
 
139
    if (defined $logconf && defined $logger) {
 
140
        setLogConf($logconf);
 
141
    }
 
142
}
 
143
 
 
144
$ENV{RQG_DEBUG} = 1 if defined $debug;
 
145
 
 
146
$validators = join(',', @$validators) if defined $validators;
 
147
$reporters = join(',', @$reporters) if defined $reporters;
 
148
$transformers = join(',', @$transformers) if defined $transformers;
 
149
 
 
150
if (!$opt_result) {
 
151
        exit(1);
 
152
} elsif ($help) {
 
153
        help();
 
154
        exit(0);
 
155
} elsif ($basedirs[0] eq '') {
 
156
        say("No basedir provided via --basedir.");
 
157
        exit(0);
 
158
} elsif (not defined $grammar_file) {
 
159
        say("No grammar file provided via --grammar");
 
160
        exit(0);
 
161
}
 
162
 
 
163
# --sqltrace may have a string value (optional). 
 
164
# Allowed values for --sqltrace:
 
165
my %sqltrace_legal_values = (
 
166
    'MarkErrors' => 1 # Prefixes invalid SQL statements for easier post-processing
 
167
);
 
168
 
 
169
# If no value is given, GetOpt will assign the value '' (empty string).
 
170
if (length($sqltrace) > 0) {
 
171
    # A value is given, check if it is legal.
 
172
    if (not exists $sqltrace_legal_values{$sqltrace}) {
 
173
        say("Invalid value for --sqltrace option: '$sqltrace'");
 
174
        say("Valid values are: ".join(', ', keys(%sqltrace_legal_values)));
 
175
        say("No value means that default/plain sqltrace will be used.");
 
176
        exit(STATUS_ENVIRONMENT_FAILURE);
 
177
    }
 
178
}
 
179
 
 
180
say("Copyright (c) 2008,2011 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.");
 
181
say("Please see http://forge.mysql.com/wiki/Category:RandomQueryGenerator for more information on this test framework.");
 
182
say("Starting: $0 ".join(" ", @ARGV_saved));
 
183
 
 
184
#
 
185
# Calculate master and slave ports based on MTR_BUILD_THREAD (MTR
 
186
# Version 1 behaviour)
 
187
#
 
188
 
 
189
if (not defined $build_thread) {
 
190
    if (defined $ENV{MTR_BUILD_THREAD}) {
 
191
        $build_thread = $ENV{MTR_BUILD_THREAD}
 
192
    } else {
 
193
        $build_thread = DEFAULT_MTR_BUILD_THREAD;
 
194
    }
 
195
}
 
196
 
 
197
if ( $build_thread eq 'auto' ) {
 
198
    say ("Please set the environment variable MTR_BUILD_THREAD to a value <> 'auto' (recommended) or unset it (will take the value ".DEFAULT_MTR_BUILD_THREAD.") ");
 
199
    exit (STATUS_ENVIRONMENT_FAILURE);
 
200
}
 
201
 
 
202
my $master_port = 10000 + 10 * $build_thread;
 
203
my $slave_port = 10000 + 10 * $build_thread + 2;
 
204
my @master_ports = ($master_port,$slave_port);
 
205
 
 
206
say("master_port : $master_port slave_port : $slave_port master_ports : @master_ports MTR_BUILD_THREAD : $build_thread ");
 
207
 
 
208
$ENV{MTR_BUILD_THREAD} = $build_thread;
 
209
 
 
210
#
 
211
# If the user has provided two vardirs and one basedir, start second
 
212
# server using the same basedir
 
213
#
 
214
 
 
215
 
 
216
if (
 
217
        ($vardirs[1] ne '') && 
 
218
        ($basedirs[1] eq '')
 
219
) {
 
220
        $basedirs[1] = $basedirs[0];    
 
221
}
 
222
 
 
223
foreach my $dir (cwd(), @basedirs) {
 
224
# calling bzr usually takes a few seconds...
 
225
    if (defined $dir) {
 
226
        my $bzrinfo = GenTest::BzrInfo->new(
 
227
            dir => $dir
 
228
            ); 
 
229
        my $revno = $bzrinfo->bzrRevno();
 
230
        my $revid = $bzrinfo->bzrRevisionId();
 
231
        
 
232
        if ((defined $revno) && (defined $revid)) {
 
233
            say("$dir Revno: $revno");
 
234
            say("$dir Revision-Id: $revid");
 
235
        } else {
 
236
            say($dir.' does not look like a bzr branch, cannot get revision info.');
 
237
        } 
 
238
    }
 
239
}
 
240
 
 
241
 
 
242
 
 
243
if (
 
244
        ($mysqld_options[1] ne '') && 
 
245
        ($basedirs[1] eq '')
 
246
) {
 
247
        $basedirs[1] = $basedirs[0];    
 
248
}
 
249
 
 
250
#
 
251
# If the user has provided identical basedirs and vardirs, warn of a potential overlap.
 
252
#
 
253
 
 
254
if (
 
255
        ($basedirs[0] eq $basedirs[1]) &&
 
256
        ($vardirs[0] eq $vardirs[1]) &&
 
257
        ($rpl_mode eq '')
 
258
) {
 
259
        die("Please specify either different --basedir[12] or different --vardir[12] in order to start two MySQL servers");
 
260
}
 
261
 
 
262
#
 
263
# If RQG_HOME is set, prepend it to config files if they can not be found without it 
 
264
#
 
265
 
 
266
$gendata = $ENV{RQG_HOME}.'/'.$gendata if defined $gendata && defined $ENV{RQG_HOME} && ! -e $gendata;
 
267
$grammar_file = $ENV{RQG_HOME}.'/'.$grammar_file if defined $grammar_file && defined $ENV{RQG_HOME} && ! -e $grammar_file;
 
268
$redefine_file = $ENV{RQG_HOME}.'/'.$redefine_file if defined $redefine_file && defined $ENV{RQG_HOME} && ! -e $redefine_file;
 
269
 
 
270
my $cwd = cwd();
 
271
 
 
272
if ($lcov) {
 
273
        unlink(tmpdir()."/lcov-rqg.info");
 
274
        system("lcov --directory $basedirs[0] --zerocounters");
 
275
}
 
276
 
 
277
#
 
278
# Start servers. Use rpl_alter if replication is needed.
 
279
#
 
280
        
 
281
foreach my $server_id (0..1) {
 
282
        next if $basedirs[$server_id] eq '';
 
283
 
 
284
        if (
 
285
                ($server_id == 0) ||
 
286
                ($rpl_mode eq '') 
 
287
        ) {
 
288
                $master_dsns[$server_id] = "dbi:mysql:host=127.0.0.1:port=".$master_ports[$server_id].":user=root:database=".$database;
 
289
        }
 
290
 
 
291
        my @mtr_options;
 
292
        push @mtr_options, lc("--mysqld=--$engine") if defined $engine && $engine !~ m{myisam|memory|heap|aria}sio;
 
293
 
 
294
        push @mtr_options, "--mem" if defined $mem;
 
295
        if ((defined $valgrind) || (defined $valgrind_xml)) {
 
296
                push @mtr_options, "--valgrind";
 
297
                if (defined $valgrind_xml) {
 
298
                        push @mtr_options, "--valgrind-option='--xml=yes'";
 
299
                        if (defined $vardirs[$server_id]) {
 
300
                                push @mtr_options, "--valgrind-option='--xml-file=".$vardirs[$server_id]."/log/valgrind.xml'";
 
301
                        } else {
 
302
                                push @mtr_options, "--valgrind-option='--xml-file=".$basedirs[$server_id]."/mysql-test/var/log/valgrind.xml'";
 
303
                        }
 
304
                }
 
305
        }
 
306
                        
 
307
        push @mtr_options, "--skip-ndb";
 
308
        push @mtr_options, "--mysqld=--core-file";
 
309
        push @mtr_options, "--mysqld=--loose-new";
 
310
        push @mtr_options, "--mysqld=--default-storage-engine=$engine" if defined $engine;
 
311
        push @mtr_options, "--mysqld=--sql-mode=no_engine_substitution" if join(' ', @ARGV_saved) !~ m{sql-mode}io;
 
312
        push @mtr_options, "--mysqld=--relay-log=slave-relay-bin";
 
313
        push @mtr_options, "--mysqld=--loose-innodb";
 
314
        push @mtr_options, "--mysqld=--loose-falcon-debug-mask=2";
 
315
        push @mtr_options, "--mysqld=--secure-file-priv=";              # Disable secure-file-priv that mtr enables.
 
316
        push @mtr_options, "--mysqld=--max-allowed-packet=16Mb";        # Allow loading bigger blobs
 
317
        push @mtr_options, "--mysqld=--loose-innodb-status-file=1";
 
318
        push @mtr_options, "--mysqld=--master-retry-count=65535";
 
319
        push @mtr_options, "--mysqld=--loose-debug-assert-if-crashed-table";
 
320
        push @mtr_options, "--mysqld=--loose-debug-assert-on-error";
 
321
        push @mtr_options, "--mysqld=--skip-name-resolve";
 
322
 
 
323
        push @mtr_options, "--start-dirty" if defined $start_dirty;
 
324
        push @mtr_options, "--gcov" if $lcov;
 
325
 
 
326
        if (($rpl_mode ne '') && ($server_id != 0)) {
 
327
                # If we are running in replication, and we start the slave separately (because it is a different binary)
 
328
                # add a few options that allow the slave and the master to be distinguished and SHOW SLAVE HOSTS to work
 
329
                push @mtr_options, "--mysqld=--server-id=".($server_id + 1);
 
330
                push @mtr_options, "--mysqld=--report-host=127.0.0.1";
 
331
                push @mtr_options, "--mysqld=--report-port=".$master_ports[$server_id];
 
332
        }
 
333
 
 
334
        my $mtr_path = $basedirs[$server_id].'/mysql-test/';
 
335
        chdir($mtr_path) or croak "unable to chdir() to $mtr_path: $!";
 
336
        
 
337
        push @mtr_options, "--vardir=$vardirs[$server_id]" if defined $vardirs[$server_id];
 
338
        push @mtr_options, "--master_port=".$master_ports[$server_id];
 
339
 
 
340
        if (defined $mysqld_options[$server_id]) {
 
341
                foreach my $mysqld_option (@{$mysqld_options[$server_id]}) {
 
342
                        push @mtr_options, '--mysqld="'.$mysqld_option.'"';
 
343
                }
 
344
        }
 
345
 
 
346
        if (
 
347
                ($rpl_mode ne '') &&
 
348
                ($server_id == 0) &&
 
349
                (not defined $vardirs[1]) &&
 
350
                (not defined $mysqld_options[1])
 
351
        ) {
 
352
                push @mtr_options, 'rpl_alter';
 
353
                push @mtr_options, "--slave_port=".$slave_port;
 
354
        } elsif ($basedirs[$server_id] =~ m{(^|[-/ ])5\.0}sgio) {
 
355
                say("Basedir implies server version 5.0. Will not use --start-and-exit 1st");
 
356
                # Do nothing, test name "1st" does not exist in 5.0
 
357
        } else {
 
358
                push @mtr_options, '1st';
 
359
        }
 
360
 
 
361
        $ENV{MTR_VERSION} = 1;
 
362
#       my $out_file = "/tmp/mtr-".$$."-".$server_id.".out";
 
363
        my $mtr_command = "perl mysql-test-run.pl --start-and-exit ".join(' ', @mtr_options)." 2>&1";
 
364
        say("Running $mtr_command .");
 
365
 
 
366
        my $vardir = $vardirs[$server_id] || $basedirs[$server_id].'/mysql-test/var';
 
367
 
 
368
        open (MTR_COMMAND, '>'.$mtr_path.'/mtr_command') or say("Unable to open mtr_command: $!");
 
369
        print MTR_COMMAND $mtr_command;
 
370
        close MTR_COMMAND;
 
371
 
 
372
        my $mtr_status = system($mtr_command);
 
373
 
 
374
        if ($mtr_status != 0) {
 
375
#               system("cat $out_file");
 
376
                system("cat \"$vardir/log/master.err\"");
 
377
                exit_test(STATUS_ENVIRONMENT_FAILURE);
 
378
        }
 
379
#       unlink($out_file);
 
380
        
 
381
        if ((defined $master_dsns[$server_id]) && (defined $engine)) {
 
382
                my $dbh = DBI->connect($master_dsns[$server_id], undef, undef, { RaiseError => 1 } );
 
383
                $dbh->do("SET GLOBAL storage_engine = '$engine'");
 
384
        }
 
385
}
 
386
 
 
387
chdir($cwd);
 
388
 
 
389
my $master_dbh = DBI->connect($master_dsns[0], undef, undef, { RaiseError => 1 } );
 
390
 
 
391
if ($rpl_mode) {
 
392
        my $slave_dsn = "dbi:mysql:host=127.0.0.1:port=".$slave_port.":user=root:database=".$database;
 
393
        my $slave_dbh = DBI->connect($slave_dsn, undef, undef, { RaiseError => 1 } );
 
394
 
 
395
        say("Establishing replication, mode $rpl_mode ...");
 
396
 
 
397
        my ($foo, $master_version) = $master_dbh->selectrow_array("SHOW VARIABLES LIKE 'version'");
 
398
 
 
399
        if (($master_version !~ m{^5\.0}sio) && ($rpl_mode ne 'default')) {
 
400
                $master_dbh->do("SET GLOBAL BINLOG_FORMAT = '$rpl_mode'");
 
401
                $slave_dbh->do("SET GLOBAL BINLOG_FORMAT = '$rpl_mode'");
 
402
        }
 
403
 
 
404
        $slave_dbh->do("STOP SLAVE");
 
405
 
 
406
        $slave_dbh->do("SET GLOBAL storage_engine = '$engine'") if defined $engine;
 
407
 
 
408
        $slave_dbh->do("CHANGE MASTER TO
 
409
                MASTER_PORT = $master_ports[0],
 
410
                MASTER_HOST = '127.0.0.1',
 
411
               MASTER_USER = 'root',
 
412
               MASTER_CONNECT_RETRY = 1
 
413
        ");
 
414
 
 
415
        $slave_dbh->do("START SLAVE");
 
416
}
 
417
 
 
418
#
 
419
# Run actual queries
 
420
#
 
421
 
 
422
my @gentest_options;
 
423
 
 
424
push @gentest_options, "--start-dirty" if defined $start_dirty;
 
425
push @gentest_options, "--gendata=$gendata" if not defined $skip_gendata;
 
426
push @gentest_options, "--notnull" if defined $notnull;
 
427
push @gentest_options, "--short_column_names" if defined $short_column_names;
 
428
push @gentest_options, "--strict_fields" if defined $strict_fields;
 
429
push @gentest_options, "--freeze_time" if defined $freeze_time;
 
430
push @gentest_options, "--engine=$engine" if defined $engine;
 
431
push @gentest_options, "--rpl_mode=$rpl_mode" if defined $rpl_mode;
 
432
push @gentest_options, map {'--validator='.$_} split(/,/,$validators) if defined $validators;
 
433
push @gentest_options, map {'--reporter='.$_} split(/,/,$reporters) if defined $reporters;
 
434
push @gentest_options, map {'--transformer='.$_} split(/,/,$transformers) if defined $transformers;
 
435
push @gentest_options, "--threads=$threads" if defined $threads;
 
436
push @gentest_options, "--queries=$queries" if defined $queries;
 
437
push @gentest_options, "--duration=$duration" if defined $duration;
 
438
push @gentest_options, "--dsn=$master_dsns[0]" if defined $master_dsns[0];
 
439
push @gentest_options, "--dsn=$master_dsns[1]" if defined $master_dsns[1];
 
440
push @gentest_options, "--grammar=$grammar_file";
 
441
push @gentest_options, "--skip-recursive-rules" if defined $skip_recursive_rules;
 
442
push @gentest_options, "--redefine=$redefine_file" if defined $redefine_file;
 
443
push @gentest_options, "--seed=$seed" if defined $seed;
 
444
push @gentest_options, "--mask=$mask" if ((defined $mask) && (not defined $no_mask));
 
445
push @gentest_options, "--mask-level=$mask_level" if defined $mask_level;
 
446
push @gentest_options, "--rows=$rows" if defined $rows;
 
447
push @gentest_options, "--views=$views" if defined $views;
 
448
push @gentest_options, "--varchar-length=$varchar_len" if defined $varchar_len;
 
449
push @gentest_options, "--xml-output=$xml_output" if defined $xml_output;
 
450
push @gentest_options, "--report-xml-tt" if defined $report_xml_tt;
 
451
push @gentest_options, "--report-xml-tt-type=$report_xml_tt_type" if defined $report_xml_tt_type;
 
452
push @gentest_options, "--report-xml-tt-dest=$report_xml_tt_dest" if defined $report_xml_tt_dest;
 
453
push @gentest_options, "--debug" if defined $debug;
 
454
push @gentest_options, "--filter=$filter" if defined $filter;
 
455
push @gentest_options, "--valgrind" if defined $valgrind;
 
456
push @gentest_options, "--valgrind-xml" if defined $valgrind_xml;
 
457
push @gentest_options, "--testname=$testname" if defined $testname;
 
458
push @gentest_options, "--sqltrace".(length($sqltrace)>0 ? "=$sqltrace" : '' ) if defined $sqltrace;
 
459
push @gentest_options, "--logfile=$logfile" if defined $logfile;
 
460
push @gentest_options, "--logconf=$logconf" if defined $logconf;
 
461
push @gentest_options, "--report-tt-logdir=$report_tt_logdir" if defined $report_tt_logdir;
 
462
push @gentest_options, "--querytimeout=$querytimeout" if defined $querytimeout;
 
463
 
 
464
# Push the number of "worker" threads into the environment.
 
465
# lib/GenTest/Generator/FromGrammar.pm will generate a corresponding grammar element.
 
466
$ENV{RQG_THREADS}= $threads;
 
467
 
 
468
my $gentest_result = system("perl ".($Carp::Verbose?"-MCarp=verbose ":"").
 
469
                            "$ENV{RQG_HOME}gentest.pl ".join(' ', @gentest_options)) >> 8;
 
470
say("gentest.pl exited with exit status ".status2text($gentest_result). " ($gentest_result)");
 
471
 
 
472
if ($lcov) {
 
473
        say("Trying to generate a genhtml lcov report in ".tmpdir()."/rqg-lcov-$$ ...");
 
474
        system("lcov --quiet --directory $basedirs[0] --capture --output-file ".tmpdir()."/lcov-rqg.info");
 
475
        system("genhtml --quiet --no-sort --output-directory=".tmpdir()."/rqg-lcov-$$ ".tmpdir()."/lcov-rqg.info");
 
476
        say("genhtml lcov report may have been generated in ".tmpdir()."/rqg-lcov-$$ .");
 
477
 
 
478
}       
 
479
 
 
480
exit_test($gentest_result);
 
481
 
 
482
sub help {
 
483
 
 
484
        print <<EOF
 
485
Copyright (c) 2008,2011 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.
 
486
 
 
487
$0 - Run a complete random query generation test, including server start with replication and master/slave verification
 
488
    
 
489
    Options related to one standalone MySQL server:
 
490
 
 
491
    --basedir   : Specifies the base directory of the stand-alone MySQL installation;
 
492
    --mysqld    : Options passed to the MySQL server
 
493
    --vardir    : Optional. (default \$basedir/mysql-test/var);
 
494
 
 
495
    Options related to two MySQL servers
 
496
 
 
497
    --basedir1  : Specifies the base directory of the first MySQL installation;
 
498
    --basedir2  : Specifies the base directory of the second MySQL installation;
 
499
    --mysqld1   : Options passed to the first MySQL server
 
500
    --mysqld2   : Options passed to the second MySQL server
 
501
    --vardir1   : Optional. (default \$basedir1/mysql-test/var);
 
502
    --vardir2   : Optional. (default \$basedir2/mysql-test/var);
 
503
 
 
504
    General options
 
505
 
 
506
    --grammar   : Grammar file to use when generating queries (REQUIRED);
 
507
    --redefine  : Grammar file to redefine and/or add rules to the given grammar
 
508
    --rpl_mode  : Replication type to use (statement|row|mixed) (default: no replication);
 
509
    --vardir1   : Optional.
 
510
    --vardir2   : Optional. 
 
511
    --engine    : Table engine to use when creating tables with gendata (default no ENGINE in CREATE TABLE);
 
512
    --threads   : Number of threads to spawn (default $default_threads);
 
513
    --queries   : Number of queries to execute per thread (default $default_queries);
 
514
    --duration  : Duration of the test in seconds (default $default_duration seconds);
 
515
    --validator : The validators to use
 
516
    --reporter  : The reporters to use
 
517
    --transformer: The transformers to use (turns on --validator=transformer). Accepts comma separated list
 
518
    --querytimeout: The timeout to use for the QueryTimeout reporter
 
519
    --gendata   : Generate data option. Passed to gentest.pl
 
520
    --seed      : PRNG seed. Passed to gentest.pl
 
521
    --mask      : Grammar mask. Passed to gentest.pl
 
522
    --mask-level: Grammar mask level. Passed to gentest.pl
 
523
    --rows      : No of rows. Passed to gentest.pl
 
524
    --varchar-length: length of strings. passed to gentest.pl
 
525
    --xml-output: Passed to gentest.pl
 
526
    --report-xml-tt: Passed to gentest.pl
 
527
    --report-xml-tt-type: Passed to gentest.pl
 
528
    --report-xml-tt-dest: Passed to gentest.pl
 
529
    --testname  : Name of test, used for reporting purposes
 
530
    --sqltrace  : Print all generated SQL statements.
 
531
                  Optional: Specify --sqltrace=MarkErrors to mark invalid statements.
 
532
    --views     : Generate views. Optionally specify view type (algorithm) as option value. Passed to gentest.pl
 
533
    --valgrind  : Passed to gentest.pl
 
534
    --filter    : Passed to gentest.pl
 
535
    --mem       : Passed to mtr
 
536
    --mtr-build-thread: Value used for MTR_BUILD_THREAD when servers are started and accessed 
 
537
    --short_column_names: Use short column names in gendata (c<number>)
 
538
    --strict_fields: Disable all AI applied to columns defined in \$fields in the gendata file. Allows for very specific column definitions
 
539
    --freeze_time: Freeze time for each query so that CURRENT_TIMESTAMP gives the same result for all transformers/validators
 
540
    --debug     : Debug mode
 
541
    --help      : This help message
 
542
 
 
543
    If you specify --basedir1 and --basedir2 or --vardir1 and --vardir2, two servers will be started and the results from the queries
 
544
    will be compared between them.
 
545
EOF
 
546
        ;
 
547
        print "$0 arguments were: ".join(' ', @ARGV_saved)."\n";
 
548
        exit_test(STATUS_UNKNOWN_ERROR);
 
549
}
 
550
 
 
551
sub exit_test {
 
552
        my $status = shift;
 
553
 
 
554
        print isoTimestamp()." [$$] $0 will exit with exit status ".status2text($status)." ($status)\n";
 
555
        safe_exit($status);
 
556
}