2 ################################################################################
4 # This script runs the transactional stress test "stress_tx_rr" against the
5 # transactional storage engine and looks for errors in two log files:
6 # var/stress/<timestamp>/mysql-stress-test.log
9 # The script assumes current working dir is mysql-test/.
11 # Regarding the server error log, currently only error lines containing the
12 # string "Error:" will be reported as a critical error, in addition to signs
15 # In the stress test log, all lines matching the regex "S\d:" (denoting an
16 # error with a specified severity) will be reported as errors.
18 # Error information including the full server log in the case of server crash
19 # is output to standard out.
21 # This script is and should be silent if no errors are detected.
23 ################################################################################
31 # Checking script is run from the correct location
32 if (! -f
"mysql-test-run.pl") {
33 print("\nERROR: This script should be run from the \'\<INSTALL_DIR\>/mysql-test\' directory.\n");
41 my $installdir=abs_path
(File
::Spec
->updir());
44 my ($v,$d,$f)=File
::Spec
->splitpath($f);
45 my $testsuitedir=$v.$d;
47 ################################################################################
48 # Run stress test, redirect output to tmp file.
49 # Duration is specified in seconds. Some nice values:
57 ################################################################################
60 # Special handling for the InnoDB plugin
61 $plugin_params="\"--plugin-load=innodb=ha_innodb_plugin.so;innodb_trx=ha_innodb_plugin.so;innodb_locks=ha_innodb_plugin.so;innodb_cmp=ha_innodb_plugin.so;innodb_cmp_reset=ha_innodb_plugin.so;innodb_cmpmem=ha_innodb_plugin.so;innodb_cmpmem_reset=ha_innodb_plugin.so\"";
62 $plugin_params=~s/so/dll/g if (windows
());
69 # Collection command line options
70 GetOptions
("engine:s" => \
$opt_engine,
71 "duration=i" => \
$opt_duration,
72 "threads=i" => \
$opt_treads,
73 "try", "help") || usage
();
75 if ($opt_help) { usage
(); }
77 print("\nERROR: --engine=\<engine\> argument is required!!!\n");
82 # setting specific engine parameters
85 if ($opt_engine eq "InnoDB") {
87 "--mysqld=--innodb " .
88 "--mysqld=--innodb-lock-wait-timeout=2 " .
91 elsif ($opt_engine eq "InnoDB_plugin") {
93 "--mysqld=--innodb " .
94 "--mysqld=--ignore-builtin-innodb " .
95 #"--mysqld=--plugin_dir=".$installdir."/lib " .
96 "--mysqld=--plugin_dir=".$installdir."/storage/innodb_plugin/.libs " .
97 "--mysqld=--innodb-lock-wait-timeout=2 " .
98 "--mysqld=".$plugin_params." " .
101 # add parameters for a new engine by modifying the 'elsif' section below
102 elsif ($opt_engine eq "zz") {
107 print("\nERROR: '".$opt_engine."' - unknown engine\n");
111 # From this point forward there is no difference between the build in InnDB and the plugin
112 $opt_engine='InnoDB' if ($opt_engine eq 'InnoDB_plugin');
114 # checking that custom files for that engine exist
115 $engine_lower= lc($opt_engine);
117 if (!-f
$testsuitedir.'init_'.$engine_lower.'.txt') {
118 print("\nERROR: config file 'init_".$engine_lower.".txt' missing.");
121 if (!-f
$testsuitedir.'t/init_'.$engine_lower.'.test') {
122 print("\nERROR: config file 'init_".$engine_lower.".test' missing.");
125 if (!-f
$testsuitedir.'r/init_'.$engine_lower.'.result') {
126 print("\nERROR: config file 'init_".$engine_lower.".result' missing.");
129 add_engine_help
() if ($missing);
131 # bilding test command line
132 $cmd="MTR_VERSION=1 " .
133 "perl ./mysql-test-run.pl " .
134 "--comment=stress_tx_rr_".$opt_engine." " .
136 "--stress-init-file=init_".$engine_lower.".txt " .
137 "--stress-test-file=run.txt " .
138 "--stress-suite=engines/rr_trx " .
139 "--stress-test-duration=".$opt_duration." " .
140 "--stress-threads=".$opt_threads." " .
141 "--mysqld=--log-output=file " .
142 "--mysqld=--sql-mode=no_engine_substitution " .
146 " > ".$runlog." 2>&1";
149 print("\n Running \'rr_trx\' test with ".$opt_threads." clients\n");
150 print(" for ".$opt_duration." seconds using the ".$opt_engine." storag engine.\n");
151 print("\n Log file: ".$runlog."\n");
153 print("\nThe following command will execute:\n");
159 ################################################################################
160 # Check for crash and other severe errors in the server log.
162 ################################################################################
164 # Open log file. If MTR_VERSION=1 this is in var/log/master.err.
165 # Otherwise, it is in ?... [stress_tx_rr not yet runnable with MTR_VERSION=2]
166 # Assuming current directory mysql-test/
167 my $serverlog=getcwd
() . "/var/log/master.err";
169 open(SERVERLOG
, $serverlog)
170 or die "Unable to open $serverlog. Test not run?";
171 my @servererrors = (); # Lines with "Severe" errors in server error log
172 my @crash = (); # Empty if no stack trace detected, non-empty otherwise.
174 # Grep for errors and crashes. Going line-by-line since the file can be large.
175 while (<SERVERLOG
>) {
177 push @crash, $line if /This could be because you hit a bug/;
178 push @servererrors, $line if /Error:/;
183 # Crash (stack trace) detected in server log.
184 print "Transactional stress test stress_tx_rr:\n\n";
185 print "SERVER CRASH DETECTED!\n";
186 print "Server log: $serverlog printed at the bottom of this log.\n\n";
187 print "########################################################\n\n";
190 # "Severe" errors detected. Print error lines to std out
191 print "CRITICAL ERRORS:\n\n";
192 foreach $error (@servererrors) {
195 print "\n########################################################\n\n";
199 ################################################################################
200 # Check for errors reported by mysql-stress-test.pl. Transactional consistency
201 # issues are shown as result diffs.
202 ################################################################################
205 find
(\
&finddir
, cwd
); # sets variable $dir
208 my $logfile="$dir/mysql-stress-test.log";
209 open(LOGFILE
, $logfile)
210 or die "Unable to open $logfile. Test not run?";
214 # Grep for errors. Going line-by-line since the file can be large.
216 #push @errors, $_ if ! /No Errors/;
217 push @errors, $_ if /S\d:/;
218 push @heading, $_ if /TestID|=====/;
222 # Print all errors, i.e. all lines that do not contain the string "No Errors"
225 print "Stress test main log file: $logfile\n";
226 print "Errors follow:\n\n";
227 # First print the heading
228 foreach $header_line (@heading) {
231 foreach $error (@errors) {
237 # If errors in server log, output the log and exit 1?
238 if (@servererrors or @crash) {
240 print "\n########################################################\n\n";
241 print "Server error log (master.err):\n\n";
243 open(SERVERLOG
, $serverlog)
244 or die "Unable to open $serverlog!";
246 while (<SERVERLOG
>) {
253 # Exit with error code != 0 if we found an error.
254 print("\nTest Completed with errors. \n");
255 print(" - See ".$runlog." for summary.\n");
256 print(" - See files under var/stress for details.\n");
260 print("\nTest Completed - See ".$runlog." for details\n");
261 ################################################################################
262 # Helper routines etc.
264 ################################################################################
267 my $file = $File::Find
::name
; # complete path to the file
269 return unless -d
$file; # process directories (-d), not files (-f)
270 return unless $_ =~ m/^\d{14}$/; # check if file matches timstamp regex,
273 #$dir= $_; # $_ = just the file name, no path
282 SYNTAX $0 --engine=<engine> [--duration=<nn>] [--thread=<nn>] [--try]
285 The engine used to run the test. \<engine\> needs to be provided exactly as
286 it is reprted in the SHOW ENGINES comand.
287 EXCEPTION: In order to use the InnoDB plugin, specify 'InnoDB_plugin'
291 The time the test should run for in seconds. Defaut value is 600 seconds (10 minutes).
295 The number of clients used by the test driver. Defaut value is 10.
299 Do not run the actual test but show what will be run
312 \nThis test is can be run against any transactional engine. However scripts need to be modifed in order
313 to support such engines (support to InnoDB is provided as an example).
314 In order to add support for a new engine, you will need to modify scripts as follows:
315 1) cd to INSTALL_DIR/mysql-test/suite/engines/rr_trx
316 2) Modify the 'run_stress_rr.pl' file by adding an 'elsif' section for your engine and have it
317 include specifc values required to be passed as startup parameters to the MySQL server by
318 specifying them using "--mysqld" options (see InnoDB example).
319 3) Copy the 'init_innodb.txt' file to 'init_<engine>.txt file and change its content to be "init_<engine>".
320 4) In the 't' directory copy the "init_innodb.test" file to "init_\<engine\>.test" and change the value of
321 the '\$engine' variable to \<engine\>.
322 5) In the 'r' directory copy "the init_innodb.result" file to "init_\<engine\>.result" and change refrences
323 to 'InnoDB' to \<engine\>.
332 ($^O
eq 'MSWin32') ||