1
by brian
clean slate |
1 |
#!/usr/bin/perl
|
2 |
# -*- cperl -*-
|
|
3 |
||
608
by Brian Aker
Adding snowman test (plus a dead variable removal). |
4 |
use utf8; |
5 |
||
1
by brian
clean slate |
6 |
#
|
7 |
##############################################################################
|
|
8 |
#
|
|
77.1.40
by Monty Taylor
More naming changes. |
9 |
# drizzle-test-run.pl
|
1
by brian
clean slate |
10 |
#
|
11 |
# Tool used for executing a suite of .test file
|
|
12 |
#
|
|
370.1.1
by arjen at com
Initial mods for making all tests work again. Some tests adapted+added. |
13 |
# For now, see the "MySQL Test framework manual" for more information
|
14 |
# http://dev.mysql.com/doc/mysqltest/en/index.html
|
|
15 |
# (as the Drizzle test environment is currently still fairly similar)
|
|
1
by brian
clean slate |
16 |
#
|
17 |
# Please keep the test framework tools identical in all versions!
|
|
18 |
#
|
|
19 |
##############################################################################
|
|
20 |
#
|
|
21 |
# Coding style directions for this perl script
|
|
22 |
#
|
|
23 |
# - To make this Perl script easy to alter even for those that not
|
|
24 |
# code Perl that often, keeep the coding style as close as possible to
|
|
25 |
# the C/C++ MySQL coding standard.
|
|
26 |
#
|
|
27 |
# - All lists of arguments to send to commands are Perl lists/arrays,
|
|
28 |
# not strings we append args to. Within reason, most string
|
|
29 |
# concatenation for arguments should be avoided.
|
|
30 |
#
|
|
31 |
# - Functions defined in the main program are not to be prefixed,
|
|
32 |
# functions in "library files" are to be prefixed with "mtr_" (for
|
|
33 |
# Mysql-Test-Run). There are some exceptions, code that fits best in
|
|
34 |
# the main program, but are put into separate files to avoid
|
|
35 |
# clutter, may be without prefix.
|
|
36 |
#
|
|
37 |
# - All stat/opendir/-f/ is to be kept in collect_test_cases(). It
|
|
38 |
# will create a struct that the rest of the program can use to get
|
|
39 |
# the information. This separates the "find information" from the
|
|
40 |
# "do the work" and makes the program more easy to maintain.
|
|
41 |
#
|
|
42 |
# - The rule when it comes to the logic of this program is
|
|
43 |
#
|
|
44 |
# command_line_setup() - is to handle the logic between flags
|
|
45 |
# collect_test_cases() - is to do its best to select what tests
|
|
46 |
# to run, dig out options, if needs restart etc.
|
|
47 |
# run_testcase() - is to run a single testcase, and follow the
|
|
48 |
# logic set in both above. No, or rare file
|
|
49 |
# system operations. If a test seems complex,
|
|
50 |
# it should probably not be here.
|
|
51 |
#
|
|
52 |
# A nice way to trace the execution of this script while debugging
|
|
53 |
# is to use the Devel::Trace package found at
|
|
54 |
# "http://www.plover.com/~mjd/perl/Trace/" and run this script like
|
|
77.1.40
by Monty Taylor
More naming changes. |
55 |
# "perl -d:Trace drizzle-test-run.pl"
|
1
by brian
clean slate |
56 |
#
|
57 |
||
58 |
||
59 |
use lib "lib/"; |
|
60 |
||
61 |
$Devel::Trace::TRACE= 0; # Don't trace boring init stuff |
|
62 |
||
63 |
#require 5.6.1;
|
|
64 |
use File::Path; |
|
65 |
use File::Basename; |
|
66 |
use File::Copy; |
|
67 |
use File::Temp qw /tempdir/; |
|
685.1.25
by Monty Taylor
Fixed absolute path generation for real. Sigh. |
68 |
use File::Spec::Functions qw /splitdir catpath catdir |
69 |
updir curdir splitpath rel2abs/; |
|
1
by brian
clean slate |
70 |
use Cwd; |
71 |
use Getopt::Long; |
|
72 |
use IO::Socket; |
|
73 |
use IO::Socket::INET; |
|
74 |
use strict; |
|
75 |
use warnings; |
|
76 |
||
77 |
select(STDOUT); |
|
78 |
$| = 1; # Automatically flush STDOUT |
|
79 |
||
236.1.22
by Monty Taylor
A couple of changes to move the actual test code to the tests dir and attempt |
80 |
require "mtr_cases.pl"; |
81 |
require "mtr_process.pl"; |
|
82 |
require "mtr_timer.pl"; |
|
83 |
require "mtr_io.pl"; |
|
84 |
require "mtr_gcov.pl"; |
|
85 |
require "mtr_gprof.pl"; |
|
86 |
require "mtr_report.pl"; |
|
87 |
require "mtr_match.pl"; |
|
88 |
require "mtr_misc.pl"; |
|
89 |
require "mtr_stress.pl"; |
|
90 |
require "mtr_unique.pl"; |
|
1
by brian
clean slate |
91 |
|
92 |
$Devel::Trace::TRACE= 1; |
|
93 |
||
94 |
##############################################################################
|
|
95 |
#
|
|
96 |
# Default settings
|
|
97 |
#
|
|
98 |
##############################################################################
|
|
99 |
||
100 |
# Misc global variables
|
|
101 |
our $mysql_version_id; |
|
1192.3.20
by Monty Taylor
Added the testsuite location finding code to support in-plugin-dir test suites. |
102 |
our $glob_suite_path= undef; |
1
by brian
clean slate |
103 |
our $glob_mysql_test_dir= undef; |
104 |
our $glob_mysql_bench_dir= undef; |
|
105 |
our $glob_scriptname= undef; |
|
106 |
our $glob_timers= undef; |
|
107 |
our @glob_test_mode; |
|
108 |
||
685.1.17
by Monty Taylor
Makde mtr work in VPATH. |
109 |
our $glob_builddir; |
110 |
||
1
by brian
clean slate |
111 |
our $glob_basedir; |
112 |
||
113 |
our $path_client_bindir; |
|
114 |
our $path_timefile; |
|
115 |
our $path_snapshot; |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
116 |
our $path_drizzletest_log; |
1
by brian
clean slate |
117 |
our $path_current_test_log; |
118 |
our $path_my_basedir; |
|
119 |
||
120 |
our $opt_vardir; # A path but set directly on cmd line |
|
121 |
our $path_vardir_trace; # unix formatted opt_vardir for trace files |
|
122 |
our $opt_tmpdir; # A path but set directly on cmd line |
|
1192.3.20
by Monty Taylor
Added the testsuite location finding code to support in-plugin-dir test suites. |
123 |
our $opt_suitepath; |
685.1.13
by Monty Taylor
Attempt at some VPATH support for test suite. |
124 |
our $opt_testdir; |
1
by brian
clean slate |
125 |
|
1101.1.34
by Monty Taylor
Made subunit output optional. |
126 |
our $opt_subunit; |
1
by brian
clean slate |
127 |
|
128 |
our $default_vardir; |
|
129 |
||
130 |
our $opt_usage; |
|
131 |
our $opt_suites; |
|
798.2.11
by Brian Aker
Factor test-run for binlog removal |
132 |
our $opt_suites_default= "main"; # Default suites to run |
1
by brian
clean slate |
133 |
our $opt_script_debug= 0; # Script debugging, enable with --script-debug |
134 |
our $opt_verbose= 0; # Verbose output, enable with --verbose |
|
135 |
||
974.1.1
by Stewart Smith
add repeat-test=n option to test-run.pl to repeat a test n times |
136 |
our $opt_repeat_test= 1; |
137 |
||
1
by brian
clean slate |
138 |
our $exe_master_mysqld; |
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
139 |
our $exe_drizzle; |
140 |
our $exe_drizzle_client_test; |
|
1
by brian
clean slate |
141 |
our $exe_bug25714; |
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
142 |
our $exe_drizzled; |
143 |
our $exe_drizzledump; |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
144 |
our $exe_drizzleslap; |
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
145 |
our $exe_drizzleimport; |
146 |
our $exe_drizzle_fix_system_tables; |
|
147 |
our $exe_drizzletest; |
|
1
by brian
clean slate |
148 |
our $exe_slave_mysqld; |
149 |
our $exe_my_print_defaults; |
|
150 |
our $exe_perror; |
|
151 |
our $lib_udf_example; |
|
152 |
our $lib_example_plugin; |
|
153 |
our $exe_libtool; |
|
154 |
||
155 |
our $opt_bench= 0; |
|
156 |
our $opt_small_bench= 0; |
|
157 |
||
158 |
our @opt_combinations; |
|
159 |
our $opt_skip_combination; |
|
160 |
||
161 |
our @opt_extra_mysqld_opt; |
|
162 |
||
163 |
our $opt_compress; |
|
164 |
||
165 |
our $opt_debug; |
|
166 |
our $opt_do_test; |
|
167 |
our @opt_cases; # The test cases names in argv |
|
496.1.1
by Paul McCullagh
Added --engine option to drizzle-test-run (default innodb) |
168 |
our $opt_engine; |
1
by brian
clean slate |
169 |
|
170 |
our $opt_extern= 0; |
|
171 |
our $opt_socket; |
|
172 |
||
173 |
our $opt_fast; |
|
174 |
our $opt_force; |
|
175 |
our $opt_reorder= 0; |
|
176 |
our $opt_enable_disabled; |
|
177 |
our $opt_mem= $ENV{'MTR_MEM'}; |
|
178 |
||
179 |
our $opt_gcov; |
|
180 |
our $opt_gcov_err; |
|
181 |
our $opt_gcov_msg; |
|
182 |
||
183 |
our $glob_debugger= 0; |
|
184 |
our $opt_gdb; |
|
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
185 |
our $opt_dbx; |
1
by brian
clean slate |
186 |
our $opt_client_gdb; |
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
187 |
our $opt_client_dbx; |
188 |
our $opt_dbx_gdb; |
|
1
by brian
clean slate |
189 |
our $opt_ddd; |
190 |
our $opt_client_ddd; |
|
191 |
our $opt_manual_gdb; |
|
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
192 |
our $opt_manual_dbx; |
1
by brian
clean slate |
193 |
our $opt_manual_ddd; |
194 |
our $opt_manual_debug; |
|
713.1.10
by Monty Taylor
Fixed default port range in test-run.pl. |
195 |
# Magic number -69.4 results in traditional test ports starting from 9306.
|
196 |
our $opt_mtr_build_thread=-69.4; |
|
1
by brian
clean slate |
197 |
our $opt_debugger; |
198 |
our $opt_client_debugger; |
|
199 |
||
200 |
our $opt_gprof; |
|
201 |
our $opt_gprof_dir; |
|
202 |
our $opt_gprof_master; |
|
203 |
our $opt_gprof_slave; |
|
204 |
||
205 |
our $master; |
|
206 |
our $slave; |
|
207 |
our $clusters; |
|
208 |
||
209 |
our $opt_master_myport; |
|
210 |
our $opt_slave_myport; |
|
1166.6.3
by Monty Taylor
Made the memcached_functions run in distcheck and VPATH builds. Also made it so that the ports don't step on each other. |
211 |
our $opt_memc_myport; |
1
by brian
clean slate |
212 |
our $opt_record; |
213 |
my $opt_report_features; |
|
214 |
our $opt_check_testcases; |
|
215 |
our $opt_mark_progress; |
|
216 |
||
798.2.11
by Brian Aker
Factor test-run for binlog removal |
217 |
our $opt_skip_rpl= 1; |
1
by brian
clean slate |
218 |
our $max_slave_num= 0; |
219 |
our $max_master_num= 1; |
|
220 |
our $use_innodb; |
|
221 |
our $opt_skip_test; |
|
222 |
||
223 |
our $opt_sleep; |
|
224 |
||
225 |
our $opt_testcase_timeout; |
|
226 |
our $opt_suite_timeout; |
|
227 |
my $default_testcase_timeout= 15; # 15 min max |
|
228 |
my $default_suite_timeout= 180; # 3 hours max |
|
229 |
||
230 |
our $opt_start_and_exit; |
|
231 |
our $opt_start_dirty; |
|
232 |
our $opt_start_from; |
|
233 |
||
234 |
our $opt_strace_client; |
|
235 |
||
236 |
our $opt_timer= 1; |
|
237 |
||
238 |
our $opt_user; |
|
239 |
||
240 |
my $opt_valgrind= 0; |
|
241 |
my $opt_valgrind_mysqld= 0; |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
242 |
my $opt_valgrind_drizzletest= 0; |
1
by brian
clean slate |
243 |
my @default_valgrind_args= ("--show-reachable=yes"); |
244 |
my @valgrind_args; |
|
245 |
my $opt_valgrind_path; |
|
246 |
my $opt_callgrind; |
|
247 |
||
248 |
our $opt_stress= ""; |
|
249 |
our $opt_stress_suite= "main"; |
|
250 |
our $opt_stress_mode= "random"; |
|
251 |
our $opt_stress_threads= 5; |
|
252 |
our $opt_stress_test_count= 0; |
|
253 |
our $opt_stress_loop_count= 0; |
|
254 |
our $opt_stress_test_duration= 0; |
|
255 |
our $opt_stress_init_file= ""; |
|
256 |
our $opt_stress_test_file= ""; |
|
257 |
||
258 |
our $opt_warnings; |
|
259 |
||
260 |
our $path_sql_dir; |
|
261 |
||
262 |
our @data_dir_lst; |
|
263 |
||
264 |
our $used_default_engine; |
|
265 |
our $debug_compiled_binaries; |
|
266 |
||
267 |
our %mysqld_variables; |
|
268 |
||
269 |
my $source_dist= 0; |
|
270 |
||
271 |
our $opt_max_save_core= 5; |
|
272 |
my $num_saved_cores= 0; # Number of core files saved in vardir/log/ so far. |
|
273 |
||
274 |
######################################################################
|
|
275 |
#
|
|
276 |
# Function declarations
|
|
277 |
#
|
|
278 |
######################################################################
|
|
279 |
||
280 |
sub main (); |
|
281 |
sub initial_setup (); |
|
282 |
sub command_line_setup (); |
|
283 |
sub set_mtr_build_thread_ports($); |
|
284 |
sub datadir_list_setup (); |
|
285 |
sub executable_setup (); |
|
286 |
sub environment_setup (); |
|
287 |
sub kill_running_servers (); |
|
288 |
sub remove_stale_vardir (); |
|
289 |
sub setup_vardir (); |
|
290 |
sub check_running_as_root(); |
|
291 |
sub mysqld_wait_started($); |
|
292 |
sub run_benchmarks ($); |
|
293 |
sub initialize_servers (); |
|
294 |
sub mysql_install_db (); |
|
295 |
sub copy_install_db ($$); |
|
296 |
sub run_testcase ($); |
|
297 |
sub run_testcase_stop_servers ($$$); |
|
298 |
sub run_testcase_start_servers ($); |
|
299 |
sub run_testcase_check_skip_test($); |
|
300 |
sub report_failure_and_restart ($); |
|
301 |
sub do_before_start_master ($); |
|
302 |
sub do_before_start_slave ($); |
|
303 |
sub mysqld_start ($$$); |
|
304 |
sub mysqld_arguments ($$$$); |
|
305 |
sub stop_all_servers (); |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
306 |
sub run_drizzletest ($); |
685.1.25
by Monty Taylor
Fixed absolute path generation for real. Sigh. |
307 |
sub collapse_path ($); |
1
by brian
clean slate |
308 |
sub usage ($); |
309 |
||
310 |
||
311 |
######################################################################
|
|
312 |
#
|
|
313 |
# Main program
|
|
314 |
#
|
|
315 |
######################################################################
|
|
316 |
||
317 |
main(); |
|
318 |
||
319 |
sub main () { |
|
320 |
||
321 |
command_line_setup(); |
|
322 |
||
323 |
check_debug_support(\%mysqld_variables); |
|
324 |
||
325 |
executable_setup(); |
|
326 |
||
327 |
environment_setup(); |
|
328 |
signal_setup(); |
|
329 |
||
330 |
if ( $opt_gcov ) |
|
331 |
{
|
|
332 |
gcov_prepare(); |
|
333 |
}
|
|
334 |
||
335 |
if ( $opt_gprof ) |
|
336 |
{
|
|
337 |
gprof_prepare(); |
|
338 |
}
|
|
339 |
||
340 |
if ( $opt_bench ) |
|
341 |
{
|
|
342 |
initialize_servers(); |
|
343 |
run_benchmarks(shift); # Shift what? Extra arguments?! |
|
344 |
}
|
|
345 |
elsif ( $opt_stress ) |
|
346 |
{
|
|
347 |
initialize_servers(); |
|
348 |
run_stress_test() |
|
349 |
}
|
|
350 |
else
|
|
351 |
{
|
|
352 |
# Figure out which tests we are going to run
|
|
353 |
if (!$opt_suites) |
|
354 |
{
|
|
355 |
$opt_suites= $opt_suites_default; |
|
356 |
||
357 |
# Check for any extra suites to enable based on the path name
|
|
88
by Brian Aker
More cleanup in mysql-test-run |
358 |
my %extra_suites= (); |
1
by brian
clean slate |
359 |
|
360 |
foreach my $dir ( reverse splitdir($glob_basedir) ) |
|
361 |
{
|
|
362 |
my $extra_suite= $extra_suites{$dir}; |
|
363 |
if (defined $extra_suite){ |
|
364 |
mtr_report("Found extra suite: $extra_suite"); |
|
365 |
$opt_suites= "$extra_suite,$opt_suites"; |
|
366 |
last; |
|
367 |
}
|
|
368 |
}
|
|
369 |
}
|
|
370 |
||
371 |
my $tests= collect_test_cases($opt_suites); |
|
372 |
||
373 |
# Turn off NDB and other similar options if no tests use it
|
|
374 |
foreach my $test (@$tests) |
|
375 |
{
|
|
376 |
next if $test->{skip}; |
|
377 |
||
378 |
if (!$opt_extern) |
|
379 |
{
|
|
380 |
# Count max number of slaves used by a test case
|
|
381 |
if ( $test->{slave_num} > $max_slave_num) { |
|
382 |
$max_slave_num= $test->{slave_num}; |
|
383 |
mtr_error("Too many slaves") if $max_slave_num > 3; |
|
384 |
}
|
|
385 |
||
386 |
# Count max number of masters used by a test case
|
|
387 |
if ( $test->{master_num} > $max_master_num) { |
|
388 |
$max_master_num= $test->{master_num}; |
|
389 |
mtr_error("Too many masters") if $max_master_num > 2; |
|
390 |
mtr_error("Too few masters") if $max_master_num < 1; |
|
391 |
}
|
|
392 |
}
|
|
393 |
$use_innodb||= $test->{'innodb_test'}; |
|
394 |
}
|
|
395 |
||
396 |
initialize_servers(); |
|
397 |
||
398 |
if ( $opt_report_features ) { |
|
399 |
run_report_features(); |
|
400 |
}
|
|
401 |
||
402 |
run_tests($tests); |
|
403 |
}
|
|
404 |
||
405 |
mtr_exit(0); |
|
406 |
}
|
|
407 |
||
408 |
##############################################################################
|
|
409 |
#
|
|
410 |
# Default settings
|
|
411 |
#
|
|
412 |
##############################################################################
|
|
413 |
||
414 |
#
|
|
415 |
# When an option is no longer used by this program, it must be explicitly
|
|
416 |
# ignored or else it will be passed through to mysqld. GetOptions will call
|
|
417 |
# this subroutine once for each such option on the command line. See
|
|
418 |
# Getopt::Long documentation.
|
|
419 |
#
|
|
420 |
||
421 |
sub warn_about_removed_option { |
|
422 |
my ($option, $value, $hash_value) = @_; |
|
423 |
||
424 |
warn "WARNING: This option is no longer used, and is ignored: --$option\n"; |
|
425 |
}
|
|
426 |
||
427 |
sub command_line_setup () { |
|
428 |
||
429 |
# These are defaults for things that are set on the command line
|
|
430 |
||
431 |
my $opt_comment; |
|
432 |
||
433 |
# If so requested, we try to avail ourselves of a unique build thread number.
|
|
434 |
if ( $ENV{'MTR_BUILD_THREAD'} ) { |
|
435 |
if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) { |
|
436 |
print "Requesting build thread... "; |
|
437 |
$ENV{'MTR_BUILD_THREAD'} = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299); |
|
438 |
print "got ".$ENV{'MTR_BUILD_THREAD'}."\n"; |
|
439 |
}
|
|
440 |
}
|
|
441 |
||
442 |
if ( $ENV{'MTR_BUILD_THREAD'} ) |
|
443 |
{
|
|
444 |
set_mtr_build_thread_ports($ENV{'MTR_BUILD_THREAD'}); |
|
445 |
}
|
|
446 |
||
447 |
# This is needed for test log evaluation in "gen-build-status-page"
|
|
448 |
# in all cases where the calling tool does not log the commands
|
|
449 |
# directly before it executes them, like "make test-force-pl" in RPM builds.
|
|
450 |
print "Logging: $0 ", join(" ", @ARGV), "\n"; |
|
451 |
||
452 |
# Read the command line
|
|
453 |
# Note: Keep list, and the order, in sync with usage at end of this file
|
|
454 |
||
455 |
# Options that are no longer used must still be processed, because all
|
|
456 |
# unprocessed options are passed directly to mysqld. The user will be
|
|
457 |
# warned that the option is being ignored.
|
|
458 |
#
|
|
459 |
# Put the complete option string here. For example, to remove the --suite
|
|
460 |
# option, remove it from GetOptions() below and put 'suite|suites=s' here.
|
|
461 |
my @removed_options = ( |
|
462 |
'skip-im', # WL#4085 "Discontinue the instance manager" |
|
463 |
);
|
|
464 |
||
465 |
Getopt::Long::Configure("pass_through"); |
|
466 |
GetOptions( |
|
467 |
# Control what engine/variation to run
|
|
468 |
'compress' => \$opt_compress, |
|
469 |
'bench' => \$opt_bench, |
|
470 |
'small-bench' => \$opt_small_bench, |
|
471 |
||
472 |
# Control what test suites or cases to run
|
|
473 |
'force' => \$opt_force, |
|
474 |
'do-test=s' => \$opt_do_test, |
|
475 |
'start-from=s' => \$opt_start_from, |
|
476 |
'suite|suites=s' => \$opt_suites, |
|
477 |
'skip-rpl' => \$opt_skip_rpl, |
|
478 |
'skip-test=s' => \$opt_skip_test, |
|
479 |
'combination=s' => \@opt_combinations, |
|
480 |
'skip-combination' => \$opt_skip_combination, |
|
481 |
||
482 |
# Specify ports
|
|
483 |
'master_port=i' => \$opt_master_myport, |
|
484 |
'slave_port=i' => \$opt_slave_myport, |
|
1166.6.3
by Monty Taylor
Made the memcached_functions run in distcheck and VPATH builds. Also made it so that the ports don't step on each other. |
485 |
'memc_port=i' => \$opt_memc_myport, |
1
by brian
clean slate |
486 |
'mtr-build-thread=i' => \$opt_mtr_build_thread, |
487 |
||
488 |
# Test case authoring
|
|
489 |
'record' => \$opt_record, |
|
490 |
'check-testcases' => \$opt_check_testcases, |
|
491 |
'mark-progress' => \$opt_mark_progress, |
|
492 |
||
493 |
# Extra options used when starting mysqld
|
|
494 |
'mysqld=s' => \@opt_extra_mysqld_opt, |
|
496.1.1
by Paul McCullagh
Added --engine option to drizzle-test-run (default innodb) |
495 |
'engine=s' => \$opt_engine, |
1
by brian
clean slate |
496 |
|
497 |
# Run test on running server
|
|
498 |
'extern' => \$opt_extern, |
|
499 |
||
1101.1.34
by Monty Taylor
Made subunit output optional. |
500 |
# Output format
|
501 |
'subunit' => \$opt_subunit, |
|
502 |
||
1
by brian
clean slate |
503 |
# Debugging
|
504 |
'gdb' => \$opt_gdb, |
|
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
505 |
'dbx' => \$opt_dbx, |
1
by brian
clean slate |
506 |
'client-gdb' => \$opt_client_gdb, |
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
507 |
'client-dbx' => \$opt_client_dbx, |
1
by brian
clean slate |
508 |
'manual-gdb' => \$opt_manual_gdb, |
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
509 |
'manual-dbx' => \$opt_manual_dbx, |
1
by brian
clean slate |
510 |
'manual-debug' => \$opt_manual_debug, |
511 |
'ddd' => \$opt_ddd, |
|
512 |
'client-ddd' => \$opt_client_ddd, |
|
513 |
'manual-ddd' => \$opt_manual_ddd, |
|
514 |
'debugger=s' => \$opt_debugger, |
|
515 |
'client-debugger=s' => \$opt_client_debugger, |
|
516 |
'strace-client' => \$opt_strace_client, |
|
517 |
'master-binary=s' => \$exe_master_mysqld, |
|
518 |
'slave-binary=s' => \$exe_slave_mysqld, |
|
519 |
'max-save-core=i' => \$opt_max_save_core, |
|
520 |
||
521 |
# Coverage, profiling etc
|
|
522 |
'gcov' => \$opt_gcov, |
|
523 |
'gprof' => \$opt_gprof, |
|
524 |
'valgrind|valgrind-all' => \$opt_valgrind, |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
525 |
'valgrind-drizzletest' => \$opt_valgrind_drizzletest, |
1
by brian
clean slate |
526 |
'valgrind-mysqld' => \$opt_valgrind_mysqld, |
527 |
'valgrind-options=s' => sub { |
|
528 |
my ($opt, $value)= @_; |
|
529 |
# Deprecated option unless it's what we know pushbuild uses
|
|
530 |
if ($value eq "--gen-suppressions=all --show-reachable=yes") { |
|
531 |
push(@valgrind_args, $_) for (split(' ', $value)); |
|
532 |
return; |
|
533 |
}
|
|
534 |
die("--valgrind-options=s is deprecated. Use ", |
|
535 |
"--valgrind-option=s, to be specified several", |
|
536 |
" times if necessary"); |
|
537 |
},
|
|
538 |
'valgrind-option=s' => \@valgrind_args, |
|
539 |
'valgrind-path=s' => \$opt_valgrind_path, |
|
540 |
'callgrind' => \$opt_callgrind, |
|
541 |
||
542 |
# Stress testing
|
|
543 |
'stress' => \$opt_stress, |
|
544 |
'stress-suite=s' => \$opt_stress_suite, |
|
545 |
'stress-threads=i' => \$opt_stress_threads, |
|
546 |
'stress-test-file=s' => \$opt_stress_test_file, |
|
547 |
'stress-init-file=s' => \$opt_stress_init_file, |
|
548 |
'stress-mode=s' => \$opt_stress_mode, |
|
549 |
'stress-loop-count=i' => \$opt_stress_loop_count, |
|
550 |
'stress-test-count=i' => \$opt_stress_test_count, |
|
551 |
'stress-test-duration=i' => \$opt_stress_test_duration, |
|
552 |
||
553 |
# Directories
|
|
554 |
'tmpdir=s' => \$opt_tmpdir, |
|
555 |
'vardir=s' => \$opt_vardir, |
|
1192.3.20
by Monty Taylor
Added the testsuite location finding code to support in-plugin-dir test suites. |
556 |
'suitepath=s' => \$opt_suitepath, |
557 |
'testdir=s' => \$opt_testdir, |
|
1
by brian
clean slate |
558 |
'benchdir=s' => \$glob_mysql_bench_dir, |
559 |
'mem' => \$opt_mem, |
|
560 |
||
561 |
# Misc
|
|
562 |
'report-features' => \$opt_report_features, |
|
563 |
'comment=s' => \$opt_comment, |
|
564 |
'debug' => \$opt_debug, |
|
565 |
'fast' => \$opt_fast, |
|
566 |
'reorder' => \$opt_reorder, |
|
567 |
'enable-disabled' => \$opt_enable_disabled, |
|
568 |
'script-debug' => \$opt_script_debug, |
|
569 |
'verbose' => \$opt_verbose, |
|
570 |
'sleep=i' => \$opt_sleep, |
|
571 |
'socket=s' => \$opt_socket, |
|
572 |
'start-dirty' => \$opt_start_dirty, |
|
573 |
'start-and-exit' => \$opt_start_and_exit, |
|
574 |
'timer!' => \$opt_timer, |
|
575 |
'user=s' => \$opt_user, |
|
576 |
'testcase-timeout=i' => \$opt_testcase_timeout, |
|
577 |
'suite-timeout=i' => \$opt_suite_timeout, |
|
578 |
'warnings|log-warnings' => \$opt_warnings, |
|
974.1.1
by Stewart Smith
add repeat-test=n option to test-run.pl to repeat a test n times |
579 |
'repeat-test=i' => \$opt_repeat_test, |
1
by brian
clean slate |
580 |
|
581 |
# Options which are no longer used
|
|
582 |
(map { $_ => \&warn_about_removed_option } @removed_options), |
|
583 |
||
584 |
'help|h' => \$opt_usage, |
|
585 |
) or usage("Can't read options"); |
|
586 |
||
587 |
usage("") if $opt_usage; |
|
588 |
||
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
589 |
usage("you cannot specify --gdb and --dbx both!") if |
590 |
($opt_gdb && $opt_dbx) || |
|
591 |
($opt_manual_gdb && $opt_manual_dbx); |
|
592 |
||
1
by brian
clean slate |
593 |
$glob_scriptname= basename($0); |
594 |
||
595 |
if ($opt_mtr_build_thread != 0) |
|
596 |
{
|
|
597 |
set_mtr_build_thread_ports($opt_mtr_build_thread) |
|
598 |
}
|
|
599 |
elsif ($ENV{'MTR_BUILD_THREAD'}) |
|
600 |
{
|
|
601 |
$opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'}; |
|
602 |
}
|
|
603 |
||
214
by Brian Aker
Rename of fields (fix issue with string and decimal .h clashing). |
604 |
if ( -d "../drizzled" ) |
1
by brian
clean slate |
605 |
{
|
606 |
$source_dist= 1; |
|
607 |
}
|
|
608 |
||
609 |
# Find the absolute path to the test directory
|
|
685.1.13
by Monty Taylor
Attempt at some VPATH support for test suite. |
610 |
if ( ! $opt_testdir ) |
611 |
{
|
|
612 |
$glob_mysql_test_dir= cwd(); |
|
613 |
}
|
|
614 |
else
|
|
615 |
{
|
|
616 |
$glob_mysql_test_dir= $opt_testdir; |
|
617 |
}
|
|
1
by brian
clean slate |
618 |
$default_vardir= "$glob_mysql_test_dir/var"; |
619 |
||
1192.3.20
by Monty Taylor
Added the testsuite location finding code to support in-plugin-dir test suites. |
620 |
if ( ! $opt_suitepath ) |
621 |
{
|
|
622 |
$glob_suite_path= "$glob_mysql_test_dir/../plugin"; |
|
623 |
}
|
|
624 |
else
|
|
625 |
{
|
|
626 |
$glob_suite_path= $opt_suitepath; |
|
627 |
}
|
|
1
by brian
clean slate |
628 |
# In most cases, the base directory we find everything relative to,
|
629 |
# is the parent directory of the "mysql-test" directory. For source
|
|
630 |
# distributions, TAR binary distributions and some other packages.
|
|
631 |
$glob_basedir= dirname($glob_mysql_test_dir); |
|
632 |
||
633 |
# In the RPM case, binaries and libraries are installed in the
|
|
634 |
# default system locations, instead of having our own private base
|
|
635 |
# directory. And we install "/usr/share/mysql-test". Moving up one
|
|
636 |
# more directory relative to "mysql-test" gives us a usable base
|
|
637 |
# directory for RPM installs.
|
|
638 |
if ( ! $source_dist and ! -d "$glob_basedir/bin" ) |
|
639 |
{
|
|
640 |
$glob_basedir= dirname($glob_basedir); |
|
641 |
}
|
|
642 |
||
713.1.10
by Monty Taylor
Fixed default port range in test-run.pl. |
643 |
if ( $opt_testdir and -d $opt_testdir and $opt_vardir and -d $opt_vardir |
685.1.17
by Monty Taylor
Makde mtr work in VPATH. |
644 |
and -f "$opt_vardir/../../drizzled/drizzled") |
645 |
{
|
|
646 |
# probably in a VPATH build
|
|
647 |
$glob_builddir= "$opt_vardir/../.."; |
|
648 |
}
|
|
685.1.21
by Monty Taylor
Removed some prints. Also fixed some bad. |
649 |
else
|
650 |
{
|
|
651 |
$glob_builddir=".."; |
|
652 |
}
|
|
685.1.17
by Monty Taylor
Makde mtr work in VPATH. |
653 |
|
1
by brian
clean slate |
654 |
# Expect mysql-bench to be located adjacent to the source tree, by default
|
655 |
$glob_mysql_bench_dir= "$glob_basedir/../mysql-bench" |
|
656 |
unless defined $glob_mysql_bench_dir; |
|
657 |
$glob_mysql_bench_dir= undef |
|
658 |
unless -d $glob_mysql_bench_dir; |
|
659 |
||
660 |
$path_my_basedir= |
|
661 |
$source_dist ? $glob_mysql_test_dir : $glob_basedir; |
|
662 |
||
663 |
$glob_timers= mtr_init_timers(); |
|
664 |
||
665 |
#
|
|
666 |
# Find the mysqld executable to be able to find the mysqld version
|
|
667 |
# number as early as possible
|
|
668 |
#
|
|
669 |
||
670 |
# Look for the client binaries directory
|
|
685.1.17
by Monty Taylor
Makde mtr work in VPATH. |
671 |
$path_client_bindir= mtr_path_exists("$glob_builddir/client", |
672 |
"$glob_basedir/client", |
|
1
by brian
clean slate |
673 |
"$glob_basedir/bin"); |
674 |
||
675 |
if (!$opt_extern) |
|
676 |
{
|
|
214
by Brian Aker
Rename of fields (fix issue with string and decimal .h clashing). |
677 |
$exe_drizzled= mtr_exe_exists ("$glob_basedir/drizzled/drizzled", |
91
by Brian Aker
Main binary now named drizzled |
678 |
"$path_client_bindir/drizzled", |
679 |
"$glob_basedir/libexec/drizzled", |
|
680 |
"$glob_basedir/bin/drizzled", |
|
685.1.17
by Monty Taylor
Makde mtr work in VPATH. |
681 |
"$glob_basedir/sbin/drizzled", |
682 |
"$glob_builddir/drizzled/drizzled"); |
|
1
by brian
clean slate |
683 |
|
684 |
# Use the mysqld found above to find out what features are available
|
|
685 |
collect_mysqld_features(); |
|
686 |
}
|
|
687 |
else
|
|
688 |
{
|
|
165.1.1
by Elliot Murphy
new port number from IANA |
689 |
$mysqld_variables{'port'}= 4427; |
1
by brian
clean slate |
690 |
}
|
691 |
||
496.1.1
by Paul McCullagh
Added --engine option to drizzle-test-run (default innodb) |
692 |
if (!$opt_engine) |
693 |
{
|
|
496.1.3
by Paul McCullagh
Set default to InnoDB |
694 |
$opt_engine= "innodb"; |
496.1.1
by Paul McCullagh
Added --engine option to drizzle-test-run (default innodb) |
695 |
}
|
696 |
||
1
by brian
clean slate |
697 |
if ( $opt_comment ) |
698 |
{
|
|
699 |
print "\n"; |
|
700 |
print '#' x 78, "\n"; |
|
701 |
print "# $opt_comment\n"; |
|
702 |
print '#' x 78, "\n\n"; |
|
703 |
}
|
|
704 |
||
705 |
foreach my $arg ( @ARGV ) |
|
706 |
{
|
|
707 |
if ( $arg =~ /^--skip-/ ) |
|
708 |
{
|
|
709 |
push(@opt_extra_mysqld_opt, $arg); |
|
710 |
}
|
|
711 |
elsif ( $arg =~ /^--$/ ) |
|
712 |
{
|
|
713 |
# It is an effect of setting 'pass_through' in option processing
|
|
714 |
# that the lone '--' separating options from arguments survives,
|
|
715 |
# simply ignore it.
|
|
716 |
}
|
|
717 |
elsif ( $arg =~ /^-/ ) |
|
718 |
{
|
|
719 |
usage("Invalid option \"$arg\""); |
|
720 |
}
|
|
721 |
else
|
|
722 |
{
|
|
723 |
push(@opt_cases, $arg); |
|
724 |
}
|
|
725 |
}
|
|
726 |
||
727 |
# --------------------------------------------------------------------------
|
|
728 |
# Find out default storage engine being used(if any)
|
|
729 |
# --------------------------------------------------------------------------
|
|
730 |
foreach my $arg ( @opt_extra_mysqld_opt ) |
|
731 |
{
|
|
732 |
if ( $arg =~ /default-storage-engine=(\S+)/ ) |
|
733 |
{
|
|
734 |
$used_default_engine= $1; |
|
735 |
}
|
|
736 |
}
|
|
737 |
mtr_report("Using default engine '$used_default_engine'") |
|
738 |
if defined $used_default_engine; |
|
739 |
||
740 |
# --------------------------------------------------------------------------
|
|
741 |
# Check if we should speed up tests by trying to run on tmpfs
|
|
742 |
# --------------------------------------------------------------------------
|
|
743 |
if ( defined $opt_mem ) |
|
744 |
{
|
|
745 |
mtr_error("Can't use --mem and --vardir at the same time ") |
|
746 |
if $opt_vardir; |
|
747 |
mtr_error("Can't use --mem and --tmpdir at the same time ") |
|
748 |
if $opt_tmpdir; |
|
749 |
||
750 |
# Search through list of locations that are known
|
|
751 |
# to be "fast disks" to list to find a suitable location
|
|
752 |
# Use --mem=<dir> as first location to look.
|
|
753 |
my @tmpfs_locations= ($opt_mem, "/dev/shm", "/tmp"); |
|
754 |
||
755 |
foreach my $fs (@tmpfs_locations) |
|
756 |
{
|
|
757 |
if ( -d $fs ) |
|
758 |
{
|
|
759 |
mtr_report("Using tmpfs in $fs"); |
|
760 |
$opt_mem= "$fs/var"; |
|
761 |
$opt_mem .= $opt_mtr_build_thread if $opt_mtr_build_thread; |
|
762 |
last; |
|
763 |
}
|
|
764 |
}
|
|
765 |
}
|
|
766 |
||
767 |
# --------------------------------------------------------------------------
|
|
768 |
# Set the "var/" directory, as it is the base for everything else
|
|
769 |
# --------------------------------------------------------------------------
|
|
685.1.29
by Monty Taylor
Some more cleanups to mtr. |
770 |
if ( ! $opt_vardir ) |
1
by brian
clean slate |
771 |
{
|
772 |
$opt_vardir= $default_vardir; |
|
773 |
}
|
|
774 |
||
775 |
$path_vardir_trace= $opt_vardir; |
|
776 |
# Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
|
|
777 |
$path_vardir_trace=~ s/^\w://; |
|
778 |
||
685.1.29
by Monty Taylor
Some more cleanups to mtr. |
779 |
$opt_vardir= collapse_path($opt_vardir); |
1
by brian
clean slate |
780 |
|
781 |
# --------------------------------------------------------------------------
|
|
782 |
# Set tmpdir
|
|
783 |
# --------------------------------------------------------------------------
|
|
784 |
$opt_tmpdir= "$opt_vardir/tmp" unless $opt_tmpdir; |
|
785 |
$opt_tmpdir =~ s,/+$,,; # Remove ending slash if any |
|
786 |
||
787 |
# --------------------------------------------------------------------------
|
|
788 |
# Record flag
|
|
789 |
# --------------------------------------------------------------------------
|
|
790 |
if ( $opt_record and ! @opt_cases ) |
|
791 |
{
|
|
792 |
mtr_error("Will not run in record mode without a specific test case"); |
|
793 |
}
|
|
794 |
||
795 |
if ( $opt_record ) |
|
796 |
{
|
|
797 |
$opt_skip_combination = 1; |
|
798 |
}
|
|
799 |
||
800 |
# --------------------------------------------------------------------------
|
|
801 |
# Bench flags
|
|
802 |
# --------------------------------------------------------------------------
|
|
803 |
if ( $opt_small_bench ) |
|
804 |
{
|
|
805 |
$opt_bench= 1; |
|
806 |
}
|
|
807 |
||
808 |
# --------------------------------------------------------------------------
|
|
809 |
# Gcov flag
|
|
810 |
# --------------------------------------------------------------------------
|
|
811 |
if ( $opt_gcov and ! $source_dist ) |
|
812 |
{
|
|
813 |
mtr_error("Coverage test needs the source - please use source dist"); |
|
814 |
}
|
|
815 |
||
816 |
# --------------------------------------------------------------------------
|
|
817 |
# Check debug related options
|
|
818 |
# --------------------------------------------------------------------------
|
|
819 |
if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd || |
|
820 |
$opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug || |
|
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
821 |
$opt_debugger || $opt_client_debugger || $opt_gdb || $opt_manual_gdb) |
1
by brian
clean slate |
822 |
{
|
823 |
# Indicate that we are using debugger
|
|
824 |
$glob_debugger= 1; |
|
825 |
if ( $opt_extern ) |
|
826 |
{
|
|
827 |
mtr_error("Can't use --extern when using debugger"); |
|
828 |
}
|
|
829 |
}
|
|
830 |
||
831 |
# --------------------------------------------------------------------------
|
|
832 |
# Check if special exe was selected for master or slave
|
|
833 |
# --------------------------------------------------------------------------
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
834 |
$exe_master_mysqld= $exe_master_mysqld || $exe_drizzled; |
835 |
$exe_slave_mysqld= $exe_slave_mysqld || $exe_drizzled; |
|
1
by brian
clean slate |
836 |
|
837 |
# --------------------------------------------------------------------------
|
|
838 |
# Check valgrind arguments
|
|
839 |
# --------------------------------------------------------------------------
|
|
840 |
if ( $opt_valgrind or $opt_valgrind_path or @valgrind_args) |
|
841 |
{
|
|
842 |
mtr_report("Turning on valgrind for all executables"); |
|
843 |
$opt_valgrind= 1; |
|
844 |
$opt_valgrind_mysqld= 1; |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
845 |
$opt_valgrind_drizzletest= 1; |
1
by brian
clean slate |
846 |
}
|
847 |
elsif ( $opt_valgrind_mysqld ) |
|
848 |
{
|
|
849 |
mtr_report("Turning on valgrind for mysqld(s) only"); |
|
850 |
$opt_valgrind= 1; |
|
851 |
}
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
852 |
elsif ( $opt_valgrind_drizzletest ) |
1
by brian
clean slate |
853 |
{
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
854 |
mtr_report("Turning on valgrind for drizzletest and drizzle_client_test only"); |
1
by brian
clean slate |
855 |
$opt_valgrind= 1; |
856 |
}
|
|
857 |
||
858 |
if ( $opt_callgrind ) |
|
859 |
{
|
|
860 |
mtr_report("Turning on valgrind with callgrind for mysqld(s)"); |
|
861 |
$opt_valgrind= 1; |
|
862 |
$opt_valgrind_mysqld= 1; |
|
863 |
||
864 |
# Set special valgrind options unless options passed on command line
|
|
865 |
push(@valgrind_args, "--trace-children=yes") |
|
866 |
unless @valgrind_args; |
|
867 |
}
|
|
868 |
||
869 |
if ( $opt_valgrind ) |
|
870 |
{
|
|
871 |
# Set valgrind_options to default unless already defined
|
|
872 |
push(@valgrind_args, @default_valgrind_args) |
|
873 |
unless @valgrind_args; |
|
874 |
||
875 |
mtr_report("Running valgrind with options \"", |
|
876 |
join(" ", @valgrind_args), "\""); |
|
877 |
}
|
|
878 |
||
879 |
if ( ! $opt_testcase_timeout ) |
|
880 |
{
|
|
881 |
$opt_testcase_timeout= $default_testcase_timeout; |
|
882 |
$opt_testcase_timeout*= 10 if $opt_valgrind; |
|
883 |
}
|
|
884 |
||
885 |
if ( ! $opt_suite_timeout ) |
|
886 |
{
|
|
887 |
$opt_suite_timeout= $default_suite_timeout; |
|
888 |
$opt_suite_timeout*= 6 if $opt_valgrind; |
|
889 |
}
|
|
890 |
||
891 |
if ( ! $opt_user ) |
|
892 |
{
|
|
893 |
if ( $opt_extern ) |
|
894 |
{
|
|
895 |
$opt_user= "test"; |
|
896 |
}
|
|
897 |
else
|
|
898 |
{
|
|
899 |
$opt_user= "root"; # We want to do FLUSH xxx commands |
|
900 |
}
|
|
901 |
}
|
|
902 |
||
903 |
# On QNX, /tmp/dir/master.sock and /tmp/dir//master.sock seem to be
|
|
904 |
# considered different, so avoid the extra slash (/) in the socket
|
|
905 |
# paths.
|
|
906 |
my $sockdir = $opt_tmpdir; |
|
907 |
$sockdir =~ s|/+$||; |
|
908 |
||
909 |
# On some operating systems, there is a limit to the length of a
|
|
910 |
# UNIX domain socket's path far below PATH_MAX, so try to avoid long
|
|
911 |
# socket path names.
|
|
912 |
$sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) >= 70 ); |
|
913 |
||
914 |
$master->[0]= |
|
915 |
{
|
|
916 |
pid => 0, |
|
917 |
type => "master", |
|
918 |
idx => 0, |
|
919 |
path_myddir => "$opt_vardir/master-data", |
|
920 |
path_myerr => "$opt_vardir/log/master.err", |
|
921 |
path_pid => "$opt_vardir/run/master.pid", |
|
922 |
path_sock => "$sockdir/master.sock", |
|
923 |
port => $opt_master_myport, |
|
924 |
start_timeout => 400, # enough time create innodb tables |
|
925 |
cluster => 0, # index in clusters list |
|
926 |
start_opts => [], |
|
927 |
};
|
|
928 |
||
929 |
$master->[1]= |
|
930 |
{
|
|
931 |
pid => 0, |
|
932 |
type => "master", |
|
933 |
idx => 1, |
|
934 |
path_myddir => "$opt_vardir/master1-data", |
|
935 |
path_myerr => "$opt_vardir/log/master1.err", |
|
936 |
path_pid => "$opt_vardir/run/master1.pid", |
|
937 |
path_sock => "$sockdir/master1.sock", |
|
938 |
port => $opt_master_myport + 1, |
|
939 |
start_timeout => 400, # enough time create innodb tables |
|
940 |
cluster => 0, # index in clusters list |
|
941 |
start_opts => [], |
|
942 |
};
|
|
943 |
||
944 |
$slave->[0]= |
|
945 |
{
|
|
946 |
pid => 0, |
|
947 |
type => "slave", |
|
948 |
idx => 0, |
|
949 |
path_myddir => "$opt_vardir/slave-data", |
|
950 |
path_myerr => "$opt_vardir/log/slave.err", |
|
951 |
path_pid => "$opt_vardir/run/slave.pid", |
|
952 |
path_sock => "$sockdir/slave.sock", |
|
953 |
port => $opt_slave_myport, |
|
954 |
start_timeout => 400, |
|
955 |
||
956 |
cluster => 1, # index in clusters list |
|
957 |
start_opts => [], |
|
958 |
};
|
|
959 |
||
960 |
$slave->[1]= |
|
961 |
{
|
|
962 |
pid => 0, |
|
963 |
type => "slave", |
|
964 |
idx => 1, |
|
965 |
path_myddir => "$opt_vardir/slave1-data", |
|
966 |
path_myerr => "$opt_vardir/log/slave1.err", |
|
967 |
path_pid => "$opt_vardir/run/slave1.pid", |
|
968 |
path_sock => "$sockdir/slave1.sock", |
|
969 |
port => $opt_slave_myport + 1, |
|
970 |
start_timeout => 300, |
|
971 |
cluster => -1, # index in clusters list |
|
972 |
start_opts => [], |
|
973 |
};
|
|
974 |
||
975 |
$slave->[2]= |
|
976 |
{
|
|
977 |
pid => 0, |
|
978 |
type => "slave", |
|
979 |
idx => 2, |
|
980 |
path_myddir => "$opt_vardir/slave2-data", |
|
981 |
path_myerr => "$opt_vardir/log/slave2.err", |
|
982 |
path_pid => "$opt_vardir/run/slave2.pid", |
|
983 |
path_sock => "$sockdir/slave2.sock", |
|
984 |
port => $opt_slave_myport + 2, |
|
985 |
start_timeout => 300, |
|
986 |
cluster => -1, # index in clusters list |
|
987 |
start_opts => [], |
|
988 |
};
|
|
989 |
||
990 |
||
991 |
# --------------------------------------------------------------------------
|
|
992 |
# extern
|
|
993 |
# --------------------------------------------------------------------------
|
|
994 |
if ( $opt_extern ) |
|
995 |
{
|
|
996 |
# Turn off features not supported when running with extern server
|
|
997 |
$opt_skip_rpl= 1; |
|
998 |
warn("Currenty broken --extern"); |
|
999 |
||
1000 |
# Setup master->[0] with the settings for the extern server
|
|
1001 |
$master->[0]->{'path_sock'}= $opt_socket ? $opt_socket : "/tmp/mysql.sock"; |
|
1002 |
mtr_report("Using extern server at '$master->[0]->{path_sock}'"); |
|
1003 |
}
|
|
1004 |
else
|
|
1005 |
{
|
|
1006 |
mtr_error("--socket can only be used in combination with --extern") |
|
1007 |
if $opt_socket; |
|
1008 |
}
|
|
1009 |
||
1010 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1011 |
$path_timefile= "$opt_vardir/log/drizzletest-time"; |
1012 |
$path_drizzletest_log= "$opt_vardir/log/drizzletest.log"; |
|
1
by brian
clean slate |
1013 |
$path_current_test_log= "$opt_vardir/log/current_test"; |
1014 |
||
1015 |
$path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/"; |
|
1016 |
||
1017 |
if ( $opt_valgrind and $opt_debug ) |
|
1018 |
{
|
|
1019 |
# When both --valgrind and --debug is selected, send
|
|
1020 |
# all output to the trace file, making it possible to
|
|
1021 |
# see the exact location where valgrind complains
|
|
1022 |
foreach my $mysqld (@{$master}, @{$slave}) |
|
1023 |
{
|
|
1024 |
my $sidx= $mysqld->{idx} ? "$mysqld->{idx}" : ""; |
|
1025 |
$mysqld->{path_myerr}= |
|
1026 |
"$opt_vardir/log/" . $mysqld->{type} . "$sidx.trace"; |
|
1027 |
}
|
|
1028 |
}
|
|
1029 |
}
|
|
1030 |
||
1031 |
#
|
|
1032 |
# To make it easier for different devs to work on the same host,
|
|
1033 |
# an environment variable can be used to control all ports. A small
|
|
1034 |
# number is to be used, 0 - 16 or similar.
|
|
1035 |
#
|
|
1036 |
# Note the MASTER_MYPORT has to be set the same in all 4.x and 5.x
|
|
1037 |
# versions of this script, else a 4.0 test run might conflict with a
|
|
1038 |
# 5.1 test run, even if different MTR_BUILD_THREAD is used. This means
|
|
1039 |
# all port numbers might not be used in this version of the script.
|
|
1040 |
#
|
|
1041 |
# Also note the limitation of ports we are allowed to hand out. This
|
|
1042 |
# differs between operating systems and configuration, see
|
|
1043 |
# http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html
|
|
1044 |
# But a fairly safe range seems to be 5001 - 32767
|
|
1045 |
#
|
|
1046 |
||
1047 |
sub set_mtr_build_thread_ports($) { |
|
1048 |
my $mtr_build_thread= shift; |
|
1049 |
||
1050 |
if ( lc($mtr_build_thread) eq 'auto' ) { |
|
1051 |
print "Requesting build thread... "; |
|
1052 |
$ENV{'MTR_BUILD_THREAD'} = $mtr_build_thread = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299); |
|
1053 |
print "got ".$mtr_build_thread."\n"; |
|
1054 |
}
|
|
1055 |
||
713.1.10
by Monty Taylor
Fixed default port range in test-run.pl. |
1056 |
$mtr_build_thread= (($mtr_build_thread * 10) % 2000) - 1000; |
1057 |
||
1
by brian
clean slate |
1058 |
# Up to two masters, up to three slaves
|
1059 |
# A magic value in command_line_setup depends on these equations.
|
|
713.1.10
by Monty Taylor
Fixed default port range in test-run.pl. |
1060 |
$opt_master_myport= $mtr_build_thread + 9000; # and 1 |
1
by brian
clean slate |
1061 |
$opt_slave_myport= $opt_master_myport + 2; # and 3 4 |
1166.6.3
by Monty Taylor
Made the memcached_functions run in distcheck and VPATH builds. Also made it so that the ports don't step on each other. |
1062 |
$opt_memc_myport= $opt_master_myport + 10; |
1
by brian
clean slate |
1063 |
|
1064 |
if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 ) |
|
1065 |
{
|
|
1066 |
mtr_error("MTR_BUILD_THREAD number results in a port", |
|
1067 |
"outside 5001 - 32767", |
|
1068 |
"($opt_master_myport - $opt_master_myport + 10)"); |
|
1069 |
}
|
|
1070 |
}
|
|
1071 |
||
1072 |
||
1073 |
sub datadir_list_setup () { |
|
1074 |
||
1075 |
# Make a list of all data_dirs
|
|
1076 |
for (my $idx= 0; $idx < $max_master_num; $idx++) |
|
1077 |
{
|
|
1078 |
push(@data_dir_lst, $master->[$idx]->{'path_myddir'}); |
|
1079 |
}
|
|
1080 |
||
1081 |
for (my $idx= 0; $idx < $max_slave_num; $idx++) |
|
1082 |
{
|
|
1083 |
push(@data_dir_lst, $slave->[$idx]->{'path_myddir'}); |
|
1084 |
}
|
|
1085 |
}
|
|
1086 |
||
1087 |
||
1088 |
##############################################################################
|
|
1089 |
#
|
|
1090 |
# Set paths to various executable programs
|
|
1091 |
#
|
|
1092 |
##############################################################################
|
|
1093 |
||
1094 |
||
1095 |
sub collect_mysqld_features () { |
|
1096 |
my $found_variable_list_start= 0; |
|
1097 |
my $tmpdir= tempdir(CLEANUP => 0); # Directory removed by this function |
|
1098 |
||
1099 |
#
|
|
1100 |
# Execute "mysqld --help --verbose" to get a list
|
|
1101 |
# list of all features and settings
|
|
1102 |
#
|
|
1103 |
# --no-defaults and --skip-grant-tables are to avoid loading
|
|
1104 |
# system-wide configs and plugins
|
|
1105 |
#
|
|
1106 |
# --datadir must exist, mysqld will chdir into it
|
|
1107 |
#
|
|
236.1.61
by Monty Taylor
Remove test references to charset dir. |
1108 |
my $list= `$exe_drizzled --no-defaults --datadir=$tmpdir --skip-grant-tables --verbose --help`; |
1
by brian
clean slate |
1109 |
|
1110 |
foreach my $line (split('\n', $list)) |
|
1111 |
{
|
|
1112 |
# First look for version
|
|
1113 |
if ( !$mysql_version_id ) |
|
1114 |
{
|
|
1115 |
# Look for version
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1116 |
my $exe_name= basename($exe_drizzled); |
1
by brian
clean slate |
1117 |
mtr_verbose("exe_name: $exe_name"); |
1118 |
if ( $line =~ /^\S*$exe_name\s\sVer\s([0-9]*)\.([0-9]*)\.([0-9]*)/ ) |
|
1119 |
{
|
|
1120 |
#print "Major: $1 Minor: $2 Build: $3\n";
|
|
1121 |
$mysql_version_id= $1*10000 + $2*100 + $3; |
|
1122 |
#print "mysql_version_id: $mysql_version_id\n";
|
|
1123 |
mtr_report("MySQL Version $1.$2.$3"); |
|
1124 |
}
|
|
1125 |
}
|
|
1126 |
else
|
|
1127 |
{
|
|
1128 |
if (!$found_variable_list_start) |
|
1129 |
{
|
|
1130 |
# Look for start of variables list
|
|
1131 |
if ( $line =~ /[\-]+\s[\-]+/ ) |
|
1132 |
{
|
|
1133 |
$found_variable_list_start= 1; |
|
1134 |
}
|
|
1135 |
}
|
|
1136 |
else
|
|
1137 |
{
|
|
1138 |
# Put variables into hash
|
|
1139 |
if ( $line =~ /^([\S]+)[ \t]+(.*?)\r?$/ ) |
|
1140 |
{
|
|
1141 |
# print "$1=\"$2\"\n";
|
|
1142 |
$mysqld_variables{$1}= $2; |
|
1143 |
}
|
|
1144 |
else
|
|
1145 |
{
|
|
1146 |
# The variable list is ended with a blank line
|
|
1147 |
if ( $line =~ /^[\s]*$/ ) |
|
1148 |
{
|
|
1149 |
last; |
|
1150 |
}
|
|
1151 |
else
|
|
1152 |
{
|
|
1153 |
# Send out a warning, we should fix the variables that has no
|
|
1154 |
# space between variable name and it's value
|
|
1155 |
# or should it be fixed width column parsing? It does not
|
|
1156 |
# look like that in function my_print_variables in my_getopt.c
|
|
1157 |
mtr_warning("Could not parse variable list line : $line"); |
|
1158 |
}
|
|
1159 |
}
|
|
1160 |
}
|
|
1161 |
}
|
|
1162 |
}
|
|
1163 |
rmtree($tmpdir); |
|
1164 |
mtr_error("Could not find version of MySQL") unless $mysql_version_id; |
|
1165 |
mtr_error("Could not find variabes list") unless $found_variable_list_start; |
|
1166 |
||
1167 |
}
|
|
1168 |
||
1169 |
||
1170 |
sub run_query($$) { |
|
1171 |
my ($mysqld, $query)= @_; |
|
1172 |
||
1173 |
my $args; |
|
1174 |
mtr_init_args(\$args); |
|
1175 |
||
1176 |
mtr_add_arg($args, "--no-defaults"); |
|
779.7.8
by Monty Taylor
Turn of the "friendly" stack trace in test-run to get a proper core file. |
1177 |
mtr_add_arg($args, "--skip-stack-trace"); |
1
by brian
clean slate |
1178 |
mtr_add_arg($args, "--user=%s", $opt_user); |
1179 |
mtr_add_arg($args, "--port=%d", $mysqld->{'port'}); |
|
1180 |
mtr_add_arg($args, "--silent"); # Tab separated output |
|
1181 |
mtr_add_arg($args, "-e '%s'", $query); |
|
1182 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1183 |
my $cmd= "$exe_drizzle " . join(' ', @$args); |
1
by brian
clean slate |
1184 |
mtr_verbose("cmd: $cmd"); |
1185 |
return `$cmd`; |
|
1186 |
}
|
|
1187 |
||
1188 |
||
1189 |
sub collect_mysqld_features_from_running_server () |
|
1190 |
{
|
|
1191 |
my $list= run_query($master->[0], "use mysql; SHOW VARIABLES"); |
|
1192 |
||
1193 |
foreach my $line (split('\n', $list)) |
|
1194 |
{
|
|
1195 |
# Put variables into hash
|
|
1196 |
if ( $line =~ /^([\S]+)[ \t]+(.*?)\r?$/ ) |
|
1197 |
{
|
|
1198 |
print "$1=\"$2\"\n"; |
|
1199 |
$mysqld_variables{$1}= $2; |
|
1200 |
}
|
|
1201 |
}
|
|
1202 |
}
|
|
1203 |
||
1204 |
sub executable_setup () { |
|
1205 |
||
89
by Brian Aker
Saving changes/removals to test run |
1206 |
#
|
1207 |
# Check if libtool is available in this distribution/clone
|
|
1208 |
# we need it when valgrinding or debugging non installed binary
|
|
1209 |
# Otherwise valgrind will valgrind the libtool wrapper or bash
|
|
1210 |
# and gdb will not find the real executable to debug
|
|
1211 |
#
|
|
1
by brian
clean slate |
1212 |
if ( -x "../libtool") |
1213 |
{
|
|
1214 |
$exe_libtool= "../libtool"; |
|
1215 |
if ($opt_valgrind or $glob_debugger) |
|
1216 |
{
|
|
1217 |
mtr_report("Using \"$exe_libtool\" when running valgrind or debugger"); |
|
1218 |
}
|
|
1219 |
}
|
|
1220 |
||
89
by Brian Aker
Saving changes/removals to test run |
1221 |
# Look for my_print_defaults
|
1
by brian
clean slate |
1222 |
$exe_my_print_defaults= |
54.1.7
by Stewart Smith
fix drizzle-test-run.pl for sql/ => server/ rename and remove some vs_config_dir references |
1223 |
mtr_exe_exists( |
89
by Brian Aker
Saving changes/removals to test run |
1224 |
"$path_client_bindir/my_print_defaults", |
685.1.17
by Monty Taylor
Makde mtr work in VPATH. |
1225 |
"$glob_basedir/extra/my_print_defaults", |
1226 |
"$glob_builddir/extra/my_print_defaults"); |
|
1
by brian
clean slate |
1227 |
|
89
by Brian Aker
Saving changes/removals to test run |
1228 |
# Look for perror
|
3
by Brian Aker
Fix test push for version. |
1229 |
$exe_perror= "perror"; |
1
by brian
clean slate |
1230 |
|
89
by Brian Aker
Saving changes/removals to test run |
1231 |
# Look for the client binaries
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1232 |
$exe_drizzledump= mtr_exe_exists("$path_client_bindir/drizzledump"); |
1233 |
$exe_drizzleimport= mtr_exe_exists("$path_client_bindir/drizzleimport"); |
|
1234 |
$exe_drizzle= mtr_exe_exists("$path_client_bindir/drizzle"); |
|
1
by brian
clean slate |
1235 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1236 |
if (!$opt_extern) |
1237 |
{
|
|
1238 |
# Look for SQL scripts directory
|
|
1239 |
if ( $mysql_version_id >= 50100 ) |
|
1240 |
{
|
|
1241 |
$exe_drizzleslap= mtr_exe_exists("$path_client_bindir/drizzleslap"); |
|
1242 |
}
|
|
1243 |
}
|
|
1244 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1245 |
# Look for drizzletest executable
|
1
by brian
clean slate |
1246 |
{
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1247 |
$exe_drizzletest= mtr_exe_exists("$path_client_bindir/drizzletest"); |
1
by brian
clean slate |
1248 |
}
|
1249 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1250 |
# Look for drizzle_client_test executable which may _not_ exist in
|
89
by Brian Aker
Saving changes/removals to test run |
1251 |
# some versions, test using it should be skipped
|
1
by brian
clean slate |
1252 |
{
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1253 |
$exe_drizzle_client_test= |
54.1.7
by Stewart Smith
fix drizzle-test-run.pl for sql/ => server/ rename and remove some vs_config_dir references |
1254 |
mtr_exe_maybe_exists( |
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1255 |
"$glob_basedir/tests/drizzle_client_test", |
1256 |
"$glob_basedir/bin/drizzle_client_test"); |
|
1
by brian
clean slate |
1257 |
}
|
1258 |
||
89
by Brian Aker
Saving changes/removals to test run |
1259 |
# Look for bug25714 executable which may _not_ exist in
|
1260 |
# some versions, test using it should be skipped
|
|
1
by brian
clean slate |
1261 |
$exe_bug25714= |
54.1.7
by Stewart Smith
fix drizzle-test-run.pl for sql/ => server/ rename and remove some vs_config_dir references |
1262 |
mtr_exe_maybe_exists( |
89
by Brian Aker
Saving changes/removals to test run |
1263 |
"$glob_basedir/tests/bug25714"); |
1
by brian
clean slate |
1264 |
}
|
1265 |
||
1266 |
||
89
by Brian Aker
Saving changes/removals to test run |
1267 |
|
1
by brian
clean slate |
1268 |
sub generate_cmdline_mysqldump ($) { |
1269 |
my($mysqld) = @_; |
|
1270 |
return
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1271 |
mtr_native_path($exe_drizzledump) . |
1
by brian
clean slate |
1272 |
" --no-defaults -uroot --debug-check " . |
1273 |
"--port=$mysqld->{'port'} "; |
|
1274 |
}
|
|
1275 |
||
1276 |
||
1277 |
##############################################################################
|
|
1278 |
#
|
|
1279 |
# Set environment to be used by childs of this process for
|
|
77.1.40
by Monty Taylor
More naming changes. |
1280 |
# things that are constant duting the whole lifetime of drizzle-test-run.pl
|
1
by brian
clean slate |
1281 |
#
|
1282 |
##############################################################################
|
|
1283 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1284 |
sub drizzle_client_test_arguments() |
1
by brian
clean slate |
1285 |
{
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1286 |
my $exe= $exe_drizzle_client_test; |
1
by brian
clean slate |
1287 |
|
1288 |
my $args; |
|
1289 |
mtr_init_args(\$args); |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1290 |
if ( $opt_valgrind_drizzletest ) |
1
by brian
clean slate |
1291 |
{
|
1292 |
valgrind_arguments($args, \$exe); |
|
1293 |
}
|
|
1294 |
||
1295 |
mtr_add_arg($args, "--no-defaults"); |
|
1296 |
mtr_add_arg($args, "--testcase"); |
|
1297 |
mtr_add_arg($args, "--user=root"); |
|
1298 |
mtr_add_arg($args, "--port=$master->[0]->{'port'}"); |
|
1299 |
||
1300 |
if ( $opt_extern || $mysql_version_id >= 50000 ) |
|
1301 |
{
|
|
1302 |
mtr_add_arg($args, "--vardir=$opt_vardir") |
|
1303 |
}
|
|
1304 |
||
1305 |
if ( $opt_debug ) |
|
1306 |
{
|
|
1307 |
mtr_add_arg($args, |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1308 |
"--debug=d:t:A,$path_vardir_trace/log/drizzle_client_test.trace"); |
1
by brian
clean slate |
1309 |
}
|
1310 |
||
1311 |
return join(" ", $exe, @$args); |
|
1312 |
}
|
|
1313 |
||
1314 |
||
1315 |
# Note that some env is setup in spawn/run, in "mtr_process.pl"
|
|
1316 |
||
1317 |
sub environment_setup () { |
|
1318 |
||
1319 |
umask(022); |
|
1320 |
||
1321 |
my @ld_library_paths; |
|
1322 |
||
1323 |
# --------------------------------------------------------------------------
|
|
1324 |
# Setup LD_LIBRARY_PATH so the libraries from this distro/clone
|
|
1325 |
# are used in favor of the system installed ones
|
|
1326 |
# --------------------------------------------------------------------------
|
|
1327 |
if ( $source_dist ) |
|
1328 |
{
|
|
779.3.43
by Monty Taylor
Fixed a couple of distcheck related things. |
1329 |
push(@ld_library_paths, "$glob_basedir/libdrizzleclient/.libs/", |
1330 |
"$glob_basedir/mysys/.libs/", |
|
1331 |
"$glob_basedir/mystrings/.libs/", |
|
779.3.44
by Monty Taylor
Added /usr/local to LD_LIBRARY_PATH in test run - it's the one most likely to not be set with an explicit rpath in the linking stage leading to pain during distcheck. |
1332 |
"$glob_basedir/drizzled/.libs/", |
1333 |
"/usr/local/lib"); |
|
1
by brian
clean slate |
1334 |
}
|
1335 |
else
|
|
1336 |
{
|
|
1337 |
push(@ld_library_paths, "$glob_basedir/lib"); |
|
1338 |
}
|
|
1339 |
||
1340 |
# --------------------------------------------------------------------------
|
|
1341 |
# Valgrind need to be run with debug libraries otherwise it's almost
|
|
1342 |
# impossible to add correct supressions, that means if "/usr/lib/debug"
|
|
1343 |
# is available, it should be added to
|
|
1344 |
# LD_LIBRARY_PATH
|
|
1345 |
#
|
|
1346 |
# But pthread is broken in libc6-dbg on Debian <= 3.1 (see Debian
|
|
1347 |
# bug 399035, http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=399035),
|
|
1348 |
# so don't change LD_LIBRARY_PATH on that platform.
|
|
1349 |
# --------------------------------------------------------------------------
|
|
1350 |
my $debug_libraries_path= "/usr/lib/debug"; |
|
1351 |
my $deb_version; |
|
1352 |
if ( $opt_valgrind and -d $debug_libraries_path and |
|
1353 |
(! -e '/etc/debian_version' or |
|
1354 |
($deb_version= mtr_grab_file('/etc/debian_version')) !~ /^[0-9]+\.[0-9]$/ or |
|
1355 |
$deb_version > 3.1 ) ) |
|
1356 |
{
|
|
1357 |
push(@ld_library_paths, $debug_libraries_path); |
|
1358 |
}
|
|
1359 |
||
992.1.2
by Monty Taylor
Append local @ld_library_paths, rather than the other way around. |
1360 |
$ENV{'LD_LIBRARY_PATH'}= join(":", |
1
by brian
clean slate |
1361 |
$ENV{'LD_LIBRARY_PATH'} ? |
992.1.2
by Monty Taylor
Append local @ld_library_paths, rather than the other way around. |
1362 |
split(':', $ENV{'LD_LIBRARY_PATH'}) : (), |
1363 |
@ld_library_paths); |
|
1
by brian
clean slate |
1364 |
mtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}"); |
1365 |
||
1366 |
$ENV{'DYLD_LIBRARY_PATH'}= join(":", @ld_library_paths, |
|
1367 |
$ENV{'DYLD_LIBRARY_PATH'} ? |
|
1368 |
split(':', $ENV{'DYLD_LIBRARY_PATH'}) : ()); |
|
1369 |
mtr_debug("DYLD_LIBRARY_PATH: $ENV{'DYLD_LIBRARY_PATH'}"); |
|
1370 |
||
1371 |
# The environment variable used for shared libs on AIX
|
|
1372 |
$ENV{'SHLIB_PATH'}= join(":", @ld_library_paths, |
|
1373 |
$ENV{'SHLIB_PATH'} ? |
|
1374 |
split(':', $ENV{'SHLIB_PATH'}) : ()); |
|
1375 |
mtr_debug("SHLIB_PATH: $ENV{'SHLIB_PATH'}"); |
|
1376 |
||
1377 |
# The environment variable used for shared libs on hp-ux
|
|
1378 |
$ENV{'LIBPATH'}= join(":", @ld_library_paths, |
|
1379 |
$ENV{'LIBPATH'} ? |
|
1380 |
split(':', $ENV{'LIBPATH'}) : ()); |
|
1381 |
mtr_debug("LIBPATH: $ENV{'LIBPATH'}"); |
|
1382 |
||
1383 |
# --------------------------------------------------------------------------
|
|
1384 |
# Also command lines in .opt files may contain env vars
|
|
1385 |
# --------------------------------------------------------------------------
|
|
1386 |
||
383.1.6
by Brian Aker
Removed more of the charset support. |
1387 |
$ENV{'CHARSETSDIR'}= ""; |
1
by brian
clean slate |
1388 |
$ENV{'UMASK'}= "0660"; # The octal *string* |
1389 |
$ENV{'UMASK_DIR'}= "0770"; # The octal *string* |
|
1390 |
||
1391 |
#
|
|
1392 |
# MySQL tests can produce output in various character sets
|
|
1393 |
# (especially, ctype_xxx.test). To avoid confusing Perl
|
|
1394 |
# with output which is incompatible with the current locale
|
|
1395 |
# settings, we reset the current values of LC_ALL and LC_CTYPE to "C".
|
|
1396 |
# For details, please see
|
|
1397 |
# Bug#27636 tests fails if LC_* variables set to *_*.UTF-8
|
|
1398 |
#
|
|
1399 |
$ENV{'LC_ALL'}= "C"; |
|
1400 |
$ENV{'LC_CTYPE'}= "C"; |
|
1401 |
||
1402 |
$ENV{'LC_COLLATE'}= "C"; |
|
1403 |
$ENV{'USE_RUNNING_SERVER'}= $opt_extern; |
|
685.1.29
by Monty Taylor
Some more cleanups to mtr. |
1404 |
$ENV{'DRIZZLE_TEST_DIR'}= collapse_path($glob_mysql_test_dir); |
1
by brian
clean slate |
1405 |
$ENV{'MYSQLTEST_VARDIR'}= $opt_vardir; |
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
1406 |
$ENV{'DRIZZLE_TMP_DIR'}= $opt_tmpdir; |
1
by brian
clean slate |
1407 |
$ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_sock'}; |
1408 |
$ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_sock'}; |
|
1409 |
$ENV{'MASTER_MYPORT'}= $master->[0]->{'port'}; |
|
1410 |
$ENV{'MASTER_MYPORT1'}= $master->[1]->{'port'}; |
|
1411 |
$ENV{'SLAVE_MYSOCK'}= $slave->[0]->{'path_sock'}; |
|
1412 |
$ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'}; |
|
1413 |
$ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'}; |
|
1414 |
$ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'}; |
|
1166.6.3
by Monty Taylor
Made the memcached_functions run in distcheck and VPATH builds. Also made it so that the ports don't step on each other. |
1415 |
$ENV{'MC_PORT'}= $opt_memc_myport; |
301
by Brian Aker
Clean up port startup |
1416 |
$ENV{'DRIZZLE_TCP_PORT'}= $mysqld_variables{'port'}; |
1
by brian
clean slate |
1417 |
|
685.1.36
by Monty Taylor
Made make test rotate ports. |
1418 |
$ENV{'MTR_BUILD_THREAD'}= $opt_mtr_build_thread; |
1
by brian
clean slate |
1419 |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1420 |
$ENV{'EXE_MYSQL'}= $exe_drizzle; |
1
by brian
clean slate |
1421 |
|
1422 |
||
1423 |
# ----------------------------------------------------
|
|
1424 |
# Setup env to childs can execute myqldump
|
|
1425 |
# ----------------------------------------------------
|
|
1426 |
my $cmdline_mysqldump= generate_cmdline_mysqldump($master->[0]); |
|
1427 |
my $cmdline_mysqldumpslave= generate_cmdline_mysqldump($slave->[0]); |
|
1428 |
||
1429 |
if ( $opt_debug ) |
|
1430 |
{
|
|
1431 |
$cmdline_mysqldump .= |
|
1432 |
" --debug=d:t:A,$path_vardir_trace/log/mysqldump-master.trace"; |
|
1433 |
$cmdline_mysqldumpslave .= |
|
1434 |
" --debug=d:t:A,$path_vardir_trace/log/mysqldump-slave.trace"; |
|
1435 |
}
|
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
1436 |
$ENV{'DRIZZLE_DUMP'}= $cmdline_mysqldump; |
1437 |
$ENV{'DRIZZLE_DUMP_SLAVE'}= $cmdline_mysqldumpslave; |
|
1
by brian
clean slate |
1438 |
|
373.1.9
by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING. |
1439 |
# ----------------------------------------------------
|
1440 |
# Setup env so childs can execute mysqlslap
|
|
1441 |
# ----------------------------------------------------
|
|
1442 |
if ( $exe_drizzleslap ) |
|
1443 |
{
|
|
1444 |
my $cmdline_drizzleslap= |
|
1445 |
mtr_native_path($exe_drizzleslap) . |
|
1446 |
" -uroot " . |
|
1447 |
"--port=$master->[0]->{'port'} "; |
|
1448 |
||
1449 |
if ( $opt_debug ) |
|
1450 |
{
|
|
1451 |
$cmdline_drizzleslap .= |
|
1452 |
" --debug=d:t:A,$path_vardir_trace/log/drizzleslap.trace"; |
|
1453 |
}
|
|
1454 |
$ENV{'DRIZZLE_SLAP'}= $cmdline_drizzleslap; |
|
1455 |
}
|
|
1456 |
||
1457 |
||
1
by brian
clean slate |
1458 |
|
1459 |
# ----------------------------------------------------
|
|
1460 |
# Setup env so childs can execute mysqlimport
|
|
1461 |
# ----------------------------------------------------
|
|
1462 |
my $cmdline_mysqlimport= |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1463 |
mtr_native_path($exe_drizzleimport) . |
1
by brian
clean slate |
1464 |
" -uroot --debug-check " . |
1465 |
"--port=$master->[0]->{'port'} "; |
|
1466 |
||
1467 |
if ( $opt_debug ) |
|
1468 |
{
|
|
1469 |
$cmdline_mysqlimport .= |
|
1470 |
" --debug=d:t:A,$path_vardir_trace/log/mysqlimport.trace"; |
|
1471 |
}
|
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
1472 |
$ENV{'DRIZZLE_IMPORT'}= $cmdline_mysqlimport; |
1
by brian
clean slate |
1473 |
|
1474 |
||
1475 |
# ----------------------------------------------------
|
|
1476 |
# Setup env so childs can execute mysql
|
|
1477 |
# ----------------------------------------------------
|
|
1478 |
my $cmdline_mysql= |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1479 |
mtr_native_path($exe_drizzle) . |
1
by brian
clean slate |
1480 |
" --no-defaults --debug-check --host=localhost --user=root --password= " . |
383.1.6
by Brian Aker
Removed more of the charset support. |
1481 |
"--port=$master->[0]->{'port'} "; |
1
by brian
clean slate |
1482 |
|
1483 |
$ENV{'MYSQL'}= $cmdline_mysql; |
|
1484 |
||
1485 |
# ----------------------------------------------------
|
|
1486 |
# Setup env so childs can execute bug25714
|
|
1487 |
# ----------------------------------------------------
|
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
1488 |
$ENV{'DRIZZLE_BUG25714'}= $exe_bug25714; |
1
by brian
clean slate |
1489 |
|
1490 |
# ----------------------------------------------------
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1491 |
# Setup env so childs can execute drizzle_client_test
|
1
by brian
clean slate |
1492 |
# ----------------------------------------------------
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
1493 |
$ENV{'DRIZZLE_CLIENT_TEST'}= drizzle_client_test_arguments(); |
1
by brian
clean slate |
1494 |
|
1495 |
||
1496 |
# ----------------------------------------------------
|
|
1497 |
# Setup env so childs can execute mysql_fix_system_tables
|
|
1498 |
# ----------------------------------------------------
|
|
87
by Brian Aker
First pass on cleaning out mysql-test-run |
1499 |
#if ( !$opt_extern)
|
54
by brian
Disabling myisam tools until incomming link patch from Monty |
1500 |
if ( 0 ) |
1
by brian
clean slate |
1501 |
{
|
1502 |
my $cmdline_mysql_fix_system_tables= |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
1503 |
"$exe_drizzle_fix_system_tables --no-defaults --host=localhost " . |
1
by brian
clean slate |
1504 |
"--user=root --password= " . |
1505 |
"--basedir=$glob_basedir --bindir=$path_client_bindir --verbose " . |
|
1506 |
"--port=$master->[0]->{'port'} "; |
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
1507 |
$ENV{'DRIZZLE_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; |
1
by brian
clean slate |
1508 |
|
1509 |
}
|
|
1510 |
||
1511 |
# ----------------------------------------------------
|
|
1512 |
# Setup env so childs can execute my_print_defaults
|
|
1513 |
# ----------------------------------------------------
|
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
1514 |
$ENV{'DRIZZLE_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults); |
1
by brian
clean slate |
1515 |
|
1516 |
# ----------------------------------------------------
|
|
973.1.3
by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it. |
1517 |
# Setup env so childs can shutdown the server
|
1
by brian
clean slate |
1518 |
# ----------------------------------------------------
|
973.1.3
by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it. |
1519 |
$ENV{'DRIZZLED_SHUTDOWN'}= mtr_native_path($exe_drizzle); |
1
by brian
clean slate |
1520 |
|
1521 |
# ----------------------------------------------------
|
|
1522 |
# Setup env so childs can execute perror
|
|
1523 |
# ----------------------------------------------------
|
|
1524 |
$ENV{'MY_PERROR'}= mtr_native_path($exe_perror); |
|
1525 |
||
1526 |
# ----------------------------------------------------
|
|
1527 |
# Add the path where mysqld will find ha_example.so
|
|
1528 |
# ----------------------------------------------------
|
|
1529 |
$ENV{'EXAMPLE_PLUGIN'}= |
|
1530 |
($lib_example_plugin ? basename($lib_example_plugin) : ""); |
|
1531 |
$ENV{'EXAMPLE_PLUGIN_OPT'}= |
|
1532 |
($lib_example_plugin ? "--plugin_dir=" . dirname($lib_example_plugin) : ""); |
|
1533 |
||
1534 |
# ----------------------------------------------------
|
|
1535 |
# Setup env so childs can execute myisampack and myisamchk
|
|
1536 |
# ----------------------------------------------------
|
|
54
by brian
Disabling myisam tools until incomming link patch from Monty |
1537 |
# $ENV{'MYISAMCHK'}= mtr_native_path(mtr_exe_exists(
|
1538 |
# "$path_client_bindir/myisamchk",
|
|
1539 |
# "$glob_basedir/storage/myisam/myisamchk",
|
|
1540 |
# "$glob_basedir/myisam/myisamchk"));
|
|
1541 |
# $ENV{'MYISAMPACK'}= mtr_native_path(mtr_exe_exists(
|
|
1542 |
# "$path_client_bindir/myisampack",
|
|
1543 |
# "$glob_basedir/storage/myisam/myisampack",
|
|
1544 |
# "$glob_basedir/myisam/myisampack"));
|
|
1
by brian
clean slate |
1545 |
|
1546 |
# ----------------------------------------------------
|
|
1547 |
# We are nice and report a bit about our settings
|
|
1548 |
# ----------------------------------------------------
|
|
1549 |
if (!$opt_extern) |
|
1550 |
{
|
|
1551 |
print "Using MTR_BUILD_THREAD = $ENV{MTR_BUILD_THREAD}\n"; |
|
1552 |
print "Using MASTER_MYPORT = $ENV{MASTER_MYPORT}\n"; |
|
1553 |
print "Using MASTER_MYPORT1 = $ENV{MASTER_MYPORT1}\n"; |
|
1554 |
print "Using SLAVE_MYPORT = $ENV{SLAVE_MYPORT}\n"; |
|
1555 |
print "Using SLAVE_MYPORT1 = $ENV{SLAVE_MYPORT1}\n"; |
|
1556 |
print "Using SLAVE_MYPORT2 = $ENV{SLAVE_MYPORT2}\n"; |
|
1166.6.3
by Monty Taylor
Made the memcached_functions run in distcheck and VPATH builds. Also made it so that the ports don't step on each other. |
1557 |
print "Using MC_PORT = $ENV{MC_PORT}\n"; |
1
by brian
clean slate |
1558 |
}
|
1559 |
||
1560 |
# Create an environment variable to make it possible
|
|
1561 |
# to detect that valgrind is being used from test cases
|
|
1562 |
$ENV{'VALGRIND_TEST'}= $opt_valgrind; |
|
1563 |
||
1564 |
}
|
|
1565 |
||
1566 |
||
1567 |
##############################################################################
|
|
1568 |
#
|
|
1569 |
# If we get a ^C, we try to clean up before termination
|
|
1570 |
#
|
|
1571 |
##############################################################################
|
|
1572 |
# FIXME check restrictions what to do in a signal handler
|
|
1573 |
||
1574 |
sub signal_setup () { |
|
1575 |
$SIG{INT}= \&handle_int_signal; |
|
1576 |
}
|
|
1577 |
||
1578 |
||
1579 |
sub handle_int_signal () { |
|
1580 |
$SIG{INT}= 'DEFAULT'; # If we get a ^C again, we die... |
|
1581 |
mtr_warning("got INT signal, cleaning up....."); |
|
1582 |
stop_all_servers(); |
|
1583 |
mtr_error("We die from ^C signal from user"); |
|
1584 |
}
|
|
1585 |
||
1586 |
||
1587 |
##############################################################################
|
|
1588 |
#
|
|
1589 |
# Handle left overs from previous runs
|
|
1590 |
#
|
|
1591 |
##############################################################################
|
|
1592 |
||
1593 |
sub kill_running_servers () { |
|
1594 |
{
|
|
1595 |
# Ensure that no old mysqld test servers are running
|
|
1596 |
# This is different from terminating processes we have
|
|
1597 |
# started from this run of the script, this is terminating
|
|
1598 |
# leftovers from previous runs.
|
|
1599 |
mtr_kill_leftovers(); |
|
1600 |
}
|
|
1601 |
}
|
|
1602 |
||
1603 |
#
|
|
1604 |
# Remove var and any directories in var/ created by previous
|
|
1605 |
# tests
|
|
1606 |
#
|
|
1607 |
sub remove_stale_vardir () { |
|
1608 |
||
1609 |
mtr_report("Removing Stale Files"); |
|
1610 |
||
1611 |
# Safety!
|
|
1612 |
mtr_error("No, don't remove the vardir when running with --extern") |
|
1613 |
if $opt_extern; |
|
1614 |
||
1615 |
mtr_verbose("opt_vardir: $opt_vardir"); |
|
1616 |
if ( $opt_vardir eq $default_vardir ) |
|
1617 |
{
|
|
1618 |
#
|
|
1619 |
# Running with "var" in mysql-test dir
|
|
1620 |
#
|
|
1621 |
if ( -l $opt_vardir) |
|
1622 |
{
|
|
1623 |
# var is a symlink
|
|
1624 |
||
1625 |
if ( $opt_mem and readlink($opt_vardir) eq $opt_mem ) |
|
1626 |
{
|
|
1627 |
# Remove the directory which the link points at
|
|
1628 |
mtr_verbose("Removing " . readlink($opt_vardir)); |
|
1629 |
mtr_rmtree(readlink($opt_vardir)); |
|
1630 |
||
1631 |
# Remove the "var" symlink
|
|
1632 |
mtr_verbose("unlink($opt_vardir)"); |
|
1633 |
unlink($opt_vardir); |
|
1634 |
}
|
|
1635 |
elsif ( $opt_mem ) |
|
1636 |
{
|
|
1637 |
# Just remove the "var" symlink
|
|
1638 |
mtr_report("WARNING: Removing '$opt_vardir' symlink it's wrong"); |
|
1639 |
||
1640 |
mtr_verbose("unlink($opt_vardir)"); |
|
1641 |
unlink($opt_vardir); |
|
1642 |
}
|
|
1643 |
else
|
|
1644 |
{
|
|
1645 |
# Some users creates a soft link in mysql-test/var to another area
|
|
1646 |
# - allow it, but remove all files in it
|
|
1647 |
||
1648 |
mtr_report("WARNING: Using the 'mysql-test/var' symlink"); |
|
1649 |
||
1650 |
# Make sure the directory where it points exist
|
|
1651 |
mtr_error("The destination for symlink $opt_vardir does not exist") |
|
1652 |
if ! -d readlink($opt_vardir); |
|
1653 |
||
1654 |
foreach my $bin ( glob("$opt_vardir/*") ) |
|
1655 |
{
|
|
1656 |
mtr_verbose("Removing bin $bin"); |
|
1657 |
mtr_rmtree($bin); |
|
1658 |
}
|
|
1659 |
}
|
|
1660 |
}
|
|
1661 |
else
|
|
1662 |
{
|
|
1663 |
# Remove the entire "var" dir
|
|
1664 |
mtr_verbose("Removing $opt_vardir/"); |
|
1665 |
mtr_rmtree("$opt_vardir/"); |
|
1666 |
}
|
|
1667 |
||
1668 |
if ( $opt_mem ) |
|
1669 |
{
|
|
1670 |
# A symlink from var/ to $opt_mem will be set up
|
|
1671 |
# remove the $opt_mem dir to assure the symlink
|
|
1672 |
# won't point at an old directory
|
|
1673 |
mtr_verbose("Removing $opt_mem"); |
|
1674 |
mtr_rmtree($opt_mem); |
|
1675 |
}
|
|
1676 |
||
1677 |
}
|
|
1678 |
else
|
|
1679 |
{
|
|
1680 |
#
|
|
1681 |
# Running with "var" in some other place
|
|
1682 |
#
|
|
1683 |
||
1684 |
# Remove the var/ dir in mysql-test dir if any
|
|
1685 |
# this could be an old symlink that shouldn't be there
|
|
1686 |
mtr_verbose("Removing $default_vardir"); |
|
1687 |
mtr_rmtree($default_vardir); |
|
1688 |
||
1689 |
# Remove the "var" dir
|
|
1690 |
mtr_verbose("Removing $opt_vardir/"); |
|
1691 |
mtr_rmtree("$opt_vardir/"); |
|
1692 |
}
|
|
1693 |
}
|
|
1694 |
||
1695 |
#
|
|
1696 |
# Create var and the directories needed in var
|
|
1697 |
#
|
|
1698 |
sub setup_vardir() { |
|
1699 |
mtr_report("Creating Directories"); |
|
1700 |
||
1701 |
if ( $opt_vardir eq $default_vardir ) |
|
1702 |
{
|
|
1703 |
#
|
|
1704 |
# Running with "var" in mysql-test dir
|
|
1705 |
#
|
|
1706 |
if ( -l $opt_vardir ) |
|
1707 |
{
|
|
1708 |
# it's a symlink
|
|
1709 |
||
1710 |
# Make sure the directory where it points exist
|
|
1711 |
mtr_error("The destination for symlink $opt_vardir does not exist") |
|
1712 |
if ! -d readlink($opt_vardir); |
|
1713 |
}
|
|
1714 |
elsif ( $opt_mem ) |
|
1715 |
{
|
|
1716 |
# Runinng with "var" as a link to some "memory" location, normally tmpfs
|
|
1717 |
mtr_verbose("Creating $opt_mem"); |
|
1718 |
mkpath($opt_mem); |
|
1719 |
||
1720 |
mtr_report("Symlinking 'var' to '$opt_mem'"); |
|
1721 |
symlink($opt_mem, $opt_vardir); |
|
1722 |
}
|
|
1723 |
}
|
|
1724 |
||
1725 |
if ( ! -d $opt_vardir ) |
|
1726 |
{
|
|
1727 |
mtr_verbose("Creating $opt_vardir"); |
|
1728 |
mkpath($opt_vardir); |
|
1729 |
}
|
|
1730 |
||
1731 |
# Ensure a proper error message if vardir couldn't be created
|
|
1732 |
unless ( -d $opt_vardir and -w $opt_vardir ) |
|
1733 |
{
|
|
1734 |
mtr_error("Writable 'var' directory is needed, use the " . |
|
1735 |
"'--vardir=<path>' option"); |
|
1736 |
}
|
|
1737 |
||
1738 |
mkpath("$opt_vardir/log"); |
|
1739 |
mkpath("$opt_vardir/run"); |
|
1740 |
mkpath("$opt_vardir/tmp"); |
|
1741 |
mkpath($opt_tmpdir) if $opt_tmpdir ne "$opt_vardir/tmp"; |
|
1742 |
||
1743 |
# Create new data dirs
|
|
1744 |
foreach my $data_dir (@data_dir_lst) |
|
1745 |
{
|
|
1746 |
mkpath("$data_dir/mysql"); |
|
1747 |
mkpath("$data_dir/test"); |
|
1748 |
}
|
|
1749 |
||
1750 |
# Make a link std_data_ln in var/ that points to std_data
|
|
685.1.29
by Monty Taylor
Some more cleanups to mtr. |
1751 |
symlink(collapse_path("$glob_mysql_test_dir/std_data"), |
685.1.28
by Monty Taylor
Fixed a coupla more relative-path bugs. |
1752 |
"$opt_vardir/std_data_ln"); |
1
by brian
clean slate |
1753 |
|
1754 |
# Remove old log files
|
|
1755 |
foreach my $name (glob("r/*.progress r/*.log r/*.warnings")) |
|
1756 |
{
|
|
1757 |
unlink($name); |
|
1758 |
}
|
|
971.1.2
by Monty Taylor
Moved recursive chmod to test-run rather than Makefile - since the dir isn't there to chmod by Makefile time. |
1759 |
system("chmod -R ugo+r $opt_vardir"); |
988.3.1
by lbieber
fix test suite permission problem - https://bugs.launchpad.net/drizzle/+bug/324689 |
1760 |
system("chmod -R ugo+r $opt_vardir/std_data_ln/*"); |
1
by brian
clean slate |
1761 |
}
|
1762 |
||
1763 |
||
1764 |
sub check_running_as_root () { |
|
1765 |
# Check if running as root
|
|
1766 |
# i.e a file can be read regardless what mode we set it to
|
|
1767 |
my $test_file= "$opt_vardir/test_running_as_root.txt"; |
|
1768 |
mtr_tofile($test_file, "MySQL"); |
|
1769 |
chmod(oct("0000"), $test_file); |
|
1770 |
||
1771 |
my $result=""; |
|
1772 |
if (open(FILE,"<",$test_file)) |
|
1773 |
{
|
|
1774 |
$result= join('', <FILE>); |
|
1775 |
close FILE; |
|
1776 |
}
|
|
1777 |
||
1778 |
# Some filesystems( for example CIFS) allows reading a file
|
|
1779 |
# although mode was set to 0000, but in that case a stat on
|
|
1780 |
# the file will not return 0000
|
|
1781 |
my $file_mode= (stat($test_file))[2] & 07777; |
|
1782 |
||
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
1783 |
$ENV{'DRIZZLE_TEST_ROOT'}= "NO"; |
1
by brian
clean slate |
1784 |
mtr_verbose("result: $result, file_mode: $file_mode"); |
1785 |
if ($result eq "MySQL" && $file_mode == 0) |
|
1786 |
{
|
|
1787 |
mtr_warning("running this script as _root_ will cause some " . |
|
1788 |
"tests to be skipped"); |
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
1789 |
$ENV{'DRIZZLE_TEST_ROOT'}= "YES"; |
1
by brian
clean slate |
1790 |
}
|
1791 |
||
1792 |
chmod(oct("0755"), $test_file); |
|
1793 |
unlink($test_file); |
|
1794 |
||
1795 |
}
|
|
1796 |
||
1797 |
||
1798 |
sub check_debug_support ($) { |
|
1799 |
my $mysqld_variables= shift; |
|
1800 |
||
1801 |
if ( ! $mysqld_variables->{'debug'} ) |
|
1802 |
{
|
|
1803 |
#mtr_report("Binaries are not debug compiled");
|
|
1804 |
$debug_compiled_binaries= 0; |
|
1805 |
||
1806 |
if ( $opt_debug ) |
|
1807 |
{
|
|
1808 |
mtr_error("Can't use --debug, binaries does not support it"); |
|
1809 |
}
|
|
1810 |
return; |
|
1811 |
}
|
|
1812 |
mtr_report("Binaries are debug compiled"); |
|
1813 |
$debug_compiled_binaries= 1; |
|
1814 |
}
|
|
1815 |
||
1816 |
||
1817 |
##############################################################################
|
|
1818 |
#
|
|
1819 |
# Run the benchmark suite
|
|
1820 |
#
|
|
1821 |
##############################################################################
|
|
1822 |
||
1823 |
sub run_benchmarks ($) { |
|
1824 |
my $benchmark= shift; |
|
1825 |
||
1826 |
my $args; |
|
1827 |
||
1828 |
{
|
|
1829 |
mysqld_start($master->[0],[],[]); |
|
1830 |
if ( ! $master->[0]->{'pid'} ) |
|
1831 |
{
|
|
1832 |
mtr_error("Can't start the mysqld server"); |
|
1833 |
}
|
|
1834 |
}
|
|
1835 |
||
1836 |
mtr_init_args(\$args); |
|
1837 |
||
1838 |
mtr_add_arg($args, "--user=%s", $opt_user); |
|
1839 |
||
1840 |
if ( $opt_small_bench ) |
|
1841 |
{
|
|
1842 |
mtr_add_arg($args, "--small-test"); |
|
1843 |
mtr_add_arg($args, "--small-tables"); |
|
1844 |
}
|
|
1845 |
||
1846 |
chdir($glob_mysql_bench_dir) |
|
1847 |
or mtr_error("Couldn't chdir to '$glob_mysql_bench_dir': $!"); |
|
1848 |
||
1849 |
if ( ! $benchmark ) |
|
1850 |
{
|
|
1851 |
mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", ""); |
|
1852 |
# FIXME check result code?!
|
|
1853 |
}
|
|
1854 |
elsif ( -x $benchmark ) |
|
1855 |
{
|
|
1856 |
mtr_run("$glob_mysql_bench_dir/$benchmark", $args, "", "", "", ""); |
|
1857 |
# FIXME check result code?!
|
|
1858 |
}
|
|
1859 |
else
|
|
1860 |
{
|
|
1861 |
mtr_error("Benchmark $benchmark not found"); |
|
1862 |
}
|
|
1863 |
||
1864 |
chdir($glob_mysql_test_dir); # Go back |
|
1865 |
||
1866 |
{
|
|
1867 |
stop_masters(); |
|
1868 |
}
|
|
1869 |
}
|
|
1870 |
||
1871 |
||
1872 |
##############################################################################
|
|
1873 |
#
|
|
1874 |
# Run the tests
|
|
1875 |
#
|
|
1876 |
##############################################################################
|
|
1877 |
||
1878 |
sub run_tests () { |
|
1879 |
my ($tests)= @_; |
|
1880 |
||
1881 |
mtr_print_thick_line(); |
|
1882 |
||
1883 |
mtr_timer_start($glob_timers,"suite", 60 * $opt_suite_timeout); |
|
1884 |
||
1885 |
mtr_report_tests_not_skipped_though_disabled($tests); |
|
1886 |
||
1887 |
mtr_print_header(); |
|
1888 |
||
1889 |
foreach my $tinfo ( @$tests ) |
|
1890 |
{
|
|
974.1.1
by Stewart Smith
add repeat-test=n option to test-run.pl to repeat a test n times |
1891 |
foreach(1..$opt_repeat_test) |
1
by brian
clean slate |
1892 |
{
|
974.1.1
by Stewart Smith
add repeat-test=n option to test-run.pl to repeat a test n times |
1893 |
if (run_testcase_check_skip_test($tinfo)) |
1894 |
{
|
|
1895 |
next; |
|
1896 |
}
|
|
1897 |
||
1898 |
mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout); |
|
1899 |
run_testcase($tinfo); |
|
1900 |
mtr_timer_stop($glob_timers,"testcase"); |
|
1
by brian
clean slate |
1901 |
}
|
1902 |
}
|
|
1903 |
||
1904 |
mtr_print_line(); |
|
1905 |
||
1906 |
if ( ! $glob_debugger and |
|
89
by Brian Aker
Saving changes/removals to test run |
1907 |
! $opt_extern ) |
1
by brian
clean slate |
1908 |
{
|
1909 |
stop_all_servers(); |
|
1910 |
}
|
|
1911 |
||
1912 |
if ( $opt_gcov ) |
|
1913 |
{
|
|
1914 |
gcov_collect(); # collect coverage information |
|
1915 |
}
|
|
1916 |
if ( $opt_gprof ) |
|
1917 |
{
|
|
1918 |
gprof_collect(); # collect coverage information |
|
1919 |
}
|
|
1920 |
||
1921 |
mtr_report_stats($tests); |
|
1922 |
||
1923 |
mtr_timer_stop($glob_timers,"suite"); |
|
1924 |
}
|
|
1925 |
||
1926 |
||
1927 |
##############################################################################
|
|
1928 |
#
|
|
1929 |
# Initiate the test databases
|
|
1930 |
#
|
|
1931 |
##############################################################################
|
|
1932 |
||
1933 |
sub initialize_servers () { |
|
1934 |
||
1935 |
datadir_list_setup(); |
|
1936 |
||
1937 |
if ( $opt_extern ) |
|
1938 |
{
|
|
1939 |
# Running against an already started server, if the specified
|
|
1940 |
# vardir does not already exist it should be created
|
|
1941 |
if ( ! -d $opt_vardir ) |
|
1942 |
{
|
|
1943 |
mtr_report("Creating '$opt_vardir'"); |
|
1944 |
setup_vardir(); |
|
1945 |
}
|
|
1946 |
else
|
|
1947 |
{
|
|
1948 |
mtr_verbose("No need to create '$opt_vardir' it already exists"); |
|
1949 |
}
|
|
1950 |
}
|
|
1951 |
else
|
|
1952 |
{
|
|
1953 |
kill_running_servers(); |
|
1954 |
||
1955 |
if ( ! $opt_start_dirty ) |
|
1956 |
{
|
|
1957 |
remove_stale_vardir(); |
|
1958 |
setup_vardir(); |
|
1959 |
||
1960 |
mysql_install_db(); |
|
1961 |
if ( $opt_force ) |
|
1962 |
{
|
|
1963 |
# Save a snapshot of the freshly installed db
|
|
1964 |
# to make it possible to restore to a known point in time
|
|
1965 |
save_installed_db(); |
|
1966 |
}
|
|
1967 |
}
|
|
1968 |
}
|
|
1969 |
check_running_as_root(); |
|
1970 |
||
77.1.40
by Monty Taylor
More naming changes. |
1971 |
mtr_log_init("$opt_vardir/log/drizzle-test-run.log"); |
1
by brian
clean slate |
1972 |
|
1973 |
}
|
|
1974 |
||
1975 |
sub mysql_install_db () { |
|
1976 |
||
1977 |
if ($max_master_num > 1) |
|
1978 |
{
|
|
1979 |
copy_install_db('master', $master->[1]->{'path_myddir'}); |
|
1980 |
}
|
|
1981 |
||
1982 |
# Install the number of slave databses needed
|
|
1983 |
for (my $idx= 0; $idx < $max_slave_num; $idx++) |
|
1984 |
{
|
|
1985 |
copy_install_db("slave".($idx+1), $slave->[$idx]->{'path_myddir'}); |
|
1986 |
}
|
|
1987 |
||
1988 |
return 0; |
|
1989 |
}
|
|
1990 |
||
1991 |
||
1992 |
sub copy_install_db ($$) { |
|
1993 |
my $type= shift; |
|
1994 |
my $data_dir= shift; |
|
1995 |
||
1996 |
mtr_report("Installing \u$type Database"); |
|
1997 |
||
1998 |
# Just copy the installed db from first master
|
|
1999 |
mtr_copy_dir($master->[0]->{'path_myddir'}, $data_dir); |
|
2000 |
||
2001 |
}
|
|
2002 |
||
2003 |
||
2004 |
#
|
|
2005 |
# Restore snapshot of the installed slave databases
|
|
2006 |
# if the snapshot exists
|
|
2007 |
#
|
|
2008 |
sub restore_slave_databases ($) { |
|
2009 |
my ($num_slaves)= @_; |
|
2010 |
||
2011 |
if ( -d $path_snapshot) |
|
2012 |
{
|
|
2013 |
for (my $idx= 0; $idx < $num_slaves; $idx++) |
|
2014 |
{
|
|
2015 |
my $data_dir= $slave->[$idx]->{'path_myddir'}; |
|
2016 |
my $name= basename($data_dir); |
|
2017 |
mtr_rmtree($data_dir); |
|
2018 |
mtr_copy_dir("$path_snapshot/$name", $data_dir); |
|
2019 |
}
|
|
2020 |
}
|
|
2021 |
}
|
|
2022 |
||
2023 |
||
2024 |
sub run_testcase_check_skip_test($) |
|
2025 |
{
|
|
2026 |
my ($tinfo)= @_; |
|
2027 |
||
2028 |
# ----------------------------------------------------------------------
|
|
2029 |
# If marked to skip, just print out and return.
|
|
2030 |
# Note that a test case not marked as 'skip' can still be
|
|
2031 |
# skipped later, because of the test case itself in cooperation
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2032 |
# with the drizzletest program tells us so.
|
1
by brian
clean slate |
2033 |
# ----------------------------------------------------------------------
|
2034 |
||
2035 |
if ( $tinfo->{'skip'} ) |
|
2036 |
{
|
|
2037 |
mtr_report_test_name($tinfo); |
|
2038 |
mtr_report_test_skipped($tinfo); |
|
2039 |
return 1; |
|
2040 |
}
|
|
2041 |
||
2042 |
return 0; |
|
2043 |
}
|
|
2044 |
||
2045 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2046 |
sub do_before_run_drizzletest($) |
1
by brian
clean slate |
2047 |
{
|
2048 |
my $tinfo= shift; |
|
2049 |
my $args; |
|
2050 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2051 |
# Remove old files produced by drizzletest
|
1
by brian
clean slate |
2052 |
my $base_file= mtr_match_extension($tinfo->{'result_file'}, |
2053 |
"result"); # Trim extension |
|
2054 |
unlink("$base_file.reject"); |
|
2055 |
unlink("$base_file.progress"); |
|
2056 |
unlink("$base_file.log"); |
|
2057 |
unlink("$base_file.warnings"); |
|
2058 |
||
2059 |
}
|
|
2060 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2061 |
sub do_after_run_drizzletest($) |
1
by brian
clean slate |
2062 |
{
|
2063 |
my $tinfo= shift; |
|
2064 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2065 |
# Save info from this testcase run to drizzletest.log
|
2066 |
mtr_appendfile_to_file($path_current_test_log, $path_drizzletest_log) |
|
1
by brian
clean slate |
2067 |
if -f $path_current_test_log; |
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2068 |
mtr_appendfile_to_file($path_timefile, $path_drizzletest_log) |
1
by brian
clean slate |
2069 |
if -f $path_timefile; |
2070 |
}
|
|
2071 |
||
2072 |
||
2073 |
sub run_testcase_mark_logs($$) |
|
2074 |
{
|
|
2075 |
my ($tinfo, $log_msg)= @_; |
|
2076 |
||
2077 |
# Write a marker to all log files
|
|
2078 |
||
2079 |
# The file indicating current test name
|
|
2080 |
mtr_tonewfile($path_current_test_log, $log_msg); |
|
2081 |
||
2082 |
# each mysqld's .err file
|
|
2083 |
foreach my $mysqld (@{$master}, @{$slave}) |
|
2084 |
{
|
|
2085 |
mtr_tofile($mysqld->{path_myerr}, $log_msg); |
|
2086 |
}
|
|
2087 |
||
2088 |
}
|
|
2089 |
||
2090 |
sub find_testcase_skipped_reason($) |
|
2091 |
{
|
|
2092 |
my ($tinfo)= @_; |
|
2093 |
||
2094 |
# Set default message
|
|
2095 |
$tinfo->{'comment'}= "Detected by testcase(no log file)"; |
|
2096 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2097 |
# Open drizzletest-time(the drizzletest log file)
|
1
by brian
clean slate |
2098 |
my $F= IO::File->new($path_timefile) |
2099 |
or return; |
|
2100 |
my $reason; |
|
2101 |
||
2102 |
while ( my $line= <$F> ) |
|
2103 |
{
|
|
2104 |
# Look for "reason: <reason for skipping test>"
|
|
2105 |
if ( $line =~ /reason: (.*)/ ) |
|
2106 |
{
|
|
2107 |
$reason= $1; |
|
2108 |
}
|
|
2109 |
}
|
|
2110 |
||
2111 |
if ( ! $reason ) |
|
2112 |
{
|
|
2113 |
mtr_warning("Could not find reason for skipping test in $path_timefile"); |
|
2114 |
$reason= "Detected by testcase(reason unknown) "; |
|
2115 |
}
|
|
2116 |
$tinfo->{'comment'}= $reason; |
|
2117 |
}
|
|
2118 |
||
2119 |
||
2120 |
##############################################################################
|
|
2121 |
#
|
|
2122 |
# Run a single test case
|
|
2123 |
#
|
|
2124 |
##############################################################################
|
|
2125 |
||
2126 |
# When we get here, we have already filtered out test cases that doesn't
|
|
2127 |
# apply to the current setup, for example if we use a running server, test
|
|
2128 |
# cases that restart the server are dropped. So this function should mostly
|
|
2129 |
# be about doing things, not a lot of logic.
|
|
2130 |
||
2131 |
# We don't start and kill the servers for each testcase. But some
|
|
2132 |
# testcases needs a restart, because they specify options to start
|
|
2133 |
# mysqld with. After that testcase, we need to restart again, to set
|
|
2134 |
# back the normal options.
|
|
2135 |
||
2136 |
sub run_testcase ($) { |
|
2137 |
my $tinfo= shift; |
|
2138 |
||
2139 |
# -------------------------------------------------------
|
|
2140 |
# Init variables that can change between each test case
|
|
2141 |
# -------------------------------------------------------
|
|
2142 |
||
2143 |
$ENV{'TZ'}= $tinfo->{'timezone'}; |
|
2144 |
mtr_verbose("Setting timezone: $tinfo->{'timezone'}"); |
|
2145 |
||
2146 |
my $master_restart= run_testcase_need_master_restart($tinfo); |
|
2147 |
my $slave_restart= run_testcase_need_slave_restart($tinfo); |
|
2148 |
||
2149 |
if ($master_restart or $slave_restart) |
|
2150 |
{
|
|
2151 |
# Can't restart a running server that may be in use
|
|
2152 |
if ( $opt_extern ) |
|
2153 |
{
|
|
2154 |
mtr_report_test_name($tinfo); |
|
2155 |
$tinfo->{comment}= "Can't restart a running server"; |
|
2156 |
mtr_report_test_skipped($tinfo); |
|
2157 |
return; |
|
2158 |
}
|
|
2159 |
||
2160 |
run_testcase_stop_servers($tinfo, $master_restart, $slave_restart); |
|
2161 |
}
|
|
2162 |
||
2163 |
# Write to all log files to indicate start of testcase
|
|
2164 |
run_testcase_mark_logs($tinfo, "CURRENT_TEST: $tinfo->{name}\n"); |
|
2165 |
||
2166 |
my $died= mtr_record_dead_children(); |
|
2167 |
if ($died or $master_restart or $slave_restart) |
|
2168 |
{
|
|
2169 |
if (run_testcase_start_servers($tinfo)) |
|
2170 |
{
|
|
2171 |
mtr_report_test_name($tinfo); |
|
2172 |
report_failure_and_restart($tinfo); |
|
2173 |
return 1; |
|
2174 |
}
|
|
2175 |
}
|
|
2176 |
# ----------------------------------------------------------------------
|
|
2177 |
# If --start-and-exit or --start-dirty given, stop here to let user manually
|
|
2178 |
# run tests
|
|
2179 |
# ----------------------------------------------------------------------
|
|
2180 |
if ( $opt_start_and_exit or $opt_start_dirty ) |
|
2181 |
{
|
|
2182 |
mtr_timer_stop_all($glob_timers); |
|
2183 |
mtr_report("\nServers started, exiting"); |
|
2184 |
exit(0); |
|
2185 |
}
|
|
2186 |
||
2187 |
{
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2188 |
do_before_run_drizzletest($tinfo); |
1
by brian
clean slate |
2189 |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2190 |
my $res= run_drizzletest($tinfo); |
1
by brian
clean slate |
2191 |
mtr_report_test_name($tinfo); |
2192 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2193 |
do_after_run_drizzletest($tinfo); |
1
by brian
clean slate |
2194 |
|
2195 |
if ( $res == 0 ) |
|
2196 |
{
|
|
2197 |
mtr_report_test_passed($tinfo); |
|
2198 |
}
|
|
2199 |
elsif ( $res == 62 ) |
|
2200 |
{
|
|
2201 |
# Testcase itself tell us to skip this one
|
|
2202 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2203 |
# Try to get reason from drizzletest.log
|
1
by brian
clean slate |
2204 |
find_testcase_skipped_reason($tinfo); |
2205 |
mtr_report_test_skipped($tinfo); |
|
2206 |
}
|
|
2207 |
elsif ( $res == 63 ) |
|
2208 |
{
|
|
2209 |
$tinfo->{'timeout'}= 1; # Mark as timeout |
|
2210 |
report_failure_and_restart($tinfo); |
|
2211 |
}
|
|
2212 |
elsif ( $res == 1 ) |
|
2213 |
{
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2214 |
# Test case failure reported by drizzletest
|
1
by brian
clean slate |
2215 |
report_failure_and_restart($tinfo); |
2216 |
}
|
|
2217 |
else
|
|
2218 |
{
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2219 |
# drizzletest failed, probably crashed
|
1
by brian
clean slate |
2220 |
$tinfo->{comment}= |
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2221 |
"drizzletest returned unexpected code $res, it has probably crashed"; |
1
by brian
clean slate |
2222 |
report_failure_and_restart($tinfo); |
2223 |
}
|
|
2224 |
}
|
|
2225 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2226 |
# Remove the file that drizzletest writes info to
|
1
by brian
clean slate |
2227 |
unlink($path_timefile); |
2228 |
||
2229 |
# ----------------------------------------------------------------------
|
|
2230 |
# Stop Instance Manager if we are processing an IM-test case.
|
|
2231 |
# ----------------------------------------------------------------------
|
|
2232 |
}
|
|
2233 |
||
2234 |
||
2235 |
#
|
|
2236 |
# Save a snapshot of the installed test db(s)
|
|
2237 |
# I.e take a snapshot of the var/ dir
|
|
2238 |
#
|
|
2239 |
sub save_installed_db () { |
|
2240 |
||
2241 |
mtr_report("Saving snapshot of installed databases"); |
|
2242 |
mtr_rmtree($path_snapshot); |
|
2243 |
||
2244 |
foreach my $data_dir (@data_dir_lst) |
|
2245 |
{
|
|
2246 |
my $name= basename($data_dir); |
|
2247 |
mtr_copy_dir("$data_dir", "$path_snapshot/$name"); |
|
2248 |
}
|
|
2249 |
}
|
|
2250 |
||
2251 |
||
2252 |
#
|
|
2253 |
# Save any interesting files in the data_dir
|
|
2254 |
# before the data dir is removed.
|
|
2255 |
#
|
|
2256 |
sub save_files_before_restore($$) { |
|
2257 |
my $test_name= shift; |
|
2258 |
my $data_dir= shift; |
|
2259 |
my $save_name= "$opt_vardir/log/$test_name"; |
|
2260 |
||
2261 |
# Look for core files
|
|
2262 |
foreach my $core_file ( glob("$data_dir/core*") ) |
|
2263 |
{
|
|
2264 |
last if $opt_max_save_core > 0 && $num_saved_cores >= $opt_max_save_core; |
|
2265 |
my $core_name= basename($core_file); |
|
2266 |
mtr_report("Saving $core_name"); |
|
2267 |
mkdir($save_name) if ! -d $save_name; |
|
2268 |
rename("$core_file", "$save_name/$core_name"); |
|
2269 |
++$num_saved_cores; |
|
2270 |
}
|
|
2271 |
}
|
|
2272 |
||
2273 |
||
2274 |
#
|
|
2275 |
# Restore snapshot of the installed test db(s)
|
|
2276 |
# if the snapshot exists
|
|
2277 |
#
|
|
2278 |
sub restore_installed_db ($) { |
|
2279 |
my $test_name= shift; |
|
2280 |
||
2281 |
if ( -d $path_snapshot) |
|
2282 |
{
|
|
2283 |
mtr_report("Restoring snapshot of databases"); |
|
2284 |
||
2285 |
foreach my $data_dir (@data_dir_lst) |
|
2286 |
{
|
|
2287 |
my $name= basename($data_dir); |
|
2288 |
save_files_before_restore($test_name, $data_dir); |
|
2289 |
mtr_rmtree("$data_dir"); |
|
2290 |
mtr_copy_dir("$path_snapshot/$name", "$data_dir"); |
|
2291 |
}
|
|
2292 |
}
|
|
2293 |
else
|
|
2294 |
{
|
|
2295 |
# No snapshot existed
|
|
2296 |
mtr_error("No snapshot existed"); |
|
2297 |
}
|
|
2298 |
}
|
|
2299 |
||
2300 |
sub report_failure_and_restart ($) { |
|
2301 |
my $tinfo= shift; |
|
2302 |
||
2303 |
mtr_report_test_failed($tinfo); |
|
2304 |
print "\n"; |
|
2305 |
if ( $opt_force ) |
|
2306 |
{
|
|
2307 |
# Stop all servers that are known to be running
|
|
2308 |
stop_all_servers(); |
|
2309 |
||
2310 |
# Restore the snapshot of the installed test db
|
|
2311 |
restore_installed_db($tinfo->{'name'}); |
|
2312 |
mtr_report("Resuming Tests\n"); |
|
2313 |
return; |
|
2314 |
}
|
|
2315 |
||
2316 |
my $test_mode= join(" ", @::glob_test_mode) || "default"; |
|
2317 |
mtr_report("Aborting: $tinfo->{'name'} failed in $test_mode mode. "); |
|
2318 |
mtr_report("To continue, re-run with '--force'."); |
|
2319 |
if ( ! $glob_debugger and |
|
89
by Brian Aker
Saving changes/removals to test run |
2320 |
! $opt_extern ) |
1
by brian
clean slate |
2321 |
{
|
2322 |
stop_all_servers(); |
|
2323 |
}
|
|
2324 |
mtr_exit(1); |
|
2325 |
||
2326 |
}
|
|
2327 |
||
2328 |
||
2329 |
sub run_master_init_script ($) { |
|
2330 |
my ($tinfo)= @_; |
|
2331 |
my $init_script= $tinfo->{'master_sh'}; |
|
2332 |
||
2333 |
# Run master initialization shell script if one exists
|
|
2334 |
if ( $init_script ) |
|
2335 |
{
|
|
2336 |
my $ret= mtr_run("/bin/sh", [$init_script], "", "", "", ""); |
|
2337 |
if ( $ret != 0 ) |
|
2338 |
{
|
|
2339 |
# FIXME rewrite those scripts to return 0 if successful
|
|
2340 |
# mtr_warning("$init_script exited with code $ret");
|
|
2341 |
}
|
|
2342 |
}
|
|
2343 |
}
|
|
2344 |
||
2345 |
||
2346 |
##############################################################################
|
|
2347 |
#
|
|
2348 |
# Start and stop servers
|
|
2349 |
#
|
|
2350 |
##############################################################################
|
|
2351 |
||
2352 |
||
2353 |
sub do_before_start_master ($) { |
|
2354 |
my ($tinfo)= @_; |
|
2355 |
||
2356 |
my $tname= $tinfo->{'name'}; |
|
2357 |
||
2358 |
# FIXME what about second master.....
|
|
2359 |
||
2360 |
# Don't delete anything if starting dirty
|
|
2361 |
return if ($opt_start_dirty); |
|
2362 |
||
2363 |
foreach my $bin ( glob("$opt_vardir/log/master*-bin*") ) |
|
2364 |
{
|
|
2365 |
unlink($bin); |
|
2366 |
}
|
|
2367 |
||
2368 |
# FIXME only remove the ones that are tied to this master
|
|
2369 |
# Remove old master.info and relay-log.info files
|
|
2370 |
unlink("$master->[0]->{'path_myddir'}/master.info"); |
|
2371 |
unlink("$master->[0]->{'path_myddir'}/relay-log.info"); |
|
2372 |
unlink("$master->[1]->{'path_myddir'}/master.info"); |
|
2373 |
unlink("$master->[1]->{'path_myddir'}/relay-log.info"); |
|
2374 |
||
2375 |
run_master_init_script($tinfo); |
|
2376 |
}
|
|
2377 |
||
2378 |
||
2379 |
sub do_before_start_slave ($) { |
|
2380 |
my ($tinfo)= @_; |
|
2381 |
||
2382 |
my $tname= $tinfo->{'name'}; |
|
2383 |
my $init_script= $tinfo->{'master_sh'}; |
|
2384 |
||
2385 |
# Don't delete anything if starting dirty
|
|
2386 |
return if ($opt_start_dirty); |
|
2387 |
||
2388 |
foreach my $bin ( glob("$opt_vardir/log/slave*-bin*") ) |
|
2389 |
{
|
|
2390 |
unlink($bin); |
|
2391 |
}
|
|
2392 |
||
2393 |
unlink("$slave->[0]->{'path_myddir'}/master.info"); |
|
2394 |
unlink("$slave->[0]->{'path_myddir'}/relay-log.info"); |
|
2395 |
||
2396 |
# Run slave initialization shell script if one exists
|
|
2397 |
if ( $init_script ) |
|
2398 |
{
|
|
2399 |
my $ret= mtr_run("/bin/sh", [$init_script], "", "", "", ""); |
|
2400 |
if ( $ret != 0 ) |
|
2401 |
{
|
|
2402 |
# FIXME rewrite those scripts to return 0 if successful
|
|
2403 |
# mtr_warning("$init_script exited with code $ret");
|
|
2404 |
}
|
|
2405 |
}
|
|
2406 |
||
2407 |
foreach my $bin ( glob("$slave->[0]->{'path_myddir'}/log.*") ) |
|
2408 |
{
|
|
2409 |
unlink($bin); |
|
2410 |
}
|
|
2411 |
}
|
|
2412 |
||
2413 |
||
2414 |
sub mysqld_arguments ($$$$) { |
|
2415 |
my $args= shift; |
|
2416 |
my $mysqld= shift; |
|
2417 |
my $extra_opt= shift; |
|
2418 |
my $slave_master_info= shift; |
|
2419 |
||
2420 |
my $idx= $mysqld->{'idx'}; |
|
2421 |
my $sidx= ""; # Index as string, 0 is empty string |
|
2422 |
if ( $idx> 0 ) |
|
2423 |
{
|
|
2424 |
$sidx= $idx; |
|
2425 |
}
|
|
2426 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
2427 |
my $prefix= ""; # If drizzletest server arg |
1
by brian
clean slate |
2428 |
|
2429 |
mtr_add_arg($args, "%s--no-defaults", $prefix); |
|
2430 |
||
685.1.29
by Monty Taylor
Some more cleanups to mtr. |
2431 |
$path_my_basedir= collapse_path($path_my_basedir); |
1
by brian
clean slate |
2432 |
mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir); |
2433 |
||
496.1.1
by Paul McCullagh
Added --engine option to drizzle-test-run (default innodb) |
2434 |
if ($opt_engine) |
2435 |
{
|
|
2436 |
mtr_add_arg($args, "%s--default-storage-engine=%s", $prefix, $opt_engine); |
|
2437 |
}
|
|
2438 |
||
1
by brian
clean slate |
2439 |
if ( $mysql_version_id >= 50036) |
2440 |
{
|
|
2441 |
# By default, prevent the started mysqld to access files outside of vardir
|
|
2442 |
mtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir); |
|
2443 |
}
|
|
2444 |
||
2445 |
mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix); |
|
2446 |
||
2447 |
# Increase default connect_timeout to avoid intermittent
|
|
2448 |
# disconnects when test servers are put under load
|
|
2449 |
# see BUG#28359
|
|
971.3.60
by Eric Day
Moved connect_timeout, net_*_timeout, and retry_count to plugin. |
2450 |
mtr_add_arg($args, "%s--oldlibdrizzle-connect-timeout=60", $prefix); |
1
by brian
clean slate |
2451 |
|
2452 |
||
2453 |
# When mysqld is run by a root user(euid is 0), it will fail
|
|
2454 |
# to start unless we specify what user to run as, see BUG#30630
|
|
2455 |
my $euid= $>; |
|
87
by Brian Aker
First pass on cleaning out mysql-test-run |
2456 |
if (grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt) == 0) { |
1
by brian
clean slate |
2457 |
mtr_add_arg($args, "%s--user=root", $prefix); |
2458 |
}
|
|
2459 |
||
2460 |
mtr_add_arg($args, "%s--pid-file=%s", $prefix, |
|
2461 |
$mysqld->{'path_pid'}); |
|
2462 |
||
2463 |
mtr_add_arg($args, "%s--port=%d", $prefix, |
|
2464 |
$mysqld->{'port'}); |
|
2465 |
||
2466 |
mtr_add_arg($args, "%s--datadir=%s", $prefix, |
|
2467 |
$mysqld->{'path_myddir'}); |
|
2468 |
||
2469 |
# Check if "extra_opt" contains --skip-log-bin
|
|
2470 |
if ( $mysqld->{'type'} eq 'master' ) |
|
2471 |
{
|
|
2472 |
mtr_add_arg($args, "%s--server-id=%d", $prefix, |
|
2473 |
$idx > 0 ? $idx + 101 : 1); |
|
2474 |
||
2475 |
mtr_add_arg($args, "%s--loose-innodb_data_file_path=ibdata1:10M:autoextend", |
|
2476 |
$prefix); |
|
2477 |
||
656.1.43
by Monty Taylor
Quick fix to lower the innodb_lock_wait_timeout so that the stinking lock_wait_timeout tests don't take a year and a day. |
2478 |
mtr_add_arg($args, "%s--loose-innodb-lock-wait-timeout=5", $prefix); |
2479 |
||
1
by brian
clean slate |
2480 |
if ( $idx > 0 or !$use_innodb) |
2481 |
{
|
|
2482 |
mtr_add_arg($args, "%s--loose-skip-innodb", $prefix); |
|
2483 |
}
|
|
2484 |
}
|
|
2485 |
else
|
|
2486 |
{
|
|
2487 |
mtr_error("unknown mysqld type") |
|
2488 |
unless $mysqld->{'type'} eq 'slave'; |
|
2489 |
||
2490 |
# Directory where slaves find the dumps generated by "load data"
|
|
2491 |
# on the server. The path need to have constant length otherwise
|
|
2492 |
# test results will vary, thus a relative path is used.
|
|
2493 |
my $slave_load_path= "../tmp"; |
|
2494 |
||
2495 |
if ( @$slave_master_info ) |
|
2496 |
{
|
|
2497 |
foreach my $arg ( @$slave_master_info ) |
|
2498 |
{
|
|
2499 |
mtr_add_arg($args, "%s%s", $prefix, $arg); |
|
2500 |
}
|
|
2501 |
}
|
|
2502 |
else
|
|
2503 |
{
|
|
2504 |
my $slave_server_id= 2 + $idx; |
|
2505 |
my $slave_rpl_rank= $slave_server_id; |
|
2506 |
mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id); |
|
2507 |
}
|
|
2508 |
} # end slave |
|
2509 |
||
2510 |
if ( $opt_debug ) |
|
2511 |
{
|
|
2512 |
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/%s%s.trace", |
|
2513 |
$prefix, $path_vardir_trace, $mysqld->{'type'}, $sidx); |
|
2514 |
}
|
|
2515 |
||
2516 |
mtr_add_arg($args, "%s--key_buffer_size=1M", $prefix); |
|
2517 |
mtr_add_arg($args, "%s--sort_buffer=256K", $prefix); |
|
2518 |
mtr_add_arg($args, "%s--max_heap_table_size=1M", $prefix); |
|
2519 |
||
2520 |
if ( $opt_warnings ) |
|
2521 |
{
|
|
2522 |
mtr_add_arg($args, "%s--log-warnings", $prefix); |
|
2523 |
}
|
|
2524 |
||
2525 |
# Indicate to "mysqld" it will be debugged in debugger
|
|
2526 |
if ( $glob_debugger ) |
|
2527 |
{
|
|
2528 |
mtr_add_arg($args, "%s--gdb", $prefix); |
|
2529 |
}
|
|
2530 |
||
2531 |
my $found_skip_core= 0; |
|
2532 |
foreach my $arg ( @opt_extra_mysqld_opt, @$extra_opt ) |
|
2533 |
{
|
|
2534 |
# Allow --skip-core-file to be set in <testname>-[master|slave].opt file
|
|
2535 |
if ($arg eq "--skip-core-file") |
|
2536 |
{
|
|
2537 |
$found_skip_core= 1; |
|
2538 |
}
|
|
2539 |
else
|
|
2540 |
{
|
|
2541 |
mtr_add_arg($args, "%s%s", $prefix, $arg); |
|
2542 |
}
|
|
2543 |
}
|
|
2544 |
if ( !$found_skip_core ) |
|
2545 |
{
|
|
2546 |
mtr_add_arg($args, "%s%s", $prefix, "--core-file"); |
|
2547 |
}
|
|
2548 |
||
2549 |
return $args; |
|
2550 |
}
|
|
2551 |
||
2552 |
||
2553 |
##############################################################################
|
|
2554 |
#
|
|
2555 |
# Start mysqld and return the PID
|
|
2556 |
#
|
|
2557 |
##############################################################################
|
|
2558 |
||
2559 |
sub mysqld_start ($$$) { |
|
2560 |
my $mysqld= shift; |
|
2561 |
my $extra_opt= shift; |
|
2562 |
my $slave_master_info= shift; |
|
2563 |
||
2564 |
my $args; # Arg vector |
|
2565 |
my $exe; |
|
2566 |
my $pid= -1; |
|
2567 |
my $wait_for_pid_file= 1; |
|
2568 |
||
2569 |
my $type= $mysqld->{'type'}; |
|
2570 |
my $idx= $mysqld->{'idx'}; |
|
2571 |
||
2572 |
if ( $type eq 'master' ) |
|
2573 |
{
|
|
2574 |
$exe= $exe_master_mysqld; |
|
2575 |
}
|
|
2576 |
elsif ( $type eq 'slave' ) |
|
2577 |
{
|
|
2578 |
$exe= $exe_slave_mysqld; |
|
2579 |
}
|
|
2580 |
else
|
|
2581 |
{
|
|
2582 |
mtr_error("Unknown 'type' \"$type\" passed to mysqld_start"); |
|
2583 |
}
|
|
2584 |
||
2585 |
mtr_init_args(\$args); |
|
2586 |
||
2587 |
if ( $opt_valgrind_mysqld ) |
|
2588 |
{
|
|
2589 |
valgrind_arguments($args, \$exe); |
|
2590 |
}
|
|
2591 |
||
2592 |
mysqld_arguments($args,$mysqld,$extra_opt,$slave_master_info); |
|
2593 |
||
2594 |
if ( $opt_gdb || $opt_manual_gdb) |
|
2595 |
{
|
|
2596 |
gdb_arguments(\$args, \$exe, "$type"."_$idx"); |
|
2597 |
}
|
|
2598 |
elsif ( $opt_ddd || $opt_manual_ddd ) |
|
2599 |
{
|
|
2600 |
ddd_arguments(\$args, \$exe, "$type"."_$idx"); |
|
2601 |
}
|
|
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
2602 |
if ( $opt_dbx || $opt_manual_dbx) |
2603 |
{
|
|
2604 |
dbx_arguments(\$args, \$exe, "$type"."_$idx"); |
|
2605 |
}
|
|
1
by brian
clean slate |
2606 |
elsif ( $opt_debugger ) |
2607 |
{
|
|
2608 |
debugger_arguments(\$args, \$exe, "$type"."_$idx"); |
|
2609 |
}
|
|
2610 |
elsif ( $opt_manual_debug ) |
|
2611 |
{
|
|
2612 |
print "\nStart $type in your debugger\n" . |
|
2613 |
"dir: $glob_mysql_test_dir\n" . |
|
2614 |
"exe: $exe\n" . |
|
2615 |
"args: " . join(" ", @$args) . "\n\n" . |
|
2616 |
"Waiting ....\n"; |
|
2617 |
||
2618 |
# Indicate the exe should not be started
|
|
2619 |
$exe= undef; |
|
2620 |
}
|
|
2621 |
else
|
|
2622 |
{
|
|
2623 |
# Default to not wait until pid file has been created
|
|
2624 |
$wait_for_pid_file= 0; |
|
2625 |
}
|
|
2626 |
||
2627 |
# Remove the pidfile
|
|
2628 |
unlink($mysqld->{'path_pid'}); |
|
2629 |
||
2630 |
if ( defined $exe ) |
|
2631 |
{
|
|
2632 |
$pid= mtr_spawn($exe, $args, "", |
|
2633 |
$mysqld->{'path_myerr'}, |
|
2634 |
$mysqld->{'path_myerr'}, |
|
2635 |
"", |
|
2636 |
{ append_log_file => 1 }); |
|
2637 |
}
|
|
2638 |
||
2639 |
||
2640 |
if ( $wait_for_pid_file && !sleep_until_file_created($mysqld->{'path_pid'}, |
|
2641 |
$mysqld->{'start_timeout'}, |
|
2642 |
$pid)) |
|
2643 |
{
|
|
2644 |
||
2645 |
mtr_error("Failed to start mysqld $mysqld->{'type'}"); |
|
2646 |
}
|
|
2647 |
||
2648 |
||
2649 |
# Remember pid of the started process
|
|
2650 |
$mysqld->{'pid'}= $pid; |
|
2651 |
||
2652 |
# Remember options used when starting
|
|
2653 |
$mysqld->{'start_opts'}= $extra_opt; |
|
2654 |
$mysqld->{'start_slave_master_info'}= $slave_master_info; |
|
2655 |
||
2656 |
mtr_verbose("mysqld pid: $pid"); |
|
2657 |
return $pid; |
|
2658 |
}
|
|
2659 |
||
2660 |
||
2661 |
sub stop_all_servers () { |
|
2662 |
||
2663 |
mtr_report("Stopping All Servers"); |
|
2664 |
||
2665 |
my %admin_pids; # hash of admin processes that requests shutdown |
|
2666 |
my @kill_pids; # list of processes to shutdown/kill |
|
2667 |
my $pid; |
|
2668 |
||
2669 |
# Start shutdown of all started masters
|
|
2670 |
foreach my $mysqld (@{$slave}, @{$master}) |
|
2671 |
{
|
|
2672 |
if ( $mysqld->{'pid'} ) |
|
2673 |
{
|
|
973.1.3
by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it. |
2674 |
$pid= mtr_server_shutdown($mysqld); |
1
by brian
clean slate |
2675 |
$admin_pids{$pid}= 1; |
2676 |
||
2677 |
push(@kill_pids,{ |
|
2678 |
pid => $mysqld->{'pid'}, |
|
2679 |
real_pid => $mysqld->{'real_pid'}, |
|
2680 |
pidfile => $mysqld->{'path_pid'}, |
|
2681 |
sockfile => $mysqld->{'path_sock'}, |
|
2682 |
port => $mysqld->{'port'}, |
|
2683 |
errfile => $mysqld->{'path_myerr'}, |
|
2684 |
});
|
|
2685 |
||
2686 |
$mysqld->{'pid'}= 0; # Assume we are done with it |
|
2687 |
}
|
|
2688 |
}
|
|
2689 |
||
2690 |
# Wait blocking until all shutdown processes has completed
|
|
2691 |
mtr_wait_blocking(\%admin_pids); |
|
2692 |
||
2693 |
# Make sure that process has shutdown else try to kill them
|
|
2694 |
mtr_check_stop_servers(\@kill_pids); |
|
2695 |
}
|
|
2696 |
||
2697 |
||
2698 |
sub run_testcase_need_master_restart($) |
|
2699 |
{
|
|
2700 |
my ($tinfo)= @_; |
|
2701 |
||
2702 |
# We try to find out if we are to restart the master(s)
|
|
2703 |
my $do_restart= 0; # Assumes we don't have to |
|
2704 |
||
89
by Brian Aker
Saving changes/removals to test run |
2705 |
if ( $tinfo->{'master_sh'} ) |
1
by brian
clean slate |
2706 |
{
|
2707 |
$do_restart= 1; # Always restart if script to run |
|
2708 |
mtr_verbose("Restart master: Always restart if script to run"); |
|
2709 |
}
|
|
2710 |
if ( $tinfo->{'force_restart'} ) |
|
2711 |
{
|
|
2712 |
$do_restart= 1; # Always restart if --force-restart in -opt file |
|
2713 |
mtr_verbose("Restart master: Restart forced with --force-restart"); |
|
2714 |
}
|
|
2715 |
elsif( $tinfo->{'component_id'} eq 'im' ) |
|
2716 |
{
|
|
2717 |
$do_restart= 1; |
|
2718 |
mtr_verbose("Restart master: Always restart for im tests"); |
|
2719 |
}
|
|
2720 |
elsif ( $master->[0]->{'running_master_options'} and |
|
2721 |
$master->[0]->{'running_master_options'}->{'timezone'} ne |
|
2722 |
$tinfo->{'timezone'}) |
|
2723 |
{
|
|
2724 |
$do_restart= 1; |
|
2725 |
mtr_verbose("Restart master: Different timezone"); |
|
2726 |
}
|
|
2727 |
# Check that running master was started with same options
|
|
2728 |
# as the current test requires
|
|
2729 |
elsif (! mtr_same_opts($master->[0]->{'start_opts'}, |
|
2730 |
$tinfo->{'master_opt'}) ) |
|
2731 |
{
|
|
2732 |
# Chech that diff is binlog format only
|
|
2733 |
my $diff_opts= mtr_diff_opts($master->[0]->{'start_opts'},$tinfo->{'master_opt'}); |
|
2734 |
if (scalar(@$diff_opts) eq 2) |
|
2735 |
{
|
|
798.2.11
by Brian Aker
Factor test-run for binlog removal |
2736 |
$do_restart= 1; |
1
by brian
clean slate |
2737 |
}
|
2738 |
else
|
|
2739 |
{
|
|
2740 |
$do_restart= 1; |
|
2741 |
mtr_verbose("Restart master: running with different options '" . |
|
2742 |
join(" ", @{$tinfo->{'master_opt'}}) . "' != '" . |
|
2743 |
join(" ", @{$master->[0]->{'start_opts'}}) . "'" ); |
|
2744 |
}
|
|
2745 |
}
|
|
2746 |
elsif( ! $master->[0]->{'pid'} ) |
|
2747 |
{
|
|
2748 |
if ( $opt_extern ) |
|
2749 |
{
|
|
2750 |
$do_restart= 0; |
|
2751 |
mtr_verbose("No restart: using extern master"); |
|
2752 |
}
|
|
2753 |
else
|
|
2754 |
{
|
|
2755 |
$do_restart= 1; |
|
2756 |
mtr_verbose("Restart master: master is not started"); |
|
2757 |
}
|
|
2758 |
}
|
|
2759 |
return $do_restart; |
|
2760 |
}
|
|
2761 |
||
2762 |
sub run_testcase_need_slave_restart($) |
|
2763 |
{
|
|
2764 |
my ($tinfo)= @_; |
|
2765 |
||
2766 |
# We try to find out if we are to restart the slaves
|
|
2767 |
my $do_slave_restart= 0; # Assumes we don't have to |
|
2768 |
||
89
by Brian Aker
Saving changes/removals to test run |
2769 |
if ( $max_slave_num == 0) |
1
by brian
clean slate |
2770 |
{
|
2771 |
mtr_verbose("Skip slave restart: No testcase use slaves"); |
|
2772 |
}
|
|
2773 |
else
|
|
2774 |
{
|
|
2775 |
||
2776 |
# Check if any slave is currently started
|
|
2777 |
my $any_slave_started= 0; |
|
2778 |
foreach my $mysqld (@{$slave}) |
|
2779 |
{
|
|
2780 |
if ( $mysqld->{'pid'} ) |
|
2781 |
{
|
|
2782 |
$any_slave_started= 1; |
|
2783 |
last; |
|
2784 |
}
|
|
2785 |
}
|
|
2786 |
||
2787 |
if ($any_slave_started) |
|
2788 |
{
|
|
2789 |
mtr_verbose("Restart slave: Slave is started, always restart"); |
|
2790 |
$do_slave_restart= 1; |
|
2791 |
}
|
|
2792 |
elsif ( $tinfo->{'slave_num'} ) |
|
2793 |
{
|
|
2794 |
mtr_verbose("Restart slave: Test need slave"); |
|
2795 |
$do_slave_restart= 1; |
|
2796 |
}
|
|
2797 |
}
|
|
2798 |
||
2799 |
return $do_slave_restart; |
|
2800 |
||
2801 |
}
|
|
2802 |
||
2803 |
# ----------------------------------------------------------------------
|
|
2804 |
# If not using a running servers we may need to stop and restart.
|
|
2805 |
# We restart in the case we have initiation scripts, server options
|
|
2806 |
# etc to run. But we also restart again after the test first restart
|
|
2807 |
# and test is run, to get back to normal server settings.
|
|
2808 |
#
|
|
2809 |
# To make the code a bit more clean, we actually only stop servers
|
|
2810 |
# here, and mark this to be done. Then a generic "start" part will
|
|
2811 |
# start up the needed servers again.
|
|
2812 |
# ----------------------------------------------------------------------
|
|
2813 |
||
2814 |
sub run_testcase_stop_servers($$$) { |
|
2815 |
my ($tinfo, $do_restart, $do_slave_restart)= @_; |
|
2816 |
my $pid; |
|
2817 |
my %admin_pids; # hash of admin processes that requests shutdown |
|
2818 |
my @kill_pids; # list of processes to shutdown/kill |
|
2819 |
||
2820 |
# Remember if we restarted for this test case (count restarts)
|
|
2821 |
$tinfo->{'restarted'}= $do_restart; |
|
2822 |
||
2823 |
if ( $do_restart ) |
|
2824 |
{
|
|
2825 |
delete $master->[0]->{'running_master_options'}; # Forget history |
|
2826 |
||
2827 |
# Start shutdown of all started masters
|
|
2828 |
foreach my $mysqld (@{$master}) |
|
2829 |
{
|
|
2830 |
if ( $mysqld->{'pid'} ) |
|
2831 |
{
|
|
973.1.3
by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it. |
2832 |
$pid= mtr_server_shutdown($mysqld); |
2833 |
||
2834 |
$admin_pids{$pid}= 1; |
|
2835 |
||
2836 |
push(@kill_pids,{ |
|
2837 |
pid => $mysqld->{'pid'}, |
|
2838 |
real_pid => $mysqld->{'real_pid'}, |
|
2839 |
pidfile => $mysqld->{'path_pid'}, |
|
2840 |
sockfile => $mysqld->{'path_sock'}, |
|
2841 |
port => $mysqld->{'port'}, |
|
2842 |
errfile => $mysqld->{'path_myerr'}, |
|
2843 |
});
|
|
2844 |
||
2845 |
$mysqld->{'pid'}= 0; # Assume we are done with it |
|
1
by brian
clean slate |
2846 |
}
|
2847 |
}
|
|
2848 |
}
|
|
2849 |
||
2850 |
if ( $do_restart || $do_slave_restart ) |
|
2851 |
{
|
|
2852 |
||
2853 |
delete $slave->[0]->{'running_slave_options'}; # Forget history |
|
2854 |
||
2855 |
# Start shutdown of all started slaves
|
|
2856 |
foreach my $mysqld (@{$slave}) |
|
2857 |
{
|
|
2858 |
if ( $mysqld->{'pid'} ) |
|
2859 |
{
|
|
973.1.3
by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it. |
2860 |
$pid= mtr_server_shutdown($mysqld); |
2861 |
||
2862 |
$admin_pids{$pid}= 1; |
|
2863 |
||
2864 |
push(@kill_pids,{ |
|
2865 |
pid => $mysqld->{'pid'}, |
|
2866 |
real_pid => $mysqld->{'real_pid'}, |
|
2867 |
pidfile => $mysqld->{'path_pid'}, |
|
2868 |
sockfile => $mysqld->{'path_sock'}, |
|
2869 |
port => $mysqld->{'port'}, |
|
2870 |
errfile => $mysqld->{'path_myerr'}, |
|
2871 |
});
|
|
2872 |
||
2873 |
$mysqld->{'pid'}= 0; # Assume we are done with it |
|
1
by brian
clean slate |
2874 |
}
|
2875 |
}
|
|
2876 |
}
|
|
2877 |
||
2878 |
# ----------------------------------------------------------------------
|
|
2879 |
# Shutdown has now been started and lists for the shutdown processes
|
|
2880 |
# and the processes to be killed has been created
|
|
2881 |
# ----------------------------------------------------------------------
|
|
2882 |
||
2883 |
# Wait blocking until all shutdown processes has completed
|
|
2884 |
mtr_wait_blocking(\%admin_pids); |
|
2885 |
||
2886 |
||
2887 |
# Make sure that process has shutdown else try to kill them
|
|
2888 |
mtr_check_stop_servers(\@kill_pids); |
|
2889 |
}
|
|
2890 |
||
2891 |
||
2892 |
#
|
|
2893 |
# run_testcase_start_servers
|
|
2894 |
#
|
|
2895 |
# Start the servers needed by this test case
|
|
2896 |
#
|
|
2897 |
# RETURN
|
|
2898 |
# 0 OK
|
|
2899 |
# 1 Start failed
|
|
2900 |
#
|
|
2901 |
||
2902 |
sub run_testcase_start_servers($) { |
|
2903 |
my $tinfo= shift; |
|
2904 |
my $tname= $tinfo->{'name'}; |
|
2905 |
||
2906 |
if ( $tinfo->{'component_id'} eq 'mysqld' ) |
|
2907 |
{
|
|
2908 |
if ( !$master->[0]->{'pid'} ) |
|
2909 |
{
|
|
2910 |
# Master mysqld is not started
|
|
2911 |
do_before_start_master($tinfo); |
|
2912 |
||
2913 |
mysqld_start($master->[0],$tinfo->{'master_opt'},[]); |
|
2914 |
||
2915 |
}
|
|
2916 |
||
2917 |
# Save this test case information, so next can examine it
|
|
2918 |
$master->[0]->{'running_master_options'}= $tinfo; |
|
2919 |
}
|
|
2920 |
||
2921 |
# ----------------------------------------------------------------------
|
|
2922 |
# Start slaves - if needed
|
|
2923 |
# ----------------------------------------------------------------------
|
|
2924 |
if ( $tinfo->{'slave_num'} ) |
|
2925 |
{
|
|
2926 |
restore_slave_databases($tinfo->{'slave_num'}); |
|
2927 |
||
2928 |
do_before_start_slave($tinfo); |
|
2929 |
||
2930 |
for ( my $idx= 0; $idx < $tinfo->{'slave_num'}; $idx++ ) |
|
2931 |
{
|
|
2932 |
if ( ! $slave->[$idx]->{'pid'} ) |
|
2933 |
{
|
|
2934 |
mysqld_start($slave->[$idx],$tinfo->{'slave_opt'}, |
|
2935 |
$tinfo->{'slave_mi'}); |
|
2936 |
||
2937 |
}
|
|
2938 |
}
|
|
2939 |
||
2940 |
# Save this test case information, so next can examine it
|
|
2941 |
$slave->[0]->{'running_slave_options'}= $tinfo; |
|
2942 |
}
|
|
2943 |
||
2944 |
# Wait for mysqld's to start
|
|
2945 |
foreach my $mysqld (@{$master},@{$slave}) |
|
2946 |
{
|
|
2947 |
||
2948 |
next if !$mysqld->{'pid'}; |
|
2949 |
||
2950 |
if (mysqld_wait_started($mysqld)) |
|
2951 |
{
|
|
2952 |
# failed to start
|
|
2953 |
$tinfo->{'comment'}= |
|
2954 |
"Failed to start $mysqld->{'type'} mysqld $mysqld->{'idx'}"; |
|
2955 |
return 1; |
|
2956 |
}
|
|
2957 |
}
|
|
2958 |
return 0; |
|
2959 |
}
|
|
2960 |
||
2961 |
#
|
|
2962 |
# Run include/check-testcase.test
|
|
2963 |
# Before a testcase, run in record mode, save result file to var
|
|
2964 |
# After testcase, run and compare with the recorded file, they should be equal!
|
|
2965 |
#
|
|
2966 |
# RETURN VALUE
|
|
2967 |
# 0 OK
|
|
2968 |
# 1 Check failed
|
|
2969 |
#
|
|
2970 |
sub run_check_testcase ($$) { |
|
2971 |
||
2972 |
my $mode= shift; |
|
2973 |
my $mysqld= shift; |
|
2974 |
||
2975 |
my $name= "check-" . $mysqld->{'type'} . $mysqld->{'idx'}; |
|
2976 |
||
2977 |
my $args; |
|
2978 |
mtr_init_args(\$args); |
|
2979 |
||
2980 |
mtr_add_arg($args, "--no-defaults"); |
|
2981 |
mtr_add_arg($args, "--silent"); |
|
2982 |
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir); |
|
2983 |
||
2984 |
mtr_add_arg($args, "--port=%d", $mysqld->{'port'}); |
|
2985 |
mtr_add_arg($args, "--database=test"); |
|
2986 |
mtr_add_arg($args, "--user=%s", $opt_user); |
|
2987 |
mtr_add_arg($args, "--password="); |
|
2988 |
||
2989 |
mtr_add_arg($args, "-R"); |
|
2990 |
mtr_add_arg($args, "$opt_vardir/tmp/$name.result"); |
|
2991 |
||
2992 |
if ( $mode eq "before" ) |
|
2993 |
{
|
|
2994 |
mtr_add_arg($args, "--record"); |
|
2995 |
}
|
|
2996 |
||
685.1.22
by Monty Taylor
Added testdir setting support to drizzletest. |
2997 |
if ( $opt_testdir ) |
2998 |
{
|
|
2999 |
mtr_add_arg($args, "--testdir=%s", $opt_testdir); |
|
3000 |
}
|
|
3001 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3002 |
my $res = mtr_run_test($exe_drizzletest,$args, |
1
by brian
clean slate |
3003 |
"include/check-testcase.test", "", "", ""); |
3004 |
||
3005 |
if ( $res == 1 and $mode eq "after") |
|
3006 |
{
|
|
3007 |
mtr_run("diff",["-u", |
|
3008 |
"$opt_vardir/tmp/$name.result", |
|
3009 |
"$opt_vardir/tmp/$name.reject"], |
|
3010 |
"", "", "", ""); |
|
3011 |
}
|
|
3012 |
elsif ( $res ) |
|
3013 |
{
|
|
3014 |
mtr_error("Could not execute 'check-testcase' $mode testcase"); |
|
3015 |
}
|
|
3016 |
return $res; |
|
3017 |
}
|
|
3018 |
||
3019 |
##############################################################################
|
|
3020 |
#
|
|
3021 |
# Report the features that were compiled in
|
|
3022 |
#
|
|
3023 |
##############################################################################
|
|
3024 |
||
3025 |
sub run_report_features () { |
|
3026 |
my $args; |
|
3027 |
||
3028 |
{
|
|
3029 |
mysqld_start($master->[0],[],[]); |
|
3030 |
if ( ! $master->[0]->{'pid'} ) |
|
3031 |
{
|
|
3032 |
mtr_error("Can't start the mysqld server"); |
|
3033 |
}
|
|
3034 |
mysqld_wait_started($master->[0]); |
|
3035 |
}
|
|
3036 |
||
3037 |
my $tinfo = {}; |
|
3038 |
$tinfo->{'name'} = 'report features'; |
|
3039 |
$tinfo->{'result_file'} = undef; |
|
3040 |
$tinfo->{'component_id'} = 'mysqld'; |
|
3041 |
$tinfo->{'path'} = 'include/report-features.test'; |
|
3042 |
$tinfo->{'timezone'}= "GMT-3"; |
|
3043 |
$tinfo->{'slave_num'} = 0; |
|
3044 |
$tinfo->{'master_opt'} = []; |
|
3045 |
$tinfo->{'slave_opt'} = []; |
|
3046 |
$tinfo->{'slave_mi'} = []; |
|
3047 |
$tinfo->{'comment'} = 'report server features'; |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3048 |
run_drizzletest($tinfo); |
1
by brian
clean slate |
3049 |
|
3050 |
{
|
|
3051 |
stop_all_servers(); |
|
3052 |
}
|
|
3053 |
}
|
|
3054 |
||
3055 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3056 |
sub run_drizzletest ($) { |
1
by brian
clean slate |
3057 |
my ($tinfo)= @_; |
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3058 |
my $exe= $exe_drizzletest; |
1
by brian
clean slate |
3059 |
my $args; |
3060 |
||
3061 |
mtr_init_args(\$args); |
|
3062 |
||
3063 |
mtr_add_arg($args, "--no-defaults"); |
|
3064 |
mtr_add_arg($args, "--silent"); |
|
3065 |
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir); |
|
3066 |
mtr_add_arg($args, "--logdir=%s/log", $opt_vardir); |
|
3067 |
||
3068 |
# Log line number and time for each line in .test file
|
|
3069 |
mtr_add_arg($args, "--mark-progress") |
|
3070 |
if $opt_mark_progress; |
|
3071 |
||
3072 |
{
|
|
3073 |
mtr_add_arg($args, "--port=%d", $master->[0]->{'port'}); |
|
3074 |
mtr_add_arg($args, "--database=test"); |
|
3075 |
mtr_add_arg($args, "--user=%s", $opt_user); |
|
3076 |
mtr_add_arg($args, "--password="); |
|
3077 |
}
|
|
3078 |
||
3079 |
if ( $opt_strace_client ) |
|
3080 |
{
|
|
3081 |
$exe= "strace"; # FIXME there are ktrace, .... |
|
3082 |
mtr_add_arg($args, "-o"); |
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3083 |
mtr_add_arg($args, "%s/log/drizzletest.strace", $opt_vardir); |
3084 |
mtr_add_arg($args, "$exe_drizzletest"); |
|
1
by brian
clean slate |
3085 |
}
|
3086 |
||
3087 |
if ( $opt_timer ) |
|
3088 |
{
|
|
3089 |
mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir); |
|
3090 |
}
|
|
3091 |
||
3092 |
if ( $opt_compress ) |
|
3093 |
{
|
|
3094 |
mtr_add_arg($args, "--compress"); |
|
3095 |
}
|
|
3096 |
||
3097 |
if ( $opt_sleep ) |
|
3098 |
{
|
|
3099 |
mtr_add_arg($args, "--sleep=%d", $opt_sleep); |
|
3100 |
}
|
|
3101 |
||
3102 |
if ( $opt_debug ) |
|
3103 |
{
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3104 |
mtr_add_arg($args, "--debug=d:t:A,%s/log/drizzletest.trace", |
1
by brian
clean slate |
3105 |
$path_vardir_trace); |
3106 |
}
|
|
3107 |
||
685.1.22
by Monty Taylor
Added testdir setting support to drizzletest. |
3108 |
if ( $opt_testdir ) |
3109 |
{
|
|
3110 |
mtr_add_arg($args, "--testdir=%s", $opt_testdir); |
|
3111 |
}
|
|
3112 |
||
3113 |
||
1
by brian
clean slate |
3114 |
# ----------------------------------------------------------------------
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
3115 |
# export DRIZZLE_TEST variable containing <path>/drizzletest <args>
|
1
by brian
clean slate |
3116 |
# ----------------------------------------------------------------------
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
3117 |
$ENV{'DRIZZLE_TEST'}= |
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3118 |
mtr_native_path($exe_drizzletest) . " " . join(" ", @$args); |
1
by brian
clean slate |
3119 |
|
3120 |
# ----------------------------------------------------------------------
|
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
3121 |
# Add arguments that should not go into the DRIZZLE_TEST env var
|
1
by brian
clean slate |
3122 |
# ----------------------------------------------------------------------
|
3123 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3124 |
if ( $opt_valgrind_drizzletest ) |
1
by brian
clean slate |
3125 |
{
|
3126 |
# Prefix the Valgrind options to the argument list.
|
|
3127 |
# We do this here, since we do not want to Valgrind the nested invocations
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3128 |
# of drizzletest; that would mess up the stderr output causing test failure.
|
1
by brian
clean slate |
3129 |
my @args_saved = @$args; |
3130 |
mtr_init_args(\$args); |
|
3131 |
valgrind_arguments($args, \$exe); |
|
3132 |
mtr_add_arg($args, "%s", $_) for @args_saved; |
|
3133 |
}
|
|
3134 |
||
3135 |
mtr_add_arg($args, "--test-file=%s", $tinfo->{'path'}); |
|
3136 |
||
3137 |
# Number of lines of resut to include in failure report
|
|
3138 |
mtr_add_arg($args, "--tail-lines=20"); |
|
3139 |
||
3140 |
if ( defined $tinfo->{'result_file'} ) { |
|
3141 |
mtr_add_arg($args, "--result-file=%s", $tinfo->{'result_file'}); |
|
3142 |
}
|
|
3143 |
||
3144 |
if ( $opt_record ) |
|
3145 |
{
|
|
3146 |
mtr_add_arg($args, "--record"); |
|
3147 |
}
|
|
3148 |
||
3149 |
if ( $opt_client_gdb ) |
|
3150 |
{
|
|
3151 |
gdb_arguments(\$args, \$exe, "client"); |
|
3152 |
}
|
|
3153 |
elsif ( $opt_client_ddd ) |
|
3154 |
{
|
|
3155 |
ddd_arguments(\$args, \$exe, "client"); |
|
3156 |
}
|
|
3157 |
elsif ( $opt_client_debugger ) |
|
3158 |
{
|
|
3159 |
debugger_arguments(\$args, \$exe, "client"); |
|
3160 |
}
|
|
3161 |
||
3162 |
if ( $opt_check_testcases ) |
|
3163 |
{
|
|
3164 |
foreach my $mysqld (@{$master}, @{$slave}) |
|
3165 |
{
|
|
3166 |
if ($mysqld->{'pid'}) |
|
3167 |
{
|
|
3168 |
run_check_testcase("before", $mysqld); |
|
3169 |
}
|
|
3170 |
}
|
|
3171 |
}
|
|
3172 |
||
3173 |
my $res = mtr_run_test($exe,$args,"","",$path_timefile,""); |
|
3174 |
||
3175 |
if ( $opt_check_testcases ) |
|
3176 |
{
|
|
3177 |
foreach my $mysqld (@{$master}, @{$slave}) |
|
3178 |
{
|
|
3179 |
if ($mysqld->{'pid'}) |
|
3180 |
{
|
|
3181 |
if (run_check_testcase("after", $mysqld)) |
|
3182 |
{
|
|
3183 |
# Check failed, mark the test case with that info
|
|
3184 |
$tinfo->{'check_testcase_failed'}= 1; |
|
3185 |
}
|
|
3186 |
}
|
|
3187 |
}
|
|
3188 |
}
|
|
3189 |
||
3190 |
return $res; |
|
3191 |
||
3192 |
}
|
|
3193 |
||
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
3194 |
#
|
3195 |
# Modify the exe and args so that program is run in gdb in xterm
|
|
3196 |
#
|
|
3197 |
sub dbx_arguments { |
|
3198 |
my $args= shift; |
|
3199 |
my $exe= shift; |
|
3200 |
my $type= shift; |
|
3201 |
||
3202 |
# Write $args to gdb init file
|
|
3203 |
my $str= join(" ", @$$args); |
|
3204 |
my $dbx_init_file= "$opt_tmpdir/dbxinit.$type"; |
|
3205 |
||
3206 |
# Remove the old gdbinit file
|
|
3207 |
unlink($dbx_init_file); |
|
1101.1.32
by Monty Taylor
Fixed the mtr launching a bit. |
3208 |
if ( $type eq "client" ) |
3209 |
{
|
|
3210 |
# write init file for client
|
|
3211 |
mtr_tofile($dbx_init_file, |
|
3212 |
"runargs $str\n" . |
|
3213 |
"run\n"); |
|
3214 |
}
|
|
3215 |
else
|
|
3216 |
{
|
|
3217 |
# write init file for drizzled
|
|
3218 |
mtr_tofile($dbx_init_file, |
|
3219 |
"stop in mysql_parse\n" . |
|
3220 |
"runargs $str\n" . |
|
3221 |
"run\n" . |
|
3222 |
"\n"); |
|
3223 |
}
|
|
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
3224 |
|
3225 |
if ( $opt_manual_dbx ) |
|
3226 |
{
|
|
3227 |
print "\nTo start dbx for $type, type in another window:\n"; |
|
1101.1.32
by Monty Taylor
Fixed the mtr launching a bit. |
3228 |
print "dbx -c 'source $dbx_init_file' $$exe\n"; |
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
3229 |
|
3230 |
# Indicate the exe should not be started
|
|
3231 |
$$exe= undef; |
|
3232 |
return; |
|
3233 |
}
|
|
3234 |
||
3235 |
$$args= []; |
|
3236 |
mtr_add_arg($$args, "-title"); |
|
3237 |
mtr_add_arg($$args, "$type"); |
|
3238 |
mtr_add_arg($$args, "-e"); |
|
3239 |
||
3240 |
mtr_add_arg($$args, "dbx"); |
|
3241 |
mtr_add_arg($$args, "-c"); |
|
1101.1.32
by Monty Taylor
Fixed the mtr launching a bit. |
3242 |
mtr_add_arg($$args, "source $dbx_init_file"); |
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
3243 |
mtr_add_arg($$args, "$$exe"); |
3244 |
||
3245 |
$$exe= "xterm"; |
|
3246 |
}
|
|
1
by brian
clean slate |
3247 |
|
3248 |
#
|
|
3249 |
# Modify the exe and args so that program is run in gdb in xterm
|
|
3250 |
#
|
|
3251 |
sub gdb_arguments { |
|
3252 |
my $args= shift; |
|
3253 |
my $exe= shift; |
|
3254 |
my $type= shift; |
|
3255 |
||
3256 |
# Write $args to gdb init file
|
|
3257 |
my $str= join(" ", @$$args); |
|
3258 |
my $gdb_init_file= "$opt_tmpdir/gdbinit.$type"; |
|
3259 |
||
3260 |
# Remove the old gdbinit file
|
|
3261 |
unlink($gdb_init_file); |
|
3262 |
||
3263 |
if ( $type eq "client" ) |
|
3264 |
{
|
|
3265 |
# write init file for client
|
|
3266 |
mtr_tofile($gdb_init_file, |
|
3267 |
"set args $str\n" . |
|
3268 |
"break main\n"); |
|
3269 |
}
|
|
3270 |
else
|
|
3271 |
{
|
|
3272 |
# write init file for mysqld
|
|
3273 |
mtr_tofile($gdb_init_file, |
|
3274 |
"set args $str\n" . |
|
3275 |
"break mysql_parse\n" . |
|
3276 |
"commands 1\n" . |
|
3277 |
"disable 1\n" . |
|
3278 |
"end\n" . |
|
3279 |
"run"); |
|
3280 |
}
|
|
3281 |
||
3282 |
if ( $opt_manual_gdb ) |
|
3283 |
{
|
|
3284 |
print "\nTo start gdb for $type, type in another window:\n"; |
|
3285 |
print "gdb -cd $glob_mysql_test_dir -x $gdb_init_file $$exe\n"; |
|
3286 |
||
3287 |
# Indicate the exe should not be started
|
|
3288 |
$$exe= undef; |
|
3289 |
return; |
|
3290 |
}
|
|
3291 |
||
3292 |
$$args= []; |
|
3293 |
mtr_add_arg($$args, "-title"); |
|
3294 |
mtr_add_arg($$args, "$type"); |
|
3295 |
mtr_add_arg($$args, "-e"); |
|
3296 |
||
3297 |
if ( $exe_libtool ) |
|
3298 |
{
|
|
3299 |
mtr_add_arg($$args, $exe_libtool); |
|
3300 |
mtr_add_arg($$args, "--mode=execute"); |
|
3301 |
}
|
|
3302 |
||
3303 |
mtr_add_arg($$args, "gdb"); |
|
3304 |
mtr_add_arg($$args, "-x"); |
|
3305 |
mtr_add_arg($$args, "$gdb_init_file"); |
|
3306 |
mtr_add_arg($$args, "$$exe"); |
|
3307 |
||
3308 |
$$exe= "xterm"; |
|
3309 |
}
|
|
3310 |
||
3311 |
||
3312 |
#
|
|
3313 |
# Modify the exe and args so that program is run in ddd
|
|
3314 |
#
|
|
3315 |
sub ddd_arguments { |
|
3316 |
my $args= shift; |
|
3317 |
my $exe= shift; |
|
3318 |
my $type= shift; |
|
3319 |
||
3320 |
# Write $args to ddd init file
|
|
3321 |
my $str= join(" ", @$$args); |
|
3322 |
my $gdb_init_file= "$opt_tmpdir/gdbinit.$type"; |
|
3323 |
||
3324 |
# Remove the old gdbinit file
|
|
3325 |
unlink($gdb_init_file); |
|
3326 |
||
3327 |
if ( $type eq "client" ) |
|
3328 |
{
|
|
3329 |
# write init file for client
|
|
3330 |
mtr_tofile($gdb_init_file, |
|
3331 |
"set args $str\n" . |
|
3332 |
"break main\n"); |
|
3333 |
}
|
|
3334 |
else
|
|
3335 |
{
|
|
3336 |
# write init file for mysqld
|
|
3337 |
mtr_tofile($gdb_init_file, |
|
3338 |
"file $$exe\n" . |
|
3339 |
"set args $str\n" . |
|
3340 |
"break mysql_parse\n" . |
|
3341 |
"commands 1\n" . |
|
3342 |
"disable 1\n" . |
|
3343 |
"end"); |
|
3344 |
}
|
|
3345 |
||
3346 |
if ( $opt_manual_ddd ) |
|
3347 |
{
|
|
3348 |
print "\nTo start ddd for $type, type in another window:\n"; |
|
3349 |
print "ddd -cd $glob_mysql_test_dir -x $gdb_init_file $$exe\n"; |
|
3350 |
||
3351 |
# Indicate the exe should not be started
|
|
3352 |
$$exe= undef; |
|
3353 |
return; |
|
3354 |
}
|
|
3355 |
||
3356 |
my $save_exe= $$exe; |
|
3357 |
$$args= []; |
|
3358 |
if ( $exe_libtool ) |
|
3359 |
{
|
|
3360 |
$$exe= $exe_libtool; |
|
3361 |
mtr_add_arg($$args, "--mode=execute"); |
|
3362 |
mtr_add_arg($$args, "ddd"); |
|
3363 |
}
|
|
3364 |
else
|
|
3365 |
{
|
|
3366 |
$$exe= "ddd"; |
|
3367 |
}
|
|
3368 |
mtr_add_arg($$args, "--command=$gdb_init_file"); |
|
3369 |
mtr_add_arg($$args, "$save_exe"); |
|
3370 |
}
|
|
3371 |
||
3372 |
||
3373 |
#
|
|
3374 |
# Modify the exe and args so that program is run in the selected debugger
|
|
3375 |
#
|
|
3376 |
sub debugger_arguments { |
|
3377 |
my $args= shift; |
|
3378 |
my $exe= shift; |
|
3379 |
my $debugger= $opt_debugger || $opt_client_debugger; |
|
3380 |
||
3381 |
if ( $debugger =~ /vcexpress|vc|devenv/ ) |
|
3382 |
{
|
|
3383 |
# vc[express] /debugexe exe arg1 .. argn
|
|
3384 |
||
3385 |
# Add /debugexe and name of the exe before args
|
|
3386 |
unshift(@$$args, "/debugexe"); |
|
3387 |
unshift(@$$args, "$$exe"); |
|
3388 |
||
3389 |
# Set exe to debuggername
|
|
3390 |
$$exe= $debugger; |
|
3391 |
||
3392 |
}
|
|
1099.3.1
by Patrick Galbraith
mtr now with dbx goodness. |
3393 |
#elsif ( $debugger eq "dbx" )
|
3394 |
#{
|
|
3395 |
# # xterm -e dbx -r exe arg1 .. argn
|
|
3396 |
#
|
|
3397 |
# unshift(@$$args, $$exe);
|
|
3398 |
# unshift(@$$args, "-r");
|
|
3399 |
# unshift(@$$args, $debugger);
|
|
3400 |
# unshift(@$$args, "-e");
|
|
3401 |
#
|
|
3402 |
# $$exe= "xterm";
|
|
3403 |
#
|
|
3404 |
# }
|
|
1
by brian
clean slate |
3405 |
else
|
3406 |
{
|
|
3407 |
mtr_error("Unknown argument \"$debugger\" passed to --debugger"); |
|
3408 |
}
|
|
3409 |
}
|
|
3410 |
||
3411 |
||
3412 |
#
|
|
3413 |
# Modify the exe and args so that program is run in valgrind
|
|
3414 |
#
|
|
3415 |
sub valgrind_arguments { |
|
3416 |
my $args= shift; |
|
3417 |
my $exe= shift; |
|
3418 |
||
3419 |
if ( $opt_callgrind) |
|
3420 |
{
|
|
3421 |
mtr_add_arg($args, "--tool=callgrind"); |
|
3422 |
mtr_add_arg($args, "--base=$opt_vardir/log"); |
|
3423 |
}
|
|
3424 |
else
|
|
3425 |
{
|
|
3426 |
mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option |
|
3427 |
mtr_add_arg($args, "--leak-check=yes"); |
|
3428 |
mtr_add_arg($args, "--num-callers=16"); |
|
3429 |
mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir) |
|
3430 |
if -f "$glob_mysql_test_dir/valgrind.supp"; |
|
3431 |
}
|
|
3432 |
||
3433 |
# Add valgrind options, can be overriden by user
|
|
3434 |
mtr_add_arg($args, '%s', $_) for (@valgrind_args); |
|
3435 |
||
3436 |
mtr_add_arg($args, $$exe); |
|
3437 |
||
3438 |
$$exe= $opt_valgrind_path || "valgrind"; |
|
3439 |
||
3440 |
if ($exe_libtool) |
|
3441 |
{
|
|
3442 |
# Add "libtool --mode-execute" before the test to execute
|
|
3443 |
# if running in valgrind(to avoid valgrinding bash)
|
|
3444 |
unshift(@$args, "--mode=execute", $$exe); |
|
3445 |
$$exe= $exe_libtool; |
|
3446 |
}
|
|
3447 |
}
|
|
3448 |
||
3449 |
||
87
by Brian Aker
First pass on cleaning out mysql-test-run |
3450 |
sub mysqld_wait_started($){ |
3451 |
my $mysqld= shift; |
|
3452 |
||
3453 |
if (sleep_until_file_created($mysqld->{'path_pid'}, |
|
3454 |
$mysqld->{'start_timeout'}, |
|
3455 |
$mysqld->{'pid'}) == 0) |
|
3456 |
{
|
|
3457 |
# Failed to wait for pid file
|
|
3458 |
return 1; |
|
3459 |
}
|
|
3460 |
||
3461 |
# Get the "real pid" of the process, it will be used for killing
|
|
3462 |
# the process in ActiveState's perl on windows
|
|
3463 |
$mysqld->{'real_pid'}= mtr_get_pid_from_file($mysqld->{'path_pid'}); |
|
3464 |
||
3465 |
return 0; |
|
3466 |
}
|
|
3467 |
||
685.1.25
by Monty Taylor
Fixed absolute path generation for real. Sigh. |
3468 |
sub collapse_path ($) { |
3469 |
||
685.1.29
by Monty Taylor
Some more cleanups to mtr. |
3470 |
my $c_path= rel2abs(shift); |
685.1.25
by Monty Taylor
Fixed absolute path generation for real. Sigh. |
3471 |
my $updir = updir($c_path); |
3472 |
my $curdir = curdir($c_path); |
|
3473 |
||
3474 |
my($vol, $dirs, $file) = splitpath($c_path); |
|
3475 |
my @dirs = splitdir($dirs); |
|
3476 |
||
3477 |
my @collapsed; |
|
3478 |
foreach my $dir (@dirs) { |
|
3479 |
if( $dir eq $updir and # if we have an updir |
|
3480 |
@collapsed and # and something to collapse |
|
3481 |
length $collapsed[-1] and # and its not the rootdir |
|
3482 |
$collapsed[-1] ne $updir and # nor another updir |
|
3483 |
$collapsed[-1] ne $curdir # nor the curdir |
|
3484 |
)
|
|
3485 |
{ # then |
|
3486 |
pop @collapsed; # collapse |
|
3487 |
}
|
|
3488 |
else { # else |
|
3489 |
push @collapsed, $dir; # just hang onto it |
|
3490 |
}
|
|
3491 |
}
|
|
3492 |
||
3493 |
return catpath($vol, catdir(@collapsed), $file); |
|
3494 |
}
|
|
87
by Brian Aker
First pass on cleaning out mysql-test-run |
3495 |
|
1
by brian
clean slate |
3496 |
##############################################################################
|
3497 |
#
|
|
3498 |
# Usage
|
|
3499 |
#
|
|
3500 |
##############################################################################
|
|
3501 |
||
3502 |
sub usage ($) { |
|
3503 |
my $message= shift; |
|
3504 |
||
3505 |
if ( $message ) |
|
3506 |
{
|
|
3507 |
print STDERR "$message\n"; |
|
3508 |
}
|
|
3509 |
||
3510 |
print <<HERE; |
|
3511 |
||
3512 |
$0 [ OPTIONS ] [ TESTCASE ]
|
|
3513 |
||
3514 |
Options to control what engine/variation to run
|
|
3515 |
||
3516 |
compress Use the compressed protocol between client and server
|
|
3517 |
bench Run the benchmark suite
|
|
3518 |
small-bench Run the benchmarks with --small-tests --small-tables
|
|
3519 |
||
3520 |
Options to control directories to use
|
|
3521 |
benchdir=DIR The directory where the benchmark suite is stored
|
|
3522 |
(default: ../../mysql-bench)
|
|
3523 |
tmpdir=DIR The directory where temporary files are stored
|
|
3524 |
(default: ./var/tmp).
|
|
3525 |
vardir=DIR The directory where files generated from the test run
|
|
3526 |
is stored (default: ./var). Specifying a ramdisk or
|
|
3527 |
tmpfs will speed up tests.
|
|
3528 |
mem Run testsuite in "memory" using tmpfs or ramdisk
|
|
3529 |
Attempts to find a suitable location
|
|
3530 |
using a builtin list of standard locations
|
|
3531 |
for tmpfs (/dev/shm)
|
|
3532 |
The option can also be set using environment
|
|
3533 |
variable MTR_MEM=[DIR]
|
|
3534 |
||
3535 |
Options to control what test suites or cases to run
|
|
3536 |
||
3537 |
force Continue to run the suite after failure
|
|
3538 |
do-test=PREFIX or REGEX
|
|
3539 |
Run test cases which name are prefixed with PREFIX
|
|
3540 |
or fulfills REGEX
|
|
3541 |
skip-test=PREFIX or REGEX
|
|
3542 |
Skip test cases which name are prefixed with PREFIX
|
|
3543 |
or fulfills REGEX
|
|
3544 |
start-from=PREFIX Run test cases starting from test prefixed with PREFIX
|
|
3545 |
suite[s]=NAME1,..,NAMEN Collect tests in suites from the comma separated
|
|
3546 |
list of suite names.
|
|
3547 |
The default is: "$opt_suites_default"
|
|
3548 |
skip-rpl Skip the replication test cases.
|
|
3549 |
combination="ARG1 .. ARG2" Specify a set of "mysqld" arguments for one
|
|
3550 |
combination.
|
|
3551 |
skip-combination Skip any combination options and combinations files
|
|
974.1.1
by Stewart Smith
add repeat-test=n option to test-run.pl to repeat a test n times |
3552 |
repeat-test=n How many times to repeat each test (default: 1)
|
1
by brian
clean slate |
3553 |
|
3554 |
Options that specify ports
|
|
3555 |
||
3556 |
master_port=PORT Specify the port number used by the first master
|
|
3557 |
slave_port=PORT Specify the port number used by the first slave
|
|
3558 |
mtr-build-thread=# Specify unique collection of ports. Can also be set by
|
|
3559 |
setting the environment variable MTR_BUILD_THREAD.
|
|
3560 |
||
3561 |
Options for test case authoring
|
|
3562 |
||
3563 |
record TESTNAME (Re)genereate the result file for TESTNAME
|
|
3564 |
check-testcases Check testcases for sideeffects
|
|
3565 |
mark-progress Log line number and elapsed time to <testname>.progress
|
|
3566 |
||
3567 |
Options that pass on options
|
|
3568 |
||
3569 |
mysqld=ARGS Specify additional arguments to "mysqld"
|
|
3570 |
||
3571 |
Options to run test on running server
|
|
3572 |
||
3573 |
extern Use running server for tests
|
|
3574 |
user=USER User for connection to extern server
|
|
3575 |
||
3576 |
Options for debugging the product
|
|
3577 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3578 |
client-ddd Start drizzletest client in ddd
|
3579 |
client-debugger=NAME Start drizzletest in the selected debugger
|
|
3580 |
client-gdb Start drizzletest client in gdb
|
|
1
by brian
clean slate |
3581 |
ddd Start mysqld in ddd
|
3582 |
debug Dump trace output for all servers and client programs
|
|
3583 |
debugger=NAME Start mysqld in the selected debugger
|
|
3584 |
gdb Start the mysqld(s) in gdb
|
|
3585 |
manual-debug Let user manually start mysqld in debugger, before
|
|
3586 |
running test(s)
|
|
3587 |
manual-gdb Let user manually start mysqld in gdb, before running
|
|
3588 |
test(s)
|
|
3589 |
manual-ddd Let user manually start mysqld in ddd, before running
|
|
3590 |
test(s)
|
|
3591 |
master-binary=PATH Specify the master "mysqld" to use
|
|
3592 |
slave-binary=PATH Specify the slave "mysqld" to use
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3593 |
strace-client Create strace output for drizzletest client
|
1
by brian
clean slate |
3594 |
max-save-core Limit the number of core files saved (to avoid filling
|
3595 |
up disks for heavily crashing server). Defaults to
|
|
3596 |
$opt_max_save_core, set to 0 for no limit.
|
|
3597 |
||
3598 |
Options for coverage, profiling etc
|
|
3599 |
||
3600 |
gcov FIXME
|
|
191
by Brian Aker
Merge from mark |
3601 |
gprof See online documentation on how to use it.
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3602 |
valgrind Run the "drizzletest" and "mysqld" executables using
|
1
by brian
clean slate |
3603 |
valgrind with default options
|
3604 |
valgrind-all Synonym for --valgrind
|
|
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3605 |
valgrind-drizzletest Run the "drizzletest" and "drizzle_client_test" executable
|
1
by brian
clean slate |
3606 |
with valgrind
|
3607 |
valgrind-mysqld Run the "mysqld" executable with valgrind
|
|
3608 |
valgrind-options=ARGS Deprecated, use --valgrind-option
|
|
3609 |
valgrind-option=ARGS Option to give valgrind, replaces default option(s),
|
|
3610 |
can be specified more then once
|
|
3611 |
valgrind-path=[EXE] Path to the valgrind executable
|
|
3612 |
callgrind Instruct valgrind to use callgrind
|
|
3613 |
||
3614 |
Misc options
|
|
3615 |
||
3616 |
comment=STR Write STR to the output
|
|
3617 |
notimer Don't show test case execution time
|
|
3618 |
script-debug Debug this script itself
|
|
3619 |
verbose More verbose output
|
|
3620 |
start-and-exit Only initialize and start the servers, using the
|
|
3621 |
startup settings for the specified test case (if any)
|
|
3622 |
start-dirty Only start the servers (without initialization) for
|
|
3623 |
the specified test case (if any)
|
|
3624 |
fast Don't try to clean up from earlier runs
|
|
3625 |
reorder Reorder tests to get fewer server restarts
|
|
3626 |
help Get this help text
|
|
3627 |
||
3628 |
testcase-timeout=MINUTES Max test case run time (default $default_testcase_timeout)
|
|
3629 |
suite-timeout=MINUTES Max test suite run time (default $default_suite_timeout)
|
|
3630 |
warnings | log-warnings Pass --log-warnings to mysqld
|
|
3631 |
||
77.3.9
by Monty Taylor
Renamed client programs to drizzle. |
3632 |
sleep=SECONDS Passed to drizzletest, will be used as fixed sleep time
|
1
by brian
clean slate |
3633 |
|
3634 |
HERE
|
|
3635 |
mtr_exit(1); |
|
3636 |
||
3637 |
}
|