📄 mtr
字号:
} # Count max number of masters used by a test case if ( $test->{master_num} > $max_master_num) { $max_master_num= $test->{master_num}; mtr_error("Too many masters") if $max_master_num > 2; mtr_error("Too few masters") if $max_master_num < 1; } $use_innodb||= $test->{'innodb_test'}; } # Check if cluster can be skipped if ( !$need_ndbcluster ) { $opt_skip_ndbcluster= 1; $opt_skip_ndbcluster_slave= 1; } # Check if slave cluster can be skipped if ($max_slave_num == 0) { $opt_skip_ndbcluster_slave= 1; } # Check if im can be skipped if ( ! $need_im ) { $opt_skip_im= 1; } initialize_servers(); if ( $opt_report_features ) { run_report_features(); } run_suite($opt_suite, $tests); } mtr_exit(0);}################################################################################ Default settings###############################################################################sub command_line_setup () { # These are defaults for things that are set on the command line $opt_suite= "main"; # Special default suite my $opt_comment; $opt_master_myport= 9306; $opt_slave_myport= 9308; $opt_ndbcluster_port= 9310; $opt_ndbcluster_port_slave= 9311; $im_port= 9312; $im_mysqld1_port= 9313; $im_mysqld2_port= 9314; # If so requested, we try to avail ourselves of a unique build thread number. if ( $ENV{'MTR_BUILD_THREAD'} ) { if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) { print "Requesting build thread... "; $ENV{'MTR_BUILD_THREAD'} = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299); print "got ".$ENV{'MTR_BUILD_THREAD'}."\n"; } } if ( $ENV{'MTR_BUILD_THREAD'} ) { set_mtr_build_thread_ports($ENV{'MTR_BUILD_THREAD'}); } # This is needed for test log evaluation in "gen-build-status-page" # in all cases where the calling tool does not log the commands # directly before it executes them, like "make test-force-pl" in RPM builds. print "Logging: $0 ", join(" ", @ARGV), "\n"; # Read the command line # Note: Keep list, and the order, in sync with usage at end of this file Getopt::Long::Configure("pass_through"); GetOptions( # Control what engine/variation to run 'embedded-server' => \$opt_embedded_server, 'ps-protocol' => \$opt_ps_protocol, 'sp-protocol' => \$opt_sp_protocol, 'view-protocol' => \$opt_view_protocol, 'cursor-protocol' => \$opt_cursor_protocol, 'ssl|with-openssl' => \$opt_ssl, 'skip-ssl' => \$opt_skip_ssl, 'compress' => \$opt_compress, 'bench' => \$opt_bench, 'small-bench' => \$opt_small_bench, 'with-ndbcluster|ndb' => \$opt_with_ndbcluster, 'vs-config' => \$opt_vs_config, # Control what test suites or cases to run 'force' => \$opt_force, 'with-ndbcluster-only' => \$opt_with_ndbcluster_only, 'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster, 'skip-ndbcluster-slave|skip-ndb-slave' => \$opt_skip_ndbcluster_slave, 'ndb-extra-test' => \$opt_ndb_extra_test, 'skip-master-binlog' => \$opt_skip_master_binlog, 'skip-slave-binlog' => \$opt_skip_slave_binlog, 'do-test=s' => \$opt_do_test, 'start-from=s' => \$opt_start_from, 'suite=s' => \$opt_suite, 'skip-rpl' => \$opt_skip_rpl, 'skip-im' => \$opt_skip_im, 'skip-test=s' => \$opt_skip_test, 'big-test' => \$opt_big_test, # Specify ports 'master_port=i' => \$opt_master_myport, 'slave_port=i' => \$opt_slave_myport, 'ndbcluster-port|ndbcluster_port=i' => \$opt_ndbcluster_port, 'ndbcluster-port-slave=i' => \$opt_ndbcluster_port_slave, 'im-port=i' => \$im_port, # Instance Manager port. 'im-mysqld1-port=i' => \$im_mysqld1_port, # Port of mysqld, controlled by IM 'im-mysqld2-port=i' => \$im_mysqld2_port, # Port of mysqld, controlled by IM 'mtr-build-thread=i' => \$opt_mtr_build_thread, # Test case authoring 'record' => \$opt_record, 'check-testcases' => \$opt_check_testcases, 'mark-progress' => \$opt_mark_progress, # Extra options used when starting mysqld 'mysqld=s' => \@opt_extra_mysqld_opt, # Run test on running server 'extern' => \$opt_extern, 'ndb-connectstring=s' => \$opt_ndbconnectstring, 'ndb-connectstring-slave=s' => \$opt_ndbconnectstring_slave, # Debugging 'gdb' => \$opt_gdb, 'client-gdb' => \$opt_client_gdb, 'manual-gdb' => \$opt_manual_gdb, 'manual-debug' => \$opt_manual_debug, 'ddd' => \$opt_ddd, 'client-ddd' => \$opt_client_ddd, 'manual-ddd' => \$opt_manual_ddd, 'debugger=s' => \$opt_debugger, 'client-debugger=s' => \$opt_client_debugger, 'strace-client' => \$opt_strace_client, 'master-binary=s' => \$exe_master_mysqld, 'slave-binary=s' => \$exe_slave_mysqld, 'max-save-core=i' => \$opt_max_save_core, # Coverage, profiling etc 'gcov' => \$opt_gcov, 'gprof' => \$opt_gprof, 'valgrind|valgrind-all' => \$opt_valgrind, 'valgrind-mysqltest' => \$opt_valgrind_mysqltest, 'valgrind-mysqld' => \$opt_valgrind_mysqld, 'valgrind-options=s' => \$opt_valgrind_options, 'valgrind-path=s' => \$opt_valgrind_path, 'callgrind' => \$opt_callgrind, # Stress testing 'stress' => \$opt_stress, 'stress-suite=s' => \$opt_stress_suite, 'stress-threads=i' => \$opt_stress_threads, 'stress-test-file=s' => \$opt_stress_test_file, 'stress-init-file=s' => \$opt_stress_init_file, 'stress-mode=s' => \$opt_stress_mode, 'stress-loop-count=i' => \$opt_stress_loop_count, 'stress-test-count=i' => \$opt_stress_test_count, 'stress-test-duration=i' => \$opt_stress_test_duration, # Directories 'tmpdir=s' => \$opt_tmpdir, 'vardir=s' => \$opt_vardir, 'benchdir=s' => \$glob_mysql_bench_dir, 'mem' => \$opt_mem, # Misc 'report-features' => \$opt_report_features, 'comment=s' => \$opt_comment, 'debug' => \$opt_debug, 'fast' => \$opt_fast, 'reorder' => \$opt_reorder, 'enable-disabled' => \$opt_enable_disabled, 'script-debug' => \$opt_script_debug, 'verbose' => \$opt_verbose, 'sleep=i' => \$opt_sleep, 'socket=s' => \$opt_socket, 'start-dirty' => \$opt_start_dirty, 'start-and-exit' => \$opt_start_and_exit, 'timer!' => \$opt_timer, 'user=s' => \$opt_user, 'testcase-timeout=i' => \$opt_testcase_timeout, 'suite-timeout=i' => \$opt_suite_timeout, 'warnings|log-warnings' => \$opt_warnings, 'help|h' => \$opt_usage, ) or usage("Can't read options"); usage("") if $opt_usage; $glob_scriptname= basename($0); if ($opt_mtr_build_thread != 0) { set_mtr_build_thread_ports($opt_mtr_build_thread) } elsif ($ENV{'MTR_BUILD_THREAD'}) { $opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'}; } # We require that we are in the "mysql-test" directory # to run mysql-test-run if (! -f $glob_scriptname) { mtr_error("Can't find the location for the mysql-test-run script\n" . "Go to to the mysql-test directory and execute the script " . "as follows:\n./$glob_scriptname"); } if ( -d "../sql" ) { $source_dist= 1; } # Find the absolute path to the test directory $glob_mysql_test_dir= cwd(); if ( $glob_cygwin_perl ) { # Windows programs like 'mysqld' needs Windows paths $glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`; chomp($glob_mysql_test_dir); } # In most cases, the base directory we find everything relative to, # is the parent directory of the "mysql-test" directory. For source # distributions, TAR binary distributions and some other packages. $glob_basedir= dirname($glob_mysql_test_dir); # In the RPM case, binaries and libraries are installed in the # default system locations, instead of having our own private base # directory. And we install "/usr/share/mysql-test". Moving up one # more directory relative to "mysql-test" gives us a usable base # directory for RPM installs. if ( ! $source_dist and ! -d "$glob_basedir/bin" ) { $glob_basedir= dirname($glob_basedir); } # Expect mysql-bench to be located adjacent to the source tree, by default $glob_mysql_bench_dir= "$glob_basedir/../mysql-bench" unless defined $glob_mysql_bench_dir; $glob_mysql_bench_dir= undef unless -d $glob_mysql_bench_dir; $path_my_basedir= $source_dist ? $glob_mysql_test_dir : $glob_basedir; $glob_timers= mtr_init_timers(); # # Find the mysqld executable to be able to find the mysqld version # number as early as possible # # Look for the client binaries directory $path_client_bindir= mtr_path_exists("$glob_basedir/client_release", "$glob_basedir/client_debug", vs_config_dirs('client', ''), "$glob_basedir/client", "$glob_basedir/bin"); if (!$opt_extern) { $exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'), vs_config_dirs('sql', 'mysqld-debug'), "$glob_basedir/sql/mysqld", "$path_client_bindir/mysqld-max-nt", "$path_client_bindir/mysqld-max", "$path_client_bindir/mysqld-nt", "$path_client_bindir/mysqld", "$path_client_bindir/mysqld-debug", "$path_client_bindir/mysqld-max", "$glob_basedir/libexec/mysqld", "$glob_basedir/bin/mysqld", "$glob_basedir/sbin/mysqld"); # Use the mysqld found above to find out what features are available collect_mysqld_features(); } else { $mysqld_variables{'port'}= 3306; $mysqld_variables{'master-port'}= 3306; } if ( $opt_comment ) { print "\n"; print '#' x 78, "\n"; print "# $opt_comment\n"; print '#' x 78, "\n\n"; } foreach my $arg ( @ARGV ) { if ( $arg =~ /^--skip-/ ) { push(@opt_extra_mysqld_opt, $arg); } elsif ( $arg =~ /^--$/ ) { # It is an effect of setting 'pass_through' in option processing # that the lone '--' separating options from arguments survives, # simply ignore it. } elsif ( $arg =~ /^-/ ) { usage("Invalid option \"$arg\""); } else { push(@opt_cases, $arg); } } # -------------------------------------------------------------------------- # Find out type of logging that are being used # -------------------------------------------------------------------------- # NOTE if the default binlog format is changed, this has to be changed $used_binlog_format= "stmt"; if (!$opt_extern && $mysql_version_id >= 50100 ) { $used_binlog_format= "mixed"; # Default value for binlog format foreach my $arg ( @opt_extra_mysqld_opt ) { if ( $arg =~ /binlog-format=(\S+)/ ) { $used_binlog_format= $1; } } mtr_report("Using binlog format '$used_binlog_format'"); } # -------------------------------------------------------------------------- # Find out default storage engine being used(if any) # -------------------------------------------------------------------------- if ( $opt_with_ndbcluster ) { # --ndb or --with-ndbcluster turns on --default-storage-engine=ndbcluster push(@opt_extra_mysqld_opt, "--default-storage-engine=ndbcluster"); } foreach my $arg ( @opt_extra_mysqld_opt ) { if ( $arg =~ /default-storage-engine=(\S+)/ ) { $used_default_engine= $1; } } mtr_report("Using default engine '$used_default_engine'") if defined $used_default_engine; # -------------------------------------------------------------------------- # Check if we should speed up tests by trying to run on tmpfs # -------------------------------------------------------------------------- if ( defined $opt_mem ) { mtr_error("Can't use --mem and --vardir at the same time ") if $opt_vardir; mtr_error("Can't use --mem and --tmpdir at the same time ") if $opt_tmpdir; # Search through list of locations that are known # to be "fast disks" to list to find a suitable location # Use --mem=<dir> as first location to look. my @tmpfs_locations= ($opt_mem, "/dev/shm", "/tmp"); foreach my $fs (@tmpfs_locations) { if ( -d $fs ) { mtr_report("Using tmpfs in $fs"); $opt_mem= "$fs/var"; $opt_mem .= $opt_mtr_build_thread if $opt_mtr_build_thread; last; } } } # -------------------------------------------------------------------------- # Set the "var/" directory, as it is the base for everything else # -------------------------------------------------------------------------- $default_vardir= "$glob_mysql_test_dir/var"; if ( ! $opt_vardir ) { $opt_vardir= $default_vardir; } elsif ( $mysql_version_id < 50000 and $opt_vardir ne $default_vardir) { # Version 4.1 and --vardir was specified
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -