3
# Copyright (C) 2008-2010 Sun Microsystems, Inc. All rights reserved.
4
# Use is subject to license terms.
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; version 2 of the License.
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
# General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
21
use lib "$ENV{RQG_HOME}/lib";
27
use GenTest::Properties;
28
use GenTest::Constants;
29
use GenTest::App::GenTest;
31
my $DEFAULT_THREADS = 10;
32
my $DEFAULT_QUERIES = 1000;
33
my $DEFAULT_DURATION = 3600;
34
my $DEFAULT_DSN = 'dbi:mysql:host=127.0.0.1:port=9306:user=root:database=test';
36
my @ARGV_saved = @ARGV;
39
my $opt_result = GetOptions($options,
61
'report-xml-tt-type=s',
62
'report-xml-tt-dest=s',
79
backwardCompatability($options);
80
my $config = GenTest::Properties->new(
82
defaults => {dsn=>[$DEFAULT_DSN],
84
queries => $DEFAULT_QUERIES,
85
duration => $DEFAULT_DURATION,
86
threads => $DEFAULT_THREADS},
104
'report-xml-tt-type',
105
'report-xml-tt-dest',
124
help() if !$opt_result || $config->help;
126
say("Starting: $0 ".join(" ", @ARGV_saved));
128
$ENV{RQG_DEBUG} = 1 if defined $config->debug;
129
my $gentest = GenTest::App::GenTest->new(config => $config);
131
my $status = $gentest->run();
138
$0 - Testing via random query generation. Options:
140
--dsn : DBI resources to connect to (default $DEFAULT_DSN).
141
Supported databases are MySQL, Drizzle, PostgreSQL, JavaDB
142
first --dsn must be to MySQL or Drizzle
143
--gendata : Execute gendata-old.pl in order to populate tables with simple data (default NO)
144
--gendata=s : Execute gendata.pl in order to populate tables with data
145
using the argument as specification file to gendata.pl
146
--engine : Table engine to use when creating tables with gendata (default: no ENGINE for CREATE TABLE)
147
--threads : Number of threads to spawn (default $DEFAULT_THREADS)
148
--queries : Numer of queries to execute per thread (default $DEFAULT_QUERIES);
149
--duration : Duration of the test in seconds (default $DEFAULT_DURATION seconds);
150
--grammar : Grammar file to use for generating the queries (REQUIRED);
151
--redefine : Grammar file to redefine and/or add rules to the given grammar
152
--seed : PRNG seed (default 1). If --seed=time, the current time will be used.
153
--rpl_mode : Replication mode
154
--validator : Validator classes to be used. Defaults
155
ErrorMessageCorruption if one or two MySQL dsns
156
ResultsetComparator3 if 3 dsns
157
ResultsetComparartor if 2 dsns
158
--reporter : ErrorLog, Backtrace if one or two MySQL dsns
159
--mask : A seed to a random mask used to mask (reduce) the grammar.
160
--mask-level: How many levels deep the mask is applied (default 1)
161
--rows : Number of rows to generate for each table in gendata.pl, unless specified in the ZZ file
162
--varchar-length: maximum length of strings (deault 1) in gendata.pl
163
--views : Pass --views to gendata-old.pl or gendata.pl
165
--sqltrace : Print all generated SQL statements.
166
--no-err-filter: Do not suppress error messages. Output all error messages encountered.
167
--start-dirty: Do not generate data (use existing database(s))
168
--xml-output: Name of a file to which an XML report will be written if this option is set.
169
--report-xml-tt: Report test results in XML-format to the Test Tool (TT) reporting framework.
170
--report-xml-tt-type: Type of TT XML transport to use (e.g. scp)
171
--report-xml-tt-dest: Destination of TT XML report (e.g. user\@host:/path/to/location (for type scp))
172
--testname : Name of test, used for reporting purposes.
175
--help : This help message
176
--debug : Provide debug output
182
sub backwardCompatability {
184
if (defined $options->{dsn}) {
185
croak ("Do not combine --dsn and --dsnX")
186
if defined $options->{dsn1} or
187
defined $options->{dsn2} or
188
defined $options->{dsn3};
192
foreach my $i (1..3) {
193
if (defined $options->{'dsn'.$i}) {
194
push @dsns, $options->{'dsn'.$i};
195
delete $options->{'dsn'.$i};
198
$options->{dsn} = \@dsns;
201
if (grep (/,/,@{$options->{reporters}})) {
202
my $newreporters = [];
203
map {push(@$newreporters,split(/,/,$_))} @{$options->{reporters}};
204
$options->{reporters}=$newreporters ;
207
if (grep (/,/,@{$options->{transformers}})) {
208
my $newtransformers = [];
209
map {push(@$newtransformers,split(/,/,$_))} @{$options->{transformers}};
210
$options->{transformers}=$newtransformers ;
213
if (grep (/,/,@{$options->{validators}})) {
214
my $newvalidators = [];
215
map {push(@$newvalidators,split(/,/,$_))} @{$options->{validators}};
216
$options->{validators}=$newvalidators ;
219
if (not defined $options->{generator}) {
220
$options->{generator} = 'FromGrammar';