~drizzle-trunk/drizzle/development

0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
1
# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
0.67.305 by Bernt M. Johnsen
Copyright headres and license added
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
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
15
# Foundation, Inc., 51 Franklin St, Suite 500, Boston, MA 02110-1335
0.67.305 by Bernt M. Johnsen
Copyright headres and license added
16
# USA
17
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
18
use lib 'lib';
19
use lib "$ENV{RQG_HOME}/lib";
0.67.69 by John H. Embretsen
pb2gentest.pl: Temporarily add randgen/lib as 'use' library until PB2 config can be fixed.
20
use lib 'randgen/lib';
0.67.740 by John H. Embretsen
pb2gentest: Add possibility for alternative randgen location.
21
#use lib 'randgen-alt/lib';
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
22
0.67.1 by Philip Stoev
initial import from internal tree
23
use strict;
0.89.1 by John H. Embretsen
Workaround for MySQL bug 48351: Support semisync plugin names both with and without 'lib'-prefix. With time only non-prefixed plugin name will be used. Also support other plugin dirs (release builds, sandbox builds etc) by doing recursive search for plugin files. First match wins.
24
use Carp;
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
25
use Cwd;
26
use DBI;
0.89.1 by John H. Embretsen
Workaround for MySQL bug 48351: Support semisync plugin names both with and without 'lib'-prefix. With time only non-prefixed plugin name will be used. Also support other plugin dirs (release builds, sandbox builds etc) by doing recursive search for plugin files. First match wins.
27
use File::Find;
0.99.26 by John H. Embretsen
Start using GenTest's windows() and solaris() checking subs instead of re-inventing the wheel in each pb2 script.
28
use GenTest;
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
29
use GenTest::Random;
0.67.398 by John H. Embretsen
Start using BzrInfo module for reporting versions to screen and XML reports.
30
use GenTest::BzrInfo;
0.67.1 by Philip Stoev
initial import from internal tree
31
use POSIX;
0.67.74 by John H. Embretsen
pb2gentest.pl: Improved output/information when starting the script and adjusted pb2 database connection details.
32
use Sys::Hostname;
0.67.1 by Philip Stoev
initial import from internal tree
33
34
my ($basedir, $vardir, $tree, $test) = @ARGV;
35
0.67.740 by John H. Embretsen
pb2gentest: Add possibility for alternative randgen location.
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
0.67.1 by Philip Stoev
initial import from internal tree
43
#
0.70.2 by John H. Embretsen
Added new test rpl_semisync to pb2gentest.pl.
44
# For further details about tests and recommended RQG options, see
45
# http://forge.mysql.com/wiki/RandomQueryGeneratorTests
46
#
47
0.67.78 by John H. Embretsen
pb2gentest.pl: Disable pb2 db lookup of branch id (while working out perl module issues on certain platforms). Get from env var instead, if set. Adjust messages accordingly
48
print("==================== Starting $0 ====================\n");
0.67.124 by John H. Embretsen
pb2gentest: Simple MTR-style reporting of test results, for xref and PB2 (pass/fail only, no signature support yet).
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");
0.67.78 by John H. Embretsen
pb2gentest.pl: Disable pb2 db lookup of branch id (while working out perl module issues on certain platforms). Get from env var instead, if set. Adjust messages accordingly
54
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
55
# Autoflush output buffers (needed when using POSIX::_exit())
56
$| = 1;
0.70.2 by John H. Embretsen
Added new test rpl_semisync to pb2gentest.pl.
57
58
#
0.67.114 by John H. Embretsen
pb2gentest: Add partn_pruning_compare_50 test definition, including setting path to installation of 5.0 release against which to do query result comparison. This is to be considered experimental for the time being.
59
# Prepare ENV variables and other settings.
0.67.67 by John H. Embretsen
pb2gentest.pl: Fixed setting of MTR_BUILD_THREAD on Windows (multiple commands on single command line). Created convenience variable for checking if we are on Windows OS.
60
#
61
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
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
0.67.114 by John H. Embretsen
pb2gentest: Add partn_pruning_compare_50 test definition, including setting path to installation of 5.0 release against which to do query result comparison. This is to be considered experimental for the time being.
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
0.67.120 by John H. Embretsen
pb2gentest: Prepare for splitting of RQG framework and grammars by making grammar and gendata file location configurable.
69
# Location of grammars and other test configuration files.
0.67.136 by John H. Embretsen
Minor fixes to comments in pb2{gentest,combinations}.pl
70
# Will use env variable RQG_CONF if set.
0.67.120 by John H. Embretsen
pb2gentest: Prepare for splitting of RQG framework and grammars by making grammar and gendata file location configurable.
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
0.67.381 by Bernt M. Johnsen
Adjustments after merge
76
if (osWindows()) {
0.67.388 by John H. Embretsen
XML and pb2gentest: Automatically enable XML reporting on more hosts. Added comments and adjusted some details.
77
	# For tail, cdb, pscp.
0.67.16 by John H. Embretsen
Update paths in PB2 scripts, having modified PB2 host setup to use the randgen branch on Launchpad.
78
	$ENV{PATH} = 'G:\pb2\scripts\randgen\bin;G:\pb2\scripts\bin;C:\Program Files\Debugging Tools for Windows (x86);'.$ENV{PATH};
0.67.1 by Philip Stoev
initial import from internal tree
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
0.67.213 by John H. Embretsen
pb2gentest: Stop printining date and time twice. Also skip uname (some host information is printed later).
84
	#system("date /T");
85
	#system("time /T");
0.67.114 by John H. Embretsen
pb2gentest: Add partn_pruning_compare_50 test definition, including setting path to installation of 5.0 release against which to do query result comparison. This is to be considered experimental for the time being.
86
87
	# Path to MySQL releases used for comparison runs.
0.67.666 by John H. Embretsen
Update pushbuild scripts to use 5.0.91 instead of 5.0.87 for comparison runs on Windows.
88
	$basedirRelease50 = 'G:\mysql-releases\mysql-5.0.91-win32'; # loki06
0.67.381 by Bernt M. Johnsen
Adjustments after merge
89
} elsif (osSolaris()) {
0.67.1 by Philip Stoev
initial import from internal tree
90
	# For libmysqlclient
91
	$ENV{LD_LIBRARY_PATH}=$ENV{LD_LIBRARY_PATH}.':/export/home/pb2/scripts/lib/';
92
0.67.400 by John H. Embretsen
pb2gentest.pl: Get tmpdir from GenTest if env var TMPDIR is not set. Also, add path to XML::Writer module to PERL5LIB for Solaris (actually only needed on techra22 (sparc32-bit) right now). Rearranged the latter to a multiline statement to make it easier to maintain.
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/';
0.67.1 by Philip Stoev
initial import from internal tree
101
	
102
	# For c++filt
103
	$ENV{PATH} = $ENV{PATH}.':/opt/studio12/SUNWspro/bin';
104
0.67.213 by John H. Embretsen
pb2gentest: Stop printining date and time twice. Also skip uname (some host information is printed later).
105
	#system("uname -a");
106
	#system("date");
0.67.114 by John H. Embretsen
pb2gentest: Add partn_pruning_compare_50 test definition, including setting path to installation of 5.0 release against which to do query result comparison. This is to be considered experimental for the time being.
107
0.67.1 by Philip Stoev
initial import from internal tree
108
}
109
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
110
################################################################################
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
111
##
112
## subroutines
113
##
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
114
################################################################################
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
115
116
#
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
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).*";
0.67.567 by John H. Embretsen
pb2gentest: Add blank line before new entries in special comments that are printed to output.
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).
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
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}) {
0.67.567 by John H. Embretsen
pb2gentest: Add blank line before new entries in special comments that are printed to output.
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
            }
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
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
#
0.67.79 by John H. Embretsen
pb2gentest: Enable rpl_semisync test on Windows, as support for this was recently added to replication development branches.
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
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
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
	}
0.67.74 by John H. Embretsen
pb2gentest.pl: Improved output/information when starting the script and adjusted pb2 database connection details.
229
	$message = $message." [ skipped ] ".$reason;
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
230
	print "$message\n";
231
	print localtime()." [$$] $0 will exit with exit status 0.\n";
232
	POSIX::_exit (0);
233
}
234
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
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
#
0.89.1 by John H. Embretsen
Workaround for MySQL bug 48351: Support semisync plugin names both with and without 'lib'-prefix. With time only non-prefixed plugin name will be used. Also support other plugin dirs (release builds, sandbox builds etc) by doing recursive search for plugin files. First match wins.
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
#
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
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
0.67.78 by John H. Embretsen
pb2gentest.pl: Disable pb2 db lookup of branch id (while working out perl module issues on certain platforms). Get from env var instead, if set. Adjust messages accordingly
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
	}
0.67.74 by John H. Embretsen
pb2gentest.pl: Improved output/information when starting the script and adjusted pb2 database connection details.
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.norway.sun.com:port=3306:user=readonly:database=pushbuild2';
302
	my $SQL_getBranchId = "SELECT branch_id FROM branches WHERE branch_name = '$branch_name'";
303
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
304
	say("Using branch name $branch_name\n");
305
	say("Trying to connect to pushbuild2 database...\n");
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
306
307
	my $dbh = DBI->connect($dsn_pb2, undef, undef, {
0.67.74 by John H. Embretsen
pb2gentest.pl: Improved output/information when starting the script and adjusted pb2 database connection details.
308
		mysql_connect_timeout => 5,
309
		PrintError => 0,
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
310
		RaiseError => 0,
311
		AutoCommit => 0,
312
	} );
313
314
	if (not defined $dbh) {
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
315
		say("connect() to pushbuild2 database failed: ".$DBI::errstr."\n");
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
316
		return;
317
	}
318
319
	my $id = $dbh->selectrow_array($SQL_getBranchId);
320
	$dbh->disconnect;
321
	return $id;
322
}
323
324
#### end subroutines ###########################################################
325
0.67.387 by John H. Embretsen
pb2gentest: Display user name before running test. To ease debugging in a non-uniform deployment environment.
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
0.67.740 by John H. Embretsen
pb2gentest: Add possibility for alternative randgen location.
334
chdir($randgen);
0.67.1 by Philip Stoev
initial import from internal tree
335
0.67.398 by John H. Embretsen
Start using BzrInfo module for reporting versions to screen and XML reports.
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
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
342
say("===== Information on the host system: =====\n");
343
say(" - Local time  : ".localtime()."\n");
344
say(" - Hostname    : ".hostname()."\n");
0.67.387 by John H. Embretsen
pb2gentest: Display user name before running test. To ease debugging in a non-uniform deployment environment.
345
say(" - Username    : ".$username."\n");
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
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");
0.67.398 by John H. Embretsen
Start using BzrInfo module for reporting versions to screen and XML reports.
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'});
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
360
say("===== Information on Random Query Generator version (bzr): =====\n");
0.67.398 by John H. Embretsen
Start using BzrInfo module for reporting versions to screen and XML reports.
361
say(" - Date (rev)  : ".$bzrinfo->bzrDate());
0.67.411 by John H. Embretsen
pb2gentest: Some cosmetic printout fixes.
362
#say(" - Date (now) : ".$bzrinfo->bzrBuildDate());  # Shows current date, we already have that.
0.67.398 by John H. Embretsen
Start using BzrInfo module for reporting versions to screen and XML reports.
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"));
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
367
say("\n");
0.67.1 by Philip Stoev
initial import from internal tree
368
0.67.116 by John H. Embretsen
pb2gentest: Support "rqg_" prefix in test names. If it is there, strip it off before processing further.
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.
0.67.124 by John H. Embretsen
pb2gentest: Simple MTR-style reporting of test results, for xref and PB2 (pass/fail only, no signature support yet).
376
my $test_name = $test;
377
my $test_suite_name = 'serverqa'; # used for xref reporting
378
$test =~ s/^rqg_//;	# test_name without prefix
0.67.116 by John H. Embretsen
pb2gentest: Support "rqg_" prefix in test names. If it is there, strip it off before processing further.
379
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
380
# Server port numbers:
381
#
0.67.212 by John H. Embretsen
pb2gentest: No longer set MTR_BUILD_THREAD unless specified by user. Our PB2 hosts should run Cat most 1 test at a time.
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.
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
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)
0.67.212 by John H. Embretsen
pb2gentest: No longer set MTR_BUILD_THREAD unless specified by user. Our PB2 hosts should run Cat most 1 test at a time.
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");
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
404
my $port_range_id; # Corresponding to MTR_BUILD_THREAD in the MySQL MTR world.
0.67.212 by John H. Embretsen
pb2gentest: No longer set MTR_BUILD_THREAD unless specified by user. Our PB2 hosts should run Cat most 1 test at a time.
405
# First, see if user has supplied us with a value for MTR_BUILD_THREAD:
0.67.83 by John H. Embretsen
pb2gentest: Do not pick a port base ID if MTR_BUILD_THREAD is already set by user. This allows the user to control which ports will be used.
406
$port_range_id = $ENV{MTR_BUILD_THREAD};
407
if (defined $port_range_id) {
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
408
	say("Environment variable MTR_BUILD_THREAD was already set.\n");
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
409
}
0.67.212 by John H. Embretsen
pb2gentest: No longer set MTR_BUILD_THREAD unless specified by user. Our PB2 hosts should run Cat most 1 test at a time.
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
#}
0.67.74 by John H. Embretsen
pb2gentest.pl: Improved output/information when starting the script and adjusted pb2 database connection details.
420
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
421
say("Configuring test...");
422
say("");
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
423
0.67.420 by John H. Embretsen
pb2gentest: Do not set --loose-log-output option when testing MySQL 5.0.x, otherwise the server will refuse to start.
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
0.67.1 by Philip Stoev
initial import from internal tree
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) {
0.67.411 by John H. Embretsen
pb2gentest: Some cosmetic printout fixes.
438
	say("Detected that this test is about the $engine engine.");
0.67.1 by Philip Stoev
initial import from internal tree
439
}
440
441
if (($rpl_mode) = $test =~ m{(rbr|sbr|mbr|statement|mixed|row)}io) {
0.67.411 by John H. Embretsen
pb2gentest: Some cosmetic printout fixes.
442
	say("Detected that this test is about replication mode $rpl_mode.");
0.67.1 by Philip Stoev
initial import from internal tree
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
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
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.
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
451
#
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
452
# Starting out with "legacy" Falcon tests.
453
#
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
454
if ($test =~ m{falcon_.*transactions}io ) {
0.67.1 by Philip Stoev
initial import from internal tree
455
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
456
		--grammar='.$conf.'/transactions/transactions.yy
457
		--gendata='.$conf.'/transactions/transactions.zz
0.67.1 by Philip Stoev
initial import from internal tree
458
		--mysqld=--falcon-consistent-read=1
459
		--mysqld=--transaction-isolation=REPEATABLE-READ
460
		--validator=DatabaseConsistency
461
		--mem
462
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
463
} elsif ($test =~ m{falcon_.*durability}io ) {
0.67.1 by Philip Stoev
initial import from internal tree
464
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
465
		--grammar='.$conf.'/transactions/transaction_durability.yy
0.67.1 by Philip Stoev
initial import from internal tree
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
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
473
} elsif ($test =~ m{falcon_repeatable_read}io ) {
0.67.1 by Philip Stoev
initial import from internal tree
474
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
475
		--grammar='.$conf.'/transactions/repeatable_read.yy
476
		--gendata='.$conf.'/transactions/transactions.zz
0.67.1 by Philip Stoev
initial import from internal tree
477
		--mysqld=--falcon-consistent-read=1
478
		--mysqld=--transaction-isolation=REPEATABLE-READ
479
		--validator=RepeatableRead
480
		--mysqld=--falcon-consistent-read=1
481
		--mem
482
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
483
} elsif ($test =~ m{falcon_chill_thaw_compare}io) {
0.67.1 by Philip Stoev
initial import from internal tree
484
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
485
	        --grammar='.$conf.'/engines/falcon/falcon_chill_thaw.yy
486
		--gendata='.$conf.'/engines/falcon/falcon_chill_thaw.zz
0.67.1 by Philip Stoev
initial import from internal tree
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
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
494
} elsif ($test =~ m{falcon_chill_thaw}io) {
0.67.1 by Philip Stoev
initial import from internal tree
495
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
496
	        --grammar='.$conf.'/engines/falcon/falcon_chill_thaw.yy
0.67.1 by Philip Stoev
initial import from internal tree
497
	        --mysqld=--falcon-index-chill-threshold=4K 
498
	        --mysqld=--falcon-record-chill-threshold=4K
499
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
500
} elsif ($test =~ m{falcon_online_alter}io) {
0.67.1 by Philip Stoev
initial import from internal tree
501
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
502
	        --grammar='.$conf.'/engines/falcon/falcon_online_alter.yy
0.67.1 by Philip Stoev
initial import from internal tree
503
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
504
} elsif ($test =~ m{falcon_ddl}io) {
0.67.1 by Philip Stoev
initial import from internal tree
505
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
506
	        --grammar='.$conf.'/engines/falcon/falcon_ddl.yy
0.67.1 by Philip Stoev
initial import from internal tree
507
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
508
} elsif ($test =~ m{falcon_limit_compare_self}io ) {
0.67.1 by Philip Stoev
initial import from internal tree
509
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
510
		--grammar='.$conf.'/engines/falcon/falcon_nolimit.yy
0.67.1 by Philip Stoev
initial import from internal tree
511
		--threads=1
512
		--validator=Limit
513
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
514
} elsif ($test =~ m{falcon_limit_compare_innodb}io ) {
0.67.1 by Philip Stoev
initial import from internal tree
515
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
516
		--grammar='.$conf.'/engines/falcon/limit_compare.yy
0.67.1 by Philip Stoev
initial import from internal tree
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
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
524
} elsif ($test =~ m{falcon_limit}io ) {
0.67.1 by Philip Stoev
initial import from internal tree
525
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
526
	        --grammar='.$conf.'/engines/falcon/falcon_limit.yy
0.67.1 by Philip Stoev
initial import from internal tree
527
		--mysqld=--loose-maria-pagecache-buffer-size=64M
528
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
529
} elsif ($test =~ m{falcon_recovery}io ) {
0.67.1 by Philip Stoev
initial import from internal tree
530
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
531
	        --grammar='.$conf.'/engines/falcon/falcon_recovery.yy
532
		--gendata='.$conf.'/engines/falcon/falcon_recovery.zz
0.67.1 by Philip Stoev
initial import from internal tree
533
		--mysqld=--falcon-checkpoint-schedule="1 1 1 1 1"
534
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
535
} elsif ($test =~ m{falcon_pagesize_32K}io ) {
0.67.1 by Philip Stoev
initial import from internal tree
536
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
537
		--grammar='.$conf.'/engines/falcon/falcon_pagesize.yy
0.67.1 by Philip Stoev
initial import from internal tree
538
		--mysqld=--falcon-page-size=32K
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
539
		--gendata='.$conf.'/engines/falcon/falcon_pagesize32K.zz
0.67.1 by Philip Stoev
initial import from internal tree
540
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
541
} elsif ($test =~ m{falcon_pagesize_2K}io) {
0.67.1 by Philip Stoev
initial import from internal tree
542
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
543
		--grammar='.$conf.'/engines/falcon/falcon_pagesize.yy
0.67.1 by Philip Stoev
initial import from internal tree
544
		--mysqld=--falcon-page-size=2K
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
545
		--gendata='.$conf.'/engines/falcon/falcon_pagesize2K.zz
0.67.1 by Philip Stoev
initial import from internal tree
546
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
547
} elsif ($test =~ m{falcon_select_autocommit}io) {
0.67.1 by Philip Stoev
initial import from internal tree
548
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
549
		--grammar='.$conf.'/engines/falcon/falcon_select_autocommit.yy
0.67.1 by Philip Stoev
initial import from internal tree
550
		--queries=10000000
551
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
552
} elsif ($test =~ m{falcon_backlog}io ) {
0.67.1 by Philip Stoev
initial import from internal tree
553
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
554
		--grammar='.$conf.'/engines/falcon/falcon_backlog.yy
555
		--gendata='.$conf.'/engines/falcon/falcon_backlog.zz
0.67.1 by Philip Stoev
initial import from internal tree
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 = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
565
		--grammar='.$conf.'/engines/falcon/falcon_data_types_no_year_time.yy
566
		--gendata='.$conf.'/engines/falcon/falcon_data_types_no_year_time.zz
0.67.1 by Philip Stoev
initial import from internal tree
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
	';
0.67.290 by John H. Embretsen
pb2gentest: Disable compare_self testing against InnoDB, MyISAM, as this test makes most sense to run against more unstable, 'broken' storage engines.
574
} elsif ($test =~ m{falcon_compare_self}io ) {
0.67.238 by John H. Embretsen
pb2gentest: Enable 'compare_self' (datatypes) test also for other engines (myisam, innodb) than falcon.
575
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
576
		--grammar='.$conf.'/engines/falcon/falcon_data_types.yy
577
		--gendata='.$conf.'/engines/falcon/falcon_data_types.zz
0.67.238 by John H. Embretsen
pb2gentest: Enable 'compare_self' (datatypes) test also for other engines (myisam, innodb) than falcon.
578
		--vardir1='.$vardir.'/'.$engine.'-vardir1
579
		--vardir2='.$vardir.'/'.$engine.'-vardir2
580
		--threads=1
581
		--reporters=
582
	';
0.67.290 by John H. Embretsen
pb2gentest: Disable compare_self testing against InnoDB, MyISAM, as this test makes most sense to run against more unstable, 'broken' storage engines.
583
#
584
# END OF FALCON-ONLY TESTS
585
#
0.67.236 by John H. Embretsen
pb2gentest: Add configuration for innodb_repeatable_read test (based on existing falcon equivalent).
586
} elsif ($test =~ m{innodb_repeatable_read}io ) {
587
	# Transactional test. See also falcon_repeatable_read.
588
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
589
		--grammar='.$conf.'/transactions/repeatable_read.yy
590
		--gendata='.$conf.'/transactions/transactions.zz
0.67.236 by John H. Embretsen
pb2gentest: Add configuration for innodb_repeatable_read test (based on existing falcon equivalent).
591
		--mysqld=--transaction-isolation=REPEATABLE-READ
592
		--validator=RepeatableRead
593
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
594
} elsif ($test =~ m{(falcon|myisam)_blob_recovery}io ) {
595
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
596
		--grammar='.$conf.'/engines/falcon/falcon_blobs.yy
597
		--gendata='.$conf.'/engines/falcon/falcon_blobs.zz
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
598
		--duration=130
599
		--threads=1
0.67.88 by John H. Embretsen
pb2gentest: Use Recovery reporter in myisam_blob_recovery test (this was a regression caused by a previous change).
600
		--reporters=Deadlock,ErrorLog,Backtrace,Recovery,Shutdown
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
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
	}
0.67.227 by John H. Embretsen
many_indexes: Temporarily disable use of UTF16 until WL#1213 is pushed to non-falcon branches. Add support for innodb and myisam engines in pb2gentest.
608
} elsif ($test =~ m{(falcon|innodb|myisam)_many_indexes}io ) {
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
609
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
610
		--grammar='.$conf.'/engines/many_indexes.yy
611
		--gendata='.$conf.'/engines/many_indexes.zz
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
612
	';
0.67.224 by John H. Embretsen
pb2gentest: Explicitly add support for innodb and myisam engines for test using falcon_tiny_inserts grammar.
613
} elsif ($test =~ m{(falcon|innodb|myisam)_tiny_inserts}io) {
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
614
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
615
		--gendata='.$conf.'/engines/tiny_inserts.zz
616
		--grammar='.$conf.'/engines/tiny_inserts.yy
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
617
		--queries=10000000
618
	';
0.67.231 by John H. Embretsen
pb2gentest: Definition for rqg_innodb_transactions test.
619
} elsif ($test =~ m{innodb_transactions}io) {
620
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
621
		--grammar='.$conf.'/transactions/transactions.yy
622
		--gendata='.$conf.'/transactions/transactions.zz
0.67.231 by John H. Embretsen
pb2gentest: Definition for rqg_innodb_transactions test.
623
		--mysqld=--transaction-isolation=REPEATABLE-READ
624
		--validator=DatabaseConsistency
625
	';
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
626
#
0.67.224 by John H. Embretsen
pb2gentest: Explicitly add support for innodb and myisam engines for test using falcon_tiny_inserts grammar.
627
# END OF STORAGE ENGINE TESTS
0.67.92 by John H. Embretsen
pb2gentest: Reorder (alphabetize) non-falcon test definitions for easier lookup.
628
#
629
# Keep the following tests in alphabetical order (based on letters in regex)
630
# for easy lookup.
631
#
0.81.2 by John H. Embretsen
pb2gentest: Add --valgrind option to runall commands for tests which names include 'valgrind'.
632
} elsif ($test =~ m{^backup_.*?_simple}io) {
0.67.92 by John H. Embretsen
pb2gentest: Reorder (alphabetize) non-falcon test definitions for easier lookup.
633
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
634
		--grammar='.$conf.'/backup/backup_simple.yy
0.67.92 by John H. Embretsen
pb2gentest: Reorder (alphabetize) non-falcon test definitions for easier lookup.
635
		--reporters=Deadlock,ErrorLog,Backtrace
0.67.145 by John H. Embretsen
pb2gentest: Make sure backup feature is enabled for backup tests (add --mysql-bakcup option). Also add --innodb option to server command line if backup test is for InnoDB.
636
		--mysqld=--mysql-backup
0.67.92 by John H. Embretsen
pb2gentest: Reorder (alphabetize) non-falcon test definitions for easier lookup.
637
	';
0.81.2 by John H. Embretsen
pb2gentest: Add --valgrind option to runall commands for tests which names include 'valgrind'.
638
} elsif ($test =~ m{^backup_.*?_consistency}io) {
0.67.92 by John H. Embretsen
pb2gentest: Reorder (alphabetize) non-falcon test definitions for easier lookup.
639
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
640
		--gendata='.$conf.'/backup/invariant.zz
641
		--grammar='.$conf.'/backup/invariant.yy
0.67.92 by John H. Embretsen
pb2gentest: Reorder (alphabetize) non-falcon test definitions for easier lookup.
642
		--validator=Invariant
643
		--reporters=Deadlock,ErrorLog,Backtrace,BackupAndRestoreInvariant,Shutdown
0.67.145 by John H. Embretsen
pb2gentest: Make sure backup feature is enabled for backup tests (add --mysql-bakcup option). Also add --innodb option to server command line if backup test is for InnoDB.
644
		--mysqld=--mysql-backup
0.67.92 by John H. Embretsen
pb2gentest: Reorder (alphabetize) non-falcon test definitions for easier lookup.
645
		--duration=600
646
		--threads=25
647
	';
648
} elsif ($test =~ m{dml_alter}io ) {
649
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
650
		--gendata='.$conf.'/engines/maria/maria.zz
651
		--grammar='.$conf.'/engines/maria/maria_dml_alter.yy
0.67.92 by John H. Embretsen
pb2gentest: Reorder (alphabetize) non-falcon test definitions for easier lookup.
652
	';
0.81.2 by John H. Embretsen
pb2gentest: Add --valgrind option to runall commands for tests which names include 'valgrind'.
653
} elsif ($test =~ m{^info_schema}io ) {
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
654
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
655
		--grammar='.$conf.'/runtime/information_schema.yy
0.72.1 by John H. Embretsen
pb2gentest: info_schema test should use 10 threads, not 100 (100 is overkill).
656
		--threads=10
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
657
		--duration=300
0.67.148 by Philip Stoev
better INFORMATION_SCHEMA test
658
		--mysqld=--log-output=file
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
659
	';
0.83.2 by John H. Embretsen
pb2gentest: Add mdl_stability test config.
660
} elsif ($test =~ m{^mdl_stability}io ) {
661
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
662
		--grammar='.$conf.'/runtime/metadata_stability.yy
663
		--gendata='.$conf.'/runtime/metadata_stability.zz
0.83.2 by John H. Embretsen
pb2gentest: Add mdl_stability test config.
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
0.67.322 by John H. Embretsen
pb2gentest: Add --loose- to --table-lock-wait-timeout option, removed in MySQL 5.5
670
		--mysqld=--loose-table-lock-wait-timeout=1
0.83.2 by John H. Embretsen
pb2gentest: Add mdl_stability test config.
671
		--mysqld=--innodb-lock-wait-timeout=1
672
		--mysqld=--log-output=file
673
		--queries=1M
674
		--duration=600
675
	';
0.99.5 by John H. Embretsen
pb2gentest: Add mdl_deadlock test, using higher lock wait timeouts than other MDL tests in order to detect more potential deadlocks. The downside is that this test may also detect more false deadlocks (valid lock waits).
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
0.99.8 by John H. Embretsen
pb2gentest: Correct lock timeout name in mdl_deadlock test.
683
    # lock-wait-timeout=31536000 (bug#45225).
684
    # We may want to switch to real (implicit) defaults later.
0.99.5 by John H. Embretsen
pb2gentest: Add mdl_deadlock test, using higher lock wait timeouts than other MDL tests in order to detect more potential deadlocks. The downside is that this test may also detect more false deadlocks (valid lock waits).
685
    #
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
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
    }
0.99.5 by John H. Embretsen
pb2gentest: Add mdl_deadlock test, using higher lock wait timeouts than other MDL tests in order to detect more potential deadlocks. The downside is that this test may also detect more false deadlocks (valid lock waits).
695
    $command = '
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
696
        --grammar='.$grammar.'
0.99.5 by John H. Embretsen
pb2gentest: Add mdl_deadlock test, using higher lock wait timeouts than other MDL tests in order to detect more potential deadlocks. The downside is that this test may also detect more false deadlocks (valid lock waits).
697
        --threads=10
698
        --queries=1M
0.99.13 by John H. Embretsen
pb2gentest: Change duration for mdl_deadlock test to 20 mins (more Pushbuild friendly).
699
        --duration=1200
0.99.5 by John H. Embretsen
pb2gentest: Add mdl_deadlock test, using higher lock wait timeouts than other MDL tests in order to detect more potential deadlocks. The downside is that this test may also detect more false deadlocks (valid lock waits).
700
        --mysqld=--innodb
701
        --mysqld=--innodb-lock-wait-timeout=50
0.99.8 by John H. Embretsen
pb2gentest: Correct lock timeout name in mdl_deadlock test.
702
        --mysqld=--lock-wait-timeout=31536000
0.99.5 by John H. Embretsen
pb2gentest: Add mdl_deadlock test, using higher lock wait timeouts than other MDL tests in order to detect more potential deadlocks. The downside is that this test may also detect more false deadlocks (valid lock waits).
703
        --mysqld=--log-output=file
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
704
        ';
0.83.1 by John H. Embretsen
pb2gentest: Rename mdl test to mdl_stress.
705
} elsif ($test =~ m{^mdl_stress}io ) {
0.81.8 by John H. Embretsen
pb2gentest: Add test config for comprehensive metadata locking test (WL#5004)
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).
0.67.152 by John H. Embretsen
pb2gentest: Rename mdl_innodb to mdl and enable innodb explicitly, based on feedback from pstoev (test is not per se for innodb so having innodb in the test name may be confusing).
708
	#
709
	# InnoDB should be loaded but the test is not per se for InnoDB, hence
710
	# no "innodb" in test name.
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
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
	}
0.81.8 by John H. Embretsen
pb2gentest: Add test config for comprehensive metadata locking test (WL#5004)
721
	$command = '
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
722
		--grammar='.$grammar.'
0.81.8 by John H. Embretsen
pb2gentest: Add test config for comprehensive metadata locking test (WL#5004)
723
		--threads=10
724
		--queries=1M
725
		--duration=1800
0.67.152 by John H. Embretsen
pb2gentest: Rename mdl_innodb to mdl and enable innodb explicitly, based on feedback from pstoev (test is not per se for innodb so having innodb in the test name may be confusing).
726
		--mysqld=--innodb
0.81.8 by John H. Embretsen
pb2gentest: Add test config for comprehensive metadata locking test (WL#5004)
727
	';
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
728
	
729
0.67.413 by John H. Embretsen
pb2gentest: Add outer_join test based on recommendations from Patrick C.
730
#
0.106.13 by John H. Embretsen
pb2gentest: Increase queries for outer_join test, but lower duration (more coverage on faster machines while limiting load on slower ones).
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.
0.67.413 by John H. Embretsen
pb2gentest: Add outer_join test based on recommendations from Patrick C.
733
#
0.67.415 by John H. Embretsen
pb2gentest: Add opt_access_exp test based on recommendations from Patrick C.
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
	';
0.67.741 by John H. Embretsen
Add config for optimizer trace tests (variant of existing tests, _trace in end of test name).
746
} elsif ($test =~ m{^opt_no_subquery(_trace)$}io ) {
0.67.418 by John H. Embretsen
pb2gentest: Add opt_no_subquery test, following recommendations from Patrick C.
747
	$command = '
748
        --threads=1
749
        --queries=100K
750
        --grammar='.$conf.'/optimizer/optimizer_no_subquery.yy
751
        --duration=1200
752
	';
0.67.416 by John H. Embretsen
pb2gentest: Add opt_no_subquery_compare_50 test for comparing queries for current server to 5.0 server.
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
	';
0.67.419 by John H. Embretsen
pb2gentest: Add opt_range_access (longish-running) test. Also fix so that opt_no_subquery is not run when we mean to run opt_no_subquery_compare_50.
769
} elsif ($test =~ m{^opt_range_access}io ) {
0.67.423 by John H. Embretsen
pb2gentest: Reduce duration for range_access test until we are able to prove to PB2 that we are alive even with no output to stdout for 30 minutes. Should probably look more detailed at the test as well to see what is going on.
770
    # We should use a larger than default duration to allow even slower machines to do
0.67.419 by John H. Embretsen
pb2gentest: Add opt_range_access (longish-running) test. Also fix so that opt_no_subquery is not run when we mean to run opt_no_subquery_compare_50.
771
    # useful testing.
772
    # 15K queries means runtime of ~40 mins on standard desktop hardware of Apr2010.
0.67.423 by John H. Embretsen
pb2gentest: Reduce duration for range_access test until we are able to prove to PB2 that we are alive even with no output to stdout for 30 minutes. Should probably look more detailed at the test as well to see what is going on.
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
0.67.419 by John H. Embretsen
pb2gentest: Add opt_range_access (longish-running) test. Also fix so that opt_no_subquery is not run when we mean to run opt_no_subquery_compare_50.
776
	$command = '
777
        --threads=1
778
        --queries=15K
779
        --gendata='.$conf.'/optimizer/range_access.zz
780
        --grammar='.$conf.'/optimizer/range_access.yy
0.67.423 by John H. Embretsen
pb2gentest: Reduce duration for range_access test until we are able to prove to PB2 that we are alive even with no output to stdout for 30 minutes. Should probably look more detailed at the test as well to see what is going on.
781
        --duration=1500
0.67.419 by John H. Embretsen
pb2gentest: Add opt_range_access (longish-running) test. Also fix so that opt_no_subquery is not run when we mean to run opt_no_subquery_compare_50.
782
	';
0.67.414 by John H. Embretsen
pb2gentest: Add opt_subquery test based on recommendations from Patrick C. Also fix typo in comment.
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
	';
0.67.417 by John H. Embretsen
pb2gentest: Alphabetize optimizer test definitions.
792
} elsif ($test =~ m{^outer_join}io ) {
0.106.13 by John H. Embretsen
pb2gentest: Increase queries for outer_join test, but lower duration (more coverage on faster machines while limiting load on slower ones).
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.
0.67.417 by John H. Embretsen
pb2gentest: Alphabetize optimizer test definitions.
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
0.106.13 by John H. Embretsen
pb2gentest: Increase queries for outer_join test, but lower duration (more coverage on faster machines while limiting load on slower ones).
799
        --queries=80K
0.67.417 by John H. Embretsen
pb2gentest: Alphabetize optimizer test definitions.
800
        --gendata='.$conf.'/optimizer/outer_join.zz
801
        --grammar='.$conf.'/optimizer/outer_join.yy
0.106.13 by John H. Embretsen
pb2gentest: Increase queries for outer_join test, but lower duration (more coverage on faster machines while limiting load on slower ones).
802
        --duration=900
0.67.417 by John H. Embretsen
pb2gentest: Alphabetize optimizer test definitions.
803
	';
0.67.414 by John H. Embretsen
pb2gentest: Add opt_subquery test based on recommendations from Patrick C. Also fix typo in comment.
804
#
805
# End of optimizer tests.
806
#
0.81.2 by John H. Embretsen
pb2gentest: Add --valgrind option to runall commands for tests which names include 'valgrind'.
807
} elsif ($test =~ m{^partition_ddl}io ) {
0.67.93 by John H. Embretsen
pb2gentest: Add configuration for 'partition_ddl' test.
808
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
809
		--grammar='.$conf.'/partitioning/partitions-ddl.yy
0.67.142 by John H. Embretsen
pb2gentest: Set option --mysqld=--innodb for tests that always use innodb.
810
		--mysqld=--innodb
0.67.93 by John H. Embretsen
pb2gentest: Add configuration for 'partition_ddl' test.
811
		--threads=1
812
		--queries=100K
813
	';
0.81.2 by John H. Embretsen
pb2gentest: Add --valgrind option to runall commands for tests which names include 'valgrind'.
814
} elsif ($test =~ m{partn_pruning(|.valgrind)$}io ) {
0.67.126 by John H. Embretsen
pb2gentest: partn_pruning: Reduce duration from default (600s) to 300s, since we also spend a lot of time creating tables.
815
	# reduced duration to half since gendata phase takes longer in this case
0.67.94 by John H. Embretsen
pb2gentest: Add first version of config for 'partition_pruning' test.
816
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
817
		--gendata='.$conf.'/partitioning/partition_pruning.zz
818
		--grammar='.$conf.'/partitioning/partition_pruning.yy
0.67.142 by John H. Embretsen
pb2gentest: Set option --mysqld=--innodb for tests that always use innodb.
819
		--mysqld=--innodb
0.67.94 by John H. Embretsen
pb2gentest: Add first version of config for 'partition_pruning' test.
820
		--threads=1
821
		--queries=100000
0.67.126 by John H. Embretsen
pb2gentest: partn_pruning: Reduce duration from default (600s) to 300s, since we also spend a lot of time creating tables.
822
		--duration=300
0.67.94 by John H. Embretsen
pb2gentest: Add first version of config for 'partition_pruning' test.
823
	';
0.81.2 by John H. Embretsen
pb2gentest: Add --valgrind option to runall commands for tests which names include 'valgrind'.
824
} elsif ($test =~ m{^partn_pruning_compare_50}io) {
0.67.114 by John H. Embretsen
pb2gentest: Add partn_pruning_compare_50 test definition, including setting path to installation of 5.0 release against which to do query result comparison. This is to be considered experimental for the time being.
825
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
826
	--gendata='.$conf.'/partitioning/partition_pruning.zz
827
	--grammar='.$conf.'/partitioning/partition_pruning.yy
0.67.114 by John H. Embretsen
pb2gentest: Add partn_pruning_compare_50 test definition, including setting path to installation of 5.0 release against which to do query result comparison. This is to be considered experimental for the time being.
828
	--basedir1='.$basedir.'
829
	--basedir2='.$basedirRelease50.'
830
	--vardir1='.$vardir.'/vardir-bzr
831
	--vardir2='.$vardir.'/vardir-5.0
0.67.142 by John H. Embretsen
pb2gentest: Set option --mysqld=--innodb for tests that always use innodb.
832
	--mysqld=--innodb
0.80.5 by John H. Embretsen
pb2gentest: Changes to partn_pruning_compare_50:
833
	--validators=ResultsetComparator
834
	--reporters=Deadlock,ErrorLog,Backtrace
0.67.114 by John H. Embretsen
pb2gentest: Add partn_pruning_compare_50 test definition, including setting path to installation of 5.0 release against which to do query result comparison. This is to be considered experimental for the time being.
835
	--threads=1
836
	--queries=10000
0.80.5 by John H. Embretsen
pb2gentest: Changes to partn_pruning_compare_50:
837
	--duration=300
0.67.114 by John H. Embretsen
pb2gentest: Add partn_pruning_compare_50 test definition, including setting path to installation of 5.0 release against which to do query result comparison. This is to be considered experimental for the time being.
838
	';
0.81.2 by John H. Embretsen
pb2gentest: Add --valgrind option to runall commands for tests which names include 'valgrind'.
839
} elsif ($test =~ m{^rpl_.*?_simple}io) {
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
840
	# Not used; rpl testing needs adjustments (some of the failures this
841
	# produces are known replication issues documented in the manual).
0.67.1 by Philip Stoev
initial import from internal tree
842
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
843
		--gendata='.$conf.'/replication/replication_single_engine.zz
844
		--grammar='.$conf.'/replication/replication_simple.yy
0.67.1 by Philip Stoev
initial import from internal tree
845
		--mysqld=--log-output=table,file
0.70.2 by John H. Embretsen
Added new test rpl_semisync to pb2gentest.pl.
846
	';
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
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 = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
851
		--gendata='.$conf.'/replication/replication_single_engine_pk.zz
852
		--grammar='.$conf.'/replication/replication.yy
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
853
		--mysqld=--log-output=table,file
0.67.142 by John H. Embretsen
pb2gentest: Set option --mysqld=--innodb for tests that always use innodb.
854
		--mysqld=--innodb
0.67.84 by John H. Embretsen
pb2gentest: Made test configurations that support or are used for the Falcon engine only trigger only if falcon is mentioned in test name. Otherwise this may interfere with other tests for other features. This should make myisam_blob_recovery work (used to fail due to unknown falcon option being specified). Also moved multi-engine or engine independent tests closer together.
855
	';
0.81.2 by John H. Embretsen
pb2gentest: Add --valgrind option to runall commands for tests which names include 'valgrind'.
856
} elsif ($test =~ m{^rpl_semisync}io) {
0.70.2 by John H. Embretsen
Added new test rpl_semisync to pb2gentest.pl.
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.
0.70.3 by John H. Embretsen
pb2gentest: Logic for making sure correct plugin file name is passed on to the RQG/MySQL on Windows (.dll vs .so) for rpl_semisync test.
862
0.67.79 by John H. Embretsen
pb2gentest: Enable rpl_semisync test on Windows, as support for this was recently added to replication development branches.
863
	# Plugin file names and location vary between platforms.
0.67.187 by John H. Embretsen
pb2gentest: Extra comment about semisync plugin location, in case we see issues with this in the future.
864
	# See http://bugs.mysql.com/bug.php?id=49170 for details.
0.89.1 by John H. Embretsen
Workaround for MySQL bug 48351: Support semisync plugin names both with and without 'lib'-prefix. With time only non-prefixed plugin name will be used. Also support other plugin dirs (release builds, sandbox builds etc) by doing recursive search for plugin files. First match wins.
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.
0.67.187 by John H. Embretsen
pb2gentest: Extra comment about semisync plugin location, in case we see issues with this in the future.
868
	# Unix file name extenstions other than .so may exist, but support for this
869
	# is not yet implemented here.
0.67.79 by John H. Embretsen
pb2gentest: Enable rpl_semisync test on Windows, as support for this was recently added to replication development branches.
870
	my $plugin_dir;
0.70.3 by John H. Embretsen
pb2gentest: Logic for making sure correct plugin file name is passed on to the RQG/MySQL on Windows (.dll vs .so) for rpl_semisync test.
871
	my $plugins;
0.67.381 by Bernt M. Johnsen
Adjustments after merge
872
	if (osWindows()) {
0.89.1 by John H. Embretsen
Workaround for MySQL bug 48351: Support semisync plugin names both with and without 'lib'-prefix. With time only non-prefixed plugin name will be used. Also support other plugin dirs (release builds, sandbox builds etc) by doing recursive search for plugin files. First match wins.
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';
0.70.3 by John H. Embretsen
pb2gentest: Logic for making sure correct plugin file name is passed on to the RQG/MySQL on Windows (.dll vs .so) for rpl_semisync test.
879
	} else {
0.67.79 by John H. Embretsen
pb2gentest: Enable rpl_semisync test on Windows, as support for this was recently added to replication development branches.
880
		# tested on Linux and Solaris
0.89.1 by John H. Embretsen
Workaround for MySQL bug 48351: Support semisync plugin names both with and without 'lib'-prefix. With time only non-prefixed plugin name will be used. Also support other plugin dirs (release builds, sandbox builds etc) by doing recursive search for plugin files. First match wins.
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';
0.70.3 by John H. Embretsen
pb2gentest: Logic for making sure correct plugin file name is passed on to the RQG/MySQL on Windows (.dll vs .so) for rpl_semisync test.
895
	}
0.67.120 by John H. Embretsen
pb2gentest: Prepare for splitting of RQG framework and grammars by making grammar and gendata file location configurable.
896
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
897
		--gendata='.$conf.'/replication/replication_single_engine.zz
0.67.63 by Philip Stoev
fixes to pb2gentest.pl for semisynch replication
898
		--engine=InnoDB
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
899
		--grammar='.$conf.'/replication/replication_simple.yy
0.70.2 by John H. Embretsen
Added new test rpl_semisync to pb2gentest.pl.
900
		--rpl_mode=default
0.67.120 by John H. Embretsen
pb2gentest: Prepare for splitting of RQG framework and grammars by making grammar and gendata file location configurable.
901
		--mysqld=--plugin-dir='.$plugin_dir.'
902
		--mysqld=--plugin-load='.$plugins.'
0.70.2 by John H. Embretsen
Added new test rpl_semisync to pb2gentest.pl.
903
		--mysqld=--rpl_semi_sync_master_enabled=1
904
		--mysqld=--rpl_semi_sync_slave_enabled=1
0.81.1 by John H. Embretsen
pb2gentest: Generalize use of --innodb option. Add it if test name includes 'innodb'. Also continue adding it for special tests whose names do not incldue 'innodb'. innodb_limit test added for script testing purposes (for now).
905
		--mysqld=--innodb
0.67.63 by Philip Stoev
fixes to pb2gentest.pl for semisynch replication
906
		--reporters=ReplicationSemiSync,Deadlock,Backtrace,ErrorLog
0.67.186 by John H. Embretsen
pb2gentest: Specify 'None' validator when we do not want to use any validators. See bug#49167.
907
		--validators=None
0.70.2 by John H. Embretsen
Added new test rpl_semisync to pb2gentest.pl.
908
		--threads=1
909
		--duration=300
910
		--queries=1M
0.67.120 by John H. Embretsen
pb2gentest: Prepare for splitting of RQG framework and grammars by making grammar and gendata file location configurable.
911
	';
0.67.92 by John H. Embretsen
pb2gentest: Reorder (alphabetize) non-falcon test definitions for easier lookup.
912
} elsif ($test =~ m{signal_resignal}io ) {
0.67.1 by Philip Stoev
initial import from internal tree
913
	$command = '
0.67.92 by John H. Embretsen
pb2gentest: Reorder (alphabetize) non-falcon test definitions for easier lookup.
914
		--threads=10
915
		--queries=1M
916
		--duration=300
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
917
		--grammar='.$conf.'/runtime/signal_resignal.yy
0.67.92 by John H. Embretsen
pb2gentest: Reorder (alphabetize) non-falcon test definitions for easier lookup.
918
		--mysqld=--max-sp-recursion-depth=10
0.67.1 by Philip Stoev
initial import from internal tree
919
	';
0.67.222 by John H. Embretsen
pb2gentest: Explicitly support innodb and myisam engines for test using maria_stress grammar.
920
} elsif ($test =~ m{(innodb|maria|myisam)_stress}io ) {
0.67.1 by Philip Stoev
initial import from internal tree
921
	$command = '
0.99.3 by John H. Embretsen
Categorized configuration files by moving them into subdirectories with descriptive names.
922
		--grammar='.$conf.'/engines/maria/maria_stress.yy
0.67.1 by Philip Stoev
initial import from internal tree
923
	';
0.67.398 by John H. Embretsen
Start using BzrInfo module for reporting versions to screen and XML reports.
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 {
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
933
	say("[ERROR]: Test configuration for test name '$test' is not ".
0.67.85 by John H. Embretsen
pb2gentest: Exit with an error message if test name is not recognized by this script.
934
		"defined in this script.\n");
935
	my $exitCode = 1;
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
936
	say("Will exit $0 with exit code $exitCode.\n");
0.67.85 by John H. Embretsen
pb2gentest: Exit with an error message if test name is not recognized by this script.
937
	POSIX::_exit ($exitCode);
0.67.1 by Philip Stoev
initial import from internal tree
938
}
939
0.67.741 by John H. Embretsen
Add config for optimizer trace tests (variant of existing tests, _trace in end of test name).
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
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
953
#
0.67.565 by John H. Embretsen
pb2gentest*: Automatically look for redefine file to match the given grammar file. If found, add --redefine=file to RQG command line. Also:
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
#
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
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
#
0.67.1 by Philip Stoev
initial import from internal tree
965
if ($command =~ m{--reporters}io) {
966
	# Reporters have already been specified	
967
} elsif ($test =~ m{rpl}io ) {
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
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';
0.67.1 by Philip Stoev
initial import from internal tree
976
} else {
0.71.1 by John H. Embretsen
Added new tests info_schema and signal_resignal to pb2gentest, and added basic "skip test" functionality.
977
	# Default reporters for tests whose name does not contain "rpl" or "falcon"
978
	$command = $command.' --reporters=Deadlock,ErrorLog,Backtrace,Shutdown';
0.67.1 by Philip Stoev
initial import from internal tree
979
}
980
0.81.1 by John H. Embretsen
pb2gentest: Generalize use of --innodb option. Add it if test name includes 'innodb'. Also continue adding it for special tests whose names do not incldue 'innodb'. innodb_limit test added for script testing purposes (for now).
981
#
982
# Other defaults...
983
#
984
0.67.1 by Philip Stoev
initial import from internal tree
985
if ($command !~ m{--duration}io ) {
0.67.103 by John H. Embretsen
pb2gentest: Set default duration of 10 minutes. 20 minutes is too long when the number of RQG tests in PB2 increases, causing delays.
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';
0.67.1 by Philip Stoev
initial import from internal tree
991
}
992
0.67.115 by John H. Embretsen
pb2gentest: Do not set default --basedir if some basedir is already set.
993
if ($command !~ m{--basedir}io ) {
994
	$command = $command." --basedir=\"$basedir\"";
995
}
996
0.67.1 by Philip Stoev
initial import from internal tree
997
if ($command !~ m{--vardir}io && $command !~ m{--mem}io ) {
998
	$command = $command." --vardir=\"$vardir\"";
999
}
1000
0.67.420 by John H. Embretsen
pb2gentest: Do not set --loose-log-output option when testing MySQL 5.0.x, otherwise the server will refuse to start.
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.
0.67.1 by Philip Stoev
initial import from internal tree
1003
if ($command !~ m{--log-output}io) {
0.67.420 by John H. Embretsen
pb2gentest: Do not set --loose-log-output option when testing MySQL 5.0.x, otherwise the server will refuse to start.
1004
	if (!$version50) {
1005
		$command = $command.' --mysqld=--log-output=file';
1006
	} 
0.67.1 by Philip Stoev
initial import from internal tree
1007
}
1008
0.67.330 by John H. Embretsen
pb2gentest: Decrease default lock-wait timeouts to 1s. Add new option --loose-lock-wait-timeout=1 by default.
1009
# 1s to enable increased concurrency. NOTE: Removed in MySQL 5.5, Feb 2010.
0.67.323 by John H. Embretsen
pb2gentest: Make sure custom set values of lock timeouts are not overridden.
1010
if ($command !~ m{table-lock-wait-timeout}io) {
0.67.330 by John H. Embretsen
pb2gentest: Decrease default lock-wait timeouts to 1s. Add new option --loose-lock-wait-timeout=1 by default.
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.
0.67.323 by John H. Embretsen
pb2gentest: Make sure custom set values of lock timeouts are not overridden.
1021
if ($command !~ m{innodb-lock-wait-timeout}io) {
0.67.330 by John H. Embretsen
pb2gentest: Decrease default lock-wait timeouts to 1s. Add new option --loose-lock-wait-timeout=1 by default.
1022
    $command = $command.' --mysqld=--loose-innodb-lock-wait-timeout=1';
0.67.323 by John H. Embretsen
pb2gentest: Make sure custom set values of lock timeouts are not overridden.
1023
}
1024
0.67.1 by Philip Stoev
initial import from internal tree
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
0.82.1 by John H. Embretsen
pb2gentest: Add --engine=innodb for all named innodb tests.
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
	}
0.81.1 by John H. Embretsen
pb2gentest: Generalize use of --innodb option. Add it if test name includes 'innodb'. Also continue adding it for special tests whose names do not incldue 'innodb'. innodb_limit test added for script testing purposes (for now).
1042
}
1043
0.67.1 by Philip Stoev
initial import from internal tree
1044
if (($command !~ m{--rpl_mode}io)  && ($rpl_mode ne '')) {
1045
	$command = $command." --rpl_mode=$rpl_mode";
1046
}
0.81.2 by John H. Embretsen
pb2gentest: Add --valgrind option to runall commands for tests which names include 'valgrind'.
1047
1048
# if test name contains (usually ends with) "valgrind", add the valgrind option to runall.pl
1049
if ($test =~ m{valgrind}io){
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
1050
	say("Detected that this test should enable valgrind instrumentation.\n");
0.81.2 by John H. Embretsen
pb2gentest: Add --valgrind option to runall commands for tests which names include 'valgrind'.
1051
	if (system("valgrind --version")) {
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
1052
		say("  *** valgrind executable not found! Not setting --valgrind flag.\n");
0.81.2 by John H. Embretsen
pb2gentest: Add --valgrind option to runall commands for tests which names include 'valgrind'.
1053
	} else {
1054
		$command = $command.' --valgrind';
1055
	}
1056
}
0.67.1 by Philip Stoev
initial import from internal tree
1057
	
0.67.323 by John H. Embretsen
pb2gentest: Make sure custom set values of lock timeouts are not overridden.
1058
$command = "perl runall.pl --mysqld=--loose-skip-safemalloc ".$command;
0.67.1 by Philip Stoev
initial import from internal tree
1059
0.67.388 by John H. Embretsen
XML and pb2gentest: Automatically enable XML reporting on more hosts. Added comments and adjusted some details.
1060
### XML reporting setup START
1061
0.67.386 by John H. Embretsen
pb2gentest: Try out XML reporting to TT in Pushbuild. Temporary code.
1062
# Pass test name to RQG, for reporting purposes
1063
$command = $command." --testname=".$test_name;
0.67.388 by John H. Embretsen
XML and pb2gentest: Automatically enable XML reporting on more hosts. Added comments and adjusted some details.
1064
0.67.386 by John H. Embretsen
pb2gentest: Try out XML reporting to TT in Pushbuild. Temporary code.
1065
# Enable XML reporting to TestTool.
0.67.388 by John H. Embretsen
XML and pb2gentest: Automatically enable XML reporting on more hosts. Added comments and adjusted some details.
1066
# For now only on given hosts...
0.67.386 by John H. Embretsen
pb2gentest: Try out XML reporting to TT in Pushbuild. Temporary code.
1067
my %report_xml_from_hosts = (
0.67.388 by John H. Embretsen
XML and pb2gentest: Automatically enable XML reporting on more hosts. Added comments and adjusted some details.
1068
    'loki06'   => '',
1069
    'nanna21'  => '',
1070
    'techra22' => '',
1071
    'tor06-z1' => '',
1072
    'tyr41'    => ''
0.67.386 by John H. Embretsen
pb2gentest: Try out XML reporting to TT in Pushbuild. Temporary code.
1073
);
1074
my $hostname = hostname();
1075
my $xmlfile;
0.67.388 by John H. Embretsen
XML and pb2gentest: Automatically enable XML reporting on more hosts. Added comments and adjusted some details.
1076
my $delete_xmlfile = 0; # boolean indicator whether to delete local XML file.
0.67.386 by John H. Embretsen
pb2gentest: Try out XML reporting to TT in Pushbuild. Temporary code.
1077
if (exists $report_xml_from_hosts{$hostname}) {
0.67.388 by John H. Embretsen
XML and pb2gentest: Automatically enable XML reporting on more hosts. Added comments and adjusted some details.
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.
0.67.400 by John H. Embretsen
pb2gentest.pl: Get tmpdir from GenTest if env var TMPDIR is not set. Also, add path to XML::Writer module to PERL5LIB for Solaris (actually only needed on techra22 (sparc32-bit) right now). Rearranged the latter to a multiline statement to make it easier to maintain.
1083
    # GenTest looks for other tmpdir alternatives.
1084
    my $tmpdir = $ENV{'TMPDIR'} || tmpdir();
0.67.386 by John H. Embretsen
pb2gentest: Try out XML reporting to TT in Pushbuild. Temporary code.
1085
    if (length($tmpdir) > 1) {
0.67.400 by John H. Embretsen
pb2gentest.pl: Get tmpdir from GenTest if env var TMPDIR is not set. Also, add path to XML::Writer module to PERL5LIB for Solaris (actually only needed on techra22 (sparc32-bit) right now). Rearranged the latter to a multiline statement to make it easier to maintain.
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';
0.67.386 by John H. Embretsen
pb2gentest: Try out XML reporting to TT in Pushbuild. Temporary code.
1089
    } else {
0.67.400 by John H. Embretsen
pb2gentest.pl: Get tmpdir from GenTest if env var TMPDIR is not set. Also, add path to XML::Writer module to PERL5LIB for Solaris (actually only needed on techra22 (sparc32-bit) right now). Rearranged the latter to a multiline statement to make it easier to maintain.
1090
        # tmpdir not found. Write report to current directory.
1091
        say("A suitable tmpdir was not found. Writing temporary files to current directory");
0.67.388 by John H. Embretsen
XML and pb2gentest: Automatically enable XML reporting on more hosts. Added comments and adjusted some details.
1092
        # This file should be deleted after test end so that disks won't fill up.
0.67.386 by John H. Embretsen
pb2gentest: Try out XML reporting to TT in Pushbuild. Temporary code.
1093
        $delete_xmlfile = 1;
1094
        $xmlfile = $test_name.'.xml';
1095
    }
0.67.388 by John H. Embretsen
XML and pb2gentest: Automatically enable XML reporting on more hosts. Added comments and adjusted some details.
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.norway.sun.com:/raid/xml_results/TestTool/xml/';
0.67.386 by John H. Embretsen
pb2gentest: Try out XML reporting to TT in Pushbuild. Temporary code.
1103
}
0.67.388 by John H. Embretsen
XML and pb2gentest: Automatically enable XML reporting on more hosts. Added comments and adjusted some details.
1104
### XML reporting setup END
1105
0.67.386 by John H. Embretsen
pb2gentest: Try out XML reporting to TT in Pushbuild. Temporary code.
1106
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
1107
# Add env variable to specify unique port range to use to avoid conflicts.
0.67.212 by John H. Embretsen
pb2gentest: No longer set MTR_BUILD_THREAD unless specified by user. Our PB2 hosts should run Cat most 1 test at a time.
1108
# Trying not to do this unless actually needed.
1109
if (defined $port_range_id) {
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
1110
	say("MTR_BUILD_THREAD=$port_range_id\n");
0.67.381 by Bernt M. Johnsen
Adjustments after merge
1111
	if (osWindows()) {
0.67.212 by John H. Embretsen
pb2gentest: No longer set MTR_BUILD_THREAD unless specified by user. Our PB2 hosts should run Cat most 1 test at a time.
1112
		$command = "set MTR_BUILD_THREAD=$port_range_id && ".$command;
1113
	} else {
1114
		$command = "MTR_BUILD_THREAD=$port_range_id ".$command;
1115
	}
0.67.67 by John H. Embretsen
pb2gentest.pl: Fixed setting of MTR_BUILD_THREAD on Windows (multiple commands on single command line). Created convenience variable for checking if we are on Windows OS.
1116
}
0.67.66 by John H. Embretsen
pb2gentest: Set MTR_BUILD_THREAD to avoid port number conflicts during parallel test runs on the same host.
1117
0.67.1 by Philip Stoev
initial import from internal tree
1118
$command =~ s{[\r\n\t]}{ }sgio;
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
1119
say("Running runall.pl...\n");
0.67.1 by Philip Stoev
initial import from internal tree
1120
my $command_result = system($command);
0.67.124 by John H. Embretsen
pb2gentest: Simple MTR-style reporting of test results, for xref and PB2 (pass/fail only, no signature support yet).
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
0.67.265 by John H. Embretsen
pb2gentest: Try-out code to mark failing tests as 'experimental' in a test branch in PB2.
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
	}
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
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");
0.67.124 by John H. Embretsen
pb2gentest: Simple MTR-style reporting of test results, for xref and PB2 (pass/fail only, no signature support yet).
1148
} else {
1149
	print($full_test_name." [ pass ]\n");
1150
}
0.67.1 by Philip Stoev
initial import from internal tree
1151
0.67.386 by John H. Embretsen
pb2gentest: Try out XML reporting to TT in Pushbuild. Temporary code.
1152
if ($delete_xmlfile && -e $xmlfile) {
1153
    unlink $xmlfile;
1154
    say("Temporary XML file $xmlfile deleted");
1155
}
0.80.4 by John H. Embretsen
pb2gentest: Kill remaining mysqld processes also on Windows (requires pskill from MS SysInternals PsTools).
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.
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
1160
say("Checking for remaining mysqld processes...\n");
0.67.381 by Bernt M. Johnsen
Adjustments after merge
1161
if (osWindows()) {
0.80.4 by John H. Embretsen
pb2gentest: Kill remaining mysqld processes also on Windows (requires pskill from MS SysInternals PsTools).
1162
	# assumes MS Sysinternals PsTools is installed in C:\bin
0.67.136 by John H. Embretsen
Minor fixes to comments in pb2{gentest,combinations}.pl
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
0.107.8 by John H. Embretsen
pb2gentest*.pl: Support vardir as relative path by adjusting pskill commands.
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
0.80.6 by John H. Embretsen
pb2gentest: Fix quoting and output redirection around pslist and pskill commands.
1174
	if (system('C:\bin\pslist mysqld') == 0) {
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
1175
		say(" ^--- Found running mysqld process(es), to be killed if possible.\n");
0.107.8 by John H. Embretsen
pb2gentest*.pl: Support vardir as relative path by adjusting pskill commands.
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');
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
1178
	} else { say("  None found.\n"); }
0.80.4 by John H. Embretsen
pb2gentest: Kill remaining mysqld processes also on Windows (requires pskill from MS SysInternals PsTools).
1179
	
1180
} else {
1181
	# Unix/Linux.
1182
	# Avoid "bad argument count" messages from kill by checking if process exists first.
0.67.125 by John H. Embretsen
pb2gentest: Get rid of spurious error messages at end of runs (from kill and killall) by:
1183
	if (system("pgrep mysqld") == 0) {
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
1184
		say(" ^--- Found running mysqld process(es), to be killed if possible.\n");
0.67.125 by John H. Embretsen
pb2gentest: Get rid of spurious error messages at end of runs (from kill and killall) by:
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
		}
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
1191
	} else { say("  None found.\n"); }
0.67.1 by Philip Stoev
initial import from internal tree
1192
}
1193
0.99.27 by John H. Embretsen
Use say() instead of print() where we can, to get a uniform prefix for all chatter (PB2 scripts). Almost all remaining prints are nedded to conform with current external (PB2) log parsers.
1194
say(" [$$] $0 will exit with exit status ".$command_result_shifted."\n");
0.67.124 by John H. Embretsen
pb2gentest: Simple MTR-style reporting of test results, for xref and PB2 (pass/fail only, no signature support yet).
1195
POSIX::_exit ($command_result_shifted);