📄 mtr
字号:
#!/usr/bin/perl# -*- cperl -*-################################################################################# mysql-test-run.pl## Tool used for executing a suite of .test file## See the "MySQL Test framework manual" for more information# http://dev.mysql.com/doc/mysqltest/en/index.html## Please keep the test framework tools identical in all versions!################################################################################# Coding style directions for this perl script## - To make this Perl script easy to alter even for those that not# code Perl that often, keeep the coding style as close as possible to# the C/C++ MySQL coding standard.## - All lists of arguments to send to commands are Perl lists/arrays,# not strings we append args to. Within reason, most string# concatenation for arguments should be avoided.## - Functions defined in the main program are not to be prefixed,# functions in "library files" are to be prefixed with "mtr_" (for# Mysql-Test-Run). There are some exceptions, code that fits best in# the main program, but are put into separate files to avoid# clutter, may be without prefix.## - All stat/opendir/-f/ is to be kept in collect_test_cases(). It# will create a struct that the rest of the program can use to get# the information. This separates the "find information" from the# "do the work" and makes the program more easy to maintain.## - The rule when it comes to the logic of this program is## command_line_setup() - is to handle the logic between flags# collect_test_cases() - is to do its best to select what tests# to run, dig out options, if needs restart etc.# run_testcase() - is to run a single testcase, and follow the# logic set in both above. No, or rare file# system operations. If a test seems complex,# it should probably not be here.## A nice way to trace the execution of this script while debugging# is to use the Devel::Trace package found at# "http://www.plover.com/~mjd/perl/Trace/" and run this script like# "perl -d:Trace mysql-test-run.pl"#$Devel::Trace::TRACE= 0; # Don't trace boring init stuff#require 5.6.1;use File::Path;use File::Basename;use File::Copy;use File::Temp qw / tempdir /;use Cwd;use Getopt::Long;use IO::Socket;use IO::Socket::INET;use strict;use warnings;select(STDOUT);$| = 1; # Automatically flush STDOUTour $glob_win32_perl= ($^O eq "MSWin32"); # ActiveState Win32 Perlour $glob_cygwin_perl= ($^O eq "cygwin"); # Cygwin Perlour $glob_win32= ($glob_win32_perl or $glob_cygwin_perl);our $glob_netware= ($^O eq "NetWare"); # NetWarerequire "lib/mtr_cases.pl";require "lib/mtr_im.pl";require "lib/mtr_process.pl";require "lib/mtr_timer.pl";require "lib/mtr_io.pl";require "lib/mtr_gcov.pl";require "lib/mtr_gprof.pl";require "lib/mtr_report.pl";require "lib/mtr_match.pl";require "lib/mtr_misc.pl";require "lib/mtr_stress.pl";require "lib/mtr_unique.pl";$Devel::Trace::TRACE= 1;################################################################################ Default settings################################################################################ Misc global variablesour $mysql_version_id;our $glob_mysql_test_dir= undef;our $glob_mysql_bench_dir= undef;our $glob_scriptname= undef;our $glob_timers= undef;our $glob_use_running_ndbcluster= 0;our $glob_use_running_ndbcluster_slave= 0;our $glob_use_embedded_server= 0;our @glob_test_mode;our $glob_basedir;our $path_charsetsdir;our $path_client_bindir;our $path_language;our $path_timefile;our $path_snapshot;our $path_mysqltest_log;our $path_current_test_log;our $path_my_basedir;our $opt_vardir; # A path but set directly on cmd lineour $path_vardir_trace; # unix formatted opt_vardir for trace filesour $opt_tmpdir; # A path but set directly on cmd line# Visual Studio produces executables in different sub-directories based on the# configuration used to build them. To make life easier, an environment# variable or command-line option may be specified to control which set of# executables will be used by the test suite.our $opt_vs_config = $ENV{'MTR_VS_CONFIG'};our $default_vardir;our $opt_usage;our $opt_suite;our $opt_script_debug= 0; # Script debugging, enable with --script-debugour $opt_verbose= 0; # Verbose output, enable with --verboseour $exe_master_mysqld;our $exe_mysql;our $exe_mysqladmin;our $exe_mysql_upgrade;our $exe_mysqlbinlog;our $exe_mysql_client_test;our $exe_bug25714;our $exe_mysqld;our $exe_mysqlcheck;our $exe_mysqldump;our $exe_mysqlslap;our $exe_mysqlimport;our $exe_mysqlshow;our $exe_mysql_fix_system_tables;our $file_mysql_fix_privilege_tables;our $exe_mysqltest;our $exe_ndbd;our $exe_ndb_mgmd;our $exe_slave_mysqld;our $exe_im;our $exe_my_print_defaults;our $exe_perror;our $lib_udf_example;our $exe_libtool;our $opt_bench= 0;our $opt_small_bench= 0;our $opt_big_test= 0;our @opt_extra_mysqld_opt;our $opt_compress;our $opt_ssl;our $opt_skip_ssl;our $opt_ssl_supported;our $opt_ps_protocol;our $opt_sp_protocol;our $opt_cursor_protocol;our $opt_view_protocol;our $opt_debug;our $opt_do_test;our @opt_cases; # The test cases names in argvour $opt_embedded_server;our $opt_extern= 0;our $opt_socket;our $opt_fast;our $opt_force;our $opt_reorder= 0;our $opt_enable_disabled;our $opt_mem= $ENV{'MTR_MEM'};our $opt_gcov;our $opt_gcov_err;our $opt_gcov_msg;our $glob_debugger= 0;our $opt_gdb;our $opt_client_gdb;our $opt_ddd;our $opt_client_ddd;our $opt_manual_gdb;our $opt_manual_ddd;our $opt_manual_debug;our $opt_mtr_build_thread=0;our $opt_debugger;our $opt_client_debugger;our $opt_gprof;our $opt_gprof_dir;our $opt_gprof_master;our $opt_gprof_slave;our $master;our $slave;our $clusters;our $instance_manager;our $opt_master_myport;our $opt_slave_myport;our $im_port;our $im_mysqld1_port;our $im_mysqld2_port;our $opt_ndbcluster_port;our $opt_ndbconnectstring;our $opt_ndbcluster_port_slave;our $opt_ndbconnectstring_slave;our $opt_record;my $opt_report_features;our $opt_check_testcases;our $opt_mark_progress;our $opt_skip_rpl;our $max_slave_num= 0;our $max_master_num= 1;our $use_innodb;our $opt_skip_test;our $opt_skip_im;our $opt_sleep;our $opt_testcase_timeout;our $opt_suite_timeout;my $default_testcase_timeout= 15; # 15 min maxmy $default_suite_timeout= 180; # 3 hours maxour $opt_start_and_exit;our $opt_start_dirty;our $opt_start_from;our $opt_strace_client;our $opt_timer= 1;our $opt_user;our $opt_valgrind= 0;our $opt_valgrind_mysqld= 0;our $opt_valgrind_mysqltest= 0;our $default_valgrind_options= "--show-reachable=yes";our $opt_valgrind_options;our $opt_valgrind_path;our $opt_callgrind;our $opt_stress= "";our $opt_stress_suite= "main";our $opt_stress_mode= "random";our $opt_stress_threads= 5;our $opt_stress_test_count= 0;our $opt_stress_loop_count= 0;our $opt_stress_test_duration= 0;our $opt_stress_init_file= "";our $opt_stress_test_file= "";our $opt_warnings;our $opt_skip_ndbcluster= 0;our $opt_skip_ndbcluster_slave= 0;our $opt_with_ndbcluster= 0;our $opt_with_ndbcluster_only= 0;our $glob_ndbcluster_supported= 0;our $opt_ndb_extra_test= 0;our $opt_skip_master_binlog= 0;our $opt_skip_slave_binlog= 0;our $exe_ndb_mgm;our $exe_ndb_waiter;our $path_ndb_tools_dir;our $path_ndb_examples_dir;our $exe_ndb_example;our $path_ndb_testrun_log;our $path_sql_dir;our @data_dir_lst;our $used_binlog_format;our $used_default_engine;our $debug_compiled_binaries;our %mysqld_variables;my $source_dist= 0;our $opt_max_save_core= 5;my $num_saved_cores= 0; # Number of core files saved in vardir/log/ so far.######################################################################## Function declarations#######################################################################sub main ();sub initial_setup ();sub command_line_setup ();sub set_mtr_build_thread_ports($);sub datadir_list_setup ();sub executable_setup ();sub environment_setup ();sub kill_running_servers ();sub remove_stale_vardir ();sub setup_vardir ();sub check_ssl_support ($);sub check_running_as_root();sub check_ndbcluster_support ($);sub rm_ndbcluster_tables ($);sub ndbcluster_start_install ($);sub ndbcluster_start ($$);sub ndbcluster_wait_started ($$);sub mysqld_wait_started($);sub run_benchmarks ($);sub initialize_servers ();sub mysql_install_db ();sub install_db ($$);sub copy_install_db ($$);sub run_testcase ($);sub run_testcase_stop_servers ($$$);sub run_testcase_start_servers ($);sub run_testcase_check_skip_test($);sub report_failure_and_restart ($);sub do_before_start_master ($);sub do_before_start_slave ($);sub ndbd_start ($$$);sub ndb_mgmd_start ($);sub mysqld_start ($$$);sub mysqld_arguments ($$$$);sub stop_all_servers ();sub run_mysqltest ($);sub usage ($);######################################################################## Main program#######################################################################main();sub main () { command_line_setup(); check_ndbcluster_support(\%mysqld_variables); check_ssl_support(\%mysqld_variables); check_debug_support(\%mysqld_variables); executable_setup(); environment_setup(); signal_setup(); if ( $opt_gcov ) { gcov_prepare(); } if ( $opt_gprof ) { gprof_prepare(); } if ( $opt_bench ) { initialize_servers(); run_benchmarks(shift); # Shift what? Extra arguments?! } elsif ( $opt_stress ) { initialize_servers(); run_stress_test() } else { # Figure out which tests we are going to run my $tests= collect_test_cases($opt_suite); # Turn off NDB and other similar options if no tests use it my ($need_ndbcluster,$need_im); foreach my $test (@$tests) { next if $test->{skip}; $need_ndbcluster||= $test->{ndb_test}; $need_im||= $test->{component_id} eq 'im'; # Count max number of slaves used by a test case if ( $test->{slave_num} > $max_slave_num) { $max_slave_num= $test->{slave_num}; mtr_error("Too many slaves") if $max_slave_num > 3;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -