2
# Copyright (C) 2006 MySQL AB
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.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
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
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
# This is a library file used by the Perl version of mysql-test-run,
18
# and is part of the translation of the Bourne shell script with the
24
# These are not to be prefixed with "mtr_"
26
sub run_stress_test ();
28
##############################################################################
30
# Run tests in the stress mode
32
##############################################################################
34
sub run_stress_test ()
40
mtr_report("Starting stress testing\n");
42
if ( ! $::glob_use_embedded_server )
44
if ( ! mysqld_start($::master->[0],[],[]) )
46
mtr_error("Can't start the mysqld server");
50
my $stress_basedir=File::Spec->catdir($::opt_vardir, "stress");
53
if ( -d $stress_basedir )
55
rmtree($stress_basedir);
57
mkpath($stress_basedir);
59
if ($::opt_stress_suite ne 'main' && $::opt_stress_suite ne 'default' )
61
$stress_suitedir=File::Spec->catdir($::glob_mysql_test_dir, "suite",
66
$stress_suitedir=$::glob_mysql_test_dir;
69
if ( -d $stress_suitedir )
71
#$stress_suite_t_dir=File::Spec->catdir($stress_suitedir, "t");
72
#$stress_suite_r_dir=File::Spec->catdir($stress_suitedir, "r");
73
#FIXME: check dirs above for existence to ensure that test suite
74
# contains tests and results dirs
78
mtr_error("Specified test suite $::opt_stress_suite doesn't exist");
83
$::opt_stress_test_file=File::Spec->catfile($stress_basedir, "stress_tests.txt");
84
open(STRESS_FILE, ">$::opt_stress_test_file");
85
print STRESS_FILE join("\n",@::opt_cases),"\n";
88
elsif ( $::opt_stress_test_file )
90
$::opt_stress_test_file=File::Spec->catfile($stress_suitedir,
91
$::opt_stress_test_file);
92
if ( ! -f $::opt_stress_test_file )
94
mtr_error("Specified file $::opt_stress_test_file with list of tests does not exist\n",
95
"Please ensure that file exists and has proper permissions");
100
$::opt_stress_test_file=File::Spec->catfile($stress_suitedir,
102
if ( ! -f $::opt_stress_test_file )
104
mtr_error("Default file $::opt_stress_test_file with list of tests does not exist\n",
105
"Please use --stress-test-file option to specify custom one or you can\n",
106
"just specify name of test for testing as last argument in command line");
111
if ( $::opt_stress_init_file )
113
$::opt_stress_init_file=File::Spec->catfile($stress_suitedir,
114
$::opt_stress_init_file);
115
if ( ! -f $::opt_stress_init_file )
117
mtr_error("Specified file $::opt_stress_init_file with list of tests does not exist\n",
118
"Please ensure that file exists and has proper permissions");
123
$::opt_stress_init_file=File::Spec->catfile($stress_suitedir,
125
if ( ! -f $::opt_stress_init_file )
127
$::opt_stress_init_file='';
131
if ( $::opt_stress_mode ne 'random' && $::opt_stress_mode ne 'seq' )
133
mtr_error("You specified wrong mode $::opt_stress_mode for stress test\n",
134
"Correct values are 'random' or 'seq'");
137
mtr_init_args(\$args);
139
mtr_add_arg($args, "--server-socket=%s", $::master->[0]->{'path_sock'});
140
mtr_add_arg($args, "--server-user=%s", $::opt_user);
141
mtr_add_arg($args, "--server-database=%s", "test");
142
mtr_add_arg($args, "--stress-suite-basedir=%s", $::glob_mysql_test_dir);
143
mtr_add_arg($args, "--suite=%s", $::opt_stress_suite);
144
mtr_add_arg($args, "--stress-tests-file=%s", $::opt_stress_test_file);
145
mtr_add_arg($args, "--stress-basedir=%s", $stress_basedir);
146
mtr_add_arg($args, "--server-logs-dir=%s", $stress_basedir);
147
mtr_add_arg($args, "--stress-mode=%s", $::opt_stress_mode);
148
mtr_add_arg($args, "--mysqltest=%s", $::exe_mysqltest);
149
mtr_add_arg($args, "--threads=%s", $::opt_stress_threads);
150
mtr_add_arg($args, "--verbose");
151
mtr_add_arg($args, "--cleanup");
152
mtr_add_arg($args, "--log-error-details");
153
mtr_add_arg($args, "--abort-on-error");
155
if ( $::opt_stress_init_file )
157
mtr_add_arg($args, "--stress-init-file=%s", $::opt_stress_init_file);
160
if ( !$::opt_stress_loop_count && !$::opt_stress_test_count &&
161
!$::opt_stress_test_duration )
163
#Limit stress testing with 20 loops in case when any limit parameter
165
$::opt_stress_test_count=20;
168
if ( $::opt_stress_loop_count )
170
mtr_add_arg($args, "--loop-count=%s", $::opt_stress_loop_count);
173
if ( $::opt_stress_test_count )
175
mtr_add_arg($args, "--test-count=%s", $::opt_stress_test_count);
178
if ( $::opt_stress_test_duration )
180
mtr_add_arg($args, "--test-duration=%s", $::opt_stress_test_duration);
184
mtr_run("$::glob_mysql_test_dir/mysql-stress-test.pl", $args, "", "", "", "");
185
if ( ! $::glob_use_embedded_server )