Commit 2e56e821 authored by anozdrin@mysql.com's avatar anozdrin@mysql.com

Fix of test suite in scope of fixing BUG#18023: IM: instance

can be started several times; monitor interval must be > 2sec
parent 59d20e26
Success: the process has been started.
SHOW INSTANCES; SHOW INSTANCES;
instance_name status instance_name status
mysqld1 online mysqld1 online
......
--------------------------------------------------------------------
-- 1.1.1.
--------------------------------------------------------------------
Success: the process has been started.
SHOW INSTANCES; SHOW INSTANCES;
instance_name status instance_name status
mysqld1 online mysqld1 online
mysqld2 offline mysqld2 offline
SHOW INSTANCE STATUS mysqld1;
instance_name status version --------------------------------------------------------------------
mysqld1 online VERSION -- 1.1.2.
SHOW INSTANCE STATUS mysqld2; --------------------------------------------------------------------
instance_name status version
mysqld2 offline VERSION
START INSTANCE mysqld2; START INSTANCE mysqld2;
SHOW INSTANCES; Success: the process has been started.
instance_name status
mysqld1 online
mysqld2 online
SHOW INSTANCE STATUS mysqld1;
instance_name status version
mysqld1 online VERSION
SHOW INSTANCE STATUS mysqld2;
instance_name status version
mysqld2 online VERSION
SHOW VARIABLES LIKE 'port'; SHOW VARIABLES LIKE 'port';
Variable_name Value Variable_name Value
port IM_MYSQLD1_PORT port IM_MYSQLD2_PORT
--------------------------------------------------------------------
-- 1.1.3.
--------------------------------------------------------------------
STOP INSTANCE mysqld2; STOP INSTANCE mysqld2;
SHOW INSTANCES; Success: the process has been stopped.
instance_name status
mysqld1 online --------------------------------------------------------------------
mysqld2 offline -- 1.1.4.
SHOW INSTANCE STATUS mysqld1; --------------------------------------------------------------------
instance_name status version
mysqld1 online VERSION
SHOW INSTANCE STATUS mysqld2;
instance_name status version
mysqld2 offline VERSION
START INSTANCE mysqld3; START INSTANCE mysqld3;
ERROR HY000: Bad instance name. Check that the instance with such a name exists ERROR HY000: Bad instance name. Check that the instance with such a name exists
START INSTANCE mysqld1; START INSTANCE mysqld1;
ERROR HY000: The instance is already started ERROR HY000: The instance is already started
--------------------------------------------------------------------
-- 1.1.5.
--------------------------------------------------------------------
STOP INSTANCE mysqld3; STOP INSTANCE mysqld3;
ERROR HY000: Bad instance name. Check that the instance with such a name exists ERROR HY000: Bad instance name. Check that the instance with such a name exists
--------------------------------------------------------------------
-- 1.1.6.
--------------------------------------------------------------------
SHOW INSTANCES; SHOW INSTANCES;
instance_name status instance_name status
mysqld1 online mysqld1 online
...@@ -50,20 +51,25 @@ SHOW INSTANCES; ...@@ -50,20 +51,25 @@ SHOW INSTANCES;
instance_name status instance_name status
mysqld1 online mysqld1 online
mysqld2 offline mysqld2 offline
--------------------------------------------------------------------
-- 1.1.7.
--------------------------------------------------------------------
START INSTANCE mysqld2; START INSTANCE mysqld2;
SHOW INSTANCES; Success: the process has been started.
instance_name status
mysqld1 online
mysqld2 online
Killing the process... Killing the process...
Sleeping... Sleeping...
Success: the process was killed. Success: the process was killed.
SHOW INSTANCES;
instance_name status --------------------------------------------------------------------
mysqld1 online -- 1.1.8.
mysqld2 offline --------------------------------------------------------------------
SHOW INSTANCE STATUS; SHOW INSTANCE STATUS;
ERROR 42000: You have an error in your command syntax. Check the manual that corresponds to your MySQL Instance Manager version for the right syntax to use ERROR 42000: You have an error in your command syntax. Check the manual that corresponds to your MySQL Instance Manager version for the right syntax to use
--------------------------------------------------------------------
-- BUG#12813
--------------------------------------------------------------------
START INSTANCE mysqld1,mysqld2,mysqld3; START INSTANCE mysqld1,mysqld2,mysqld3;
ERROR 42000: You have an error in your command syntax. Check the manual that corresponds to your MySQL Instance Manager version for the right syntax to use ERROR 42000: You have an error in your command syntax. Check the manual that corresponds to your MySQL Instance Manager version for the right syntax to use
STOP INSTANCE mysqld1,mysqld2,mysqld3; STOP INSTANCE mysqld1,mysqld2,mysqld3;
......
Success: the process has been started.
SHOW INSTANCES; SHOW INSTANCES;
instance_name status instance_name status
mysqld1 online mysqld1 online
...@@ -42,7 +43,9 @@ skip-innodb VALUE ...@@ -42,7 +43,9 @@ skip-innodb VALUE
skip-bdb VALUE skip-bdb VALUE
skip-ndbcluster VALUE skip-ndbcluster VALUE
START INSTANCE mysqld2; START INSTANCE mysqld2;
Success: the process has been started.
STOP INSTANCE mysqld2; STOP INSTANCE mysqld2;
Success: the process has been stopped.
SHOW mysqld1 LOG FILES; SHOW mysqld1 LOG FILES;
Logfile Path File size Logfile Path File size
ERROR LOG PATH FILE_SIZE ERROR LOG PATH FILE_SIZE
......
--run-as-service --run-as-service
--log=$MYSQLTEST_VARDIR/log/im.log --log=$MYSQLTEST_VARDIR/log/im.log
--monitoring-interval=1
...@@ -10,6 +10,22 @@ ...@@ -10,6 +10,22 @@
########################################################################### ###########################################################################
# Wait for mysqld1 (guarded instance) to start.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
# Let IM detect that mysqld1 is online. This delay should be longer than
# monitoring interval.
--sleep 3
# Check that start conditions are as expected.
SHOW INSTANCES; SHOW INSTANCES;
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted ###########################################################################
# Kill the IM main process and check that the IM Angel will restart the main
# process.
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30
...@@ -17,11 +17,23 @@ ...@@ -17,11 +17,23 @@
# #
########################################################################### ###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.1.
--echo --------------------------------------------------------------------
# Wait for mysqld1 (guarded instance) to start.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
# Let IM detect that mysqld1 is online. This delay should be longer than
# monitoring interval.
--sleep 3
# Check that start conditions are as expected.
SHOW INSTANCES; SHOW INSTANCES;
--replace_column 3 VERSION
SHOW INSTANCE STATUS mysqld1;
--replace_column 3 VERSION
SHOW INSTANCE STATUS mysqld2;
########################################################################### ###########################################################################
# #
...@@ -33,20 +45,24 @@ SHOW INSTANCE STATUS mysqld2; ...@@ -33,20 +45,24 @@ SHOW INSTANCE STATUS mysqld2;
# #
########################################################################### ###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.2.
--echo --------------------------------------------------------------------
START INSTANCE mysqld2; START INSTANCE mysqld2;
# FIXME # FIXME: START INSTANCE should be synchronous.
--sleep 3 --exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
SHOW INSTANCES; # FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
--replace_column 3 VERSION # synchronous. Even waiting for mysqld to start by looking at its pid file is
SHOW INSTANCE STATUS mysqld1; # not enough, because IM may not detect that mysqld has started.
--replace_column 3 VERSION # SHOW INSTANCES;
SHOW INSTANCE STATUS mysqld2;
--connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK) --connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD2_PORT,$IM_MYSQLD2_SOCK)
--connection mysql_con --connection mysql_con
--replace_result $IM_MYSQLD1_PORT IM_MYSQLD1_PORT --replace_result $IM_MYSQLD2_PORT IM_MYSQLD2_PORT
SHOW VARIABLES LIKE 'port'; SHOW VARIABLES LIKE 'port';
--connection default --connection default
...@@ -61,15 +77,19 @@ SHOW VARIABLES LIKE 'port'; ...@@ -61,15 +77,19 @@ SHOW VARIABLES LIKE 'port';
# #
########################################################################### ###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.3.
--echo --------------------------------------------------------------------
STOP INSTANCE mysqld2; STOP INSTANCE mysqld2;
# FIXME # FIXME: STOP INSTANCE should be synchronous.
--sleep 3 --exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
SHOW INSTANCES; # FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
--replace_column 3 VERSION # synchronous. Even waiting for mysqld to start by looking at its pid file is
SHOW INSTANCE STATUS mysqld1; # not enough, because IM may not detect that mysqld has started.
--replace_column 3 VERSION # SHOW INSTANCES;
SHOW INSTANCE STATUS mysqld2;
########################################################################### ###########################################################################
# #
...@@ -81,16 +101,17 @@ SHOW INSTANCE STATUS mysqld2; ...@@ -81,16 +101,17 @@ SHOW INSTANCE STATUS mysqld2;
# #
########################################################################### ###########################################################################
--error 3000 --echo
--echo --------------------------------------------------------------------
--echo -- 1.1.4.
--echo --------------------------------------------------------------------
--error 3000 # ER_BAD_INSTANCE_NAME
START INSTANCE mysqld3; START INSTANCE mysqld3;
--error 3002 --error 3002 # ER_INSTANCE_ALREADY_STARTED
START INSTANCE mysqld1; START INSTANCE mysqld1;
# FIXME TODO
# BUG#12813: START/STOP INSTANCE commands accept a list as argument
# START INSTANCE mysqld1, mysqld2;
########################################################################### ###########################################################################
# #
# 1.1.5. Check that Instance Manager reports correct errors for 'STOP INSTANCE' # 1.1.5. Check that Instance Manager reports correct errors for 'STOP INSTANCE'
...@@ -101,27 +122,40 @@ START INSTANCE mysqld1; ...@@ -101,27 +122,40 @@ START INSTANCE mysqld1;
# #
########################################################################### ###########################################################################
--error 3000 --echo
--echo --------------------------------------------------------------------
--echo -- 1.1.5.
--echo --------------------------------------------------------------------
--error 3000 # ER_BAD_INSTANCE_NAME
STOP INSTANCE mysqld3; STOP INSTANCE mysqld3;
# TODO: IM should be fixed. # TODO: IM should be fixed.
# BUG#12673: Instance Manager allows to stop the instance many times # BUG#12673: Instance Manager allows to stop the instance many times
# --error 3002 # --error 3002 # ER_INSTANCE_ALREADY_STARTED
# STOP INSTANCE mysqld2; # STOP INSTANCE mysqld2;
# FIXME TODO
# BUG#12813: START/STOP INSTANCE commands accept a list as argument
# STOP INSTANCE mysqld1, mysqld2;
########################################################################### ###########################################################################
# #
# 1.1.6. Check that Instance Manager is able to restart guarded instances. # 1.1.6. Check that Instance Manager is able to restart guarded instances.
# #
########################################################################### ###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.6.
--echo --------------------------------------------------------------------
SHOW INSTANCES; SHOW INSTANCES;
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted --exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30
# Give some time to IM to detect that mysqld was restarted. It should be longer
# than monitoring interval.
--sleep 3
SHOW INSTANCES;
########################################################################### ###########################################################################
# #
...@@ -129,17 +163,26 @@ SHOW INSTANCES; ...@@ -129,17 +163,26 @@ SHOW INSTANCES;
# #
########################################################################### ###########################################################################
SHOW INSTANCES; --echo
--echo --------------------------------------------------------------------
--echo -- 1.1.7.
--echo --------------------------------------------------------------------
START INSTANCE mysqld2; START INSTANCE mysqld2;
# FIXME # FIXME: START INSTANCE should be synchronous.
--sleep 3 --exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
SHOW INSTANCES; # FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
# synchronous. Even waiting for mysqld to start by looking at its pid file is
# not enough, because IM may not detect that mysqld has started.
# SHOW INSTANCES;
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed --exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10
SHOW INSTANCES; # FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
# synchronous. Even waiting for mysqld to start by looking at its pid file is
# not enough, because IM may not detect that mysqld has started.
# SHOW INSTANCES;
########################################################################### ###########################################################################
# #
...@@ -147,7 +190,13 @@ SHOW INSTANCES; ...@@ -147,7 +190,13 @@ SHOW INSTANCES;
# incomplete SHOW INSTANCE STATUS command. # incomplete SHOW INSTANCE STATUS command.
# #
########################################################################### ###########################################################################
--error 1149
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.8.
--echo --------------------------------------------------------------------
--error ER_SYNTAX_ERROR
SHOW INSTANCE STATUS; SHOW INSTANCE STATUS;
# #
...@@ -159,8 +208,13 @@ SHOW INSTANCE STATUS; ...@@ -159,8 +208,13 @@ SHOW INSTANCE STATUS;
# a list as argument. # a list as argument.
# #
--error 1149 --echo
--echo --------------------------------------------------------------------
--echo -- BUG#12813
--echo --------------------------------------------------------------------
--error ER_SYNTAX_ERROR
START INSTANCE mysqld1,mysqld2,mysqld3; START INSTANCE mysqld1,mysqld2,mysqld3;
--error 1149 --error ER_SYNTAX_ERROR
STOP INSTANCE mysqld1,mysqld2,mysqld3; STOP INSTANCE mysqld1,mysqld2,mysqld3;
--monitoring-interval=1
...@@ -17,6 +17,17 @@ ...@@ -17,6 +17,17 @@
# - the second instance is offline; # - the second instance is offline;
# #
# Wait for mysqld1 (guarded instance) to start.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
# Let IM detect that mysqld1 is online. This delay should be longer than
# monitoring interval.
--sleep 3
# Check that start conditions are as expected.
SHOW INSTANCES; SHOW INSTANCES;
# #
...@@ -40,11 +51,10 @@ SHOW INSTANCE OPTIONS mysqld2; ...@@ -40,11 +51,10 @@ SHOW INSTANCE OPTIONS mysqld2;
# #
START INSTANCE mysqld2; START INSTANCE mysqld2;
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
# FIXME
-- sleep 3
STOP INSTANCE mysqld2; STOP INSTANCE mysqld2;
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
# #
# Check 'SHOW LOG FILES' command: # Check 'SHOW LOG FILES' command:
......
#!/bin/sh #!/bin/sh
if [ $# -ne 2 ]; then ###########################################################################
echo "Usage: kill_n_check.sh <pid file path> killed|restarted"
# NOTE: this script returns 0 (success) even in case of failure. This is
# because this script is executed under mysql-test-run[.pl] and it's better to
# examine particular problem in log file, than just having said that the test
# case has failed.
###########################################################################
check_restart()
{
if [ ! -r "$pid_path" ]; then
user_msg='the process was killed'
return 1
fi
new_pid=`cat "$pid_path" 2>/dev/null`
if [ $? -eq 0 -a "$original_pid" = "$new_pid" ]; then
user_msg='the process was not restarted'
return 1
fi
user_msg='the process was restarted'
return 0
}
###########################################################################
if [ $# -ne 3 ]; then
echo "Usage: kill_n_check.sh <pid file path> killed|restarted <timeout>"
exit 0 exit 0
fi fi
pid_path="$1" pid_path="$1"
expected_result="$2" expected_result="$2"
total_timeout="$3"
if [ -z "$pid_path" -o ! -r "$pid_path" ]; then if [ "$expected_result" != 'killed' -a \
echo "Error: invalid PID path ($pid_path) or PID file does not exist." "$expected_result" != 'restarted' ]; then
echo "Error: invalid second argument ('killed' or 'restarted' expected)."
exit 0 exit 0
fi fi
if [ "$expected_result" != "killed" -a \ if [ -z "$pid_path" ]; then
"$expected_result" != "restarted" ]; then echo "Error: invalid PID path ($pid_path)."
echo "Error: expected result must be either 'killed' or 'restarted'."
exit 0 exit 0
fi fi
# echo "PID path: '$pid_path'" if [ $expected_result = 'killed' -a ! -r "$pid_path" ]; then
echo "Error: PID file ($pid_path) does not exist."
exit 0
fi
original_pid=`cat "$pid_path"` if [ -z "$total_timeout" ]; then
echo "Error: timeout is not specified."
exit 0
fi
# echo "Original PID: $original_pid" ###########################################################################
original_pid=`cat "$pid_path"`
echo "Killing the process..." echo "Killing the process..."
kill -9 $original_pid kill -9 $original_pid
###########################################################################
echo "Sleeping..." echo "Sleeping..."
sleep 3 if [ "$expected_result" = "restarted" ]; then
new_pid="" # Wait for the process to restart.
[ -r "$pid_path" ] && new_pid=`cat "$pid_path"` cur_attempt=1
# echo "New PID: $new_pid" while true; do
if [ "$expected_result" = "restarted" ]; then if check_restart; then
echo "Success: $user_msg."
exit 0
fi
if [ -z "$new_pid" ]; then [ $cur_attempt -ge $total_timeout ] && break
echo "Error: the process was killed."
exit 0
fi
if [ "$original_pid" -eq "$new_pid" ]; then sleep 1
echo "Error: the process was not restarted."
exit 0 cur_attempt=`expr $cur_attempt + 1`
fi
done
echo "Success: the process was restarted."
echo "Error: $user_msg."
exit 0 exit 0
else # $expected_result = killed else # $expected_result == killed
# Here we have to sleep for some long time to ensure that the process will
# not be restarted.
sleep $total_timeout
new_pid=`cat "$pid_path" 2>/dev/null`
if [ "$new_pid" -a "$new_pid" -ne "$original_pid" ]; then if [ "$new_pid" -a "$new_pid" -ne "$original_pid" ]; then
echo "Error: the process was restarted." echo "Error: the process was restarted."
exit 0 else
echo "Success: the process was killed."
fi fi
echo "Success: the process was killed."
exit 0 exit 0
fi fi
#!/bin/sh
###########################################################################
pid_path="$1"
total_attempts="$2"
event="$3"
case "$3" in
started)
check_fn='check_started';
;;
stopped)
check_fn='check_stopped';
;;
*)
echo "Error: invalid third argument ('started' or 'stopped' expected)."
exit 0
esac
###########################################################################
check_started()
{
[ ! -r "$pid_path" ] && return 1
new_pid=`cat "$pid_path" 2>/dev/null`
[ $? -eq 0 -a "$original_pid" = "$new_pid" ] && return 1
return 0
}
###########################################################################
check_stopped()
{
[ -r "$pid_path" ] && return 1
return 0
}
###########################################################################
cur_attempt=1
while true; do
if ( eval $check_fn ); then
echo "Success: the process has been $event."
exit 0
fi
[ $cur_attempt -ge $total_attempts ] && break
sleep 1
cur_attempt=`expr $cur_attempt + 1`
done
echo "Error: the process has not been $event in $total_attempts secs."
exit 0
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