📄 mtr
字号:
$path_timefile= "$opt_vardir/log/mysqltest-time"; $path_mysqltest_log= "$opt_vardir/log/mysqltest.log"; $path_current_test_log= "$opt_vardir/log/current_test"; $path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log"; $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/"; if ( $opt_valgrind and $opt_debug ) { # When both --valgrind and --debug is selected, send # all output to the trace file, making it possible to # see the exact location where valgrind complains foreach my $mysqld (@{$master}, @{$slave}) { my $sidx= $mysqld->{idx} ? "$mysqld->{idx}" : ""; $mysqld->{path_myerr}= "$opt_vardir/log/" . $mysqld->{type} . "$sidx.trace"; } }}## To make it easier for different devs to work on the same host,# an environment variable can be used to control all ports. A small# number is to be used, 0 - 16 or similar.## Note the MASTER_MYPORT has to be set the same in all 4.x and 5.x# versions of this script, else a 4.0 test run might conflict with a# 5.1 test run, even if different MTR_BUILD_THREAD is used. This means# all port numbers might not be used in this version of the script.## Also note the limitation of ports we are allowed to hand out. This# differs between operating systems and configuration, see# http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html# But a fairly safe range seems to be 5001 - 32767#sub set_mtr_build_thread_ports($) { my $mtr_build_thread= shift; if ( lc($mtr_build_thread) eq 'auto' ) { print "Requesting build thread... "; $ENV{'MTR_BUILD_THREAD'} = $mtr_build_thread = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299); print "got ".$mtr_build_thread."\n"; } # Up to two masters, up to three slaves $opt_master_myport= $mtr_build_thread * 10 + 10000; # and 1 $opt_slave_myport= $opt_master_myport + 2; # and 3 4 $opt_ndbcluster_port= $opt_master_myport + 5; $opt_ndbcluster_port_slave= $opt_master_myport + 6; $im_port= $opt_master_myport + 7; $im_mysqld1_port= $opt_master_myport + 8; $im_mysqld2_port= $opt_master_myport + 9; if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 ) { mtr_error("MTR_BUILD_THREAD number results in a port", "outside 5001 - 32767", "($opt_master_myport - $opt_master_myport + 10)"); }}sub datadir_list_setup () { # Make a list of all data_dirs for (my $idx= 0; $idx < $max_master_num; $idx++) { push(@data_dir_lst, $master->[$idx]->{'path_myddir'}); } for (my $idx= 0; $idx < $max_slave_num; $idx++) { push(@data_dir_lst, $slave->[$idx]->{'path_myddir'}); } unless ($opt_skip_im) { foreach my $instance (@{$instance_manager->{'instances'}}) { push(@data_dir_lst, $instance->{'path_datadir'}); } }}################################################################################ Set paths to various executable programs###############################################################################sub collect_mysqld_features () { my $found_variable_list_start= 0; # # Execute "mysqld --no-defaults --help --verbose" to get a # list of all features and settings # my $list= `$exe_mysqld --no-defaults --verbose --help`; foreach my $line (split('\n', $list)) { # First look for version if ( !$mysql_version_id ) { # Look for version my $exe_name= basename($exe_mysqld); mtr_verbose("exe_name: $exe_name"); if ( $line =~ /^\S*$exe_name\s\sVer\s([0-9]*)\.([0-9]*)\.([0-9]*)/ ) { #print "Major: $1 Minor: $2 Build: $3\n"; $mysql_version_id= $1*10000 + $2*100 + $3; #print "mysql_version_id: $mysql_version_id\n"; mtr_report("MySQL Version $1.$2.$3"); } } else { if (!$found_variable_list_start) { # Look for start of variables list if ( $line =~ /[\-]+\s[\-]+/ ) { $found_variable_list_start= 1; } } else { # Put variables into hash if ( $line =~ /^([\S]+)[ \t]+(.*?)\r?$/ ) { # print "$1=\"$2\"\n"; $mysqld_variables{$1}= $2; } else { # The variable list is ended with a blank line if ( $line =~ /^[\s]*$/ ) { last; } else { # Send out a warning, we should fix the variables that has no # space between variable name and it's value # or should it be fixed width column parsing? It does not # look like that in function my_print_variables in my_getopt.c mtr_warning("Could not parse variable list line : $line"); } } } } } mtr_error("Could not find version of MySQL") unless $mysql_version_id; mtr_error("Could not find variabes list") unless $found_variable_list_start;}sub run_query($$) { my ($mysqld, $query)= @_; my $args; mtr_init_args(\$args); mtr_add_arg($args, "--no-defaults"); mtr_add_arg($args, "--user=%s", $opt_user); mtr_add_arg($args, "--port=%d", $mysqld->{'port'}); mtr_add_arg($args, "--socket=%s", $mysqld->{'path_sock'}); mtr_add_arg($args, "--silent"); # Tab separated output mtr_add_arg($args, "-e '%s'", $query); my $cmd= "$exe_mysql " . join(' ', @$args); mtr_verbose("cmd: $cmd"); return `$cmd`;}sub collect_mysqld_features_from_running_server (){ my $list= run_query($master->[0], "use mysql; SHOW VARIABLES"); foreach my $line (split('\n', $list)) { # Put variables into hash if ( $line =~ /^([\S]+)[ \t]+(.*?)\r?$/ ) { print "$1=\"$2\"\n"; $mysqld_variables{$1}= $2; } }}sub executable_setup_im () { # Look for instance manager binary - mysqlmanager $exe_im= mtr_exe_maybe_exists( "$glob_basedir/server-tools/instance-manager/mysqlmanager", "$glob_basedir/libexec/mysqlmanager", "$glob_basedir/bin/mysqlmanager", "$glob_basedir/sbin/mysqlmanager"); return ($exe_im eq "");}sub executable_setup_ndb () { # Look for ndb tols and binaries my $ndb_path= mtr_file_exists("$glob_basedir/ndb", "$glob_basedir/storage/ndb", "$glob_basedir/bin"); $exe_ndbd= mtr_exe_maybe_exists("$ndb_path/src/kernel/ndbd", "$ndb_path/ndbd"); $exe_ndb_mgm= mtr_exe_maybe_exists("$ndb_path/src/mgmclient/ndb_mgm", "$ndb_path/ndb_mgm"); $exe_ndb_mgmd= mtr_exe_maybe_exists("$ndb_path/src/mgmsrv/ndb_mgmd", "$ndb_path/ndb_mgmd"); $exe_ndb_waiter= mtr_exe_maybe_exists("$ndb_path/tools/ndb_waiter", "$ndb_path/ndb_waiter"); # May not exist $path_ndb_tools_dir= mtr_file_exists("$ndb_path/tools", "$ndb_path"); # May not exist $path_ndb_examples_dir= mtr_file_exists("$ndb_path/ndbapi-examples", "$ndb_path/examples"); # May not exist $exe_ndb_example= mtr_file_exists("$path_ndb_examples_dir/ndbapi_simple/ndbapi_simple"); return ( $exe_ndbd eq "" or $exe_ndb_mgm eq "" or $exe_ndb_mgmd eq "" or $exe_ndb_waiter eq "");}sub executable_setup () { # # Check if libtool is available in this distribution/clone # we need it when valgrinding or debugging non installed binary # Otherwise valgrind will valgrind the libtool wrapper or bash # and gdb will not find the real executable to debug # if ( -x "../libtool") { $exe_libtool= "../libtool"; if ($opt_valgrind or $glob_debugger) { mtr_report("Using \"$exe_libtool\" when running valgrind or debugger"); } } # Look for language files and charsetsdir, use same share my $path_share= mtr_path_exists("$glob_basedir/share/mysql", "$glob_basedir/sql/share", "$glob_basedir/share"); $path_language= mtr_path_exists("$path_share/english"); $path_charsetsdir= mtr_path_exists("$path_share/charsets"); # Look for my_print_defaults $exe_my_print_defaults= mtr_exe_exists(vs_config_dirs('extra', 'my_print_defaults'), "$path_client_bindir/my_print_defaults", "$glob_basedir/extra/my_print_defaults"); # Look for perror $exe_perror= mtr_exe_exists(vs_config_dirs('extra', 'perror'), "$glob_basedir/extra/perror", "$path_client_bindir/perror"); # Look for the client binaries $exe_mysqlcheck= mtr_exe_exists("$path_client_bindir/mysqlcheck"); $exe_mysqldump= mtr_exe_exists("$path_client_bindir/mysqldump"); $exe_mysqlimport= mtr_exe_exists("$path_client_bindir/mysqlimport"); $exe_mysqlshow= mtr_exe_exists("$path_client_bindir/mysqlshow"); $exe_mysqlbinlog= mtr_exe_exists("$path_client_bindir/mysqlbinlog"); $exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin"); $exe_mysql= mtr_exe_exists("$path_client_bindir/mysql"); if (!$opt_extern) { # Look for SQL scripts directory if ( mtr_file_exists("$path_share/mysql_system_tables.sql") ne "") { # The SQL scripts are in path_share $path_sql_dir= $path_share; } else { $path_sql_dir= mtr_path_exists("$glob_basedir/share", "$glob_basedir/scripts"); } if ( $mysql_version_id >= 50100 ) { $exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap"); } if ( $mysql_version_id >= 50000 and !$glob_use_embedded_server ) { $exe_mysql_upgrade= mtr_exe_exists("$path_client_bindir/mysql_upgrade") } else { $exe_mysql_upgrade= ""; } if ( ! $glob_win32 ) { # Look for mysql_fix_system_table script $exe_mysql_fix_system_tables= mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables", "$path_client_bindir/mysql_fix_privilege_tables"); } # Look for mysql_fix_privilege_tables.sql script $file_mysql_fix_privilege_tables= mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql", "$glob_basedir/share/mysql_fix_privilege_tables.sql"); if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) { mtr_warning("Could not find all required ndb binaries, " . "all ndb tests will fail, use --skip-ndbcluster to " . "skip testing it."); foreach my $cluster (@{$clusters}) { $cluster->{"executable_setup_failed"}= 1; } } if ( ! $opt_skip_im and executable_setup_im()) { mtr_warning("Could not find all required instance manager binaries, " . "all im tests will fail, use --skip-im to " . "continue without instance manager"); $instance_manager->{"executable_setup_failed"}= 1; } # Look for the udf_example library $lib_udf_example= mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'), "$glob_basedir/sql/.libs/udf_example.so",); } # Look for mysqltest executable if ( $glob_use_embedded_server ) { $exe_mysqltest= mtr_exe_exists(vs_config_dirs('libmysqld/examples','mysqltest_embedded'), "$glob_basedir/libmysqld/examples/mysqltest_embedded", "$path_client_bindir/mysqltest_embedded"); } else { $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest"); } # Look for mysql_client_test executable which may _not_ exist in # some versions, test using it should be skipped if ( $glob_use_embedded_server ) { $exe_mysql_client_test= mtr_exe_maybe_exists( vs_config_dirs('libmysqld/examples', 'mysql_client_test_embedded'), "$glob_basedir/libmysqld/examples/mysql_client_test_embedded"); } else { $exe_mysql_client_test= mtr_exe_maybe_exists(vs_config_dirs('tests', 'mysql_client_test'), "$glob_basedir/tests/mysql_client_test", "$glob_basedir/bin/mysql_client_test"); } # Look for bug25714 executable which may _not_ exist in # some versions, test using it should be skipped $exe_bug25714= mtr_exe_maybe_exists(vs_config_dirs('tests', 'bug25714'), "$glob_basedir/tests/bug25714");}sub generate_cmdline_mysqldump ($) { my($mysqld) = @_; return mtr_native_path($exe_mysqldump) . " --no-defaults -uroot " . "--port=$mysqld->{'port'} " . "--socket=$mysqld->{'path_sock'} --password=";}################################################################################ Set environment to be used by childs of this process for# things that are constant duting the whole lifetime of mysql-test-run.pl###############################################################################sub mysql_client_test_arguments(){ my $exe= $exe_mysql_client_test; my $args;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -