1
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2
# Use is subject to license terms.
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.
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.
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
19
use lib "$ENV{RQG_HOME}/lib";
20
use lib 'randgen/lib';
21
#use lib 'randgen-alt/lib';
34
my ($basedir, $vardir, $tree, $test) = @ARGV;
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';
44
# For further details about tests and recommended RQG options, see
45
# http://forge.mysql.com/wiki/RandomQueryGeneratorTests
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");
53
print("##############################################################################\n");
55
# Autoflush output buffers (needed when using POSIX::_exit())
59
# Prepare ENV variables and other settings.
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;
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';
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;
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';
82
#ENV{MYSQL_FULL_MINIDUMP} = 1;
87
# Path to MySQL releases used for comparison runs.
88
$basedirRelease50 = 'G:\mysql-releases\mysql-5.0.91-win32'; # loki06
89
} elsif (osSolaris()) {
91
$ENV{LD_LIBRARY_PATH}=$ENV{LD_LIBRARY_PATH}.':/export/home/pb2/scripts/lib/';
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/';
103
$ENV{PATH} = $ENV{PATH}.':/opt/studio12/SUNWspro/bin';
110
################################################################################
114
################################################################################
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.
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.
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.
128
sub redefine_filename ($){
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.
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;
146
say("No redefine file found for grammar ".$grammar_filename.".");
147
print_special_comments($grammar_filename);
151
croak("redefine_filename: Option --grammar not found in command. Command is: $command_string");
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.
159
# Input: Filename (path)
161
sub print_special_comments ($){
162
# Corresponding Unix command: grep '.*\(WL#\|Bug#\|Disabled\).*' grammar_file_redefine.yy
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).
172
say("Looking for special comments in grammar or redefine file...");
173
say("Using pattern: ".$pattern);
174
say("\n#### SPECIAL COMMENTS IN FILE $filename: ####");
176
open FILE, "$filename" or croak("Unable to open file $filename");
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}) {
192
say("#### END OF SPECIAL COMMENTS ####\n");
198
# Removes leading and trailing whitespace.
210
# Skips the test, displays reason (argument to the routine) quasi-MTR-style and
211
# exits with exit code 0.
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");
217
# will appear in output as:
218
# rpl_semisync [ skipped ] This feature/test does not support the Windows platform at this time
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)
227
$message = $message.' ';
229
$message = $message." [ skipped ] ".$reason;
231
print localtime()." [$$] $0 will exit with exit status 0.\n";
236
# Returns a random number between 1 and 499.
238
sub pick_random_port_range_id {
239
my $prng = GenTest::Random->new( seed => time );
240
return $prng->uint16(1,499);
244
# Searches recursively for a given file name under the given directory.
245
# Default top search directory is $basedir.
247
# Arg1 (mandatory): file name (excluding path)
248
# Arg2 (optional) : directory where search will start
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.
256
my ($plugin_name, $dir) = @_;
257
if (not defined $plugin_name) {
258
carp("File name required as argument to subroutine findDirectory()");
260
if (not defined $dir) {
263
my $fullPath; # the result
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;
270
# any return value is ignored
276
# Get the bzr branch ID from the pushbuild2 database (internal), based on the
277
# branch name ($tree variable).
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.
282
sub get_pb2_branch_id {
284
# First, check if the environment variable BRANCH_ID is set.
285
if (defined $ENV{BRANCH_ID}) {
286
return $ENV{BRANCH_ID};
288
# Disable db lookup for the time being due to issues on sparc32.
289
# Remove this "else" block to enable
292
# Lookup by branch name. Get branch name from tree, which could be url.
293
my $branch_name = $tree;
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{.*/([^/]+)($|/$)};
301
my $dsn_pb2 = 'dbi:mysql:host=trollheim.norway.sun.com:port=3306:user=readonly:database=pushbuild2';
302
my $SQL_getBranchId = "SELECT branch_id FROM branches WHERE branch_name = '$branch_name'";
304
say("Using branch name $branch_name\n");
305
say("Trying to connect to pushbuild2 database...\n");
307
my $dbh = DBI->connect($dsn_pb2, undef, undef, {
308
mysql_connect_timeout => 5,
314
if (not defined $dbh) {
315
say("connect() to pushbuild2 database failed: ".$DBI::errstr."\n");
319
my $id = $dbh->selectrow_array($SQL_getBranchId);
324
#### end subroutines ###########################################################
326
# Find out active user name and mention it in the output to ease debugging.
328
if (osLinux() || osSolaris()) {
329
$username = $ENV{'LOGNAME'};
331
$username = $ENV{'USERNAME'};
336
say("Gathering info from the environment...");
337
# calling bzr usually takes a few seconds...
338
my $bzrinfo = GenTest::BzrInfo->new(
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");
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"));
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
380
# Server port numbers:
382
# If several instances of this script may run at the same time on the same
383
# host, port number conflicts may occur.
385
# If needed, use use a port range ID (integer) that is unique for this host at
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
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)
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.
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");
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();
417
# print("Using pb2 branch ID as port base ID.\n");
421
say("Configuring test...");
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.");
437
if (($engine) = $test =~ m{(maria|falcon|innodb|myisam|pbxt)}io) {
438
say("Detected that this test is about the $engine engine.");
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';
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.
452
# Starting out with "legacy" Falcon tests.
454
if ($test =~ m{falcon_.*transactions}io ) {
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
463
} elsif ($test =~ m{falcon_.*durability}io ) {
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
473
} elsif ($test =~ m{falcon_repeatable_read}io ) {
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
483
} elsif ($test =~ m{falcon_chill_thaw_compare}io) {
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
490
--vardir1='.$vardir.'/chillthaw-vardir
491
--vardir2='.$vardir.'/default-vardir
492
--reporters=Deadlock,ErrorLog,Backtrace
494
} elsif ($test =~ m{falcon_chill_thaw}io) {
496
--grammar='.$conf.'/engines/falcon/falcon_chill_thaw.yy
497
--mysqld=--falcon-index-chill-threshold=4K
498
--mysqld=--falcon-record-chill-threshold=4K
500
} elsif ($test =~ m{falcon_online_alter}io) {
502
--grammar='.$conf.'/engines/falcon/falcon_online_alter.yy
504
} elsif ($test =~ m{falcon_ddl}io) {
506
--grammar='.$conf.'/engines/falcon/falcon_ddl.yy
508
} elsif ($test =~ m{falcon_limit_compare_self}io ) {
510
--grammar='.$conf.'/engines/falcon/falcon_nolimit.yy
514
} elsif ($test =~ m{falcon_limit_compare_innodb}io ) {
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
524
} elsif ($test =~ m{falcon_limit}io ) {
526
--grammar='.$conf.'/engines/falcon/falcon_limit.yy
527
--mysqld=--loose-maria-pagecache-buffer-size=64M
529
} elsif ($test =~ m{falcon_recovery}io ) {
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"
535
} elsif ($test =~ m{falcon_pagesize_32K}io ) {
537
--grammar='.$conf.'/engines/falcon/falcon_pagesize.yy
538
--mysqld=--falcon-page-size=32K
539
--gendata='.$conf.'/engines/falcon/falcon_pagesize32K.zz
541
} elsif ($test =~ m{falcon_pagesize_2K}io) {
543
--grammar='.$conf.'/engines/falcon/falcon_pagesize.yy
544
--mysqld=--falcon-page-size=2K
545
--gendata='.$conf.'/engines/falcon/falcon_pagesize2K.zz
547
} elsif ($test =~ m{falcon_select_autocommit}io) {
549
--grammar='.$conf.'/engines/falcon/falcon_select_autocommit.yy
552
} elsif ($test =~ m{falcon_backlog}io ) {
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
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.
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
574
} elsif ($test =~ m{falcon_compare_self}io ) {
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
584
# END OF FALCON-ONLY TESTS
586
} elsif ($test =~ m{innodb_repeatable_read}io ) {
587
# Transactional test. See also falcon_repeatable_read.
589
--grammar='.$conf.'/transactions/repeatable_read.yy
590
--gendata='.$conf.'/transactions/transactions.zz
591
--mysqld=--transaction-isolation=REPEATABLE-READ
592
--validator=RepeatableRead
594
} elsif ($test =~ m{(falcon|myisam)_blob_recovery}io ) {
596
--grammar='.$conf.'/engines/falcon/falcon_blobs.yy
597
--gendata='.$conf.'/engines/falcon/falcon_blobs.zz
600
--reporters=Deadlock,ErrorLog,Backtrace,Recovery
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
608
} elsif ($test =~ m{(falcon|innodb|myisam)_many_indexes}io ) {
610
--grammar='.$conf.'/engines/many_indexes.yy
611
--gendata='.$conf.'/engines/many_indexes.zz
613
} elsif ($test =~ m{(falcon|innodb|myisam)_tiny_inserts}io) {
615
--gendata='.$conf.'/engines/tiny_inserts.zz
616
--grammar='.$conf.'/engines/tiny_inserts.yy
619
} elsif ($test =~ m{innodb_transactions}io) {
621
--grammar='.$conf.'/transactions/transactions.yy
622
--gendata='.$conf.'/transactions/transactions.zz
623
--mysqld=--transaction-isolation=REPEATABLE-READ
624
--validator=DatabaseConsistency
627
# END OF STORAGE ENGINE TESTS
629
# Keep the following tests in alphabetical order (based on letters in regex)
632
} elsif ($test =~ m{^backup_.*?_simple}io) {
634
--grammar='.$conf.'/backup/backup_simple.yy
635
--reporters=Deadlock,ErrorLog,Backtrace
636
--mysqld=--mysql-backup
638
} elsif ($test =~ m{^backup_.*?_consistency}io) {
640
--gendata='.$conf.'/backup/invariant.zz
641
--grammar='.$conf.'/backup/invariant.yy
642
--validator=Invariant
643
--reporters=Deadlock,ErrorLog,Backtrace,BackupAndRestoreInvariant
644
--mysqld=--mysql-backup
648
} elsif ($test =~ m{dml_alter}io ) {
650
--gendata='.$conf.'/engines/maria/maria.zz
651
--grammar='.$conf.'/engines/maria/maria_dml_alter.yy
653
} elsif ($test =~ m{^info_schema}io ) {
655
--grammar='.$conf.'/runtime/information_schema.yy
658
--mysqld=--log-output=file
660
} elsif ($test =~ m{^mdl_stability}io ) {
662
--grammar='.$conf.'/runtime/metadata_stability.yy
663
--gendata='.$conf.'/runtime/metadata_stability.zz
664
--validator=SelectStability,QueryProperties
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
676
} elsif ($test =~ m{^mdl_deadlock}io ) {
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.
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
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";
696
--grammar='.$grammar.'
701
--mysqld=--innodb-lock-wait-timeout=50
702
--mysqld=--lock-wait-timeout=31536000
703
--mysqld=--log-output=file
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).
709
# InnoDB should be loaded but the test is not per se for InnoDB, hence
710
# no "innodb" in test name.
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
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";
722
--grammar='.$grammar.'
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.
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
738
# This test is for hitting as many table access methods as possible.
742
--gendata='.$conf.'/optimizer/range_access.zz
743
--grammar='.$conf.'/optimizer/optimizer_access_exp.yy
746
} elsif ($test =~ m{^opt_no_subquery(_trace)$}io ) {
750
--grammar='.$conf.'/optimizer/optimizer_no_subquery.yy
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.
757
--basedir1='.$basedir.'
758
--basedir2='.$basedirRelease50.'
759
--vardir1='.$vardir.'/vardir-bzr
760
--vardir2='.$vardir.'/vardir-5.0
763
--grammar='.$conf.'/optimizer/optimizer_no_subquery_portable.yy
764
--validator=ResultsetComparatorSimplify
765
--reporters=Deadlock,ErrorLog,Backtrace
769
} elsif ($test =~ m{^opt_range_access}io ) {
770
# We should use a larger than default duration to allow even slower machines to do
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
779
--gendata='.$conf.'/optimizer/range_access.zz
780
--grammar='.$conf.'/optimizer/range_access.yy
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.
789
--grammar='.$conf.'/optimizer/optimizer_subquery.yy
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.
800
--gendata='.$conf.'/optimizer/outer_join.zz
801
--grammar='.$conf.'/optimizer/outer_join.yy
805
# End of optimizer tests.
807
} elsif ($test =~ m{^partition_ddl}io ) {
809
--grammar='.$conf.'/partitioning/partitions-ddl.yy
814
} elsif ($test =~ m{partn_pruning(|.valgrind)$}io ) {
815
# reduced duration to half since gendata phase takes longer in this case
817
--gendata='.$conf.'/partitioning/partition_pruning.zz
818
--grammar='.$conf.'/partitioning/partition_pruning.yy
824
} elsif ($test =~ m{^partn_pruning_compare_50}io) {
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
833
--validators=ResultsetComparator
834
--reporters=Deadlock,ErrorLog,Backtrace
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).
843
--gendata='.$conf.'/replication/replication_single_engine.zz
844
--grammar='.$conf.'/replication/replication_simple.yy
845
--mysqld=--log-output=table,file
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).
851
--gendata='.$conf.'/replication/replication_single_engine_pk.zz
852
--grammar='.$conf.'/replication/replication.yy
853
--mysqld=--log-output=table,file
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.
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.
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!";
878
$plugins = 'rpl_semi_sync_master='.$master_plugin_name.';rpl_semi_sync_slave=semisync_slave.dll';
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.
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)";
894
$plugins = 'rpl_semi_sync_master='.$prefix.$master_plugin_name.':rpl_semi_sync_slave='.$prefix.'semisync_slave.so';
897
--gendata='.$conf.'/replication/replication_single_engine.zz
899
--grammar='.$conf.'/replication/replication_simple.yy
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
906
--reporters=ReplicationSemiSync,Deadlock,Backtrace,ErrorLog
912
} elsif ($test =~ m{signal_resignal}io ) {
917
--grammar='.$conf.'/runtime/signal_resignal.yy
918
--mysqld=--max-sp-recursion-depth=10
920
} elsif ($test =~ m{(innodb|maria|myisam)_stress}io ) {
922
--grammar='.$conf.'/engines/maria/maria_stress.yy
924
} elsif ($test =~ m{example}io ) {
925
# this is here for the purpose testing this script
927
--grammar='.$conf.'/examples/example.yy
933
say("[ERROR]: Test configuration for test name '$test' is not ".
934
"defined in this script.\n");
936
say("Will exit $0 with exit code $exitCode.\n");
937
POSIX::_exit ($exitCode);
940
# Additional tests that are variants of the above defined tests:
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';
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.
958
$redefine_file = redefine_filename($command);
959
$command = $command.' --redefine='.$redefine_file if defined $redefine_file;
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.
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';
977
# Default reporters for tests whose name does not contain "rpl" or "falcon"
978
# Not using Shutdown reporter as it is not compatible with runall-new.pl (which shuts down its own server).
979
$command = $command.' --reporters=Deadlock,ErrorLog,Backtrace';
986
if ($command !~ m{--duration}io ) {
987
# Set default duration for tests where duration is not specified.
988
# In PB2 we cannot run tests for too long since there are many branches
989
# and many pushes (or other test triggers).
990
# Setting it to 10 minutes for now.
991
$command = $command.' --duration=600';
994
if ($command !~ m{--basedir}io ) {
995
$command = $command." --basedir=\"$basedir\"";
998
if ($command !~ m{--vardir}io && $command !~ m{--mem}io ) {
999
$command = $command." --vardir=\"$vardir\"";
1002
# Logging to file is faster than table. And we want some form of logging.
1003
# This option is not present in versions prior to 5.1.6, so skipping for 5.0.
1004
if ($command !~ m{--log-output}io) {
1006
$command = $command.' --mysqld=--log-output=file';
1010
# 1s to enable increased concurrency. NOTE: Removed in MySQL 5.5, Feb 2010.
1011
if ($command !~ m{table-lock-wait-timeout}io) {
1012
$command = $command.' --mysqld=--loose-table-lock-wait-timeout=1';
1015
# 1s to enable increased concurrency. NOTE: Added in MySQL 5.5, Feb 2010 (bug#45225).
1016
# Default value in the server is 1 year.
1017
if ($command !~ m{(--|--loose-)lock-wait-timeout}io) {
1018
$command = $command.' --mysqld=--loose-lock-wait-timeout=1';
1021
# Decrease from default (50s) to 1s to enable increased concurrency.
1022
if ($command !~ m{innodb-lock-wait-timeout}io) {
1023
$command = $command.' --mysqld=--loose-innodb-lock-wait-timeout=1';
1026
if ($command !~ m{--queries}io) {
1027
$command = $command.' --queries=100000';
1030
if (($command !~ m{--(engine|default-storage-engine)}io) && (defined $engine)) {
1031
$command = $command." --engine=$engine";
1034
# if test name contains "innodb", add the --mysqld=--innodb and --engine=innodb
1035
# options if they are not there already.
1036
if ( ($test =~ m{innodb}io) ){
1037
if ($command !~ m{mysqld=--innodb}io){
1038
$command = $command.' --mysqld=--innodb';
1040
if ($command !~ m{engine=innodb}io){
1041
$command = $command.' --engine=innodb';
1045
if (($command !~ m{--rpl_mode}io) && ($rpl_mode ne '')) {
1046
$command = $command." --rpl_mode=$rpl_mode";
1049
# if test name contains (usually ends with) "valgrind", add the valgrind option to runall.pl
1050
if ($test =~ m{valgrind}io){
1051
say("Detected that this test should enable valgrind instrumentation.\n");
1052
if (system("valgrind --version")) {
1053
say(" *** valgrind executable not found! Not setting --valgrind flag.\n");
1055
$command = $command.' --valgrind';
1059
$command = "perl runall-new.pl --mysqld=--loose-skip-safemalloc ".$command;
1061
### XML reporting setup START
1063
# Pass test name to RQG, for reporting purposes
1064
$command = $command." --testname=".$test_name;
1066
# Enable XML reporting to TestTool.
1067
# For now only on given hosts...
1068
my %report_xml_from_hosts = (
1075
my $hostname = hostname();
1077
my $delete_xmlfile = 0; # boolean indicator whether to delete local XML file.
1078
if (exists $report_xml_from_hosts{$hostname}) {
1079
# We should enable XML reporting on this host...
1080
say("XML reporting to TestTool automatically enabled based on hostname.");
1081
# We need to write the XML to a file before sending to reporting framework.
1082
# This is done by specifying xml-output option.
1083
# TMPDIR should be set by Pushbuild to indicate a suitable location for temp files.
1084
# GenTest looks for other tmpdir alternatives.
1085
my $tmpdir = $ENV{'TMPDIR'} || tmpdir();
1086
if (length($tmpdir) > 1) {
1087
# tmpdir may or may not end with a file separator. Make sure it does.
1088
$tmpdir = $tmpdir.'/' if ($tmpdir =~ m{[^\/\\]+$});
1089
$xmlfile = $tmpdir.$test_name.'.xml';
1091
# tmpdir not found. Write report to current directory.
1092
say("A suitable tmpdir was not found. Writing temporary files to current directory");
1093
# This file should be deleted after test end so that disks won't fill up.
1094
$delete_xmlfile = 1;
1095
$xmlfile = $test_name.'.xml';
1097
# Enable XML reporting to TT (assuming this is not already enabled):
1098
$command = $command.' --xml-output='.$xmlfile.' --report-xml-tt';
1099
# Specify XML reporting transport type (not relying on defaults):
1100
# We assume SSH keys have been properly set up to enable seamless scp use.
1101
$command = $command.' --report-xml-tt-type=scp';
1102
# Specify destination for XML reports (not relying on defaults):
1103
$command = $command.' --report-xml-tt-dest=regin.norway.sun.com:/raid/xml_results/TestTool/xml/';
1105
### XML reporting setup END
1108
# Add env variable to specify unique port range to use to avoid conflicts.
1109
# Trying not to do this unless actually needed.
1110
if (defined $port_range_id) {
1111
say("MTR_BUILD_THREAD=$port_range_id\n");
1113
$command = "set MTR_BUILD_THREAD=$port_range_id && ".$command;
1115
$command = "MTR_BUILD_THREAD=$port_range_id ".$command;
1119
$command =~ s{[\r\n\t]}{ }sgio;
1120
say("Running runall-new.pl...\n");
1121
my $command_result = system($command);
1122
# shift result code to the right to obtain the code returned from the called script
1123
my $command_result_shifted = ($command_result >> 8);
1125
# Report test result in an MTR fashion so that PB2 will see it and add to
1126
# xref database etc.
1127
# Format: TESTSUITE.TESTCASE 'TESTMODE' [ RESULT ]
1128
# Example: ndb.ndb_dd_alter 'InnoDB plugin' [ fail ]
1129
# Not using TESTMODE for now.
1131
my $full_test_name = $test_suite_name.'.'.$test_name;
1132
# keep test statuses more or less vertically aligned
1133
while (length $full_test_name < 40)
1135
$full_test_name = $full_test_name.' ';
1138
if ($command_result_shifted > 0) {
1140
# Trying out marking a test as "experimental" by reporting exp-fail:
1141
# Mark all failures in next-mr-johnemb as experimental (temporary).
1142
if ($ENV{BRANCH_NAME} =~ m{mysql-next-mr-johnemb}) {
1143
print($full_test_name." [ exp-fail ]\n");
1145
print($full_test_name." [ fail ]\n");
1147
say('runall-new.pl failed with exit code '.$command_result_shifted."\n");
1148
say("Look above this message in the test log for failure details.\n");
1150
print($full_test_name." [ pass ]\n");
1153
if ($delete_xmlfile && -e $xmlfile) {
1155
say("Temporary XML file $xmlfile deleted");
1158
# Kill remaining mysqld processes.
1159
# Assuming only one test run going on at the same time, and that all mysqld
1160
# processes are ours.
1161
say("Checking for remaining mysqld processes...\n");
1163
# assumes MS Sysinternals PsTools is installed in C:\bin
1164
# If you need to run pslist or pskill as non-Admin user, some adjustments
1165
# may be needed. See:
1166
# http://blogs.technet.com/markrussinovich/archive/2007/07/09/1449341.aspx
1168
# Vardir may be relative path on windows, so convert to absolute path first:
1169
my $vardir_abspath = $vardir;
1170
if ($vardir !~ m/^[A-Z]:[\/\\]/i) {
1171
# use basedir as prefix
1172
$vardir_abspath = $basedir.'\\'.$vardir;
1175
if (system('C:\bin\pslist mysqld') == 0) {
1176
say(" ^--- Found running mysqld process(es), to be killed if possible.\n");
1177
system('C:\bin\pskill mysqld > '.$vardir_abspath.'/pskill_mysqld.out 2>&1');
1178
system('C:\bin\pskill mysqld-nt > '.$vardir_abspath.'/pskill_mysqld-nt.out 2>&1');
1179
} else { say(" None found.\n"); }
1183
# Avoid "bad argument count" messages from kill by checking if process exists first.
1184
if (system("pgrep mysqld") == 0) {
1185
say(" ^--- Found running mysqld process(es), to be killed if possible.\n");
1186
system("pgrep mysqld | xargs kill -15"); # "soft" kill
1188
if (system("pgrep mysqld > /dev/null") == 0) {
1189
# process is still around...
1190
system("pgrep mysqld | xargs kill -9"); # "hard" kill
1192
} else { say(" None found.\n"); }
1195
say(" [$$] $0 will exit with exit status ".$command_result_shifted."\n");
1196
POSIX::_exit ($command_result_shifted);