Commit db2e22bf authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Portability fixes.

Changed mysql-test-run.sh to test for files to get shorter, more reliable timeouts.
parent 6b02f13c
...@@ -13636,7 +13636,6 @@ connection between a MySQL server and a MySQL client. ...@@ -13636,7 +13636,6 @@ connection between a MySQL server and a MySQL client.
If you are using MySQL 4.0, you can also use internal openssl support. If you are using MySQL 4.0, you can also use internal openssl support.
@xref{Secure connections}. @xref{Secure connections}.
To make a MySQL system secure, you should strongly consider the To make a MySQL system secure, you should strongly consider the
following suggestions: following suggestions:
...@@ -13652,8 +13651,7 @@ this: ...@@ -13652,8 +13651,7 @@ this:
@example @example
shell> mysql -u root mysql shell> mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('new_password') mysql> UPDATE user SET Password=PASSWORD('new_password') WHERE user='root';
WHERE user='root';
mysql> FLUSH PRIVILEGES; mysql> FLUSH PRIVILEGES;
@end example @end example
...@@ -15395,17 +15393,17 @@ password using the @code{PASSWORD()} function): ...@@ -15395,17 +15393,17 @@ password using the @code{PASSWORD()} function):
@example @example
shell> mysql -u root mysql shell> mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('new_password') mysql> SET PASSWORD FOR root@@localhost=PASSWORD('new_password');
WHERE user='root';
mysql> FLUSH PRIVILEGES;
@end example @end example
You can, in MySQL Version 3.22 and above, use the @code{SET PASSWORD} If you know what you are doing, you can also directly manipulate the
statement: privilege tables:
@example @example
shell> mysql -u root mysql shell> mysql -u root mysql
mysql> SET PASSWORD FOR root=PASSWORD('new_password'); mysql> UPDATE user SET Password=PASSWORD('new_password')
WHERE user='root';
mysql> FLUSH PRIVILEGES;
@end example @end example
Another way to set the password is by using the @code{mysqladmin} command: Another way to set the password is by using the @code{mysqladmin} command:
...@@ -75,17 +75,21 @@ ...@@ -75,17 +75,21 @@
#define MAX_EXPECTED_ERRORS 10 #define MAX_EXPECTED_ERRORS 10
#define QUERY_SEND 1 #define QUERY_SEND 1
#define QUERY_REAP 2 #define QUERY_REAP 2
#define CON_RETRY_SLEEP 1 /* how long to sleep before trying to connect again*/
#define MAX_CON_TRIES 2 /* sometimes in a test the client starts before
* the server - to solve the problem, we try again
* after some sleep if connection fails the first
* time */
#ifndef MYSQL_MANAGER_PORT #ifndef MYSQL_MANAGER_PORT
#define MYSQL_MANAGER_PORT 23546 #define MYSQL_MANAGER_PORT 23546
#endif #endif
/*
Sometimes in a test the client starts before
the server - to solve the problem, we try again
after some sleep if connection fails the first
time
*/
#define CON_RETRY_SLEEP 2
#define MAX_CON_TRIES 5
enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD, enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD,
OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT}; OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT};
static int record = 0, verbose = 0, silent = 0, opt_sleep=0; static int record = 0, verbose = 0, silent = 0, opt_sleep=0;
static char *db = 0, *pass=0; static char *db = 0, *pass=0;
......
...@@ -43,6 +43,39 @@ which () ...@@ -43,6 +43,39 @@ which ()
} }
sleep_until_file_deleted ()
{
file=$1
loop=$SLEEP_TIME
while (test $loop -gt 0)
do
sleep 1
if [ ! -f $file ]
then
return
fi
loop=`expr $loop - 1`
done
}
sleep_until_file_exists ()
{
file=$1
loop=60 # Should be long enough enough for all cases
while (test $loop -gt 0)
do
sleep 1
if [ -f $file ]
then
return
fi
loop=`expr $loop - 1`
done
echo "ERROR: $file was not created in 60 seconds; Aborting"
exit 1;
}
# No paths below as we can't be sure where the program is! # No paths below as we can't be sure where the program is!
BASENAME=`which basename | head -1` BASENAME=`which basename | head -1`
...@@ -91,7 +124,7 @@ else ...@@ -91,7 +124,7 @@ else
BINARY_DIST=1 BINARY_DIST=1
fi fi
#BASEDIR is always one above mysql-test directory #BASEDIR is always one above mysql-test directory
CWD=`pwd` CWD=`pwd`
cd .. cd ..
BASEDIR=`pwd` BASEDIR=`pwd`
...@@ -101,7 +134,7 @@ export MYSQL_TEST_DIR ...@@ -101,7 +134,7 @@ export MYSQL_TEST_DIR
STD_DATA=$MYSQL_TEST_DIR/std_data STD_DATA=$MYSQL_TEST_DIR/std_data
hostname=`hostname` # Installed in the mysql privilege table hostname=`hostname` # Installed in the mysql privilege table
MANAGER_QUIET_OPT="-q" MANAGER_QUIET_OPT="-q"
TESTDIR="$MYSQL_TEST_DIR/t" TESTDIR="$MYSQL_TEST_DIR/t"
TESTSUFFIX=test TESTSUFFIX=test
TOT_SKIP=0 TOT_SKIP=0
...@@ -139,7 +172,7 @@ DO_GCOV="" ...@@ -139,7 +172,7 @@ DO_GCOV=""
DO_GDB="" DO_GDB=""
DO_DDD="" DO_DDD=""
DO_CLIENT_GDB="" DO_CLIENT_GDB=""
SLEEP_TIME=2 SLEEP_TIME=10
CHARACTER_SET=latin1 CHARACTER_SET=latin1
DBUSER="" DBUSER=""
START_WAIT_TIMEOUT=3 START_WAIT_TIMEOUT=3
...@@ -176,7 +209,7 @@ while test $# -gt 0; do ...@@ -176,7 +209,7 @@ while test $# -gt 0; do
;; ;;
--start-and-exit) --start-and-exit)
START_AND_EXIT=1 START_AND_EXIT=1
;; ;;
--skip-innobase) --skip-innobase)
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-innobase" EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-innobase"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-innobase" ;; EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-innobase" ;;
...@@ -195,7 +228,7 @@ while test $# -gt 0; do ...@@ -195,7 +228,7 @@ while test $# -gt 0; do
--bench) --bench)
DO_BENCH=1 DO_BENCH=1
NO_SLAVE=1 NO_SLAVE=1
;; ;;
--big*) # Actually --big-test --big*) # Actually --big-test
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;; EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;;
--compress) --compress)
...@@ -218,7 +251,7 @@ while test $# -gt 0; do ...@@ -218,7 +251,7 @@ while test $# -gt 0; do
;; ;;
--gprof ) --gprof )
DO_GPROF=1 DO_GPROF=1
;; ;;
--gdb ) --gdb )
START_WAIT_TIMEOUT=300 START_WAIT_TIMEOUT=300
STOP_WAIT_TIMEOUT=300 STOP_WAIT_TIMEOUT=300
...@@ -249,7 +282,7 @@ while test $# -gt 0; do ...@@ -249,7 +282,7 @@ while test $# -gt 0; do
;; ;;
--strace-client ) --strace-client )
STRACE_CLIENT=1 STRACE_CLIENT=1
;; ;;
--debug) --debug)
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT \ EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT \
--debug=d:t:i:O,$MYSQL_TEST_DIR/var/log/master.trace" --debug=d:t:i:O,$MYSQL_TEST_DIR/var/log/master.trace"
...@@ -292,7 +325,7 @@ if [ x$SOURCE_DIST = x1 ] ; then ...@@ -292,7 +325,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
MY_BASEDIR=$MYSQL_TEST_DIR MY_BASEDIR=$MYSQL_TEST_DIR
else else
MY_BASEDIR=$BASEDIR MY_BASEDIR=$BASEDIR
fi fi
# Create the directories # Create the directories
...@@ -321,7 +354,7 @@ if [ x$SOURCE_DIST = x1 ] ; then ...@@ -321,7 +354,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
if [ -n "$STRACE_CLIENT" ]; then if [ -n "$STRACE_CLIENT" ]; then
MYSQL_TEST="strace -o $MYSQL_TEST_DIR/var/log/mysqltest.strace $MYSQL_TEST" MYSQL_TEST="strace -o $MYSQL_TEST_DIR/var/log/mysqltest.strace $MYSQL_TEST"
fi fi
MYSQLADMIN="$BASEDIR/client/mysqladmin" MYSQLADMIN="$BASEDIR/client/mysqladmin"
MYSQL_MANAGER_CLIENT="$BASEDIR/client/mysqlmanagerc" MYSQL_MANAGER_CLIENT="$BASEDIR/client/mysqlmanagerc"
MYSQL_MANAGER="$BASEDIR/tools/mysqlmanager" MYSQL_MANAGER="$BASEDIR/tools/mysqlmanager"
...@@ -339,7 +372,7 @@ else ...@@ -339,7 +372,7 @@ else
MYSQL_MANAGER_PWGEN="$BASEDIR/bin/mysqlmanager-pwgen" MYSQL_MANAGER_PWGEN="$BASEDIR/bin/mysqlmanager-pwgen"
MYSQL="$BASEDIR/bin/mysql" MYSQL="$BASEDIR/bin/mysql"
INSTALL_DB="./install_test_db -bin" INSTALL_DB="./install_test_db -bin"
if test -d "$BASEDIR/share/mysql/english" if test -d "$BASEDIR/share/mysql/english"
then then
LANGUAGE="$BASEDIR/share/mysql/english/" LANGUAGE="$BASEDIR/share/mysql/english/"
CHARSETSDIR="$BASEDIR/share/mysql/charsets" CHARSETSDIR="$BASEDIR/share/mysql/charsets"
...@@ -409,12 +442,12 @@ show_failed_diff () ...@@ -409,12 +442,12 @@ show_failed_diff ()
reject_file=r/$1.reject reject_file=r/$1.reject
result_file=r/$1.result result_file=r/$1.result
eval_file=r/$1.eval eval_file=r/$1.eval
if [ -f $eval_file ] if [ -f $eval_file ]
then then
result_file=$eval_file result_file=$eval_file
fi fi
if [ -x "$DIFF" ] && [ -f $reject_file ] if [ -x "$DIFF" ] && [ -f $reject_file ]
then then
echo "Below are the diffs between actual and expected results:" echo "Below are the diffs between actual and expected results:"
...@@ -424,7 +457,7 @@ show_failed_diff () ...@@ -424,7 +457,7 @@ show_failed_diff ()
echo "Please follow the instructions outlined at" echo "Please follow the instructions outlined at"
echo "http://www.mysql.com/doc/R/e/Reporting_mysqltest_bugs.html" echo "http://www.mysql.com/doc/R/e/Reporting_mysqltest_bugs.html"
echo "to find the reason to this problem and how to report this." echo "to find the reason to this problem and how to report this."
fi fi
} }
do_gdb_test () do_gdb_test ()
...@@ -469,12 +502,12 @@ report_stats () { ...@@ -469,12 +502,12 @@ report_stats () {
if [ $TOT_FAIL = 0 ]; then if [ $TOT_FAIL = 0 ]; then
$ECHO "All $TOT_TEST tests were successful." $ECHO "All $TOT_TEST tests were successful."
else else
xten=`$EXPR $TOT_PASS \* 10000` xten=`$EXPR $TOT_PASS \* 10000`
raw=`$EXPR $xten / $TOT_TEST` raw=`$EXPR $xten / $TOT_TEST`
raw=`$PRINTF %.4d $raw` raw=`$PRINTF %.4d $raw`
whole=`$PRINTF %.2s $raw` whole=`$PRINTF %.2s $raw`
xwhole=`$EXPR $whole \* 100` xwhole=`$EXPR $whole \* 100`
deci=`$EXPR $raw - $xwhole` deci=`$EXPR $raw - $xwhole`
$ECHO "Failed ${TOT_FAIL}/${TOT_TEST} tests, ${whole}.${deci}% successful." $ECHO "Failed ${TOT_FAIL}/${TOT_TEST} tests, ${whole}.${deci}% successful."
$ECHO "" $ECHO ""
$ECHO "The log files in $MYSQL_TEST_DIR/var/log may give you some hint" $ECHO "The log files in $MYSQL_TEST_DIR/var/log may give you some hint"
...@@ -500,23 +533,21 @@ mysql_install_db () { ...@@ -500,23 +533,21 @@ mysql_install_db () {
error "Could not install slave test DBs" error "Could not install slave test DBs"
exit 1 exit 1
fi fi
for slave_num in 1 2 ; for slave_num in 1 2 ;
do do
rm -rf var/slave$slave_num-data/ $RM -rf var/slave$slave_num-data/
mkdir -p var/slave$slave_num-data/mysql mkdir -p var/slave$slave_num-data/mysql
mkdir -p var/slave$slave_num-data/test mkdir -p var/slave$slave_num-data/test
cp var/slave-data/mysql/* var/slave$slave_num-data/mysql cp var/slave-data/mysql/* var/slave$slave_num-data/mysql
done done
# Give mysqld some time to die.
sleep $SLEEP_TIME
return 0 return 0
} }
gprof_prepare () gprof_prepare ()
{ {
rm -rf $GPROF_DIR $RM -rf $GPROF_DIR
mkdir -p $GPROF_DIR mkdir -p $GPROF_DIR
} }
gprof_collect () gprof_collect ()
...@@ -556,7 +587,7 @@ abort_if_failed() ...@@ -556,7 +587,7 @@ abort_if_failed()
if [ ! $? = 0 ] ; then if [ ! $? = 0 ] ; then
echo $1 echo $1
exit 1 exit 1
fi fi
} }
start_manager() start_manager()
...@@ -575,7 +606,7 @@ start_manager() ...@@ -575,7 +606,7 @@ start_manager()
fi fi
fi fi
rm -f $MANAGER_PID_FILE $RM -f $MANAGER_PID_FILE
MYSQL_MANAGER_PW=`$MYSQL_MANAGER_PWGEN -u $MYSQL_MANAGER_USER \ MYSQL_MANAGER_PW=`$MYSQL_MANAGER_PWGEN -u $MYSQL_MANAGER_USER \
-o $MYSQL_MANAGER_PW_FILE` -o $MYSQL_MANAGER_PW_FILE`
$MYSQL_MANAGER --log=$MYSQL_MANAGER_LOG --port=$MYSQL_MANAGER_PORT \ $MYSQL_MANAGER --log=$MYSQL_MANAGER_LOG --port=$MYSQL_MANAGER_PORT \
...@@ -613,7 +644,7 @@ manager_launch() ...@@ -613,7 +644,7 @@ manager_launch()
shift shift
if [ $USE_MANAGER = 0 ] ; then if [ $USE_MANAGER = 0 ] ; then
$@ >$CUR_MYERR 2>&1 & $@ >$CUR_MYERR 2>&1 &
sleep 2 #hack sleep 2 #hack
return return
fi fi
$MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \ $MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \
...@@ -646,181 +677,186 @@ EOF ...@@ -646,181 +677,186 @@ EOF
start_master() start_master()
{ {
if [ x$MASTER_RUNNING = x1 ] || [ x$LOCAL_MASTER = x1 ] ; then if [ x$MASTER_RUNNING = x1 ] || [ x$LOCAL_MASTER = x1 ] ; then
return return
fi fi
# Remove old berkeley db log files that can confuse the server # Remove old berkeley db log files that can confuse the server
$RM -f $MASTER_MYDDIR/log.* $RM -f $MASTER_MYDDIR/log.*
# Remove stale binary logs # Remove stale binary logs
$RM -f $MYSQL_TEST_DIR/var/log/master-bin.* $RM -f $MYSQL_TEST_DIR/var/log/master-bin.*
#run master initialization shell script if one exists
if [ -f "$master_init_script" ] ; #run master initialization shell script if one exists
then
/bin/sh $master_init_script if [ -f "$master_init_script" ] ;
fi then
cd $BASEDIR # for gcov /bin/sh $master_init_script
#start master fi
if [ -z "$DO_BENCH" ] cd $BASEDIR # for gcov
then #start master
master_args="--no-defaults --log-bin=$MYSQL_TEST_DIR/var/log/master-bin \ if [ -z "$DO_BENCH" ]
--server-id=1 --rpl-recovery-rank=1 \ then
--basedir=$MY_BASEDIR --init-rpl-role=master \ master_args="--no-defaults --log-bin=$MYSQL_TEST_DIR/var/log/master-bin \
--port=$MASTER_MYPORT \ --server-id=1 --rpl-recovery-rank=1 \
--exit-info=256 \ --basedir=$MY_BASEDIR --init-rpl-role=master \
--core \ --port=$MASTER_MYPORT \
--datadir=$MASTER_MYDDIR \ --exit-info=256 \
--pid-file=$MASTER_MYPID \ --core \
--socket=$MASTER_MYSOCK \ --datadir=$MASTER_MYDDIR \
--log=$MASTER_MYLOG \ --pid-file=$MASTER_MYPID \
--character-sets-dir=$CHARSETSDIR \ --socket=$MASTER_MYSOCK \
--default-character-set=$CHARACTER_SET \ --log=$MASTER_MYLOG \
--tmpdir=$MYSQL_TMP_DIR \ --character-sets-dir=$CHARSETSDIR \
--language=$LANGUAGE \ --default-character-set=$CHARACTER_SET \
--innodb_data_file_path=ibdata1:50M \ --tmpdir=$MYSQL_TMP_DIR \
$SMALL_SERVER \ --language=$LANGUAGE \
$EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT" --innodb_data_file_path=ibdata1:50M \
else $SMALL_SERVER \
master_args="--no-defaults --log-bin=$MYSQL_TEST_DIR/var/log/master-bin \ $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT"
--server-id=1 --rpl-recovery-rank=1 \ else
--basedir=$MY_BASEDIR --init-rpl-role=master \ master_args="--no-defaults --log-bin=$MYSQL_TEST_DIR/var/log/master-bin \
--port=$MASTER_MYPORT \ --server-id=1 --rpl-recovery-rank=1 \
--datadir=$MASTER_MYDDIR \ --basedir=$MY_BASEDIR --init-rpl-role=master \
--pid-file=$MASTER_MYPID \ --port=$MASTER_MYPORT \
--socket=$MASTER_MYSOCK \ --datadir=$MASTER_MYDDIR \
--character-sets-dir=$CHARSETSDIR \ --pid-file=$MASTER_MYPID \
--default-character-set=$CHARACTER_SET \ --socket=$MASTER_MYSOCK \
--core \ --character-sets-dir=$CHARSETSDIR \
--tmpdir=$MYSQL_TMP_DIR \ --default-character-set=$CHARACTER_SET \
--language=$LANGUAGE \ --core \
--innodb_data_file_path=ibdata1:50M \ --tmpdir=$MYSQL_TMP_DIR \
$SMALL_SERVER \ --language=$LANGUAGE \
$EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT" --innodb_data_file_path=ibdata1:50M \
fi $SMALL_SERVER \
$EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT"
CUR_MYERR=$MASTER_MYERR fi
CUR_MYSOCK=$MASTER_MYSOCK
CUR_MYERR=$MASTER_MYERR
if [ x$DO_DDD = x1 ] CUR_MYSOCK=$MASTER_MYSOCK
then
$ECHO "set args $master_args" > $GDB_MASTER_INIT if [ x$DO_DDD = x1 ]
manager_launch master ddd -display $DISPLAY --debugger \ then
"gdb -x $GDB_MASTER_INIT" $MYSQLD $ECHO "set args $master_args" > $GDB_MASTER_INIT
elif [ x$DO_GDB = x1 ] manager_launch master ddd -display $DISPLAY --debugger \
then "gdb -x $GDB_MASTER_INIT" $MYSQLD
( echo set args $master_args; elif [ x$DO_GDB = x1 ]
if [ $USE_MANAGER = 0 ] ; then then
cat <<EOF ( echo set args $master_args;
if [ $USE_MANAGER = 0 ] ; then
cat <<EOF
b mysql_parse b mysql_parse
commands 1 commands 1
disa 1 disa 1
end end
r r
EOF EOF
fi ) > $GDB_MASTER_INIT fi ) > $GDB_MASTER_INIT
manager_launch master $XTERM -display $DISPLAY \ manager_launch master $XTERM -display $DISPLAY \
-title "Master" -e gdb -x $GDB_MASTER_INIT $MYSQLD -title "Master" -e gdb -x $GDB_MASTER_INIT $MYSQLD
else else
manager_launch master $MYSQLD $master_args manager_launch master $MYSQLD $master_args
fi fi
sleep_until_file_exists $MASTER_MYPID
MASTER_RUNNING=1 MASTER_RUNNING=1
} }
start_slave() start_slave()
{ {
[ x$SKIP_SLAVE = x1 ] && return [ x$SKIP_SLAVE = x1 ] && return
eval "this_slave_running=\$SLAVE$1_RUNNING" eval "this_slave_running=\$SLAVE$1_RUNNING"
[ x$this_slave_running = 1 ] && return [ x$this_slave_running = 1 ] && return
#when testing fail-safe replication, we will have more than one slave #when testing fail-safe replication, we will have more than one slave
#in this case, we start secondary slaves with an argument #in this case, we start secondary slaves with an argument
slave_ident="slave$1" slave_ident="slave$1"
if [ -n "$1" ] ; if [ -n "$1" ] ;
then then
slave_server_id=`$EXPR 2 + $1` slave_server_id=`$EXPR 2 + $1`
slave_rpl_rank=$slave_server_id slave_rpl_rank=$slave_server_id
slave_port=`expr $SLAVE_MYPORT + $1` slave_port=`expr $SLAVE_MYPORT + $1`
slave_log="$SLAVE_MYLOG.$1" slave_log="$SLAVE_MYLOG.$1"
slave_err="$SLAVE_MYERR.$1" slave_err="$SLAVE_MYERR.$1"
slave_datadir="var/$slave_ident-data/" slave_datadir="var/$slave_ident-data/"
slave_pid="$MYRUN_DIR/mysqld-$slave_ident.pid" slave_pid="$MYRUN_DIR/mysqld-$slave_ident.pid"
slave_sock="$SLAVE_MYSOCK-$1" slave_sock="$SLAVE_MYSOCK-$1"
else else
slave_server_id=2 slave_server_id=2
slave_rpl_rank=2 slave_rpl_rank=2
slave_port=$SLAVE_MYPORT slave_port=$SLAVE_MYPORT
slave_log=$SLAVE_MYLOG slave_log=$SLAVE_MYLOG
slave_err=$SLAVE_MYERR slave_err=$SLAVE_MYERR
slave_datadir=$SLAVE_MYDDIR slave_datadir=$SLAVE_MYDDIR
slave_pid=$SLAVE_MYPID slave_pid=$SLAVE_MYPID
slave_sock="$SLAVE_MYSOCK" slave_sock="$SLAVE_MYSOCK"
fi fi
# Remove stale binary logs # Remove stale binary logs
$RM -f $MYSQL_TEST_DIR/var/log/$slave_ident-bin.* $RM -f $MYSQL_TEST_DIR/var/log/$slave_ident-bin.*
#run slave initialization shell script if one exists #run slave initialization shell script if one exists
if [ -f "$slave_init_script" ] ; if [ -f "$slave_init_script" ] ;
then then
/bin/sh $slave_init_script /bin/sh $slave_init_script
fi fi
if [ -z "$SLAVE_MASTER_INFO" ] ; then if [ -z "$SLAVE_MASTER_INFO" ] ; then
master_info="--master-user=root \ master_info="--master-user=root \
--master-connect-retry=1 \ --master-connect-retry=1 \
--master-host=127.0.0.1 \ --master-host=127.0.0.1 \
--master-password= \ --master-password= \
--master-port=$MASTER_MYPORT \ --master-port=$MASTER_MYPORT \
--server-id=$slave_server_id --rpl-recovery-rank=$slave_rpl_rank" --server-id=$slave_server_id --rpl-recovery-rank=$slave_rpl_rank"
else else
master_info=$SLAVE_MASTER_INFO master_info=$SLAVE_MASTER_INFO
fi fi
$RM -f $slave_datadir/log.* $RM -f $slave_datadir/log.*
slave_args="--no-defaults $master_info \ slave_args="--no-defaults $master_info \
--exit-info=256 \ --exit-info=256 \
--log-bin=$MYSQL_TEST_DIR/var/log/$slave_ident-bin \ --log-bin=$MYSQL_TEST_DIR/var/log/$slave_ident-bin \
--log-slave-updates \ --log-slave-updates \
--log=$slave_log \ --log=$slave_log \
--basedir=$MY_BASEDIR \ --basedir=$MY_BASEDIR \
--datadir=$slave_datadir \ --datadir=$slave_datadir \
--pid-file=$slave_pid \ --pid-file=$slave_pid \
--port=$slave_port \ --port=$slave_port \
--socket=$slave_sock \ --socket=$slave_sock \
--character-sets-dir=$CHARSETSDIR \ --character-sets-dir=$CHARSETSDIR \
--default-character-set=$CHARACTER_SET \ --default-character-set=$CHARACTER_SET \
--core --init-rpl-role=slave \ --core --init-rpl-role=slave \
--tmpdir=$MYSQL_TMP_DIR \ --tmpdir=$MYSQL_TMP_DIR \
--language=$LANGUAGE \ --language=$LANGUAGE \
--skip-innodb --skip-slave-start \ --skip-innodb --skip-slave-start \
--slave-load-tmpdir=$SLAVE_LOAD_TMPDIR \ --slave-load-tmpdir=$SLAVE_LOAD_TMPDIR \
--report-host=127.0.0.1 --report-user=root \ --report-host=127.0.0.1 --report-user=root \
--report-port=$slave_port \ --report-port=$slave_port \
--master-retry-count=5 \ --master-retry-count=5 \
$SMALL_SERVER \ $SMALL_SERVER \
$EXTRA_SLAVE_OPT $EXTRA_SLAVE_MYSQLD_OPT" $EXTRA_SLAVE_OPT $EXTRA_SLAVE_MYSQLD_OPT"
CUR_MYERR=$slave_err CUR_MYERR=$slave_err
CUR_MYSOCK=$slave_sock CUR_MYSOCK=$slave_sock
if [ x$DO_DDD = x1 ] if [ x$DO_DDD = x1 ]
then then
$ECHO "set args $master_args" > $GDB_SLAVE_INIT $ECHO "set args $master_args" > $GDB_SLAVE_INIT
manager_launch $slave_ident ddd -display $DISPLAY --debugger \ manager_launch $slave_ident ddd -display $DISPLAY --debugger \
"gdb -x $GDB_SLAVE_INIT" $SLAVE_MYSQLD "gdb -x $GDB_SLAVE_INIT" $SLAVE_MYSQLD
elif [ x$DO_GDB = x1 ] elif [ x$DO_GDB = x1 ]
then then
$ECHO "set args $slave_args" > $GDB_SLAVE_INIT $ECHO "set args $slave_args" > $GDB_SLAVE_INIT
manager_launch $slave_ident $XTERM -display $DISPLAY -title "Slave" -e \ manager_launch $slave_ident $XTERM -display $DISPLAY -title "Slave" -e \
gdb -x $GDB_SLAVE_INIT $SLAVE_MYSQLD gdb -x $GDB_SLAVE_INIT $SLAVE_MYSQLD
else else
manager_launch $slave_ident $SLAVE_MYSQLD $slave_args manager_launch $slave_ident $SLAVE_MYSQLD $slave_args
fi fi
eval "SLAVE$1_RUNNING=1" eval "SLAVE$1_RUNNING=1"
sleep_until_file_exists $slave_pid
} }
mysql_start () { mysql_start ()
$ECHO "Starting MySQL daemon" {
start_master $ECHO "Starting MySQL daemon"
start_slave start_master
cd $MYSQL_TEST_DIR start_slave
return 1 cd $MYSQL_TEST_DIR
return 1
} }
stop_slave () stop_slave ()
...@@ -832,7 +868,7 @@ stop_slave () ...@@ -832,7 +868,7 @@ stop_slave ()
slave_pid="$MYRUN_DIR/mysqld-$slave_ident.pid" slave_pid="$MYRUN_DIR/mysqld-$slave_ident.pid"
else else
slave_pid=$SLAVE_MYPID slave_pid=$SLAVE_MYPID
fi fi
if [ x$this_slave_running = x1 ] if [ x$this_slave_running = x1 ]
then then
manager_term $slave_ident manager_term $slave_ident
...@@ -840,17 +876,17 @@ stop_slave () ...@@ -840,17 +876,17 @@ stop_slave ()
then # try harder! then # try harder!
$ECHO "slave not cooperating with mysqladmin, will try manual kill" $ECHO "slave not cooperating with mysqladmin, will try manual kill"
kill `$CAT $slave_pid` kill `$CAT $slave_pid`
sleep $SLEEP_TIME sleep_until_file_deleted $slave_pid
if [ -f $SLAVE_MYPID ] ; then if [ -f $slave_pid ] ; then
$ECHO "slave refused to die. Sending SIGKILL" $ECHO "slave refused to die. Sending SIGKILL"
kill -9 `$CAT $slave_pid` kill -9 `$CAT $slave_pid`
$RM -f $slave_pid $RM -f $slave_pid
else else
$ECHO "slave responded to SIGTERM " $ECHO "slave responded to SIGTERM "
fi fi
fi fi
eval "SLAVE$1_RUNNING=0" eval "SLAVE$1_RUNNING=0"
fi fi
} }
stop_master () stop_master ()
...@@ -862,13 +898,13 @@ stop_master () ...@@ -862,13 +898,13 @@ stop_master ()
then # try harder! then # try harder!
$ECHO "master not cooperating with mysqladmin, will try manual kill" $ECHO "master not cooperating with mysqladmin, will try manual kill"
kill `$CAT $MASTER_MYPID` kill `$CAT $MASTER_MYPID`
sleep $SLEEP_TIME sleep_until_file_deleted $MASTER_MYPID
if [ -f $MASTER_MYPID ] ; then if [ -f $MASTER_MYPID ] ; then
$ECHO "master refused to die. Sending SIGKILL" $ECHO "master refused to die. Sending SIGKILL"
kill -9 `$CAT $MASTER_MYPID` kill -9 `$CAT $MASTER_MYPID`
$RM -f $MASTER_MYPID $RM -f $MASTER_MYPID
else else
$ECHO "master responded to SIGTERM " $ECHO "master responded to SIGTERM "
fi fi
fi fi
MASTER_RUNNING=0 MASTER_RUNNING=0
...@@ -886,21 +922,20 @@ mysql_stop () ...@@ -886,21 +922,20 @@ mysql_stop ()
stop_slave 1 stop_slave 1
stop_slave 2 stop_slave 2
$ECHO "Slave shutdown finished" $ECHO "Slave shutdown finished"
return 1 return 1
} }
mysql_restart () { mysql_restart ()
{
mysql_stop mysql_stop
mysql_start mysql_start
return 1
return 1
} }
mysql_loadstd () { mysql_loadstd () {
# cp $STD_DATA/*.frm $STD_DATA/*.MRG $MASTER_MYDDIR/test # cp $STD_DATA/*.frm $STD_DATA/*.MRG $MASTER_MYDDIR/test
return 1 return 1
} }
...@@ -916,9 +951,9 @@ run_testcase () ...@@ -916,9 +951,9 @@ run_testcase ()
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0` SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
if [ $USE_MANAGER = 1 ] ; then if [ $USE_MANAGER = 1 ] ; then
many_slaves=`$EXPR \( $tname : rpl_failsafe \) != 0` many_slaves=`$EXPR \( $tname : rpl_failsafe \) != 0`
fi fi
if [ -n "$SKIP_TEST" ] ; then if [ -n "$SKIP_TEST" ] ; then
SKIP_THIS_TEST=`$EXPR \( $tname : "$SKIP_TEST" \) != 0` SKIP_THIS_TEST=`$EXPR \( $tname : "$SKIP_TEST" \) != 0`
if [ x$SKIP_THIS_TEST = x1 ] ; if [ x$SKIP_THIS_TEST = x1 ] ;
then then
...@@ -926,7 +961,7 @@ run_testcase () ...@@ -926,7 +961,7 @@ run_testcase ()
fi fi
fi fi
if [ -n "$DO_TEST" ] ; then if [ -n "$DO_TEST" ] ; then
DO_THIS_TEST=`$EXPR \( $tname : "$DO_TEST" \) != 0` DO_THIS_TEST=`$EXPR \( $tname : "$DO_TEST" \) != 0`
if [ x$DO_THIS_TEST = x0 ] ; if [ x$DO_THIS_TEST = x0 ] ;
then then
...@@ -961,10 +996,10 @@ run_testcase () ...@@ -961,10 +996,10 @@ run_testcase ()
EXTRA_MASTER_OPT="" EXTRA_MASTER_OPT=""
stop_master stop_master
start_master start_master
fi fi
fi fi
do_slave_restart=0 do_slave_restart=0
if [ -f $slave_opt_file ] ; if [ -f $slave_opt_file ] ;
then then
EXTRA_SLAVE_OPT=`$CAT $slave_opt_file` EXTRA_SLAVE_OPT=`$CAT $slave_opt_file`
...@@ -973,8 +1008,8 @@ run_testcase () ...@@ -973,8 +1008,8 @@ run_testcase ()
if [ ! -z "$EXTRA_SLAVE_OPT" ] || [ x$SLAVE_RUNNING != x1 ] ; if [ ! -z "$EXTRA_SLAVE_OPT" ] || [ x$SLAVE_RUNNING != x1 ] ;
then then
EXTRA_SLAVE_OPT="" EXTRA_SLAVE_OPT=""
do_slave_restart=1 do_slave_restart=1
fi fi
fi fi
if [ -f $slave_master_info_file ] ; then if [ -f $slave_master_info_file ] ; then
...@@ -984,8 +1019,8 @@ run_testcase () ...@@ -984,8 +1019,8 @@ run_testcase ()
if [ ! -z "$SLAVE_MASTER_INFO" ] || [ x$SLAVE_RUNNING != x1 ] ; if [ ! -z "$SLAVE_MASTER_INFO" ] || [ x$SLAVE_RUNNING != x1 ] ;
then then
SLAVE_MASTER_INFO="" SLAVE_MASTER_INFO=""
do_slave_restart=1 do_slave_restart=1
fi fi
fi fi
if [ x$do_slave_restart = x1 ] ; then if [ x$do_slave_restart = x1 ] ; then
...@@ -998,7 +1033,7 @@ run_testcase () ...@@ -998,7 +1033,7 @@ run_testcase ()
fi fi
fi fi
cd $MYSQL_TEST_DIR cd $MYSQL_TEST_DIR
if [ -f $tf ] ; then if [ -f $tf ] ; then
$RM -f r/$tname.*reject $RM -f r/$tname.*reject
mysql_test_args="-R r/$tname.result $EXTRA_MYSQL_TEST_OPT" mysql_test_args="-R r/$tname.result $EXTRA_MYSQL_TEST_OPT"
...@@ -1007,7 +1042,7 @@ run_testcase () ...@@ -1007,7 +1042,7 @@ run_testcase ()
else else
do_gdb_test "$mysql_test_args" "$tf" do_gdb_test "$mysql_test_args" "$tf"
fi fi
res=$? res=$?
if [ $res = 0 ]; then if [ $res = 0 ]; then
...@@ -1028,12 +1063,12 @@ run_testcase () ...@@ -1028,12 +1063,12 @@ run_testcase ()
timestr="$USERT $SYST $REALT" timestr="$USERT $SYST $REALT"
pname=`$ECHO "$tname "|$CUT -c 1-24` pname=`$ECHO "$tname "|$CUT -c 1-24`
RES="$pname $timestr" RES="$pname $timestr"
if [ x$many_slaves = x1 ] ; then if [ x$many_slaves = x1 ] ; then
stop_slave 1 stop_slave 1
stop_slave 2 stop_slave 2
fi fi
if [ $res = 0 ]; then if [ $res = 0 ]; then
total_inc total_inc
pass_inc pass_inc
...@@ -1061,7 +1096,7 @@ run_testcase () ...@@ -1061,7 +1096,7 @@ run_testcase ()
fi fi
exit 1 exit 1
fi fi
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ] if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
then then
mysql_restart mysql_restart
...@@ -1073,26 +1108,47 @@ run_testcase () ...@@ -1073,26 +1108,47 @@ run_testcase ()
fi fi
} }
###################################################################### ######################################################################
# Main script starts here # Main script starts here
###################################################################### ######################################################################
[ "$DO_GCOV" -a ! -x "$GCOV" ] && error "No gcov found" [ "$DO_GCOV" -a ! -x "$GCOV" ] && error "No gcov found"
[ "$DO_GCOV" ] && gcov_prepare [ "$DO_GCOV" ] && gcov_prepare
[ "$DO_GPROF" ] && gprof_prepare [ "$DO_GPROF" ] && gprof_prepare
# Ensure that no old mysqld test servers are running
if [ -z "$USE_RUNNING_SERVER" ] if [ -z "$USE_RUNNING_SERVER" ]
then then
# Ensure that no old mysqld test servers are running
$MYSQLADMIN --no-defaults --socket=$MASTER_MYSOCK -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1 $MYSQLADMIN --no-defaults --socket=$MASTER_MYSOCK -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
$MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1 $MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
$MYSQLADMIN --no-defaults --host=$hostname --port=$MASTER_MYPORT -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
$MYSQLADMIN --no-defaults --host=$hostname --port=$SLAVE_MYPORT -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
$MYSQLADMIN --no-defaults --host=$hostname --port=`expr $SLAVE_MYPORT + 1` -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
sleep_until_file_deleted $MASTER_MYPID
sleep_until_file_deleted $SLAVE_MYPID
# Kill any running managers
if [ -f "$MANAGER_PID_FILE" ]
then
kill `cat $MANAGER_PID_FILE`
sleep 1
if [ -f "$MANAGER_PID_FILE" ]
then
kill -9 `cat $MANAGER_PID_FILE`
sleep 1
fi
fi
# Remove files that can cause problems
$RM -f $MYSQL_TEST_DIR/var/run/* $MYSQL_TEST_DIR/var/tmp/*
$ECHO "Installing Test Databases" $ECHO "Installing Test Databases"
mysql_install_db mysql_install_db
start_manager start_manager
#do not automagically start deamons if we are in gdb or running only one test
#case # Do not automagically start deamons if we are in gdb or running only one test
# case
if [ -z "$DO_GDB" ] && [ -z "$DO_DDD" ] if [ -z "$DO_GDB" ] && [ -z "$DO_DDD" ]
then then
mysql_start mysql_start
...@@ -1110,24 +1166,24 @@ $ECHO "Starting Tests" ...@@ -1110,24 +1166,24 @@ $ECHO "Starting Tests"
if [ "$DO_BENCH" = 1 ] if [ "$DO_BENCH" = 1 ]
then then
BENCHDIR=$BASEDIR/sql-bench/ BENCHDIR=$BASEDIR/sql-bench/
savedir=`pwd` savedir=`pwd`
cd $BENCHDIR cd $BENCHDIR
if [ -z "$1" ] if [ -z "$1" ]
then
./run-all-tests --socket=$MASTER_MYSOCK --user=root
else
if [ -x "./$1" ]
then then
./$1 --socket=$MASTER_MYSOCK --user=root ./run-all-tests --socket=$MASTER_MYSOCK --user=root
else else
echo "benchmark $1 not found" if [ -x "./$1" ]
then
./$1 --socket=$MASTER_MYSOCK --user=root
else
echo "benchmark $1 not found"
fi
fi fi
fi cd $savedir
cd $savedir mysql_stop
mysql_stop stop_manager
stop_manager exit
exit
fi fi
$ECHO $ECHO
...@@ -1145,7 +1201,7 @@ then ...@@ -1145,7 +1201,7 @@ then
done done
$RM -f $TIMEFILE # Remove for full test $RM -f $TIMEFILE # Remove for full test
fi fi
else else
while [ ! -z "$1" ]; do while [ ! -z "$1" ]; do
tname=`$BASENAME $1 .test` tname=`$BASENAME $1 .test`
tf=$TESTDIR/$tname.$TESTSUFFIX tf=$TESTDIR/$tname.$TESTSUFFIX
......
...@@ -291,10 +291,4 @@ show status like "Qcache_queries_in_cache"; ...@@ -291,10 +291,4 @@ show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 2 Qcache_queries_in_cache 2
reset query cache; reset query cache;
show variables like "query_cache_size";
Variable_name Value
query_cache_size 1039700
show status like "Qcache_free_memory";
Variable_name Value
Qcache_free_memory 1039700
drop table t1; drop table t1;
...@@ -178,6 +178,9 @@ enable_result_log; ...@@ -178,6 +178,9 @@ enable_result_log;
show status like "Qcache_hits"; show status like "Qcache_hits";
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
reset query cache; reset query cache;
show variables like "query_cache_size";
show status like "Qcache_free_memory";
drop table t1; drop table t1;
# The following tests can't be done as the values differen on 32 and 64 bit
# machines :(
#show variables like "query_cache_size";
#show status like "Qcache_free_memory";
...@@ -2672,6 +2672,7 @@ uint Query_cache::filename_2_table_key (char *key, const char *path) ...@@ -2672,6 +2672,7 @@ uint Query_cache::filename_2_table_key (char *key, const char *path)
void Query_cache::wreck(uint line, const char *message) void Query_cache::wreck(uint line, const char *message)
{ {
THD *thd=current_thd;
DBUG_ENTER("Query_cache::wreck"); DBUG_ENTER("Query_cache::wreck");
query_cache_size = 0; query_cache_size = 0;
if (*message) if (*message)
...@@ -2679,7 +2680,8 @@ void Query_cache::wreck(uint line, const char *message) ...@@ -2679,7 +2680,8 @@ void Query_cache::wreck(uint line, const char *message)
DBUG_PRINT("warning", ("==================================")); DBUG_PRINT("warning", ("=================================="));
DBUG_PRINT("warning", ("%5d QUERY CACHE WRECK => DISABLED",line)); DBUG_PRINT("warning", ("%5d QUERY CACHE WRECK => DISABLED",line));
DBUG_PRINT("warning", ("==================================")); DBUG_PRINT("warning", ("=================================="));
current_thd->killed = 1; if (thd)
thd->killed = 1;
bins_dump(); bins_dump();
cache_dump(); cache_dump();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment