📄 mysql-test-run-shell
字号:
--character-sets-dir=$CHARSETSDIR \ --default-character-set=$CHARACTER_SET \ --tmpdir=$MYSQL_TMP_DIR \ --language=$LANGUAGE \ --innodb_data_file_path=ibdata1:128M:autoextend \ --open-files-limit=1024 \ --log-bin-trust-function-creators \ $MASTER_40_ARGS \ $SMALL_SERVER \ $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT \ $NOT_FIRST_MASTER_EXTRA_OPTS $CURR_MASTER_MYSQLD_TRACE" else master_args="--no-defaults --log-bin=$MYSQL_TEST_DIR/var/log/master-bin$1 \ --server-id=$id --rpl-recovery-rank=1 \ --basedir=$MY_BASEDIR --init-rpl-role=master \ --port=$this_master_myport \ --port-open-timeout=380 \ --local-infile \ --datadir=$MASTER_MYDDIR$1 \ --pid-file=$MASTER_MYPID$1 \ --socket=$MASTER_MYSOCK$1 \ --character-sets-dir=$CHARSETSDIR \ --default-character-set=$CHARACTER_SET \ --core \ $USE_NDBCLUSTER \ --tmpdir=$MYSQL_TMP_DIR \ --language=$LANGUAGE \ --innodb_data_file_path=ibdata1:128M:autoextend \ --log-bin-trust-function-creators \ $MASTER_40_ARGS \ $SMALL_SERVER \ $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT \ $NOT_FIRST_MASTER_EXTRA_OPTS" fi CUR_MYERR=$MASTER_MYERR$1 CUR_MYSOCK=$MASTER_MYSOCK$1 # For embedded server we collect the server flags and return if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then # Add a -A to each argument to pass it to embedded server EMBEDDED_SERVER_OPTS="" for opt in $master_args do EMBEDDED_SERVER_OPTS="$EMBEDDED_SERVER_OPTS -A $opt" done EXTRA_MYSQL_TEST_OPT="$EMBEDDED_SERVER_OPTS" return fi if [ x$DO_DDD = x1 ] then $ECHO "set args $master_args" > $GDB_MASTER_INIT$1 manager_launch master ddd -display $DISPLAY --debugger \ "gdb -x $GDB_MASTER_INIT$1" $MASTER_MYSQLD elif [ x$DO_GDB = x1 ] then if [ x$MANUAL_GDB = x1 ] then $ECHO "set args $master_args" > $GDB_MASTER_INIT$1 $ECHO "To start gdb for the master , type in another window:" $ECHO "cd $MYSQL_TEST_DIR ; gdb -x $GDB_MASTER_INIT$1 $MASTER_MYSQLD" wait_for_master=1500 else ( $ECHO set args $master_args; if [ $USE_MANAGER = 0 ] ; then cat <<EOFb mysql_parsecommands 1disa 1endrEOF fi ) > $GDB_MASTER_INIT$1 manager_launch master $XTERM -display $DISPLAY \ -title "Master" -e gdb -x $GDB_MASTER_INIT$1 $MASTER_MYSQLD fi else manager_launch master $MASTER_MYSQLD $master_args fi sleep_until_file_created $MASTER_MYPID$1 $wait_for_master wait_for_master=$SLEEP_TIME_FOR_SECOND_MASTER eval "MASTER$1_RUNNING=1"}start_slave(){ [ x$SKIP_SLAVE = x1 ] && return eval "this_slave_running=\$SLAVE$1_RUNNING" [ x$this_slave_running = 1 ] && return # When testing fail-safe replication, we will have more than one slave # in this case, we start secondary slaves with an argument slave_ident="slave$1" if [ -n "$1" ] ; then slave_server_id=`$EXPR 2 + $1` slave_rpl_rank=$slave_server_id slave_port=`expr $SLAVE_MYPORT + $1` slave_log="$SLAVE_MYLOG.$1" slave_err="$SLAVE_MYERR.$1" slave_datadir="$SLAVE_MYDDIR/../$slave_ident-data/" slave_pid="$MYRUN_DIR/mysqld-$slave_ident.pid" slave_sock="$SLAVE_MYSOCK-$1" else slave_server_id=2 slave_rpl_rank=2 slave_port=$SLAVE_MYPORT slave_log=$SLAVE_MYLOG slave_err=$SLAVE_MYERR slave_datadir=$SLAVE_MYDDIR slave_pid=$SLAVE_MYPID slave_sock="$SLAVE_MYSOCK" fi # Remove stale binary logs and old master.info files # except for too tests which need them if [ "$tname" != "rpl_crash_binlog_ib_1b" ] && [ "$tname" != "rpl_crash_binlog_ib_2b" ] && [ "$tname" != "rpl_crash_binlog_ib_3b" ] then $RM -f $MYSQL_TEST_DIR/var/log/$slave_ident-*bin.* $RM -f $slave_datadir/master.info $slave_datadir/relay-log.info fi #run slave initialization shell script if one exists if [ -f "$slave_init_script" ] ; then /bin/sh $slave_init_script fi if [ -z "$SLAVE_MASTER_INFO" ] ; then master_info="--master-user=root \ --master-connect-retry=1 \ --master-host=127.0.0.1 \ --master-password="" \ --master-port=$MASTER_MYPORT \ --server-id=$slave_server_id --rpl-recovery-rank=$slave_rpl_rank" else master_info=$SLAVE_MASTER_INFO fi $RM -f $slave_datadir/log.* slave_args="--no-defaults $master_info \ --exit-info=256 \ --log-bin=$MYSQL_TEST_DIR/var/log/$slave_ident-bin \ --relay-log=$MYSQL_TEST_DIR/var/log/$slave_ident-relay-bin \ --log-slave-updates \ --log=$slave_log \ --basedir=$MY_BASEDIR \ --datadir=$slave_datadir \ --pid-file=$slave_pid \ --port=$slave_port \ --port-open-timeout=380 \ --socket=$slave_sock \ --character-sets-dir=$CHARSETSDIR \ --default-character-set=$CHARACTER_SET \ --core --init-rpl-role=slave \ --tmpdir=$MYSQL_TMP_DIR \ --language=$LANGUAGE \ --skip-innodb --skip-ndbcluster --skip-slave-start \ --slave-load-tmpdir=$SLAVE_LOAD_TMPDIR \ --report-host=127.0.0.1 --report-user=root \ --report-port=$slave_port \ --master-retry-count=10 \ -O slave_net_timeout=10 \ --log-bin-trust-function-creators \ $SMALL_SERVER \ $EXTRA_SLAVE_OPT $EXTRA_SLAVE_MYSQLD_OPT" CUR_MYERR=$slave_err CUR_MYSOCK=$slave_sock if [ x$DO_DDD = x1 ] then $ECHO "set args $slave_args" > $GDB_SLAVE_INIT manager_launch $slave_ident ddd -display $DISPLAY --debugger \ "gdb -x $GDB_SLAVE_INIT" $SLAVE_MYSQLD elif [ x$DO_GDB = x1 ] then if [ x$MANUAL_GDB = x1 ] then $ECHO "set args $slave_args" > $GDB_SLAVE_INIT echo "To start gdb for the slave, type in another window:" echo "cd $MYSQL_TEST_DIR ; gdb -x $GDB_SLAVE_INIT $SLAVE_MYSQLD" wait_for_slave=1500 else ( $ECHO set args $slave_args; if [ $USE_MANAGER = 0 ] ; then cat <<EOFb mysql_parsecommands 1disa 1endrEOF fi ) > $GDB_SLAVE_INIT manager_launch $slave_ident $XTERM -display $DISPLAY -title "Slave" -e \ gdb -x $GDB_SLAVE_INIT $SLAVE_MYSQLD fi else manager_launch $slave_ident $SLAVE_MYSQLD $slave_args fi eval "SLAVE$1_RUNNING=1" sleep_until_file_created $slave_pid $wait_for_slave wait_for_slave=$SLEEP_TIME_FOR_SECOND_SLAVE}mysql_start (){# We should not start the daemon here as we don't know the arguments# for the test. Better to let the test start the daemon# $ECHO "Starting MySQL daemon"# start_master# start_slave cd $MYSQL_TEST_DIR start_ndbcluster return 1}stop_slave (){ eval "this_slave_running=\$SLAVE$1_RUNNING" slave_ident="slave$1" if [ -n "$1" ] ; then slave_pid="$MYRUN_DIR/mysqld-$slave_ident.pid" else slave_pid=$SLAVE_MYPID fi if [ x$this_slave_running = x1 ] then pid=`$CAT $slave_pid` manager_term $pid $slave_ident if [ $? != 0 ] && [ -f $slave_pid ] then # try harder! $ECHO "slave not cooperating with mysqladmin, will try manual kill" kill $pid sleep_until_file_deleted $pid $slave_pid if [ -f $slave_pid ] ; then $ECHO "slave refused to die. Sending SIGKILL" kill -9 `$CAT $slave_pid` $RM -f $slave_pid else $ECHO "slave responded to SIGTERM " fi else sleep $SLEEP_TIME_AFTER_RESTART fi eval "SLAVE$1_RUNNING=0" fi}stop_slave_threads (){ eval "this_slave_running=\$SLAVE$1_RUNNING" slave_ident="slave$1" if [ x$this_slave_running = x1 ] then $MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$slave_ident.sock stop-slave > /dev/null 2>&1 fi}stop_master (){ eval "this_master_running=\$MASTER$1_RUNNING" if [ x$this_master_running = x1 ] then # For embedded server we don't stop anyting but mark that # MASTER_RUNNING=0 to get cleanup when calling start_master(). if [ x$USE_EMBEDDED_SERVER != x1 ] ; then pid=`$CAT $MASTER_MYPID$1` manager_term $pid master $1 if [ $? != 0 ] && [ -f $MASTER_MYPID$1 ] then # try harder! $ECHO "master not cooperating with mysqladmin, will try manual kill" kill $pid sleep_until_file_deleted $pid $MASTER_MYPID$1 if [ -f $MASTER_MYPID$1 ] ; then $ECHO "master refused to die. Sending SIGKILL" kill -9 `$CAT $MASTER_MYPID$1` $RM -f $MASTER_MYPID$1 else $ECHO "master responded to SIGTERM " fi else sleep $SLEEP_TIME_AFTER_RESTART fi fi eval "MASTER$1_RUNNING=0" fi}mysql_stop (){ if [ "$MASTER_RUNNING" = 1 ] then $ECHO "Ending Tests" $ECHO "Shutting-down MySQL daemon" $ECHO "" stop_master stop_master 1 $ECHO "Master shutdown finished" stop_slave stop_slave 1 stop_slave 2 $ECHO "Slave shutdown finished" stop_ndbcluster fi return 1}mysql_restart (){ mysql_stop mysql_start return 1}mysql_loadstd () { # cp $STD_DATA/*.frm $STD_DATA/*.MRG $MASTER_MYDDIR/test return 1}run_testcase (){ tf=$1 tname=`$BASENAME $tf .test` master_opt_file=$TESTDIR/$tname-master.opt slave_opt_file=$TESTDIR/$tname-slave.opt master_init_script=$TESTDIR/$tname-master.sh slave_init_script=$TESTDIR/$tname-slave.sh slave_master_info_file=$TESTDIR/$tname.slave-mi tsrcdir=$TESTDIR/$tname-src result_file="r/$tname.result" echo $tname > $CURRENT_TEST SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0 \& \( $tname : federated \) = 0` NDBCLUSTER_TEST=`$EXPR \( $tname : '.*ndb.*' \) != 0` if [ "x$USE_NDBCLUSTER_ONLY" = "x1" -a "x$NDBCLUSTER_TEST" != "x1" ] ; then skip_test $tname return fi if [ "$USE_MANAGER" = 1 ] ; then many_slaves=`$EXPR \( \( $tname : rpl_failsafe \) != 0 \) \| \( \( $tname : rpl_chain_temp_table \) != 0 \)` fi if $EXPR "$tname" '<' "$START_FROM" > /dev/null ; then #skip_test $tname return fi if [ "$SKIP_TEST" ] ; then if $EXPR \( "$tname" : "$SKIP_TEST" \) > /dev/null ; then skip_test $tname return fi fi if [ "$DO_TEST" ] ; then if $EXPR \( "$tname" : "$DO_TEST" \) > /dev/null ; then : #empty command to keep some shells happy else #skip_test $tname return fi fi if [ x${NO_SLAVE}x$SKIP_SLAVE = x1x0 ] ; then skip_test $tname return fi# if [ -f "$TESTDIR/$tname.disabled" ]# then# comment=`$CAT $TESTDIR/$tname.disabled`;# disable_test $tname "$comment"# return# fi if [ -f "$TESTDIR/disabled.def" ] ; then comment=`$GREP "^$tname *: *" $TESTDIR/disabled.def`; if [ -n "$comment" ] then comment=`echo $comment | sed 's/^[^:]*: *//'` disable_test $tname "$comment" return fi fi if [ "x$USE_EMBEDDED_SERVER" != "x1" ] ; then # Stop all slave threads, so that we don't have useless reconnection # attempts and error messages in case the slave and master servers restart. stop_slave_threads stop_slave_threads 1 stop_slave_threads 2 fi # FIXME temporary solution, we will get a new C version of this # script soon anyway so it is not worth it spending the time if [ "x$USE_EMBEDDED_SERVER" = "x1" -a -z "$DO_TEST" ] ; then for t in \ "init_connect" \ "init_file" do if [ "$tname" = "$t" ] ; then skip_test $tname return fi done fi if [ $USE_RUNNING_SERVER -eq 0 ] ; then if [ -f $master_opt_file ] ; then EXTRA_MASTER_OPT=`$CAT $master_opt_file | $SED -e "s;\\$MYSQL_TEST_DIR;$MYSQL_TEST_DIR;"` case "$EXTRA_MASTER_OPT" in --timezone=*) TZ=`$ECHO "$EXTRA_MASTER_OPT" | $SED -e "s;--timezone=;;"` export TZ # Note that this must be set to space, not "" for test-reset to work EXTRA_MASTER_OPT=" " ;; --result-file=*) result_file=`$ECHO "$EXTRA_MASTER_OPT" | $SED -e "s;--result-file=;;"` result_file="r/$result_file.result" # Note that this must be set to space, not "" for test-reset to work EXTRA_MASTER_OPT=" " ;; --force-restart) # Note that this must be set to space, not "" for test-reset to work EXTRA_MASTER_OPT=" " ;; esac stop_master stop_master 1 report_current_test $tname start_master if [ -n "$USE_NDBCLUSTER" -a -z "$DO_BENCH" -a -z "$DO_STRESS" ] ; then start_master 1 fi TZ=$MY_TZ; export TZ else # If we had extra master opts to the previous run # or there is no master running (FIXME strange.....) # or there is a master init script if [ ! -z "$EXTRA_MASTER_OPT" ] || [ x$MASTER_RUNNING != x1 ] || \ [ -f $master_init_script ] then EXTRA_MASTER_OPT="" stop_master stop_master 1 report_current_test $tname
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -