~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to pb2gentest.pl

  • Committer: Andy Lester
  • Date: 2008-08-10 01:24:02 UTC
  • mto: (266.1.31 use-replace-funcs)
  • mto: This revision was merged to the branch mainline in revision 295.
  • Revision ID: andy@petdance.com-20080810012402-poten4vrxv1y7rki
make things more const-correct

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
use strict;
2
 
use POSIX;
3
 
use Cwd;
4
 
 
5
 
my ($basedir, $vardir, $tree, $test) = @ARGV;
6
 
 
7
 
#
8
 
# For further details about tests and recommended RQG options, see
9
 
# http://forge.mysql.com/wiki/RandomQueryGeneratorTests
10
 
#
11
 
 
12
 
# Autoflush output buffers (needed when using POSIX::_exit())
13
 
$| = 1;
14
 
 
15
 
#
16
 
# Prepare ENV variables
17
 
#
18
 
 
19
 
if (
20
 
        ($^O eq 'MSWin32') ||
21
 
        ($^O eq 'MSWin64')
22
 
) {
23
 
        # For tail and for cdb
24
 
        $ENV{PATH} = 'G:\pb2\scripts\randgen\bin;G:\pb2\scripts\bin;C:\Program Files\Debugging Tools for Windows (x86);'.$ENV{PATH};
25
 
        $ENV{_NT_SYMBOL_PATH} = 'srv*c:\\cdb_symbols*http://msdl.microsoft.com/download/symbols;cache*c:\\cdb_symbols';
26
 
 
27
 
        # For vlad
28
 
        #ENV{MYSQL_FULL_MINIDUMP} = 1;
29
 
 
30
 
        system("date /T");
31
 
        system("time /T");
32
 
} elsif ($^O eq 'solaris') {
33
 
        # For libmysqlclient
34
 
        $ENV{LD_LIBRARY_PATH}=$ENV{LD_LIBRARY_PATH}.':/export/home/pb2/scripts/lib/';
35
 
 
36
 
        # For DBI and DBD::mysql
37
 
        $ENV{PERL5LIB}=$ENV{PERL5LIB}.':/export/home/pb2/scripts/DBI-1.607/:/export/home/pb2/scripts/DBI-1.607/lib:/export/home/pb2/scripts/DBI-1.607/blib/arch/:/export/home/pb2/scripts/DBD-mysql-4.008/lib/:/export/home/pb2/scripts/DBD-mysql-4.008/blib/arch/';
38
 
        
39
 
        # For c++filt
40
 
        $ENV{PATH} = $ENV{PATH}.':/opt/studio12/SUNWspro/bin';
41
 
 
42
 
        system("uname -a");
43
 
        system("date");
44
 
}
45
 
 
46
 
##
47
 
## subroutines
48
 
##
49
 
 
50
 
#
51
 
# Skips the test, displays reason (argument to the routine) and exits with
52
 
# exit code 0.
53
 
#
54
 
sub skip_test {
55
 
        my $reason = @_[0];
56
 
        my $message = "$test";
57
 
        # Using MTR-style output for the readers' convenience.
58
 
        # (at least 41 chars before "[ skipped ]")
59
 
        while (length $message < 40)
60
 
        {
61
 
                $message = $message.' ';
62
 
        }
63
 
        $message = $message." [ skipped ] ".$reason;
64
 
        print "$message\n";
65
 
        print localtime()." [$$] $0 will exit with exit status 0.\n";
66
 
        POSIX::_exit (0);
67
 
}
68
 
 
69
 
chdir('randgen');
70
 
 
71
 
print localtime()." [$$] Information on the host system:\n";
72
 
system("hostname");
73
 
 
74
 
#print localtime()." [$$] Information on Random Query Generator version:\n";
75
 
#system("bzr parent");
76
 
#system("bzr version-info");
77
 
 
78
 
my $cwd = cwd();
79
 
 
80
 
my $command;
81
 
my $engine;
82
 
my $rpl_mode;
83
 
 
84
 
if (($engine) = $test =~ m{(maria|falcon|innodb|myisam|pbxt)}io) {
85
 
        print "Detected that this test is about the $engine engine.\n";
86
 
}
87
 
 
88
 
if (($rpl_mode) = $test =~ m{(rbr|sbr|mbr|statement|mixed|row)}io) {
89
 
        print "Detected that this test is about replication mode $rpl_mode.\n";
90
 
        $rpl_mode = 'mixed' if $rpl_mode eq 'mbr';
91
 
        $rpl_mode = 'statement' if $rpl_mode eq 'sbr';
92
 
        $rpl_mode = 'row' if $rpl_mode eq 'rbr';
93
 
}
94
 
 
95
 
#
96
 
# Start defining tests. Test name can be whatever matches the regex in the if().
97
 
# TODO: Define less ambiguous test names to avoid accidental misconfiguration.
98
 
# Starting out with "legacy" Falcon tests.
99
 
#
100
 
if ($test =~ m{transactions}io ) {
101
 
        $command = '
102
 
                --grammar=conf/transactions.yy
103
 
                --gendata=conf/transactions.zz
104
 
                --mysqld=--falcon-consistent-read=1
105
 
                --mysqld=--transaction-isolation=REPEATABLE-READ
106
 
                --validator=DatabaseConsistency
107
 
                --mem
108
 
        ';
109
 
} elsif ($test =~ m{durability}io ) {
110
 
        $command = '
111
 
                --grammar=conf/transaction_durability.yy
112
 
                --vardir1='.$vardir.'/vardir-'.$engine.'
113
 
                --vardir2='.$vardir.'/vardir-innodb
114
 
                --mysqld=--default-storage-engine='.$engine.'
115
 
                --mysqld=--falcon-checkpoint-schedule=\'1 1 1 1 1\'
116
 
                --mysqld2=--default-storage-engine=Innodb
117
 
                --validator=ResultsetComparator
118
 
        ';
119
 
} elsif ($test =~ m{repeatable_read}io ) {
120
 
        $command = '
121
 
                --grammar=conf/repeatable_read.yy
122
 
                --gendata=conf/transactions.zz
123
 
                --mysqld=--falcon-consistent-read=1
124
 
                --mysqld=--transaction-isolation=REPEATABLE-READ
125
 
                --validator=RepeatableRead
126
 
                --mysqld=--falcon-consistent-read=1
127
 
                --mem
128
 
        ';
129
 
} elsif ($test =~ m{blob_recovery}io ) {
130
 
        $command = '
131
 
                --grammar=conf/falcon_blobs.yy
132
 
                --gendata=conf/falcon_blobs.zz
133
 
                --duration=130
134
 
                --threads=1
135
 
                --mysqld=--falcon-page-cache-size=128M
136
 
        ';
137
 
} elsif ($test =~ m{many_indexes}io ) {
138
 
        $command = '
139
 
                --grammar=conf/many_indexes.yy
140
 
                --gendata=conf/many_indexes.zz
141
 
        ';
142
 
} elsif ($test =~ m{chill_thaw_compare}io) {
143
 
        $command = '
144
 
                --grammar=conf/falcon_chill_thaw.yy
145
 
                --gendata=conf/falcon_chill_thaw.zz
146
 
                --mysqld=--falcon-record-chill-threshold=1K
147
 
                --mysqld=--falcon-index-chill-threshold=1K 
148
 
                --threads=1
149
 
                --vardir1='.$vardir.'/chillthaw-vardir
150
 
                --vardir2='.$vardir.'/default-vardir
151
 
                --reporters=Deadlock,ErrorLog,Backtrace
152
 
        ';
153
 
} elsif ($test =~ m{chill_thaw}io) {
154
 
        $command = '
155
 
                --grammar=conf/falcon_chill_thaw.yy 
156
 
                --mysqld=--falcon-index-chill-threshold=4K 
157
 
                --mysqld=--falcon-record-chill-threshold=4K
158
 
        ';
159
 
} elsif ($test =~ m{online_alter}io) {
160
 
        $command = '
161
 
                --grammar=conf/falcon_online_alter.yy 
162
 
        ';
163
 
} elsif ($test =~ m{ddl}io) {
164
 
        $command = '
165
 
                --grammar=conf/falcon_ddl.yy
166
 
        ';
167
 
} elsif ($test =~ m{limit_compare_self}io ) {
168
 
        $command = '
169
 
                --grammar=conf/falcon_nolimit.yy
170
 
                --threads=1
171
 
                --validator=Limit
172
 
        ';
173
 
} elsif ($test =~ m{limit_compare_innodb}io ) {
174
 
        $command = '
175
 
                --grammar=conf/limit_compare.yy
176
 
                --vardir1='.$vardir.'/vardir-falcon
177
 
                --vardir2='.$vardir.'/vardir-innodb
178
 
                --mysqld=--default-storage-engine=Falcon
179
 
                --mysqld2=--default-storage-engine=Innodb
180
 
                --threads=1
181
 
                --reporters=
182
 
        ';
183
 
} elsif ($test =~ m{limit}io ) {
184
 
        $command = '
185
 
                --grammar=conf/falcon_limit.yy
186
 
                --mysqld=--loose-maria-pagecache-buffer-size=64M
187
 
        ';
188
 
} elsif ($test =~ m{recovery}io ) {
189
 
        $command = '
190
 
                --grammar=conf/falcon_recovery.yy
191
 
                --gendata=conf/falcon_recovery.zz
192
 
                --mysqld=--falcon-checkpoint-schedule="1 1 1 1 1"
193
 
        ';
194
 
} elsif ($test =~ m{pagesize_32K}io ) {
195
 
        $command = '
196
 
                --grammar=conf/falcon_pagesize.yy
197
 
                --mysqld=--falcon-page-size=32K
198
 
                --gendata=conf/falcon_pagesize32K.zz
199
 
        ';
200
 
} elsif ($test =~ m{pagesize_2K}io) {
201
 
        $command = '
202
 
                --grammar=conf/falcon_pagesize.yy
203
 
                --mysqld=--falcon-page-size=2K
204
 
                --gendata=conf/falcon_pagesize2K.zz
205
 
        ';
206
 
} elsif ($test =~ m{select_autocommit}io) {
207
 
        $command = '
208
 
                --grammar=conf/falcon_select_autocommit.yy
209
 
                --queries=10000000
210
 
        ';
211
 
} elsif ($test =~ m{tiny_inserts}io) {
212
 
        $command = '
213
 
                --gendata=conf/falcon_tiny_inserts.zz
214
 
                --grammar=conf/falcon_tiny_inserts.yy
215
 
                --queries=10000000
216
 
        ';
217
 
} elsif ($test =~ m{backlog}io ) {
218
 
        $command = '
219
 
                --grammar=conf/falcon_backlog.yy
220
 
                --gendata=conf/falcon_backlog.zz
221
 
                --mysqld=--transaction-isolation=REPEATABLE-READ
222
 
                --mysqld=--falcon-record-memory-max=10M
223
 
                --mysqld=--falcon-record-chill-threshold=1K
224
 
                --mysqld=--falcon-page-cache-size=128M
225
 
        ';
226
 
} elsif ($test =~ m{compare_self}io ) {
227
 
        $command = '
228
 
                --grammar=conf/falcon_data_types.yy
229
 
                --gendata=conf/falcon_data_types.zz
230
 
                --vardir1='.$vardir.'/falcon-vardir1
231
 
                --vardir2='.$vardir.'/falcon-vardir2
232
 
                --threads=1
233
 
                --reporters=
234
 
        ';
235
 
} elsif ($test =~ m{falcon_compare_innodb}io ) {
236
 
        # Datatypes YEAR and TIME disabled in grammars due to Bug#45499 (InnoDB). 
237
 
        # Revert to falcon_data_types.{yy|zz} when that bug is resolved in relevant branches.
238
 
        $command = '
239
 
                --grammar=conf/falcon_data_types_no_year_time.yy
240
 
                --gendata=conf/falcon_data_types_no_year_time.zz
241
 
                --vardir1='.$vardir.'/vardir-falcon
242
 
                --vardir2='.$vardir.'/vardir-innodb
243
 
                --mysqld=--default-storage-engine=Falcon
244
 
                --mysqld2=--default-storage-engine=Innodb
245
 
                --threads=1
246
 
                --reporters=
247
 
        ';
248
 
#
249
 
# END OF FALCON TESTS
250
 
#
251
 
} elsif ($test =~ m{^info_schema$}io ) {
252
 
        $command = '
253
 
                --grammar=conf/information_schema.yy
254
 
                --threads=10
255
 
                --duration=300
256
 
        ';
257
 
} elsif ($test =~ m{signal_resignal}io ) {
258
 
        $command = '
259
 
                --threads=10
260
 
                --queries=1M
261
 
                --duration=300
262
 
                --grammar=conf/signal_resignal.yy
263
 
                --mysqld=--max-sp-recursion-depth=10
264
 
        ';
265
 
} elsif ($test =~ m{stress}io ) {
266
 
        $command = '
267
 
                --grammar=conf/maria_stress.yy
268
 
        ';
269
 
} elsif ($test =~ m{dml_alter}io ) {
270
 
        $command = '
271
 
                --gendata=conf/maria.zz
272
 
                --grammar=conf/maria_dml_alter.yy
273
 
        ';
274
 
} elsif ($test =~ m{mostly_selects}io ) {
275
 
        $command = '
276
 
                --gendata=conf/maria.zz
277
 
                --grammar=conf/maria_mostly_selects.yy
278
 
        ';
279
 
} elsif ($test =~ m{bulk_insert}io ) {
280
 
        $command = '
281
 
                --grammar=conf/maria_bulk_insert.yy
282
 
        ';
283
 
} elsif ($test =~ m{^rpl_.*?_simple$}io) {
284
 
        $command = '
285
 
                --gendata=conf/replication_single_engine.zz
286
 
                --grammar=conf/replication_simple.yy
287
 
                --mysqld=--log-output=table,file
288
 
        ';
289
 
} elsif ($test =~ m{^rpl_semisync$}io) {
290
 
        # --rpl_mode=default is used because the .YY file changes the binary log format dynamically.
291
 
        # --threads=1 is used to avoid any replication failures due to concurrent DDL.
292
 
        # --validator= line will remove the default replication Validator, which would otherwise
293
 
        #   report test failure when the slave I/O thread is stopped, which is OK in the context
294
 
        #   of this particular test.
295
 
        # --plugin-dir is relative (to the server's basedir)
296
 
 
297
 
        # File name extension for plugins varies. Using .ddl for Windows and .so for others (*nix).
298
 
        # TODO: If plugins are used for more tests, generalize e.g. into a variable for the file extension only.
299
 
        my $plugins;
300
 
        if (    ($^O eq 'MSWin32') ||
301
 
                ($^O eq 'MSWin64')
302
 
        ) {
303
 
                $plugins = 'rpl_semi_sync_master=libsemisync_master.dll:rpl_semi_sync_slave=libsemisync_slave.dll';
304
 
 
305
 
                # We are on Windows OS, but the feature (semisynchroneous replication (plugins))
306
 
                # is not yet supported there, so we skip this test for the time being.
307
 
                skip_test("This feature/test does not support the Windows platform at this time");
308
 
        } else {
309
 
                $plugins = 'rpl_semi_sync_master=libsemisync_master.so:rpl_semi_sync_slave=libsemisync_slave.so';
310
 
        }
311
 
        $command = "
312
 
                --gendata=conf/replication_innodb_myisam.zz
313
 
                --grammar=conf/replication.yy
314
 
                --rpl_mode=default
315
 
                --mysqld=--plugin-dir=$basedir/lib/mysql/plugin
316
 
                --mysqld=--plugin-load=$plugins
317
 
                --mysqld=--rpl_semi_sync_master_enabled=1
318
 
                --mysqld=--rpl_semi_sync_slave_enabled=1
319
 
                --reporter=ReplicationSemiSync,Deadlock,Backtrace,ErrorLog
320
 
                --validator=
321
 
                --threads=1
322
 
                --duration=300
323
 
                --queries=1M
324
 
        ";
325
 
} elsif ($test =~ m{complex}io) {
326
 
        $command = '
327
 
                --gendata=conf/replication_single_engine_pk.zz
328
 
                --grammar=conf/replication.yy
329
 
                --mysqld=--log-output=table,file
330
 
        ';
331
 
} elsif ($test =~ m{optimizer_semijoin$}io) {
332
 
        $command = '
333
 
                --grammar=conf/subquery_semijoin.yy
334
 
                --mysqld=--log-output=table,file
335
 
        ';
336
 
} elsif ($test =~ m{optimizer_semijoin_nested}io) {
337
 
        $command = '
338
 
                --grammar=conf/subquery_semijoin_nested.yy
339
 
                --mysqld=--log-output=table,file
340
 
        ';
341
 
} elsif ($test =~ m{optimizer_semijoin_compare}io) {
342
 
        $command = '
343
 
                --threads=1
344
 
                --engine=Innodb
345
 
                --grammar=conf/subquery_semijoin.yy
346
 
                --mysqld=--log-output=table,file
347
 
                --vardir1='.$vardir.'/vardir-semijoin
348
 
                --vardir2='.$vardir.'/vardir-nosemijoin
349
 
                --validator=ResultsetComparator
350
 
                --mysqld2=--init-file='.$cwd.'/init/no_semijoin.sql
351
 
                --reporters=
352
 
        ';
353
 
} elsif ($test =~ m{optimizer_materialization_compare}io) {
354
 
        $command = '
355
 
                --threads=1
356
 
                --engine=Innodb
357
 
                --grammar=conf/subquery_materialization.yy
358
 
                --mysqld=--log-output=table,file
359
 
                --vardir1='.$vardir.'/vardir-materialization
360
 
                --vardir2='.$vardir.'/vardir-nomaterialization
361
 
                --validator=ResultsetComparator
362
 
                --mysqld2=--init-file='.$cwd.'/init/no_materialization.sql
363
 
                --reporters=
364
 
        ';
365
 
} elsif ($test =~ m{optimizer_semijoin_engines}io) {
366
 
        $command = '
367
 
                --threads=1
368
 
                --grammar=conf/subquery_semijoin.yy
369
 
                --mysqld=--log-output=table,file
370
 
                --mysqld=--default-storage-engine=MyISAM
371
 
                --mysqld2=--default-storage-engine=Innodb
372
 
                --vardir1='.$vardir.'/vardir-myisam
373
 
                --vardir2='.$vardir.'/vardir-innodb
374
 
                --validator=ResultsetComparator
375
 
                --reporters=
376
 
        ';
377
 
} elsif ($test =~ m{optimizer_semijoin_orderby}io) {
378
 
        $command = '
379
 
                --threads=1
380
 
                --grammar=conf/subquery_semijoin.yy
381
 
                --validator=OrderBy
382
 
                --mysqld=--log-output=table,file
383
 
        ';
384
 
} elsif ($test =~ m{optimizer_subquery_stability}io) {
385
 
        $command = '
386
 
                --threads=1
387
 
                --grammar=conf/subquery_materialization.yy
388
 
                --validator=SelectStability
389
 
        ';
390
 
} elsif ($test =~ m{^backup_.*?_simple$}io) {
391
 
        $command = '
392
 
                --grammar=conf/backup_simple.yy
393
 
                --reporters=Deadlock,ErrorLog,Backtrace
394
 
        ';
395
 
} elsif ($test =~ m{^backup_.*?_consistency$}io) {
396
 
        $command = '
397
 
                --gendata=conf/invariant.zz
398
 
                --grammar=conf/invariant.yy
399
 
                --validator=Invariant
400
 
                --reporters=Deadlock,ErrorLog,Backtrace,BackupAndRestoreInvariant,Shutdown
401
 
                --duration=600
402
 
                --threads=25
403
 
        ';
404
 
}
405
 
 
406
 
#
407
 
# Specify some "default" Reporters if none have been specified already.
408
 
# The RQG itself also specifies some default values for some options if not set.
409
 
#
410
 
if ($command =~ m{--reporters}io) {
411
 
        # Reporters have already been specified 
412
 
} elsif ($test =~ m{rpl}io ) {
413
 
        # Don't include Recovery for replication tests, because
414
 
        $command = $command.' --reporters=Deadlock,ErrorLog,Backtrace';
415
 
} elsif ($test =~ m{falcon}io ) {
416
 
        # Include the Recovery reporter for Falcon tests in order to test
417
 
        # recovery by default after each such test.
418
 
        $command = $command.' --reporters=Deadlock,ErrorLog,Backtrace,Recovery,Shutdown';
419
 
        # Falcon-only options (avoid "unknown variable" warnings in non-Falcon builds)
420
 
        $command = $command.' --mysqld=--loose-falcon-lock-wait-timeout=5 --mysqld=--loose-falcon-debug-mask=2';
421
 
} else {
422
 
        # Default reporters for tests whose name does not contain "rpl" or "falcon"
423
 
        $command = $command.' --reporters=Deadlock,ErrorLog,Backtrace,Shutdown';
424
 
}
425
 
 
426
 
if ($command !~ m{--duration}io ) {
427
 
        if ($rpl_mode ne '') {
428
 
                $command = $command.' --duration=600';
429
 
        } else {
430
 
                $command = $command.' --duration=1200';
431
 
        }
432
 
}
433
 
 
434
 
if ($command !~ m{--vardir}io && $command !~ m{--mem}io ) {
435
 
        $command = $command." --vardir=\"$vardir\"";
436
 
}
437
 
 
438
 
if ($command !~ m{--log-output}io) {
439
 
        $command = $command.' --mysqld=--log-output=file';
440
 
}
441
 
 
442
 
if ($command !~ m{--queries}io) {
443
 
        $command = $command.' --queries=100000';
444
 
}
445
 
 
446
 
if (($command !~ m{--(engine|default-storage-engine)}io) && (defined $engine)) {
447
 
        $command = $command." --engine=$engine";
448
 
}
449
 
 
450
 
if (($command !~ m{--rpl_mode}io)  && ($rpl_mode ne '')) {
451
 
        $command = $command." --rpl_mode=$rpl_mode";
452
 
}
453
 
        
454
 
$command = "perl runall.pl --basedir=\"$basedir\" --mysqld=--loose-innodb-lock-wait-timeout=5 --mysqld=--table-lock-wait-timeout=5 --mysqld=--skip-safemalloc ".$command;
455
 
 
456
 
$command =~ s{[\r\n\t]}{ }sgio;
457
 
my $command_result = system($command);
458
 
 
459
 
if (
460
 
        ($^O ne 'MSWin32') &&
461
 
        ($^O ne 'MSWin64')
462
 
) {
463
 
        system("killall -15 mysqld");
464
 
        system("ps -A | grep mysqld | awk -F' ' '{ print \$1 }' | xargs kill -15");
465
 
        sleep(5);
466
 
        system("killall -9 mysqld");
467
 
        system("ps -A | grep mysqld | awk -F' ' '{ print \$1 }' | xargs kill -9");
468
 
}
469
 
 
470
 
POSIX::_exit ($command_result >> 8);