0.67.1
by Philip Stoev
initial import from internal tree |
1 |
#!/usr/bin/perl
|
0.67.305
by Bernt M. Johnsen
Copyright headres and license added |
2 |
|
3 |
# Copyright (C) 2008-2010 Sun Microsystems, Inc. All rights reserved.
|
|
4 |
# Use is subject to license terms.
|
|
5 |
#
|
|
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.
|
|
9 |
#
|
|
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.
|
|
14 |
#
|
|
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
|
|
18 |
# USA
|
|
19 |
||
0.67.1
by Philip Stoev
initial import from internal tree |
20 |
use lib 'lib'; |
21 |
use lib "$ENV{RQG_HOME}/lib"; |
|
22 |
use strict; |
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
23 |
use Carp; |
0.67.350
by Bernt M. Johnsen
gentest.pl made a wrapper of new module GenTest::App::GenTest.pm |
24 |
use Getopt::Long; |
0.67.160
by Bernt M. Johnsen
Changes + merge |
25 |
|
0.67.1
by Philip Stoev
initial import from internal tree |
26 |
use GenTest; |
0.67.160
by Bernt M. Johnsen
Changes + merge |
27 |
use GenTest::Properties; |
0.67.55
by Bernt M. Johnsen
Fixed status check in gentest.pl |
28 |
use GenTest::Constants; |
0.67.350
by Bernt M. Johnsen
gentest.pl made a wrapper of new module GenTest::App::GenTest.pm |
29 |
use GenTest::App::GenTest; |
0.67.1
by Philip Stoev
initial import from internal tree |
30 |
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
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'; |
|
0.67.1
by Philip Stoev
initial import from internal tree |
35 |
|
36 |
my @ARGV_saved = @ARGV; |
|
37 |
||
0.67.160
by Bernt M. Johnsen
Changes + merge |
38 |
my $options = {}; |
39 |
my $opt_result = GetOptions($options, |
|
40 |
'config=s', |
|
41 |
'dsn=s@', |
|
42 |
'dsn1=s', |
|
43 |
'dsn2=s', |
|
44 |
'dsn3=s', |
|
45 |
'engine=s', |
|
46 |
'gendata:s', |
|
47 |
'grammar=s', |
|
48 |
'redefine=s', |
|
0.101.35
by John H. Embretsen
XML: Option --testname requires a value. Also add its usage docs to runall, gentest. |
49 |
'testname=s', |
0.67.160
by Bernt M. Johnsen
Changes + merge |
50 |
'threads=i', |
51 |
'queries=s', |
|
52 |
'duration=s', |
|
53 |
'help', |
|
54 |
'debug', |
|
55 |
'rpl_mode=s', |
|
0.67.185
by Bernt M. Johnsen
Fix for Bug#49167 |
56 |
'validators:s@', |
57 |
'reporters:s@', |
|
0.101.29
by John H. Embretsen
XML: Add new options to support XML report delivery. |
58 |
'report-xml-tt', |
59 |
'report-xml-tt-type=s', |
|
60 |
'report-xml-tt-dest=s', |
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
61 |
'seed=s', |
62 |
'mask=i', |
|
63 |
'mask-level=i', |
|
64 |
'rows=i', |
|
65 |
'varchar-length=i', |
|
0.101.18
by John H. Embretsen
Fix issues with XML reporting after latest merge (gentest.pl). |
66 |
'xml-output=s', |
0.67.160
by Bernt M. Johnsen
Changes + merge |
67 |
'views', |
68 |
'start-dirty', |
|
69 |
'filter=s', |
|
70 |
'valgrind'); |
|
71 |
backwardCompatability($options); |
|
72 |
my $config = GenTest::Properties->new( |
|
73 |
options => $options, |
|
74 |
defaults => {dsn=>[$DEFAULT_DSN], |
|
75 |
seed => 1, |
|
76 |
queries => $DEFAULT_QUERIES, |
|
77 |
duration => $DEFAULT_DURATION, |
|
78 |
threads => $DEFAULT_THREADS}, |
|
79 |
required => ['grammar'], |
|
80 |
legal => ['dsn', |
|
81 |
'engine', |
|
82 |
'gendata', |
|
83 |
'redefine', |
|
0.101.26
by John H. Embretsen
Merge from lp:randgen, revno 366, 2010-03-26. |
84 |
'testname', |
0.67.160
by Bernt M. Johnsen
Changes + merge |
85 |
'threads', |
86 |
'queries', |
|
87 |
'duration', |
|
88 |
'help', |
|
89 |
'debug', |
|
90 |
'rpl_mode', |
|
0.67.185
by Bernt M. Johnsen
Fix for Bug#49167 |
91 |
'validators', |
92 |
'reporters', |
|
0.101.29
by John H. Embretsen
XML: Add new options to support XML report delivery. |
93 |
'report-xml-tt', |
94 |
'report-xml-tt-type', |
|
95 |
'report-xml-tt-dest', |
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
96 |
'seed', |
97 |
'mask', |
|
98 |
'mask-level', |
|
99 |
'rows', |
|
100 |
'varchar-length', |
|
101 |
'xml-output', |
|
102 |
'views', |
|
103 |
'start-dirty', |
|
104 |
'filter', |
|
0.103.2
by Bernt M. Johnsen
Sqltrace option for re-runs |
105 |
'valgrind', |
106 |
'sqltrace'], |
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
107 |
help => \&help); |
0.67.1
by Philip Stoev
initial import from internal tree |
108 |
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
109 |
help() if !$opt_result || $config->help; |
0.67.1
by Philip Stoev
initial import from internal tree |
110 |
|
111 |
say("Starting \n $0 \\ \n ".join(" \\ \n ", @ARGV_saved)); |
|
112 |
||
0.67.350
by Bernt M. Johnsen
gentest.pl made a wrapper of new module GenTest::App::GenTest.pm |
113 |
my $gentest = GenTest::App::GenTest->new(config => $config); |
114 |
||
0.67.355
by Bernt M. Johnsen
return instead of exit from GenTest::App::GenTest |
115 |
my $status = $gentest->run(); |
0.67.350
by Bernt M. Johnsen
gentest.pl made a wrapper of new module GenTest::App::GenTest.pm |
116 |
|
0.67.355
by Bernt M. Johnsen
return instead of exit from GenTest::App::GenTest |
117 |
safe_exit($status); |
0.67.1
by Philip Stoev
initial import from internal tree |
118 |
|
119 |
sub help { |
|
120 |
||
0.67.31
by Bernt M. Johnsen
Updated some help function (more to do here) |
121 |
print <<EOF |
122 |
$0 - Testing via random query generation. Options:
|
|
123 |
||
0.67.160
by Bernt M. Johnsen
Changes + merge |
124 |
--dsn : DBI resources to connect to (default $DEFAULT_DSN).
|
0.67.31
by Bernt M. Johnsen
Updated some help function (more to do here) |
125 |
Supported databases are MySQL, Drizzle, PostgreSQL, JavaDB
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
126 |
first --dsn must be to MySQL or Drizzle
|
0.67.31
by Bernt M. Johnsen
Updated some help function (more to do here) |
127 |
--gendata : Execute gendata-old.pl in order to populate tables with simple data (default NO)
|
128 |
--gendata=s : Execute gendata.pl in order to populate tables with data
|
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
129 |
using the argument as specification file to gendata.pl
|
0.67.31
by Bernt M. Johnsen
Updated some help function (more to do here) |
130 |
--engine : Table engine to use when creating tables with gendata (default: no ENGINE for CREATE TABLE)
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
131 |
--threads : Number of threads to spawn (default $DEFAULT_THREADS)
|
132 |
--queries : Numer of queries to execute per thread (default $DEFAULT_QUERIES);
|
|
133 |
--duration : Duration of the test in seconds (default $DEFAULT_DURATION seconds);
|
|
0.67.31
by Bernt M. Johnsen
Updated some help function (more to do here) |
134 |
--grammar : Grammar file to use for generating the queries (REQUIRED);
|
0.67.52
by Bernt M. Johnsen
Added --redefine option to gentest.pl |
135 |
--redefine : Grammar file to redefine and/or add rules to the given grammar
|
0.67.31
by Bernt M. Johnsen
Updated some help function (more to do here) |
136 |
--seed : PRNG seed (default 1). If --seed=time, the current time will be used.
|
137 |
--rpl_mode : Replication mode
|
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
138 |
--validator : Validator classes to be used. Defaults
|
0.67.31
by Bernt M. Johnsen
Updated some help function (more to do here) |
139 |
ErrorMessageCorruption if one or two MySQL dsns
|
140 |
ResultsetComparator3 if 3 dsns
|
|
141 |
ResultsetComparartor if 2 dsns
|
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
142 |
--reporter : ErrorLog, Backtrace if one or two MySQL dsns
|
143 |
--mask : A seed to a random mask used to mask (reduce) the grammar.
|
|
0.67.31
by Bernt M. Johnsen
Updated some help function (more to do here) |
144 |
--mask-level: How many levels deep the mask is applied (default 1)
|
145 |
--rows : Number of rows to generate for each table in gendata.pl, unless specified in the ZZ file
|
|
146 |
--varchar-length: maximum length of strings (deault 1) in gendata.pl
|
|
147 |
--views : Pass --views to gendata-old.pl or gendata.pl
|
|
148 |
--filter : ......
|
|
0.67.49
by Bernt M. Johnsen
Refactored gendata.pl and gendata-old.pl to modules. The scripts are kept as wrappers |
149 |
--start-dirty: Do not generate data (use existing database(s))
|
0.101.18
by John H. Embretsen
Fix issues with XML reporting after latest merge (gentest.pl). |
150 |
--xml-output: Name of a file to which an XML report will be written if this option is set.
|
0.101.29
by John H. Embretsen
XML: Add new options to support XML report delivery. |
151 |
--report-xml-tt: Report test results in XML-format to the Test Tool (TT) reporting framework.
|
152 |
--report-xml-tt-type: Type of TT XML transport to use (e.g. scp)
|
|
153 |
--report-xml-tt-dest: Destination of TT XML report (e.g. user\@host:/path/to/location (for type scp))
|
|
0.101.35
by John H. Embretsen
XML: Option --testname requires a value. Also add its usage docs to runall, gentest. |
154 |
--testname : Name of test, used for reporting purposes.
|
0.67.31
by Bernt M. Johnsen
Updated some help function (more to do here) |
155 |
--valgrind : ......
|
156 |
--filter : ......
|
|
157 |
--help : This help message
|
|
158 |
--debug : Provide debug output
|
|
0.67.1
by Philip Stoev
initial import from internal tree |
159 |
EOF
|
160 |
;
|
|
161 |
safe_exit(1); |
|
162 |
}
|
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
163 |
|
164 |
sub backwardCompatability { |
|
165 |
my ($options) = @_; |
|
166 |
if (defined $options->{dsn}) { |
|
167 |
croak ("Do not combine --dsn and --dsnX") |
|
168 |
if defined $options->{dsn1} or |
|
169 |
defined $options->{dsn2} or |
|
170 |
defined $options->{dsn3}; |
|
171 |
||
172 |
} else { |
|
173 |
my @dsns; |
|
174 |
foreach my $i (1..3) { |
|
175 |
if (defined $options->{'dsn'.$i}) { |
|
176 |
push @dsns, $options->{'dsn'.$i}; |
|
177 |
delete $options->{'dsn'.$i}; |
|
178 |
}
|
|
179 |
}
|
|
180 |
$options->{dsn} = \@dsns; |
|
181 |
}
|
|
182 |
||
0.67.185
by Bernt M. Johnsen
Fix for Bug#49167 |
183 |
|
184 |
if (grep (/,/,@{$options->{reporters}})) { |
|
185 |
my $newreporters = []; |
|
186 |
map {push(@$newreporters,split(/,/,$_))} @{$options->{reporters}}; |
|
187 |
$options->{reporters}=$newreporters ; |
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
188 |
}
|
0.67.185
by Bernt M. Johnsen
Fix for Bug#49167 |
189 |
if (grep (/,/,@{$options->{validators}})) { |
190 |
my $newvalidators = []; |
|
191 |
map {push(@$newvalidators,split(/,/,$_))} @{$options->{validators}}; |
|
192 |
$options->{validators}=$newvalidators ; |
|
0.67.160
by Bernt M. Johnsen
Changes + merge |
193 |
}
|
194 |
}
|
|
195 |