📄 mtr
字号:
# Only supported as a symlink from var/ # by setting up $opt_mem that symlink will be created if ( ! $glob_win32 ) { # Only platforms that have native symlinks can use the vardir trick $opt_mem= $opt_vardir; mtr_report("Using 4.1 vardir trick"); } $opt_vardir= $default_vardir; } $path_vardir_trace= $opt_vardir; # Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/... $path_vardir_trace=~ s/^\w://; # We make the path absolute, as the server will do a chdir() before usage unless ( $opt_vardir =~ m,^/, or ($glob_win32 and $opt_vardir =~ m,^[a-z]:/,i) ) { # Make absolute path, relative test dir $opt_vardir= "$glob_mysql_test_dir/$opt_vardir"; } # -------------------------------------------------------------------------- # Set tmpdir # -------------------------------------------------------------------------- $opt_tmpdir= "$opt_vardir/tmp" unless $opt_tmpdir; $opt_tmpdir =~ s,/+$,,; # Remove ending slash if any # -------------------------------------------------------------------------- # Check im suport # -------------------------------------------------------------------------- if ($opt_extern) { mtr_report("Disable instance manager when running with extern mysqld"); $opt_skip_im= 1; } elsif ( $mysql_version_id < 50000 ) { # Instance manager is not supported until 5.0 $opt_skip_im= 1; } elsif ( $glob_win32 ) { mtr_report("Disable Instance manager - testing not supported on Windows"); $opt_skip_im= 1; } # -------------------------------------------------------------------------- # Record flag # -------------------------------------------------------------------------- if ( $opt_record and ! @opt_cases ) { mtr_error("Will not run in record mode without a specific test case"); } # -------------------------------------------------------------------------- # Embedded server flag # -------------------------------------------------------------------------- if ( $opt_embedded_server ) { $glob_use_embedded_server= 1; push(@glob_test_mode, "embedded"); $opt_skip_rpl= 1; # We never run replication with embedded $opt_skip_ndbcluster= 1; # Turn off use of NDB cluster $opt_skip_ssl= 1; # Turn off use of SSL # Turn off use of bin log push(@opt_extra_mysqld_opt, "--skip-log-bin"); if ( $opt_extern ) { mtr_error("Can't use --extern with --embedded-server"); } } # -------------------------------------------------------------------------- # ps protcol flag # -------------------------------------------------------------------------- if ( $opt_ps_protocol ) { push(@glob_test_mode, "ps-protocol"); } # -------------------------------------------------------------------------- # Ndb cluster flags # -------------------------------------------------------------------------- if ( $opt_ndbconnectstring ) { $glob_use_running_ndbcluster= 1; mtr_error("Can't specify --ndb-connectstring and --skip-ndbcluster") if $opt_skip_ndbcluster; mtr_error("Can't specify --ndb-connectstring and --ndbcluster-port") if $opt_ndbcluster_port; } else { # Set default connect string $opt_ndbconnectstring= "host=localhost:$opt_ndbcluster_port"; } if ( $opt_ndbconnectstring_slave ) { $glob_use_running_ndbcluster_slave= 1; mtr_error("Can't specify ndb-connectstring_slave and " . "--skip-ndbcluster-slave") if $opt_skip_ndbcluster; mtr_error("Can't specify --ndb-connectstring-slave and " . "--ndbcluster-port-slave") if $opt_ndbcluster_port_slave; } else { # Set default connect string $opt_ndbconnectstring_slave= "host=localhost:$opt_ndbcluster_port_slave"; } # -------------------------------------------------------------------------- # Bench flags # -------------------------------------------------------------------------- if ( $opt_small_bench ) { $opt_bench= 1; } # -------------------------------------------------------------------------- # Big test flags # -------------------------------------------------------------------------- if ( $opt_big_test ) { $ENV{'BIG_TEST'}= 1; } # -------------------------------------------------------------------------- # Gcov flag # -------------------------------------------------------------------------- if ( $opt_gcov and ! $source_dist ) { mtr_error("Coverage test needs the source - please use source dist"); } # -------------------------------------------------------------------------- # Check debug related options # -------------------------------------------------------------------------- if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd || $opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug || $opt_debugger || $opt_client_debugger ) { # Indicate that we are using debugger $glob_debugger= 1; if ( $opt_extern ) { mtr_error("Can't use --extern when using debugger"); } } # -------------------------------------------------------------------------- # Check if special exe was selected for master or slave # -------------------------------------------------------------------------- $exe_master_mysqld= $exe_master_mysqld || $exe_mysqld; $exe_slave_mysqld= $exe_slave_mysqld || $exe_mysqld; # -------------------------------------------------------------------------- # Check valgrind arguments # -------------------------------------------------------------------------- if ( $opt_valgrind or $opt_valgrind_path or defined $opt_valgrind_options) { mtr_report("Turning on valgrind for all executables"); $opt_valgrind= 1; $opt_valgrind_mysqld= 1; $opt_valgrind_mysqltest= 1; } elsif ( $opt_valgrind_mysqld ) { mtr_report("Turning on valgrind for mysqld(s) only"); $opt_valgrind= 1; } elsif ( $opt_valgrind_mysqltest ) { mtr_report("Turning on valgrind for mysqltest and mysql_client_test only"); $opt_valgrind= 1; } if ( $opt_callgrind ) { mtr_report("Turning on valgrind with callgrind for mysqld(s)"); $opt_valgrind= 1; $opt_valgrind_mysqld= 1; # Set special valgrind options unless options passed on command line $opt_valgrind_options="--trace-children=yes" unless defined $opt_valgrind_options; } if ( $opt_valgrind ) { # Set valgrind_options to default unless already defined $opt_valgrind_options=$default_valgrind_options unless defined $opt_valgrind_options; mtr_report("Running valgrind with options \"$opt_valgrind_options\""); } if ( ! $opt_testcase_timeout ) { $opt_testcase_timeout= $default_testcase_timeout; $opt_testcase_timeout*= 10 if $opt_valgrind; } if ( ! $opt_suite_timeout ) { $opt_suite_timeout= $default_suite_timeout; $opt_suite_timeout*= 6 if $opt_valgrind; } if ( ! $opt_user ) { if ( $opt_extern ) { $opt_user= "test"; } else { $opt_user= "root"; # We want to do FLUSH xxx commands } } # On QNX, /tmp/dir/master.sock and /tmp/dir//master.sock seem to be # considered different, so avoid the extra slash (/) in the socket # paths. my $sockdir = $opt_tmpdir; $sockdir =~ s|/+$||; # On some operating systems, there is a limit to the length of a # UNIX domain socket's path far below PATH_MAX, so try to avoid long # socket path names. $sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) >= 70 ); $master->[0]= { pid => 0, type => "master", idx => 0, path_myddir => "$opt_vardir/master-data", path_myerr => "$opt_vardir/log/master.err", path_pid => "$opt_vardir/run/master.pid", path_sock => "$sockdir/master.sock", port => $opt_master_myport, start_timeout => 400, # enough time create innodb tables cluster => 0, # index in clusters list start_opts => [], }; $master->[1]= { pid => 0, type => "master", idx => 1, path_myddir => "$opt_vardir/master1-data", path_myerr => "$opt_vardir/log/master1.err", path_pid => "$opt_vardir/run/master1.pid", path_sock => "$sockdir/master1.sock", port => $opt_master_myport + 1, start_timeout => 400, # enough time create innodb tables cluster => 0, # index in clusters list start_opts => [], }; $slave->[0]= { pid => 0, type => "slave", idx => 0, path_myddir => "$opt_vardir/slave-data", path_myerr => "$opt_vardir/log/slave.err", path_pid => "$opt_vardir/run/slave.pid", path_sock => "$sockdir/slave.sock", port => $opt_slave_myport, start_timeout => 400, cluster => 1, # index in clusters list start_opts => [], }; $slave->[1]= { pid => 0, type => "slave", idx => 1, path_myddir => "$opt_vardir/slave1-data", path_myerr => "$opt_vardir/log/slave1.err", path_pid => "$opt_vardir/run/slave1.pid", path_sock => "$sockdir/slave1.sock", port => $opt_slave_myport + 1, start_timeout => 300, cluster => -1, # index in clusters list start_opts => [], }; $slave->[2]= { pid => 0, type => "slave", idx => 2, path_myddir => "$opt_vardir/slave2-data", path_myerr => "$opt_vardir/log/slave2.err", path_pid => "$opt_vardir/run/slave2.pid", path_sock => "$sockdir/slave2.sock", port => $opt_slave_myport + 2, start_timeout => 300, cluster => -1, # index in clusters list start_opts => [], }; $instance_manager= { path_err => "$opt_vardir/log/im.err", path_log => "$opt_vardir/log/im.log", path_pid => "$opt_vardir/run/im.pid", path_angel_pid => "$opt_vardir/run/im.angel.pid", path_sock => "$sockdir/im.sock", port => $im_port, start_timeout => $master->[0]->{'start_timeout'}, admin_login => 'im_admin', admin_password => 'im_admin_secret', admin_sha1 => '*598D51AD2DFF7792045D6DF3DDF9AA1AF737B295', password_file => "$opt_vardir/im.passwd", defaults_file => "$opt_vardir/im.cnf", }; $instance_manager->{'instances'}->[0]= { server_id => 1, port => $im_mysqld1_port, path_datadir => "$opt_vardir/im_mysqld_1.data", path_sock => "$sockdir/mysqld_1.sock", path_pid => "$opt_vardir/run/mysqld_1.pid", start_timeout => 400, # enough time create innodb tables old_log_format => 1 }; $instance_manager->{'instances'}->[1]= { server_id => 2, port => $im_mysqld2_port, path_datadir => "$opt_vardir/im_mysqld_2.data", path_sock => "$sockdir/mysqld_2.sock", path_pid => "$opt_vardir/run/mysqld_2.pid", nonguarded => 1, start_timeout => 400, # enough time create innodb tables old_log_format => 1 }; my $data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port"; $clusters->[0]= { name => "Master", nodes => 2, port => "$opt_ndbcluster_port", data_dir => "$data_dir", connect_string => "$opt_ndbconnectstring", path_pid => "$data_dir/ndb_3.pid", # Nodes + 1 pid => 0, # pid of ndb_mgmd installed_ok => 0, }; $data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port_slave"; $clusters->[1]= { name => "Slave", nodes => 1, port => "$opt_ndbcluster_port_slave", data_dir => "$data_dir", connect_string => "$opt_ndbconnectstring_slave", path_pid => "$data_dir/ndb_2.pid", # Nodes + 1 pid => 0, # pid of ndb_mgmd installed_ok => 0, }; # Init pids of ndbd's foreach my $cluster ( @{$clusters} ) { for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ ) { my $nodeid= $idx+1; $cluster->{'ndbds'}->[$idx]= { pid => 0, nodeid => $nodeid, path_pid => "$cluster->{'data_dir'}/ndb_${nodeid}.pid", path_fs => "$cluster->{'data_dir'}/ndb_${nodeid}_fs", }; } } if ( $opt_extern ) { # Turn off features not supported when running with extern server $opt_skip_rpl= 1; $opt_skip_ndbcluster= 1; # Setup master->[0] with the settings for the extern server $master->[0]->{'path_sock'}= $opt_socket ? $opt_socket : "/tmp/mysql.sock"; mtr_report("Using extern server at '$master->[0]->{path_sock}'"); } else { mtr_error("--socket can only be used in combination with --extern") if $opt_socket; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -