~ubuntu-branches/ubuntu/vivid/drizzle/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/kewpie/randgen/pb2gentest.pl

  • Committer: Package Import Robot
  • Author(s): Tobias Frost
  • Date: 2013-08-22 20:18:31 UTC
  • mto: (20.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20130822201831-gn3ozsh7o7wmc5tk
Tags: upstream-7.2.3
ImportĀ upstreamĀ versionĀ 7.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
2
 
# Use is subject to license terms.
3
 
#
4
 
# This program is free software; you can redistribute it and/or modify
5
 
# it under the terms of the GNU General Public License as published by
6
 
# the Free Software Foundation; version 2 of the License.
7
 
#
8
 
# This program is distributed in the hope that it will be useful, but
9
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
 
# General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin St, Suite 500, Boston, MA 02110-1335
16
 
# USA
17
 
 
18
 
use lib 'lib';
19
 
use lib "$ENV{RQG_HOME}/lib";
20
 
use lib 'randgen/lib';
21
 
#use lib 'randgen-alt/lib';
22
 
 
23
 
use strict;
24
 
use Carp;
25
 
use Cwd;
26
 
use DBI;
27
 
use File::Find;
28
 
use GenTest;
29
 
use GenTest::Random;
30
 
use GenTest::BzrInfo;
31
 
use POSIX;
32
 
use Sys::Hostname;
33
 
 
34
 
my ($basedir, $vardir, $tree, $test) = @ARGV;
35
 
 
36
 
# Which randgen variant do we use?
37
 
# When modifying this, remember to also modify the "use" statement above.
38
 
# (and ENV{PATH} for windows below)
39
 
my $randgen = 'randgen';
40
 
#my $randgen = 'randgen-alt';
41
 
 
42
 
 
43
 
#
44
 
# For further details about tests and recommended RQG options, see
45
 
# http://forge.mysql.com/wiki/RandomQueryGeneratorTests
46
 
#
47
 
 
48
 
print("==================== Starting $0 ====================\n");
49
 
# Print MTR-style output saying which test suite/mode this is for PB2 reporting.
50
 
# So far we only support running one test at a time.
51
 
print("##############################################################################\n");
52
 
print("# $test\n");
53
 
print("##############################################################################\n");
54
 
 
55
 
# Autoflush output buffers (needed when using POSIX::_exit())
56
 
$| = 1;
57
 
 
58
 
#
59
 
# Prepare ENV variables and other settings.
60
 
#
61
 
 
62
 
# Variable to indicate usage and location of grammar redefine files.
63
 
# Variable should remain undef if no redefine file is used.
64
 
my $redefine_file = undef;
65
 
 
66
 
# Local "installation" of MySQL 5.0. Default is for Unix hosts. See below for Windows.
67
 
my $basedirRelease50 = '/export/home/mysql-releases/mysql-5.0';
68
 
 
69
 
# Location of grammars and other test configuration files.
70
 
# Will use env variable RQG_CONF if set.
71
 
# Default is currently "conf" while using legacy setup.
72
 
# If not absolute path, it is relative to cwd at run time, which is the randgen directory.
73
 
my $conf = $ENV{RQG_CONF};
74
 
$conf = 'conf' if not defined $conf;
75
 
 
76
 
if (osWindows()) {
77
 
        # For tail, cdb, pscp.
78
 
        $ENV{PATH} = 'G:\pb2\scripts\randgen\bin;G:\pb2\scripts\bin;C:\Program Files\Debugging Tools for Windows (x86);'.$ENV{PATH};
79
 
        $ENV{_NT_SYMBOL_PATH} = 'srv*c:\\cdb_symbols*http://msdl.microsoft.com/download/symbols;cache*c:\\cdb_symbols';
80
 
 
81
 
        # For vlad
82
 
        #ENV{MYSQL_FULL_MINIDUMP} = 1;
83
 
 
84
 
        #system("date /T");
85
 
        #system("time /T");
86
 
 
87
 
        # Path to MySQL releases used for comparison runs.
88
 
        $basedirRelease50 = 'G:\mysql-releases\mysql-5.0.91-win32'; # loki06
89
 
} elsif (osSolaris()) {
90
 
        # For libmysqlclient
91
 
        $ENV{LD_LIBRARY_PATH}=$ENV{LD_LIBRARY_PATH}.':/export/home/pb2/scripts/lib/';
92
 
 
93
 
        # For DBI and DBD::mysql and XML::Writer on hosts with local setup.
94
 
        $ENV{PERL5LIB}=$ENV{PERL5LIB}.
95
 
                ':/export/home/pb2/scripts/DBI-1.607/'.
96
 
                ':/export/home/pb2/scripts/DBI-1.607/lib'.
97
 
                ':/export/home/pb2/scripts/DBI-1.607/blib/arch/'.
98
 
                ':/export/home/pb2/scripts/DBD-mysql-4.008/lib/'.
99
 
                ':/export/home/pb2/scripts/DBD-mysql-4.008/blib/arch/'.
100
 
                ':/export/home/pb2/scripts/XML-Writer-0.610/lib/site_perl/';
101
 
        
102
 
        # For c++filt
103
 
        $ENV{PATH} = $ENV{PATH}.':/opt/studio12/SUNWspro/bin';
104
 
 
105
 
        #system("uname -a");
106
 
        #system("date");
107
 
 
108
 
}
109
 
 
110
 
################################################################################
111
 
##
112
 
## subroutines
113
 
##
114
 
################################################################################
115
 
 
116
 
#
117
 
# Looks for a file name with the same name as the grammar mentioned in the
118
 
# command line string, except with a "_redefine.yy" suffix.
119
 
#
120
 
# The redefine file is expected to be in the same directory as the grammar 
121
 
# itself, at least for now.
122
 
# If such a file is not found, undef is returned.
123
 
#
124
 
# Input: Command string including "--grammar=...".
125
 
# Output: Filename of redefine file, to be used with --redefine option.
126
 
#         Returns undef if such a file is not found where expected.
127
 
#
128
 
sub redefine_filename ($){
129
 
    # Steps:
130
 
    #  1. Find out the grammar file name.
131
 
    #  2. Construct the expected redefine file name
132
 
    #     (replacing ".yy" with "_redefine.yy").
133
 
    #  3. Check if the redefine file exists.
134
 
    #  4. Return the redefine file name, or undef.
135
 
    #
136
 
    my $command_string = @_[0];
137
 
    if ($command_string =~ /(--grammar)=(.+)\s/m) {
138
 
        my $grammar_filename = $2;
139
 
        my $redefine_filename = $grammar_filename;
140
 
        $redefine_filename =~ s/\.yy/_redefine\.yy/;
141
 
        if (-e $redefine_filename) {
142
 
            say("Using redefine file ".$redefine_filename.".");
143
 
            print_special_comments($redefine_filename);
144
 
            return $redefine_filename;
145
 
        } else {
146
 
            say("No redefine file found for grammar ".$grammar_filename.".");
147
 
            print_special_comments($grammar_filename);
148
 
            return undef;
149
 
        }
150
 
    } else {
151
 
        croak("redefine_filename: Option --grammar not found in command. Command is: $command_string");
152
 
    }
153
 
}
154
 
 
155
 
#
156
 
# Looks in a file for comments of a certain format and prints them to standard
157
 
# output with some cruft to separate it from other output.
158
 
#
159
 
# Input: Filename (path)
160
 
#
161
 
sub print_special_comments ($){
162
 
    # Corresponding Unix command: grep '.*\(WL#\|Bug#\|Disabled\).*' grammar_file_redefine.yy
163
 
    
164
 
    my $filename = @_[0];
165
 
    my $pattern = "# +(WL#|Bug#|Disabled).*";
166
 
    my $pattern_new_entry = "# +(WL#|Bug#).+";
167
 
    # We assume that "Disabled" always comes after "Bug#" or "WL#" in files with
168
 
    # special comments with agreed structure. So in a line that matches the
169
 
    # first pattern we look for indicators of a new entry by using 
170
 
    # $pattern_new_entry (see below).
171
 
 
172
 
    say("Looking for special comments in grammar or redefine file...");
173
 
    say("Using pattern: ".$pattern);
174
 
    say("\n#### SPECIAL COMMENTS IN FILE $filename: ####");
175
 
    say();
176
 
    open FILE, "$filename" or croak("Unable to open file $filename");
177
 
    my $line;
178
 
    while ( <FILE> ) {
179
 
        $line = trim($_);
180
 
        if ($line =~ m{$pattern}) {
181
 
            # Add a blank line before all new entries, so that it is easier to 
182
 
            # distinguish separate entries in the test log. 
183
 
            if ($line =~ m{$pattern_new_entry}) {
184
 
                say("\n\t".$line);
185
 
            } else {
186
 
                say("\t".$line);
187
 
            }
188
 
        }
189
 
    }
190
 
    close FILE;
191
 
    say("");
192
 
    say("#### END OF SPECIAL COMMENTS ####\n");
193
 
    say("");
194
 
}
195
 
 
196
 
 
197
 
#
198
 
# Removes leading and trailing whitespace.
199
 
#
200
 
sub trim($)
201
 
{
202
 
    my $string = shift;
203
 
    $string =~ s/^\s+//;
204
 
    $string =~ s/\s+$//;
205
 
    return $string;
206
 
}
207
 
 
208
 
 
209
 
#
210
 
# Skips the test, displays reason (argument to the routine) quasi-MTR-style and
211
 
# exits with exit code 0.
212
 
#
213
 
# Example usage:
214
 
#   # This feature is not yet supported on Windows, so skip this test
215
 
#   skip_test("This feature/test does not support the Windows platform at this time");
216
 
#
217
 
# will appear in output as:
218
 
#   rpl_semisync                             [ skipped ] This feature/test does not support the Windows platform at this time
219
 
#
220
 
sub skip_test {
221
 
        my $reason = @_[0];
222
 
        my $message = "$test";
223
 
        # Using MTR-style output for the readers' convenience.
224
 
        # (at least 41 chars before "[ skipped ]")
225
 
        while (length $message < 40)
226
 
        {
227
 
                $message = $message.' ';
228
 
        }
229
 
        $message = $message." [ skipped ] ".$reason;
230
 
        print "$message\n";
231
 
        print localtime()." [$$] $0 will exit with exit status 0.\n";
232
 
        POSIX::_exit (0);
233
 
}
234
 
 
235
 
#
236
 
# Returns a random number between 1 and 499.
237
 
#
238
 
sub pick_random_port_range_id {
239
 
        my $prng = GenTest::Random->new( seed => time );
240
 
        return $prng->uint16(1,499);
241
 
}
242
 
 
243
 
#
244
 
# Searches recursively for a given file name under the given directory.
245
 
# Default top search directory is $basedir.
246
 
#
247
 
# Arg1 (mandatory): file name (excluding path)
248
 
# Arg2 (optional) : directory where search will start
249
 
#
250
 
# Returns full path to the directory where the file resides, if found.
251
 
# If more than one matching file is found, the directory of the first one found
252
 
# in a depth-first search will be returned.
253
 
# Returns undef if none is found.
254
 
#
255
 
sub findDirectory {
256
 
        my ($plugin_name, $dir) = @_;
257
 
        if (not defined $plugin_name) {
258
 
                carp("File name required as argument to subroutine findDirectory()");
259
 
        }
260
 
        if (not defined $dir) {
261
 
                $dir = $basedir;
262
 
        }
263
 
        my $fullPath;   # the result
264
 
        find(sub {
265
 
                        # This subroutine is called for each file and dir it finds.
266
 
                        # According to docs it does depth-first search.
267
 
                        if ($_ eq $plugin_name) {
268
 
                                $fullPath = $File::Find::dir if not defined $fullPath;
269
 
                        }
270
 
                        # any return value is ignored
271
 
                }, $dir);
272
 
        return $fullPath;
273
 
}
274
 
 
275
 
#
276
 
# Get the bzr branch ID from the pushbuild2 database (internal), based on the
277
 
# branch name ($tree variable).
278
 
#
279
 
# If the branch name (tree) is not found in the database, or we are unable to
280
 
# connect to the database, undef is returned.
281
 
#
282
 
sub get_pb2_branch_id {
283
 
 
284
 
        # First, check if the environment variable BRANCH_ID is set.
285
 
        if (defined $ENV{BRANCH_ID}) {
286
 
                return $ENV{BRANCH_ID};
287
 
        } else {
288
 
                # Disable db lookup for the time being due to issues on sparc32.
289
 
                # Remove this "else" block to enable
290
 
                return;
291
 
        }
292
 
        # Lookup by branch name. Get branch name from tree, which could be url.
293
 
        my $branch_name = $tree;
294
 
        if ($tree =~ m{/}) {
295
 
                # Found '/', assuming tree is URL.
296
 
                # Find last substring that is between a '/' and either end-of-string or a '/' followed by end of string.
297
 
                $tree =~ m{.*/([^/]+)($|/$)};
298
 
                $branch_name=$1;
299
 
        }
300
 
 
301
 
        my $dsn_pb2 = 'dbi:mysql:host=trollheim.no.oracle.com:port=3306:user=readonly:database=pushbuild2';
302
 
        my $SQL_getBranchId = "SELECT branch_id FROM branches WHERE branch_name = '$branch_name'";
303
 
 
304
 
        say("Using branch name $branch_name\n");
305
 
        say("Trying to connect to pushbuild2 database...\n");
306
 
 
307
 
        my $dbh = DBI->connect($dsn_pb2, undef, undef, {
308
 
                mysql_connect_timeout => 5,
309
 
                PrintError => 0,
310
 
                RaiseError => 0,
311
 
                AutoCommit => 0,
312
 
        } );
313
 
 
314
 
        if (not defined $dbh) {
315
 
                say("connect() to pushbuild2 database failed: ".$DBI::errstr."\n");
316
 
                return;
317
 
        }
318
 
 
319
 
        my $id = $dbh->selectrow_array($SQL_getBranchId);
320
 
        $dbh->disconnect;
321
 
        return $id;
322
 
}
323
 
 
324
 
#### end subroutines ###########################################################
325
 
 
326
 
# Find out active user name and mention it in the output to ease debugging.
327
 
my $username;
328
 
if (osLinux() || osSolaris()) {
329
 
    $username = $ENV{'LOGNAME'};
330
 
} else {
331
 
    $username = $ENV{'USERNAME'};
332
 
}
333
 
 
334
 
chdir($randgen);
335
 
 
336
 
say("Gathering info from the environment...");
337
 
# calling bzr usually takes a few seconds...
338
 
my $bzrinfo = GenTest::BzrInfo->new(
339
 
            dir => cwd()
340
 
);
341
 
 
342
 
say("===== Information on the host system: =====\n");
343
 
say(" - Local time  : ".localtime()."\n");
344
 
say(" - Hostname    : ".hostname()."\n");
345
 
say(" - Username    : ".$username."\n");
346
 
say(" - PID         : $$\n");
347
 
say(" - Working dir : ".cwd()."\n");
348
 
say(" - PATH        : ".$ENV{'PATH'}."\n");
349
 
say(" - Script arguments:\n");
350
 
say("       basedir = $basedir\n");
351
 
say("       vardir  = $vardir\n");
352
 
say("       tree    = $tree\n");
353
 
say("       test    = $test\n");
354
 
say("\n");
355
 
say("===== Information on the tested binaries (PB2): =====\n");
356
 
say(" - Branch URL  : ".$ENV{'BRANCH_SOURCE'});
357
 
say(" - Branch name : ".$ENV{'BRANCH_NAME'});
358
 
say(" - Revision    : ".$ENV{'PUSH_REVISION'});
359
 
say(" - Source      : ".$ENV{'SOURCE'});
360
 
say("===== Information on Random Query Generator version (bzr): =====\n");
361
 
say(" - Date (rev)  : ".$bzrinfo->bzrDate());
362
 
#say(" - Date (now) : ".$bzrinfo->bzrBuildDate());  # Shows current date, we already have that.
363
 
say(" - Revno       : ".$bzrinfo->bzrRevno());
364
 
say(" - Revision ID : ".$bzrinfo->bzrRevisionId());
365
 
say(" - Branch nick : ".$bzrinfo->bzrBranchNick());
366
 
say(" - Clean copy? : ". ($bzrinfo->bzrClean()? "Yes" : "No"));
367
 
say("\n");
368
 
 
369
 
# Test name:
370
 
#   In PB2, tests run via this script are prefixed with "rqg_" so that it is
371
 
#   easy to distinguish these tests from other "external" tests.
372
 
#   For a while we will support test names both with and without the prefix.
373
 
#   For this reason we strip off the "rqg_" prefix before continuing.
374
 
#   This also means that you cannot try to match against "rqg_" prefix in test
375
 
#   "definitions" (if statements) below.
376
 
my $test_name = $test;
377
 
my $test_suite_name = 'serverqa'; # used for xref reporting
378
 
$test =~ s/^rqg_//;     # test_name without prefix
379
 
 
380
 
# Server port numbers:
381
 
#
382
 
# If several instances of this script may run at the same time on the same
383
 
# host, port number conflicts may occur.
384
 
#
385
 
# If needed, use use a port range ID (integer) that is unique for this host at
386
 
# this time.
387
 
# This ID is used by the RQG framework to designate a port range to use for the
388
 
# test run. Passed to RQG using the MTR_BUILD_THREAD environment variable
389
 
# (this naming is a legacy from MTR, which is used by RQG to start the MySQL
390
 
# server).
391
 
#
392
 
# Solution: Use unique port range id per branch. Use "branch_id" as recorded
393
 
#           in PB2 database (guaranteed unique per branch).
394
 
# Potential issue 1: Unable to connect to pb2 database.
395
 
# Solution 1: Pick a random ID between 1 and some sensible number (e.g. 500).
396
 
# Potential issue 2: Clashing resources when running multiple pushes in same branch?
397
 
# Potential solution 2: Keep track of used ids in local file(s). Pick unused id.
398
 
#                       (not implemented yet)
399
 
#
400
 
# Currently (December 2009) PB2 RQG host should be running only one test at a
401
 
# time, so this should not be an issue, hence no need to set MTR_BUILD_THREAD.
402
 
 
403
 
#print("===== Determining port base id: =====\n");
404
 
my $port_range_id; # Corresponding to MTR_BUILD_THREAD in the MySQL MTR world.
405
 
# First, see if user has supplied us with a value for MTR_BUILD_THREAD:
406
 
$port_range_id = $ENV{MTR_BUILD_THREAD};
407
 
if (defined $port_range_id) {
408
 
        say("Environment variable MTR_BUILD_THREAD was already set.\n");
409
 
}
410
 
#else {
411
 
#       # try to obtain branch id, somehow
412
 
#       $port_range_id = get_pb2_branch_id();
413
 
#       if (not defined $port_range_id) {
414
 
#               print("Unable to get branch id. Picking a 'random' port base id...\n");
415
 
#               $port_range_id = pick_random_port_range_id();
416
 
#       } else {
417
 
#               print("Using pb2 branch ID as port base ID.\n");
418
 
#       }
419
 
#}
420
 
 
421
 
say("Configuring test...");
422
 
say("");
423
 
 
424
 
# Guess MySQL version. Some options we set later depend on this.
425
 
my $version50 = 0;      # 1 if 5.0.x, 0 otherwise. 
426
 
if( ($ENV{'BRANCH_SOURCE'} =~ m{-5\.0}io) || ($basedir =~ m{-5\.0}io) ) {
427
 
    say("Detected version 5.0.x, adjusting server options accordingly.");
428
 
    $version50 = 1;
429
 
}
430
 
 
431
 
my $cwd = cwd();
432
 
 
433
 
my $command;
434
 
my $engine;
435
 
my $rpl_mode;
436
 
 
437
 
if (($engine) = $test =~ m{(maria|falcon|innodb|myisam|pbxt)}io) {
438
 
        say("Detected that this test is about the $engine engine.");
439
 
}
440
 
 
441
 
if (($rpl_mode) = $test =~ m{(rbr|sbr|mbr|statement|mixed|row)}io) {
442
 
        say("Detected that this test is about replication mode $rpl_mode.");
443
 
        $rpl_mode = 'mixed' if $rpl_mode eq 'mbr';
444
 
        $rpl_mode = 'statement' if $rpl_mode eq 'sbr';
445
 
        $rpl_mode = 'row' if $rpl_mode eq 'rbr';
446
 
}
447
 
 
448
 
#
449
 
# Start defining tests. Test name can be whatever matches the regex in the if().
450
 
# TODO: Define less ambiguous test names to avoid accidental misconfiguration.
451
 
#
452
 
# Starting out with "legacy" Falcon tests.
453
 
#
454
 
if ($test =~ m{falcon_.*transactions}io ) {
455
 
        $command = '
456
 
                --grammar='.$conf.'/transactions/transactions.yy
457
 
                --gendata='.$conf.'/transactions/transactions.zz
458
 
                --mysqld=--falcon-consistent-read=1
459
 
                --mysqld=--transaction-isolation=REPEATABLE-READ
460
 
                --validator=DatabaseConsistency
461
 
                --mem
462
 
        ';
463
 
} elsif ($test =~ m{falcon_.*durability}io ) {
464
 
        $command = '
465
 
                --grammar='.$conf.'/transactions/transaction_durability.yy
466
 
                --vardir1='.$vardir.'/vardir-'.$engine.'
467
 
                --vardir2='.$vardir.'/vardir-innodb
468
 
                --mysqld=--default-storage-engine='.$engine.'
469
 
                --mysqld=--falcon-checkpoint-schedule=\'1 1 1 1 1\'
470
 
                --mysqld2=--default-storage-engine=Innodb
471
 
                --validator=ResultsetComparator
472
 
        ';
473
 
} elsif ($test =~ m{falcon_repeatable_read}io ) {
474
 
        $command = '
475
 
                --grammar='.$conf.'/transactions/repeatable_read.yy
476
 
                --gendata='.$conf.'/transactions/transactions.zz
477
 
                --mysqld=--falcon-consistent-read=1
478
 
                --mysqld=--transaction-isolation=REPEATABLE-READ
479
 
                --validator=RepeatableRead
480
 
                --mysqld=--falcon-consistent-read=1
481
 
                --mem
482
 
        ';
483
 
} elsif ($test =~ m{falcon_chill_thaw_compare}io) {
484
 
        $command = '
485
 
                --grammar='.$conf.'/engines/falcon/falcon_chill_thaw.yy
486
 
                --gendata='.$conf.'/engines/falcon/falcon_chill_thaw.zz
487
 
                --mysqld=--falcon-record-chill-threshold=1K
488
 
                --mysqld=--falcon-index-chill-threshold=1K 
489
 
                --threads=1
490
 
                --vardir1='.$vardir.'/chillthaw-vardir
491
 
                --vardir2='.$vardir.'/default-vardir
492
 
                --reporters=Deadlock,ErrorLog,Backtrace
493
 
        ';
494
 
} elsif ($test =~ m{falcon_chill_thaw}io) {
495
 
        $command = '
496
 
                --grammar='.$conf.'/engines/falcon/falcon_chill_thaw.yy
497
 
                --mysqld=--falcon-index-chill-threshold=4K 
498
 
                --mysqld=--falcon-record-chill-threshold=4K
499
 
        ';
500
 
} elsif ($test =~ m{falcon_online_alter}io) {
501
 
        $command = '
502
 
                --grammar='.$conf.'/engines/falcon/falcon_online_alter.yy
503
 
        ';
504
 
} elsif ($test =~ m{falcon_ddl}io) {
505
 
        $command = '
506
 
                --grammar='.$conf.'/engines/falcon/falcon_ddl.yy
507
 
        ';
508
 
} elsif ($test =~ m{falcon_limit_compare_self}io ) {
509
 
        $command = '
510
 
                --grammar='.$conf.'/engines/falcon/falcon_nolimit.yy
511
 
                --threads=1
512
 
                --validator=Limit
513
 
        ';
514
 
} elsif ($test =~ m{falcon_limit_compare_innodb}io ) {
515
 
        $command = '
516
 
                --grammar='.$conf.'/engines/falcon/limit_compare.yy
517
 
                --vardir1='.$vardir.'/vardir-falcon
518
 
                --vardir2='.$vardir.'/vardir-innodb
519
 
                --mysqld=--default-storage-engine=Falcon
520
 
                --mysqld2=--default-storage-engine=Innodb
521
 
                --threads=1
522
 
                --reporters=
523
 
        ';
524
 
} elsif ($test =~ m{falcon_limit}io ) {
525
 
        $command = '
526
 
                --grammar='.$conf.'/engines/falcon/falcon_limit.yy
527
 
                --mysqld=--loose-maria-pagecache-buffer-size=64M
528
 
        ';
529
 
} elsif ($test =~ m{falcon_recovery}io ) {
530
 
        $command = '
531
 
                --grammar='.$conf.'/engines/falcon/falcon_recovery.yy
532
 
                --gendata='.$conf.'/engines/falcon/falcon_recovery.zz
533
 
                --mysqld=--falcon-checkpoint-schedule="1 1 1 1 1"
534
 
        ';
535
 
} elsif ($test =~ m{falcon_pagesize_32K}io ) {
536
 
        $command = '
537
 
                --grammar='.$conf.'/engines/falcon/falcon_pagesize.yy
538
 
                --mysqld=--falcon-page-size=32K
539
 
                --gendata='.$conf.'/engines/falcon/falcon_pagesize32K.zz
540
 
        ';
541
 
} elsif ($test =~ m{falcon_pagesize_2K}io) {
542
 
        $command = '
543
 
                --grammar='.$conf.'/engines/falcon/falcon_pagesize.yy
544
 
                --mysqld=--falcon-page-size=2K
545
 
                --gendata='.$conf.'/engines/falcon/falcon_pagesize2K.zz
546
 
        ';
547
 
} elsif ($test =~ m{falcon_select_autocommit}io) {
548
 
        $command = '
549
 
                --grammar='.$conf.'/engines/falcon/falcon_select_autocommit.yy
550
 
                --queries=10000000
551
 
        ';
552
 
} elsif ($test =~ m{falcon_backlog}io ) {
553
 
        $command = '
554
 
                --grammar='.$conf.'/engines/falcon/falcon_backlog.yy
555
 
                --gendata='.$conf.'/engines/falcon/falcon_backlog.zz
556
 
                --mysqld=--transaction-isolation=REPEATABLE-READ
557
 
                --mysqld=--falcon-record-memory-max=10M
558
 
                --mysqld=--falcon-record-chill-threshold=1K
559
 
                --mysqld=--falcon-page-cache-size=128M
560
 
        ';
561
 
} elsif ($test =~ m{falcon_compare_innodb}io ) {
562
 
        # Datatypes YEAR and TIME disabled in grammars due to Bug#45499 (InnoDB). 
563
 
        # Revert to falcon_data_types.{yy|zz} when that bug is resolved in relevant branches.
564
 
        $command = '
565
 
                --grammar='.$conf.'/engines/falcon/falcon_data_types_no_year_time.yy
566
 
                --gendata='.$conf.'/engines/falcon/falcon_data_types_no_year_time.zz
567
 
                --vardir1='.$vardir.'/vardir-falcon
568
 
                --vardir2='.$vardir.'/vardir-innodb
569
 
                --mysqld=--default-storage-engine=Falcon
570
 
                --mysqld2=--default-storage-engine=Innodb
571
 
                --threads=1
572
 
                --reporters=
573
 
        ';
574
 
} elsif ($test =~ m{falcon_compare_self}io ) {
575
 
        $command = '
576
 
                --grammar='.$conf.'/engines/falcon/falcon_data_types.yy
577
 
                --gendata='.$conf.'/engines/falcon/falcon_data_types.zz
578
 
                --vardir1='.$vardir.'/'.$engine.'-vardir1
579
 
                --vardir2='.$vardir.'/'.$engine.'-vardir2
580
 
                --threads=1
581
 
                --reporters=
582
 
        ';
583
 
#
584
 
# END OF FALCON-ONLY TESTS
585
 
#
586
 
} elsif ($test =~ m{innodb_repeatable_read}io ) {
587
 
        # Transactional test. See also falcon_repeatable_read.
588
 
        $command = '
589
 
                --grammar='.$conf.'/transactions/repeatable_read.yy
590
 
                --gendata='.$conf.'/transactions/transactions.zz
591
 
                --mysqld=--transaction-isolation=REPEATABLE-READ
592
 
                --validator=RepeatableRead
593
 
        ';
594
 
} elsif ($test =~ m{(falcon|myisam)_blob_recovery}io ) {
595
 
        $command = '
596
 
                --grammar='.$conf.'/engines/falcon/falcon_blobs.yy
597
 
                --gendata='.$conf.'/engines/falcon/falcon_blobs.zz
598
 
                --duration=130
599
 
                --threads=1
600
 
                --reporters=Deadlock,ErrorLog,Backtrace,Recovery,Shutdown
601
 
        ';
602
 
        if ($test =~ m{falcon}io) {
603
 
                # this option works with Falcon-enabled builds only
604
 
                $command = $command.'
605
 
                        --mysqld=--falcon-page-cache-size=128M
606
 
                ';
607
 
        }
608
 
} elsif ($test =~ m{(falcon|innodb|myisam)_many_indexes}io ) {
609
 
        $command = '
610
 
                --grammar='.$conf.'/engines/many_indexes.yy
611
 
                --gendata='.$conf.'/engines/many_indexes.zz
612
 
        ';
613
 
} elsif ($test =~ m{(falcon|innodb|myisam)_tiny_inserts}io) {
614
 
        $command = '
615
 
                --gendata='.$conf.'/engines/tiny_inserts.zz
616
 
                --grammar='.$conf.'/engines/tiny_inserts.yy
617
 
                --queries=10000000
618
 
        ';
619
 
} elsif ($test =~ m{innodb_transactions}io) {
620
 
        $command = '
621
 
                --grammar='.$conf.'/transactions/transactions.yy
622
 
                --gendata='.$conf.'/transactions/transactions.zz
623
 
                --mysqld=--transaction-isolation=REPEATABLE-READ
624
 
                --validator=DatabaseConsistency
625
 
        ';
626
 
#
627
 
# END OF STORAGE ENGINE TESTS
628
 
#
629
 
# Keep the following tests in alphabetical order (based on letters in regex)
630
 
# for easy lookup.
631
 
#
632
 
} elsif ($test =~ m{^backup_.*?_simple}io) {
633
 
        $command = '
634
 
                --grammar='.$conf.'/backup/backup_simple.yy
635
 
                --reporters=Deadlock,ErrorLog,Backtrace
636
 
                --mysqld=--mysql-backup
637
 
        ';
638
 
} elsif ($test =~ m{^backup_.*?_consistency}io) {
639
 
        $command = '
640
 
                --gendata='.$conf.'/backup/invariant.zz
641
 
                --grammar='.$conf.'/backup/invariant.yy
642
 
                --validator=Invariant
643
 
                --reporters=Deadlock,ErrorLog,Backtrace,BackupAndRestoreInvariant,Shutdown
644
 
                --mysqld=--mysql-backup
645
 
                --duration=600
646
 
                --threads=25
647
 
        ';
648
 
} elsif ($test =~ m{dml_alter}io ) {
649
 
        $command = '
650
 
                --gendata='.$conf.'/engines/maria/maria.zz
651
 
                --grammar='.$conf.'/engines/maria/maria_dml_alter.yy
652
 
        ';
653
 
} elsif ($test =~ m{^info_schema}io ) {
654
 
        $command = '
655
 
                --grammar='.$conf.'/runtime/information_schema.yy
656
 
                --threads=10
657
 
                --duration=300
658
 
                --mysqld=--log-output=file
659
 
        ';
660
 
} elsif ($test =~ m{^mdl_stability}io ) {
661
 
        $command = '
662
 
                --grammar='.$conf.'/runtime/metadata_stability.yy
663
 
                --gendata='.$conf.'/runtime/metadata_stability.zz
664
 
                --validator=SelectStability,QueryProperties
665
 
                --engine=Innodb
666
 
                --mysqld=--innodb
667
 
                --mysqld=--default-storage-engine=Innodb
668
 
                --mysqld=--transaction-isolation=SERIALIZABLE
669
 
                --mysqld=--innodb-flush-log-at-trx-commit=2
670
 
                --mysqld=--loose-table-lock-wait-timeout=1
671
 
                --mysqld=--innodb-lock-wait-timeout=1
672
 
                --mysqld=--log-output=file
673
 
                --queries=1M
674
 
                --duration=600
675
 
        ';
676
 
} elsif ($test =~ m{^mdl_deadlock}io ) {
677
 
    #
678
 
    # Should be same as mdl_stress (or mdl_stability, whichever has produced
679
 
    # the most deadlocks), except with higher (~default) lock_wait_timeouts.
680
 
    # The other variants have very low wait timeouts, making it difficult to
681
 
    # detect invalid deadlocks.
682
 
    # As per Feb-26-2010 default innodb-lock-wait-timeout=50 and
683
 
    # lock-wait-timeout=31536000 (bug#45225).
684
 
    # We may want to switch to real (implicit) defaults later.
685
 
    #
686
 
    # We use full grammar + redefine file for some branches, and custom grammar
687
 
    # with possibly no redefine file for others, hence this special grammar
688
 
    # logic.
689
 
    #
690
 
    my $grammar = "conf/runtime/WL5004_sql.yy";
691
 
    if ($tree =~ m{next-mr}i) {
692
 
        say("Custom grammar selected based on tree name ($tree).");
693
 
        $grammar = "conf/runtime/WL5004_sql_custom.yy";
694
 
    }
695
 
    $command = '
696
 
        --grammar='.$grammar.'
697
 
        --threads=10
698
 
        --queries=1M
699
 
        --duration=1200
700
 
        --mysqld=--innodb
701
 
        --mysqld=--innodb-lock-wait-timeout=50
702
 
        --mysqld=--lock-wait-timeout=31536000
703
 
        --mysqld=--log-output=file
704
 
        ';
705
 
} elsif ($test =~ m{^mdl_stress}io ) {
706
 
        # Seems like --gendata=conf/WL5004_data.zz unexplicably causes more test
707
 
        # failures, so let's leave this out of PB2 for the time being (pstoev).
708
 
        #
709
 
        # InnoDB should be loaded but the test is not per se for InnoDB, hence
710
 
        # no "innodb" in test name.
711
 
        #
712
 
        # We use full grammar + redefine file for some branches, and custom grammar
713
 
        # with possibly no redefine file for others, hence this special grammar
714
 
        # logic.
715
 
        #
716
 
        my $grammar = "conf/runtime/WL5004_sql.yy";
717
 
        if ($tree =~ m{next-mr}i) {
718
 
                say("Custom grammar selected based on tree name ($tree).");
719
 
                $grammar = "conf/runtime/WL5004_sql_custom.yy";
720
 
        }
721
 
        $command = '
722
 
                --grammar='.$grammar.'
723
 
                --threads=10
724
 
                --queries=1M
725
 
                --duration=1800
726
 
                --mysqld=--innodb
727
 
        ';
728
 
        
729
 
 
730
 
#
731
 
# opt: Optimizer tests in "nice mode", primarily used for regression testing (5.1 and beyond).
732
 
#      By "nice mode" we mean relatively short duration and/or num of queries and fixed seed.
733
 
#
734
 
} elsif ($test =~ m{^opt_access_exp}io ) {
735
 
    # More queries drastically increases runtime.
736
 
    # We use a larger than default duration to allow even slower machines to do 
737
 
    # useful testing.
738
 
    # This test is for hitting as many table access methods as possible.
739
 
        $command = '
740
 
        --threads=1
741
 
        --queries=10K
742
 
        --gendata='.$conf.'/optimizer/range_access.zz
743
 
        --grammar='.$conf.'/optimizer/optimizer_access_exp.yy
744
 
        --duration=1200
745
 
        ';
746
 
} elsif ($test =~ m{^opt_no_subquery(_trace)$}io ) {
747
 
        $command = '
748
 
        --threads=1
749
 
        --queries=100K
750
 
        --grammar='.$conf.'/optimizer/optimizer_no_subquery.yy
751
 
        --duration=1200
752
 
        ';
753
 
} elsif ($test =~ m{^opt_no_subquery_compare_50}io ) {
754
 
    # Compares query results from 5.1 to those from 5.0.
755
 
    # We do not want the Shutdown reporter (default) here, in order to be able to compare dumps, so specify --reporters.
756
 
        $command = '
757
 
        --basedir1='.$basedir.'
758
 
        --basedir2='.$basedirRelease50.'
759
 
        --vardir1='.$vardir.'/vardir-bzr
760
 
        --vardir2='.$vardir.'/vardir-5.0
761
 
        --threads=1
762
 
        --queries=20K
763
 
        --grammar='.$conf.'/optimizer/optimizer_no_subquery_portable.yy
764
 
        --validator=ResultsetComparatorSimplify
765
 
        --reporters=Deadlock,ErrorLog,Backtrace
766
 
        --views
767
 
        --duration=1200
768
 
        ';
769
 
} elsif ($test =~ m{^opt_range_access}io ) {
770
 
    # We should use a larger than default duration to allow even slower machines to do
771
 
    # useful testing.
772
 
    # 15K queries means runtime of ~40 mins on standard desktop hardware of Apr2010.
773
 
    # Used to allow 45 mins (2700s) of runtime.
774
 
    # This caused PB2 timeouts (30 min), so duration is now set to 25 minutes.
775
 
    # TODO: Adjust after implementing https://blueprints.launchpad.net/randgen/+spec/heartbeat-in-output
776
 
        $command = '
777
 
        --threads=1
778
 
        --queries=15K
779
 
        --gendata='.$conf.'/optimizer/range_access.zz
780
 
        --grammar='.$conf.'/optimizer/range_access.yy
781
 
        --duration=1500
782
 
        ';
783
 
} elsif ($test =~ m{^opt_subquery}io ) {
784
 
    # Produces large and time consuming queries, so we use a larger than default 
785
 
    # duration to allow even slower machines to do useful testing.
786
 
        $command = '
787
 
        --threads=1
788
 
        --queries=75K
789
 
        --grammar='.$conf.'/optimizer/optimizer_subquery.yy
790
 
        --duration=1200
791
 
        ';
792
 
} elsif ($test =~ m{^outer_join}io ) {
793
 
    # Any larger queries value than 30k used to cause a known/documented crash (5.1).
794
 
    # This seems to have been fixed by now.
795
 
    # Produces large and time consuming queries, so we use a larger than default
796
 
    # duration to allow even slower machines to do useful testing.
797
 
        $command = '
798
 
        --threads=1
799
 
        --queries=80K
800
 
        --gendata='.$conf.'/optimizer/outer_join.zz
801
 
        --grammar='.$conf.'/optimizer/outer_join.yy
802
 
        --duration=900
803
 
        ';
804
 
#
805
 
# End of optimizer tests.
806
 
#
807
 
} elsif ($test =~ m{^partition_ddl}io ) {
808
 
        $command = '
809
 
                --grammar='.$conf.'/partitioning/partitions-ddl.yy
810
 
                --mysqld=--innodb
811
 
                --threads=1
812
 
                --queries=100K
813
 
        ';
814
 
} elsif ($test =~ m{partn_pruning(|.valgrind)$}io ) {
815
 
        # reduced duration to half since gendata phase takes longer in this case
816
 
        $command = '
817
 
                --gendata='.$conf.'/partitioning/partition_pruning.zz
818
 
                --grammar='.$conf.'/partitioning/partition_pruning.yy
819
 
                --mysqld=--innodb
820
 
                --threads=1
821
 
                --queries=100000
822
 
                --duration=300
823
 
        ';
824
 
} elsif ($test =~ m{^partn_pruning_compare_50}io) {
825
 
        $command = '
826
 
        --gendata='.$conf.'/partitioning/partition_pruning.zz
827
 
        --grammar='.$conf.'/partitioning/partition_pruning.yy
828
 
        --basedir1='.$basedir.'
829
 
        --basedir2='.$basedirRelease50.'
830
 
        --vardir1='.$vardir.'/vardir-bzr
831
 
        --vardir2='.$vardir.'/vardir-5.0
832
 
        --mysqld=--innodb
833
 
        --validators=ResultsetComparator
834
 
        --reporters=Deadlock,ErrorLog,Backtrace
835
 
        --threads=1
836
 
        --queries=10000
837
 
        --duration=300
838
 
        ';
839
 
} elsif ($test =~ m{^rpl_.*?_simple}io) {
840
 
        # Not used; rpl testing needs adjustments (some of the failures this
841
 
        # produces are known replication issues documented in the manual).
842
 
        $command = '
843
 
                --gendata='.$conf.'/replication/replication_single_engine.zz
844
 
                --grammar='.$conf.'/replication/replication_simple.yy
845
 
                --mysqld=--log-output=table,file
846
 
        ';
847
 
} elsif ($test =~ m{^rpl_.*?_complex}io) {
848
 
        # Not used; rpl testing needs adjustments (some of the failures this
849
 
        # produces are known replication issues documented in the manual).
850
 
        $command = '
851
 
                --gendata='.$conf.'/replication/replication_single_engine_pk.zz
852
 
                --grammar='.$conf.'/replication/replication.yy
853
 
                --mysqld=--log-output=table,file
854
 
                --mysqld=--innodb
855
 
        ';
856
 
} elsif ($test =~ m{^rpl_semisync}io) {
857
 
        # --rpl_mode=default is used because the .YY file changes the binary log format dynamically.
858
 
        # --threads=1 is used to avoid any replication failures due to concurrent DDL.
859
 
        # --validator= line will remove the default replication Validator, which would otherwise
860
 
        #   report test failure when the slave I/O thread is stopped, which is OK in the context
861
 
        #   of this particular test.
862
 
 
863
 
        # Plugin file names and location vary between platforms.
864
 
        # See http://bugs.mysql.com/bug.php?id=49170 for details.
865
 
        # We search for the respective file names under basedir (recursively).
866
 
        # The first matching file that is found is used.
867
 
        # We assume that both master and slave plugins are in the same dir.
868
 
        # Unix file name extenstions other than .so may exist, but support for this
869
 
        # is not yet implemented here.
870
 
        my $plugin_dir;
871
 
        my $plugins;
872
 
        if (osWindows()) {
873
 
                my $master_plugin_name = "semisync_master.dll";
874
 
                $plugin_dir=findDirectory($master_plugin_name);
875
 
                if (not defined $plugin_dir) {
876
 
                        carp "Unable to find semisync plugin $master_plugin_name!";
877
 
                }
878
 
                $plugins = 'rpl_semi_sync_master='.$master_plugin_name.';rpl_semi_sync_slave=semisync_slave.dll';
879
 
        } else {
880
 
                # tested on Linux and Solaris
881
 
                my $prefix;     # for Bug#48351
882
 
                my $master_plugin_name = "semisync_master.so";
883
 
                $plugin_dir=findDirectory($master_plugin_name);
884
 
                if (not defined $plugin_dir) {
885
 
                        # Until fix for Bug#48351 is widespread it may happen
886
 
                        # that the Unix plugin names are prefixed with "lib".
887
 
                        # Remove this when no longer needed.
888
 
                        $prefix = 'lib';
889
 
                        $plugin_dir=findDirectory($prefix.$master_plugin_name);
890
 
                        if (not defined $plugin_dir) {
891
 
                                carp "Unable to find semisync plugin! ($master_plugin_name or $prefix$master_plugin_name)";
892
 
                        }
893
 
                }
894
 
                $plugins = 'rpl_semi_sync_master='.$prefix.$master_plugin_name.':rpl_semi_sync_slave='.$prefix.'semisync_slave.so';
895
 
        }
896
 
        $command = '
897
 
                --gendata='.$conf.'/replication/replication_single_engine.zz
898
 
                --engine=InnoDB
899
 
                --grammar='.$conf.'/replication/replication_simple.yy
900
 
                --rpl_mode=default
901
 
                --mysqld=--plugin-dir='.$plugin_dir.'
902
 
                --mysqld=--plugin-load='.$plugins.'
903
 
                --mysqld=--rpl_semi_sync_master_enabled=1
904
 
                --mysqld=--rpl_semi_sync_slave_enabled=1
905
 
                --mysqld=--innodb
906
 
                --reporters=ReplicationSemiSync,Deadlock,Backtrace,ErrorLog
907
 
                --validators=None
908
 
                --threads=1
909
 
                --duration=300
910
 
                --queries=1M
911
 
        ';
912
 
} elsif ($test =~ m{signal_resignal}io ) {
913
 
        $command = '
914
 
                --threads=10
915
 
                --queries=1M
916
 
                --duration=300
917
 
                --grammar='.$conf.'/runtime/signal_resignal.yy
918
 
                --mysqld=--max-sp-recursion-depth=10
919
 
        ';
920
 
} elsif ($test =~ m{(innodb|maria|myisam)_stress}io ) {
921
 
        $command = '
922
 
                --grammar='.$conf.'/engines/maria/maria_stress.yy
923
 
        ';
924
 
} elsif ($test =~ m{example}io ) {
925
 
    # this is here for the purpose testing this script
926
 
        $command = '
927
 
                --grammar='.$conf.'/examples/example.yy
928
 
        --threads=1
929
 
        --duration=40
930
 
        --queries=10000
931
 
        ';
932
 
}else {
933
 
        say("[ERROR]: Test configuration for test name '$test' is not ".
934
 
                "defined in this script.\n");
935
 
        my $exitCode = 1;
936
 
        say("Will exit $0 with exit code $exitCode.\n");
937
 
        POSIX::_exit ($exitCode);
938
 
}
939
 
 
940
 
# Additional tests that are variants of the above defined tests:
941
 
#
942
 
# 1. Optimizer trace - all tests which name ends with "_trace":
943
 
#    Enable tracing and the OptimizerTraceParser validator.
944
 
#    NOTE: For applicable tests, must make sure regex in if checks above
945
 
#          will match the _trace suffix, otherwise the script will say
946
 
#          that the test configuration is not defined.
947
 
if ($test =~ m{.*_trace$}io ) {
948
 
    $command = $command.' --mysqld=--optimizer_trace="enabled=on"';
949
 
    $command = $command.' --validator=OptimizerTraceParser';
950
 
}
951
 
 
952
 
 
953
 
#
954
 
# Look for a redefine file for the grammar used, and add it to the command line
955
 
# if found. Also print special comments (e.g. about disabled parts) from the
956
 
# redefine file, alternatively the grammar file if no redefine file was found.
957
 
#
958
 
$redefine_file = redefine_filename($command);
959
 
$command = $command.' --redefine='.$redefine_file if defined $redefine_file;
960
 
 
961
 
#
962
 
# Specify some "default" Reporters if none have been specified already.
963
 
# The RQG itself also specifies some default values for some options if not set.
964
 
#
965
 
if ($command =~ m{--reporters}io) {
966
 
        # Reporters have already been specified 
967
 
} elsif ($test =~ m{rpl}io ) {
968
 
        # Don't include Recovery for replication tests, because
969
 
        $command = $command.' --reporters=Deadlock,ErrorLog,Backtrace';
970
 
} elsif ($test =~ m{falcon}io ) {
971
 
        # Include the Recovery reporter for Falcon tests in order to test
972
 
        # recovery by default after each such test.
973
 
        $command = $command.' --reporters=Deadlock,ErrorLog,Backtrace,Recovery,Shutdown';
974
 
        # Falcon-only options (avoid "unknown variable" warnings in non-Falcon builds)
975
 
        $command = $command.' --mysqld=--loose-falcon-lock-wait-timeout=5 --mysqld=--loose-falcon-debug-mask=2';
976
 
} else {
977
 
        # Default reporters for tests whose name does not contain "rpl" or "falcon"
978
 
        $command = $command.' --reporters=Deadlock,ErrorLog,Backtrace,Shutdown';
979
 
}
980
 
 
981
 
#
982
 
# Other defaults...
983
 
#
984
 
 
985
 
if ($command !~ m{--duration}io ) {
986
 
        # Set default duration for tests where duration is not specified.
987
 
        # In PB2 we cannot run tests for too long since there are many branches
988
 
        # and many pushes (or other test triggers).
989
 
        # Setting it to 10 minutes for now.
990
 
        $command = $command.' --duration=600';
991
 
}
992
 
 
993
 
if ($command !~ m{--basedir}io ) {
994
 
        $command = $command." --basedir=\"$basedir\"";
995
 
}
996
 
 
997
 
if ($command !~ m{--vardir}io && $command !~ m{--mem}io ) {
998
 
        $command = $command." --vardir=\"$vardir\"";
999
 
}
1000
 
 
1001
 
# Logging to file is faster than table. And we want some form of logging.
1002
 
# This option is not present in versions prior to 5.1.6, so skipping for 5.0.
1003
 
if ($command !~ m{--log-output}io) {
1004
 
        if (!$version50) {
1005
 
                $command = $command.' --mysqld=--log-output=file';
1006
 
        } 
1007
 
}
1008
 
 
1009
 
# 1s to enable increased concurrency. NOTE: Removed in MySQL 5.5, Feb 2010.
1010
 
if ($command !~ m{table-lock-wait-timeout}io) {
1011
 
    $command = $command.' --mysqld=--loose-table-lock-wait-timeout=1';
1012
 
}
1013
 
 
1014
 
# 1s to enable increased concurrency. NOTE: Added in MySQL 5.5, Feb 2010 (bug#45225).
1015
 
# Default value in the server is 1 year.
1016
 
if ($command !~ m{(--|--loose-)lock-wait-timeout}io) {
1017
 
    $command = $command.' --mysqld=--loose-lock-wait-timeout=1';
1018
 
}
1019
 
 
1020
 
# Decrease from default (50s) to 1s to enable increased concurrency.
1021
 
if ($command !~ m{innodb-lock-wait-timeout}io) {
1022
 
    $command = $command.' --mysqld=--loose-innodb-lock-wait-timeout=1';
1023
 
}
1024
 
 
1025
 
if ($command !~ m{--queries}io) {
1026
 
        $command = $command.' --queries=100000';
1027
 
}
1028
 
 
1029
 
if (($command !~ m{--(engine|default-storage-engine)}io) && (defined $engine)) {
1030
 
        $command = $command." --engine=$engine";
1031
 
}
1032
 
 
1033
 
# if test name contains "innodb", add the --mysqld=--innodb and --engine=innodb 
1034
 
# options if they are not there already.
1035
 
if ( ($test =~ m{innodb}io) ){
1036
 
        if ($command !~ m{mysqld=--innodb}io){
1037
 
                $command = $command.' --mysqld=--innodb';
1038
 
        }
1039
 
        if ($command !~ m{engine=innodb}io){
1040
 
                $command = $command.' --engine=innodb';
1041
 
        }
1042
 
}
1043
 
 
1044
 
if (($command !~ m{--rpl_mode}io)  && ($rpl_mode ne '')) {
1045
 
        $command = $command." --rpl_mode=$rpl_mode";
1046
 
}
1047
 
 
1048
 
# if test name contains (usually ends with) "valgrind", add the valgrind option to runall.pl
1049
 
if ($test =~ m{valgrind}io){
1050
 
        say("Detected that this test should enable valgrind instrumentation.\n");
1051
 
        if (system("valgrind --version")) {
1052
 
                say("  *** valgrind executable not found! Not setting --valgrind flag.\n");
1053
 
        } else {
1054
 
                $command = $command.' --valgrind';
1055
 
        }
1056
 
}
1057
 
        
1058
 
$command = "perl runall.pl --mysqld=--loose-skip-safemalloc ".$command;
1059
 
 
1060
 
### XML reporting setup START
1061
 
 
1062
 
# Pass test name to RQG, for reporting purposes
1063
 
$command = $command." --testname=".$test_name;
1064
 
 
1065
 
# Enable XML reporting to TestTool.
1066
 
# For now only on given hosts...
1067
 
my %report_xml_from_hosts = (
1068
 
    'loki06'   => '',
1069
 
    'nanna21'  => '',
1070
 
    'techra22' => '',
1071
 
    'tor06-z1' => '',
1072
 
    'tyr41'    => ''
1073
 
);
1074
 
my $hostname = hostname();
1075
 
my $xmlfile;
1076
 
my $delete_xmlfile = 0; # boolean indicator whether to delete local XML file.
1077
 
if (exists $report_xml_from_hosts{$hostname}) {
1078
 
    # We should enable XML reporting on this host...
1079
 
    say("XML reporting to TestTool automatically enabled based on hostname.");
1080
 
    # We need to write the XML to a file before sending to reporting framework.
1081
 
    # This is done by specifying xml-output option.
1082
 
    # TMPDIR should be set by Pushbuild to indicate a suitable location for temp files.
1083
 
    # GenTest looks for other tmpdir alternatives.
1084
 
    my $tmpdir = $ENV{'TMPDIR'} || tmpdir();
1085
 
    if (length($tmpdir) > 1) {
1086
 
        # tmpdir may or may not end with a file separator. Make sure it does.
1087
 
        $tmpdir = $tmpdir.'/' if ($tmpdir =~ m{[^\/\\]+$});
1088
 
        $xmlfile = $tmpdir.$test_name.'.xml';
1089
 
    } else {
1090
 
        # tmpdir not found. Write report to current directory.
1091
 
        say("A suitable tmpdir was not found. Writing temporary files to current directory");
1092
 
        # This file should be deleted after test end so that disks won't fill up.
1093
 
        $delete_xmlfile = 1;
1094
 
        $xmlfile = $test_name.'.xml';
1095
 
    }
1096
 
    # Enable XML reporting to TT (assuming this is not already enabled):
1097
 
    $command = $command.' --xml-output='.$xmlfile.' --report-xml-tt';
1098
 
    # Specify XML reporting transport type (not relying on defaults):
1099
 
    # We assume SSH keys have been properly set up to enable seamless scp use.
1100
 
    $command = $command.' --report-xml-tt-type=scp';
1101
 
    # Specify destination for XML reports (not relying on defaults):
1102
 
    $command = $command.' --report-xml-tt-dest=regin.no.oracle.com:/raid/xml_results/TestTool/xml/';
1103
 
}
1104
 
### XML reporting setup END
1105
 
 
1106
 
 
1107
 
# Add env variable to specify unique port range to use to avoid conflicts.
1108
 
# Trying not to do this unless actually needed.
1109
 
if (defined $port_range_id) {
1110
 
        say("MTR_BUILD_THREAD=$port_range_id\n");
1111
 
        if (osWindows()) {
1112
 
                $command = "set MTR_BUILD_THREAD=$port_range_id && ".$command;
1113
 
        } else {
1114
 
                $command = "MTR_BUILD_THREAD=$port_range_id ".$command;
1115
 
        }
1116
 
}
1117
 
 
1118
 
$command =~ s{[\r\n\t]}{ }sgio;
1119
 
say("Running runall.pl...\n");
1120
 
my $command_result = system($command);
1121
 
# shift result code to the right to obtain the code returned from the called script
1122
 
my $command_result_shifted = ($command_result >> 8);
1123
 
 
1124
 
# Report test result in an MTR fashion so that PB2 will see it and add to
1125
 
# xref database etc.
1126
 
# Format: TESTSUITE.TESTCASE 'TESTMODE' [ RESULT ]
1127
 
# Example: ndb.ndb_dd_alter 'InnoDB plugin'     [ fail ]
1128
 
# Not using TESTMODE for now.
1129
 
 
1130
 
my $full_test_name = $test_suite_name.'.'.$test_name;
1131
 
# keep test statuses more or less vertically aligned
1132
 
while (length $full_test_name < 40)
1133
 
{
1134
 
        $full_test_name = $full_test_name.' ';
1135
 
}
1136
 
 
1137
 
if ($command_result_shifted > 0) {
1138
 
        # test failed
1139
 
        # Trying out marking a test as "experimental" by reporting exp-fail:
1140
 
        # Mark all failures in next-mr-johnemb as experimental (temporary).
1141
 
        if ($ENV{BRANCH_NAME} =~ m{mysql-next-mr-johnemb}) {
1142
 
                print($full_test_name." [ exp-fail ]\n");
1143
 
        } else {
1144
 
                print($full_test_name." [ fail ]\n");
1145
 
        }
1146
 
        say('runall.pl failed with exit code '.$command_result_shifted."\n");
1147
 
        say("Look above this message in the test log for failure details.\n");
1148
 
} else {
1149
 
        print($full_test_name." [ pass ]\n");
1150
 
}
1151
 
 
1152
 
if ($delete_xmlfile && -e $xmlfile) {
1153
 
    unlink $xmlfile;
1154
 
    say("Temporary XML file $xmlfile deleted");
1155
 
}
1156
 
 
1157
 
# Kill remaining mysqld processes.
1158
 
# Assuming only one test run going on at the same time, and that all mysqld
1159
 
# processes are ours.
1160
 
say("Checking for remaining mysqld processes...\n");
1161
 
if (osWindows()) {
1162
 
        # assumes MS Sysinternals PsTools is installed in C:\bin
1163
 
        # If you need to run pslist or pskill as non-Admin user, some adjustments
1164
 
        # may be needed. See:
1165
 
        #   http://blogs.technet.com/markrussinovich/archive/2007/07/09/1449341.aspx
1166
 
 
1167
 
        # Vardir may be relative path on windows, so convert to absolute path first:
1168
 
        my $vardir_abspath = $vardir;
1169
 
        if ($vardir !~ m/^[A-Z]:[\/\\]/i) {
1170
 
            # use basedir as prefix
1171
 
            $vardir_abspath = $basedir.'\\'.$vardir;
1172
 
        }
1173
 
 
1174
 
        if (system('C:\bin\pslist mysqld') == 0) {
1175
 
                say(" ^--- Found running mysqld process(es), to be killed if possible.\n");
1176
 
                system('C:\bin\pskill mysqld > '.$vardir_abspath.'/pskill_mysqld.out 2>&1');
1177
 
                system('C:\bin\pskill mysqld-nt > '.$vardir_abspath.'/pskill_mysqld-nt.out 2>&1');
1178
 
        } else { say("  None found.\n"); }
1179
 
        
1180
 
} else {
1181
 
        # Unix/Linux.
1182
 
        # Avoid "bad argument count" messages from kill by checking if process exists first.
1183
 
        if (system("pgrep mysqld") == 0) {
1184
 
                say(" ^--- Found running mysqld process(es), to be killed if possible.\n");
1185
 
                system("pgrep mysqld | xargs kill -15"); # "soft" kill
1186
 
                sleep(5);
1187
 
                if (system("pgrep mysqld > /dev/null") == 0) {
1188
 
                        # process is still around...
1189
 
                        system("pgrep mysqld | xargs kill -9"); # "hard" kill
1190
 
                }
1191
 
        } else { say("  None found.\n"); }
1192
 
}
1193
 
 
1194
 
say(" [$$] $0 will exit with exit status ".$command_result_shifted."\n");
1195
 
POSIX::_exit ($command_result_shifted);