Commit 682eb07a authored by Alexander Nozdrin's avatar Alexander Nozdrin

Merge revno:2617.31.54 from 6.0.

parent 0191eb8d
SHOW VARIABLES LIKE 'server_id';
Variable_name Value
server_id 1
SHOW INSTANCES;
instance_name state
mysqld1 XXXXX
mysqld2 offline
--> Listing users...
im_admin
==> Adding user 'testuser'...
--> IM password file:
testuser:*0D3CED9BEC10A777AEC23CCC353A8C08A633045E
im_admin:*598D51AD2DFF7792045D6DF3DDF9AA1AF737B295
--> EOF
--> Printing out line for 'testuser'...
testuser:*0D3CED9BEC10A777AEC23CCC353A8C08A633045E
--> Listing users...
im_admin
testuser
==> Changing the password of 'testuser'...
--> IM password file:
im_admin:*598D51AD2DFF7792045D6DF3DDF9AA1AF737B295
testuser:*39C549BDECFBA8AFC3CE6B948C9359A0ECE08DE2
--> EOF
--> Printing out line for 'testuser'...
testuser:*39C549BDECFBA8AFC3CE6B948C9359A0ECE08DE2
--> Listing users...
testuser
im_admin
==> Dropping user 'testuser'...
--> IM password file:
im_admin:*598D51AD2DFF7792045D6DF3DDF9AA1AF737B295
--> EOF
--> Listing users...
im_admin
SHOW VARIABLES LIKE 'server_id';
Variable_name Value
server_id 1
SHOW INSTANCES;
instance_name state
mysqld1 XXXXX
mysqld2 offline
Killing the process...
Waiting...
Success: the process was restarted.
Success: server is ready to accept connection on socket.
--------------------------------------------------------------------
-- Test for BUG#12751
--------------------------------------------------------------------
START INSTANCE mysqld2;
Success: the process has been started.
Killing the process...
Waiting...
Success: the process was restarted.
Success: server is ready to accept connection on socket.
SHOW INSTANCE STATUS mysqld1;
instance_name state version_number version mysqld_compatible
mysqld1 STATE VERSION_NUMBER VERSION no
STOP INSTANCE mysqld2;
Success: the process has been stopped.
SHOW VARIABLES LIKE 'server_id';
Variable_name Value
server_id 1
SHOW INSTANCES;
instance_name state
mysqld1 XXXXX
mysqld2 offline
--------------------------------------------------------------------
server_id = 1
server_id = 2
--------------------------------------------------------------------
CREATE INSTANCE mysqld3
server_id = 3,
socket = "$MYSQL_TMP_DIR/mysqld_3.sock";
SHOW INSTANCES;
instance_name state
mysqld3 offline
mysqld2 offline
mysqld1 online
--------------------------------------------------------------------
server_id = 1
server_id = 2
server_id=3
--------------------------------------------------------------------
CREATE INSTANCE mysqld1;
ERROR HY000: Instance already exists
CREATE INSTANCE mysqld2;
ERROR HY000: Instance already exists
CREATE INSTANCE mysqld3;
ERROR HY000: Instance already exists
--------------------------------------------------------------------
nonguarded
--------------------------------------------------------------------
CREATE INSTANCE mysqld4
nonguarded,
server_id = 4,
socket = "$MYSQL_TMP_DIR/mysqld_4.sock";
SHOW INSTANCES;
instance_name state
mysqld3 offline
mysqld4 offline
mysqld1 online
mysqld2 offline
--------------------------------------------------------------------
nonguarded
nonguarded
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
CREATE INSTANCE mysqld5
test-A = 000,
test-B = test,
server_id = 5,
socket = "$MYSQL_TMP_DIR/mysqld_5.sock";
SHOW INSTANCES;
instance_name state
mysqld1 online
mysqld4 offline
mysqld5 offline
mysqld2 offline
mysqld3 offline
--------------------------------------------------------------------
test-A=000
--------------------------------------------------------------------
test-B=test
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
CREATE INSTANCE mysqld6
test-C1 = 10 ,
test-C2 = 02 ,
server_id = 6,
socket = "$MYSQL_TMP_DIR/mysqld_6.sock";
SHOW INSTANCES;
instance_name state
mysqld1 online
mysqld2 offline
mysqld5 offline
mysqld6 offline
mysqld3 offline
mysqld4 offline
--------------------------------------------------------------------
test-C1=10
--------------------------------------------------------------------
test-C2=02
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
CREATE INSTANCE mysqld7 test-D = test-D-value ;
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
SHOW INSTANCES;
instance_name state
mysqld1 online
mysqld2 offline
mysqld5 offline
mysqld6 offline
mysqld3 offline
mysqld4 offline
CREATE INSTANCE mysqld8 test-E 0 ;
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
SHOW INSTANCES;
instance_name state
mysqld1 online
mysqld2 offline
mysqld5 offline
mysqld6 offline
mysqld3 offline
mysqld4 offline
CREATE INSTANCE mysqld8 test-F = ;
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
SHOW INSTANCES;
instance_name state
mysqld1 online
mysqld2 offline
mysqld5 offline
mysqld6 offline
mysqld3 offline
mysqld4 offline
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
CREATE INSTANCE mysqld9
test-1=" hello world ",
test-2=' ',
server_id = 9,
socket = "$MYSQL_TMP_DIR/mysqld_9.sock";
SHOW INSTANCES;
instance_name state
mysqld1 online
mysqld2 offline
mysqld5 offline
mysqld6 offline
mysqld3 offline
mysqld4 offline
mysqld9 offline
CREATE INSTANCE mysqld10
test-3='\b\babc\sdef',
server_id = 10,
socket = "$MYSQL_TMP_DIR/mysqld_10.sock";
SHOW INSTANCES;
instance_name state
mysqld1 online
mysqld9 offline
mysqld5 offline
mysqld6 offline
mysqld3 offline
mysqld4 offline
mysqld10 offline
mysqld2 offline
CREATE INSTANCE mysqld11
test-4='abc\tdef',
test-5='abc\ndef',
server_id = 11,
socket = "$MYSQL_TMP_DIR/mysqld_11.sock";
SHOW INSTANCES;
instance_name state
mysqld1 online
mysqld11 offline
mysqld5 offline
mysqld6 offline
mysqld3 offline
mysqld4 offline
mysqld10 offline
mysqld2 offline
mysqld9 offline
CREATE INSTANCE mysqld12
test-6="abc\rdef",
test-7="abc\\def",
server_id = 12,
socket = "$MYSQL_TMP_DIR/mysqld_12.sock";
SHOW INSTANCES;
instance_name state
mysqld1 online
mysqld9 offline
mysqld5 offline
mysqld6 offline
mysqld3 offline
mysqld4 offline
mysqld10 offline
mysqld2 offline
mysqld12 offline
mysqld11 offline
CREATE INSTANCE mysqld13 test-bad=' \ ';
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
SHOW INSTANCES;
instance_name state
mysqld1 online
mysqld9 offline
mysqld5 offline
mysqld6 offline
mysqld3 offline
mysqld4 offline
mysqld10 offline
mysqld2 offline
mysqld12 offline
mysqld11 offline
--------------------------------------------------------------------
test-1= hello world
--------------------------------------------------------------------
test-2=
--------------------------------------------------------------------
test-3=abc def
--------------------------------------------------------------------
test-4=abc def
--------------------------------------------------------------------
test-5=abc
--------------------------------------------------------------------
test-6=abc def
--------------------------------------------------------------------
test-7=abc\def
--------------------------------------------------------------------
--------------------------------------------------------------------
CREATE INSTANCE qqq1;
ERROR HY000: Malformed instance name.
SHOW VARIABLES LIKE 'server_id';
Variable_name Value
server_id 1
SHOW INSTANCES;
instance_name state
mysqld1 XXXXX
mysqld2 offline
--------------------------------------------------------------------
-- 1.1.2.
--------------------------------------------------------------------
START INSTANCE mysqld2;
Success: the process has been started.
SHOW VARIABLES LIKE 'port';
Variable_name Value
port IM_MYSQLD2_PORT
--------------------------------------------------------------------
-- 1.1.3.
--------------------------------------------------------------------
STOP INSTANCE mysqld2;
Success: the process has been stopped.
--------------------------------------------------------------------
-- 1.1.4.
--------------------------------------------------------------------
START INSTANCE mysqld3;
ERROR HY000: Unknown instance name
START INSTANCE mysqld1;
ERROR HY000: The instance is already started
--------------------------------------------------------------------
-- 1.1.5.
--------------------------------------------------------------------
STOP INSTANCE mysqld3;
ERROR HY000: Unknown instance name
--------------------------------------------------------------------
-- 1.1.6.
--------------------------------------------------------------------
Killing the process...
Waiting...
Success: the process was restarted.
SHOW INSTANCES;
instance_name state
mysqld1 online
mysqld2 offline
--------------------------------------------------------------------
-- 1.1.7.
--------------------------------------------------------------------
START INSTANCE mysqld2;
Success: the process has been started.
Killing the process...
Waiting...
Success: the process was killed.
--------------------------------------------------------------------
-- 1.1.8.
--------------------------------------------------------------------
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
--------------------------------------------------------------------
-- BUG#12813
--------------------------------------------------------------------
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
STOP 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
STOP INSTANCE mysqld2;
ERROR HY000: Cannot stop instance. Perhaps the instance is not started, or was started manually, so IM cannot find the pidfile.
End of 5.0 tests
SHOW VARIABLES LIKE 'server_id';
Variable_name Value
server_id 1
SHOW INSTANCES;
instance_name state
mysqld1 XXXXX
mysqld2 offline
UNSET mysqld1.server_id;
ERROR HY000: The instance is active. Stop the instance first
SET mysqld1.server_id = 11;
ERROR HY000: The instance is active. Stop the instance first
CREATE INSTANCE mysqld3
datadir = '/',
server_id = 3,
socket = "$MYSQL_TMP_DIR/mysqld_3.sock";
START INSTANCE mysqld3;
UNSET mysqld3.server_id;
ERROR HY000: The instance is active. Stop the instance first
SET mysqld3.server_id = 11;
ERROR HY000: The instance is active. Stop the instance first
STOP INSTANCE mysqld3;
SHOW INSTANCE STATUS mysqld3;
instance_name state version_number version mysqld_compatible
mysqld3 offline VERSION_NUMBER VERSION no
UNSET mysqld2.server_id;
UNSET mysqld2.server_id;
SHOW INSTANCE OPTIONS mysqld2;
option_name value
instance_name option_value
socket option_value
pid-file option_value
port option_value
datadir option_value
log option_value
log-error option_value
log-slow-queries option_value
language option_value
character-sets-dir option_value
basedir option_value
shutdown-delay option_value
skip-stack-trace option_value
loose-skip-innodb option_value
loose-skip-ndbcluster option_value
nonguarded option_value
log-output option_value
SET mysqld2.server_id = 2;
SET mysqld2.server_id = 2;
SHOW INSTANCE OPTIONS mysqld2;
option_name value
instance_name option_value
socket option_value
pid-file option_value
port option_value
datadir option_value
log option_value
log-error option_value
log-slow-queries option_value
language option_value
character-sets-dir option_value
basedir option_value
shutdown-delay option_value
skip-stack-trace option_value
loose-skip-innodb option_value
loose-skip-ndbcluster option_value
nonguarded option_value
log-output option_value
server_id option_value
UNSET mysqld2.server_id = 11;
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
SET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc = 0010, mysqld3.ddd = 0020;
--------------------------------------------------------------------
aaa
--------------------------------------------------------------------
bbb
--------------------------------------------------------------------
ccc=0010
--------------------------------------------------------------------
ddd=0020
--------------------------------------------------------------------
UNSET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc, mysqld3.ddd;
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
SET mysqld2.aaa, mysqld3.bbb, mysqld.ccc = 0010;
ERROR HY000: Unknown instance name
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
SET mysqld2.aaa, mysqld3.bbb, mysqld1.ccc = 0010;
ERROR HY000: The instance is active. Stop the instance first
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
UNSET mysqld2.server_id, mysqld3.server_id, mysqld.ccc;
ERROR HY000: Unknown instance name
--------------------------------------------------------------------
server_id = 1
server_id=2
server_id=3
--------------------------------------------------------------------
UNSET mysqld2.server_id, mysqld3.server_id, mysqld1.ccc;
ERROR HY000: The instance is active. Stop the instance first
--------------------------------------------------------------------
server_id = 1
server_id=2
server_id=3
--------------------------------------------------------------------
DROP INSTANCE mysqld3;
SET mysqld2.server_id=222;
SET mysqld2.server_id = 222;
SET mysqld2.server_id = 222 ;
SET mysqld2 . server_id = 222 ;
SET mysqld2 . server_id = 222 , mysqld2 . aaa , mysqld2 . bbb ;
--------------------------------------------------------------------
server_id = 1
server_id=222
--------------------------------------------------------------------
aaa
--------------------------------------------------------------------
bbb
--------------------------------------------------------------------
UNSET mysqld2 . aaa , mysqld2 . bbb ;
--------------------------------------------------------------------
server_id = 1
server_id=222
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
server_id = 1
server_id=222
--------------------------------------------------------------------
SHOW VARIABLES LIKE 'server_id';
Variable_name Value
server_id 1
SHOW INSTANCES;
instance_name state
mysqld1 online
mysqld2 offline
FLUSH INSTANCES;
ERROR HY000: At least one instance is active. Stop all instances first
STOP INSTANCE mysqld1;
SHOW INSTANCES;
instance_name state
mysqld1 offline
mysqld2 offline
FLUSH INSTANCES;
SHOW VARIABLES LIKE 'server_id';
Variable_name Value
server_id 1
SHOW INSTANCES;
instance_name state
mysqld1 XXXXX
mysqld2 offline
SHOW INSTANCE OPTIONS mysqld1;
option_name value
instance_name VALUE
socket VALUE
pid-file VALUE
port VALUE
datadir VALUE
log VALUE
log-error VALUE
log-slow-queries VALUE
language VALUE
character-sets-dir VALUE
basedir VALUE
server_id VALUE
shutdown-delay VALUE
skip-stack-trace VALUE
loose-skip-innodb VALUE
loose-skip-ndbcluster VALUE
log-output VALUE
SHOW INSTANCE OPTIONS mysqld2;
option_name value
instance_name VALUE
socket VALUE
pid-file VALUE
port VALUE
datadir VALUE
log VALUE
log-error VALUE
log-slow-queries VALUE
language VALUE
character-sets-dir VALUE
basedir VALUE
server_id VALUE
shutdown-delay VALUE
skip-stack-trace VALUE
loose-skip-innodb VALUE
loose-skip-ndbcluster VALUE
nonguarded VALUE
log-output VALUE
START INSTANCE mysqld2;
Success: the process has been started.
STOP INSTANCE mysqld2;
Success: the process has been stopped.
SHOW mysqld1 LOG FILES;
Logfile Path File size
ERROR LOG PATH FILE_SIZE
GENERAL LOG PATH FILE_SIZE
SLOW LOG PATH FILE_SIZE
SHOW mysqld2 LOG FILES;
Logfile Path File size
ERROR LOG PATH FILE_SIZE
GENERAL LOG PATH FILE_SIZE
SLOW LOG PATH FILE_SIZE
SHOW mysqld1 LOG ERROR 10;
Log
LOG_DATA
SHOW mysqld1 LOG SLOW 10;
Log
LOG_DATA
SHOW mysqld1 LOG GENERAL 10;
Log
LOG_DATA
SHOW mysqld1 LOG ERROR 10, 2;
Log
LOG_DATA
SHOW mysqld1 LOG SLOW 10, 2;
Log
LOG_DATA
SHOW mysqld1 LOG GENERAL 10, 2;
Log
LOG_DATA
SHOW mysqld2 LOG ERROR 10;
Log
LOG_DATA
SHOW mysqld2 LOG SLOW 10;
Log
LOG_DATA
SHOW mysqld2 LOG GENERAL 10;
Log
LOG_DATA
SHOW mysqld2 LOG ERROR 10, 2;
Log
LOG_DATA
SHOW mysqld2 LOG SLOW 10, 2;
Log
LOG_DATA
SHOW mysqld2 LOG GENERAL 10, 2;
Log
LOG_DATA
##############################################################################
#
# List the test cases that are to be disabled temporarily.
#
# Separate the test case name and the comment with ':'.
#
# <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment>
#
# Do not use any TAB characters for whitespace.
#
##############################################################################
im_options : Bug#20294 2006-07-24 stewart Instance manager test im_options fails randomly
im_daemon_life_cycle : Bug#20294 2007-05-14 alik Instance manager tests fail randomly
im_cmd_line : Bug#20294 2007-05-14 alik Instance manager tests fail randomly
im_utils : Bug#20294 2007-05-30 alik Instance manager tests fail randomly
im_instance_conf : Bug#20294 2007-05-30 alik Instance manager tests fail randomly
im_life_cycle : BUG#27851 Instance manager dies on ASSERT in ~Thread_registry() or from not being able to close a mysqld instance.
im_instance_conf : BUG#28743 Instance manager generates warnings in test suite
im_utils : BUG#28743 Instance manager generates warnings in test suite
# This file is intended to be used in each IM-test. It contains stamements,
# that ensure that starting conditions (environment) for the IM-test are as
# expected.
# Check the running instances.
--connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
--connection mysql1_con
SHOW VARIABLES LIKE 'server_id';
--source include/not_windows.inc
--connection default
# Let IM detect that mysqld1 is online. This delay should be longer than
# monitoring interval.
--sleep 2
# Check that IM understands that mysqld1 is online, while mysqld2 is
# offline.
--replace_result starting XXXXX online XXXXX
SHOW INSTANCES;
###########################################################################
#
# Tests for user-management command-line options.
#
###########################################################################
--source suite/im/t/im_check_env.inc
###########################################################################
# List users so we are sure about starting conditions.
--echo --> Listing users...
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --list-users 2>&1 >/dev/null
--echo
# Add a new user.
--echo ==> Adding user 'testuser'...
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --add-user --username=testuser --password=abc 2>&1 >/dev/null
--echo
--echo --> IM password file:
--exec cat $IM_PASSWORD_PATH
--echo --> EOF
--echo
--echo --> Printing out line for 'testuser'...
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --print-password-line --username=testuser --password=abc | tail -2 | head -1
--echo
--echo --> Listing users...
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --list-users 2>&1 >/dev/null
--echo
# Edit user's attributes.
--echo ==> Changing the password of 'testuser'...
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --edit-user --username=testuser --password=xyz 2>&1 >/dev/null
--echo
--echo --> IM password file:
--exec cat $IM_PASSWORD_PATH
--echo --> EOF
--echo
--echo --> Printing out line for 'testuser'...
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --print-password-line --username=testuser --password=xyz | tail -2 | head -1
--echo
--echo --> Listing users...
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --list-users 2>&1 >/dev/null
--echo
# Drop user.
--echo ==> Dropping user 'testuser'...
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --drop-user --username=testuser 2>&1 >/dev/null
--echo
--echo --> IM password file:
--exec cat $IM_PASSWORD_PATH
--echo --> EOF
--echo
--echo --> Listing users...
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --list-users 2>&1 >/dev/null
--echo
--run-as-service
--log=$MYSQLTEST_VARDIR/log/im.log
--monitoring-interval=1
let $UTIL=$MYSQL_TEST_DIR/suite/im/t;
###########################################################################
#
# This file contains test for (1.2) test suite.
#
# Consult WL#2789 for more information.
#
###########################################################################
--exec $UTIL/log.sh im_daemon_life_cycle im_daemon_life_cycle.imtest started.
###########################################################################
--source suite/im/t/im_check_env.inc
# Turn on reconnect, not on by default anymore.
--enable_reconnect
###########################################################################
#
# The main daemon-life-cycle test case -- check that IM-angel will restart
# IM-main if it got killed:
# - kill IM-main and check that IM-angel will restart it;
# - wait for IM-main to start accepting connections before continue test
# case;
#
# NOTE: timeout is 55 seconds. Timeout should be more than shutdown-delay
# specified for managed MySQL instance. Now shutdown-delay is 10 seconds
# (set in mysql-test-run.pl). So, 55 seconds should be enough to make 5
# attempts.
#
###########################################################################
--exec $UTIL/log.sh im_daemon_life_cycle Main-test: starting...
--exec $UTIL/log.sh im_daemon_life_cycle Killing IM-main...
--exec $UTIL/kill_n_check.sh $IM_PATH_PID restarted 55 im_daemon_life_cycle
--exec $UTIL/log.sh im_daemon_life_cycle Waiting for IM-main to start accepting connections...
--exec $UTIL/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 55 im_daemon_life_cycle
--exec $UTIL/log.sh im_daemon_life_cycle Main-test: done.
###########################################################################
#
# BUG#12751: Instance Manager: client hangs
# - start nonguarded instance (mysqld2);
# - kill IM-main and get it restarted by IM-angel;
# - check that guarded instance (mysqld1) is accepting connections.
# - check that non-guarded instance (mysqld2) were not stopped.
#
###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- Test for BUG#12751
--echo --------------------------------------------------------------------
--exec $UTIL/log.sh im_daemon_life_cycle BUG12751: starting...
# 1. Start mysqld;
--exec $UTIL/log.sh im_daemon_life_cycle mysqld2: starting...
START INSTANCE mysqld2;
--exec $UTIL/log.sh im_daemon_life_cycle mysqld2: waiting to start...
--exec $UTIL/wait_for_process.sh $IM_MYSQLD2_PATH_PID 55 started im_daemon_life_cycle
--exec $UTIL/log.sh im_daemon_life_cycle mysqld2: started.
# 2. Restart IM-main;
--exec $UTIL/log.sh im_daemon_life_cycle Killing IM-main...
--exec $UTIL/kill_n_check.sh $IM_PATH_PID restarted 55 im_daemon_life_cycle
--exec $UTIL/log.sh im_daemon_life_cycle Waiting for IM-main to start accepting connections...
--exec $UTIL/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 55 im_daemon_life_cycle
# 3. Issue some statement -- connection should be re-established.
--exec $UTIL/log.sh im_daemon_life_cycle Checking that IM-main processing commands...
--replace_column 2 STATE 3 VERSION_NUMBER 4 VERSION
SHOW INSTANCE STATUS mysqld1;
# 4. Stop mysqld2, because it will not be stopped by IM, as it is nonguarded.
# So, if it we do not stop it, it will be stopped by mysql-test-run.pl with
# warning.
--exec $UTIL/log.sh im_daemon_life_cycle mysqld2: stopping...
STOP INSTANCE mysqld2;
--exec $UTIL/log.sh im_daemon_life_cycle mysqld2: waiting to stop...
--exec $UTIL/wait_for_process.sh $IM_MYSQLD2_PATH_PID 55 stopped im_daemon_life_cycle
--exec $UTIL/log.sh im_daemon_life_cycle mysqld2: stopped.
###########################################################################
--exec $UTIL/log.sh im_daemon_life_cycle BUG12751: done.
###########################################################################
#
# This test suite checks the following statements:
# - CREATE INSTANCE <instance_name> [option1[=option1_value], ...];
# - DROP INSTANCE <instance_name>;
#
# For CREATE INSTANCE we check that:
# - CREATE INSTANCE succeeds for non-existing instance;
# - CREATE INSTANCE fails for existing instance;
# - CREATE INSTANCE can get additional options with and w/o values;
# - CREATE INSTANCE parses options and handles grammar errors correctly.
# Check that strings with spaces are handled correctly, unknown (for
# mysqld) options should also be handled;
# - CREATE INSTANCE updates both config file and internal configuration cache;
# - CREATE INSTANCE allows to create instances only with properly formed
# names (mysqld*);
#
# For DROP INSTANCE we check that:
# - DROP INSTANCE succeeds for existing instance;
# - DROP INSTANCE fails for non-existing instance;
# - DROP INSTANCE fails for active instance.
# - DROP INSTANCE updates both config file and internal configuration cache;
#
# NOTE: each CREATE INSTANCE statement must specify socket-file-name, otherwise
# this results of the test can be affected by another running test suite.
#
###########################################################################
--source suite/im/t/im_check_env.inc
###########################################################################
#
# Check starting conditions.
#
###########################################################################
# Check that the configuration file contains only instances that we expect.
--echo --------------------------------------------------------------------
--exec grep '^server_id[^a-zA-Z0-9_\-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
###########################################################################
#
# CREATE INSTANCE tests.
#
###########################################################################
# Check that CREATE INSTANCE succeeds for non-existing instance and also check
# that both config file and internal configuration cache have been updated.
CREATE INSTANCE mysqld3
server_id = 3,
socket = "$MYSQL_TMP_DIR/mysqld_3.sock";
SHOW INSTANCES;
--echo --------------------------------------------------------------------
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
# Check that CREATE INSTANCE fails for existing instance. Let's all three
# existing instances (running one, stopped one and just created one). Just in
# case...
--error 3012 # ER_CREATE_EXISTING_INSTANCE
CREATE INSTANCE mysqld1;
--error 3012 # ER_CREATE_EXISTING_INSTANCE
CREATE INSTANCE mysqld2;
--error 3012 # ER_CREATE_EXISTING_INSTANCE
CREATE INSTANCE mysqld3;
# Check that CREATE INSTANCE can get additional options with and w/o values.
# Ensure that config file is updated properly.
# - without values;
--echo --------------------------------------------------------------------
--exec grep "^nonguarded\$" $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
CREATE INSTANCE mysqld4
nonguarded,
server_id = 4,
socket = "$MYSQL_TMP_DIR/mysqld_4.sock";
SHOW INSTANCES;
--echo --------------------------------------------------------------------
--exec grep "^nonguarded\$" $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
# - with value;
--echo --------------------------------------------------------------------
--exec grep '^test-A[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^test-B[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
CREATE INSTANCE mysqld5
test-A = 000,
test-B = test,
server_id = 5,
socket = "$MYSQL_TMP_DIR/mysqld_5.sock";
SHOW INSTANCES;
--echo --------------------------------------------------------------------
--exec grep '^test-A[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
--exec grep '^test-B[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
# Check that CREATE INSTANCE parses options and handles grammar errors
# correctly. Check that strings with spaces are handled correctly,
# unknown (for mysqld) options should also be handled.
# - check handling of extra spaces;
--echo --------------------------------------------------------------------
--exec grep '^test-C1[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^test-C2[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
CREATE INSTANCE mysqld6
test-C1 = 10 ,
test-C2 = 02 ,
server_id = 6,
socket = "$MYSQL_TMP_DIR/mysqld_6.sock";
SHOW INSTANCES;
--echo --------------------------------------------------------------------
--exec grep '^test-C1[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
--exec grep '^test-C2[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
# - check handling of grammar error;
--echo --------------------------------------------------------------------
--exec grep '^test-D[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^test-E[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--error ER_SYNTAX_ERROR
CREATE INSTANCE mysqld7 test-D = test-D-value ;
SHOW INSTANCES;
--error ER_SYNTAX_ERROR
CREATE INSTANCE mysqld8 test-E 0 ;
SHOW INSTANCES;
--error ER_SYNTAX_ERROR
CREATE INSTANCE mysqld8 test-F = ;
SHOW INSTANCES;
--echo --------------------------------------------------------------------
--exec grep '^test-D[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^test-E[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
# - check parsing of string option values
--echo --------------------------------------------------------------------
--exec grep '^test-1[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^test-2[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^test-3[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^test-4[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^test-5[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^test-6[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^test-7[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
CREATE INSTANCE mysqld9
test-1=" hello world ",
test-2=' ',
server_id = 9,
socket = "$MYSQL_TMP_DIR/mysqld_9.sock";
SHOW INSTANCES;
CREATE INSTANCE mysqld10
test-3='\b\babc\sdef',
server_id = 10,
socket = "$MYSQL_TMP_DIR/mysqld_10.sock";
# test-3='abc def'
SHOW INSTANCES;
CREATE INSTANCE mysqld11
test-4='abc\tdef',
test-5='abc\ndef',
server_id = 11,
socket = "$MYSQL_TMP_DIR/mysqld_11.sock";
SHOW INSTANCES;
CREATE INSTANCE mysqld12
test-6="abc\rdef",
test-7="abc\\def",
server_id = 12,
socket = "$MYSQL_TMP_DIR/mysqld_12.sock";
# test-6=abc
SHOW INSTANCES;
--error ER_SYNTAX_ERROR
CREATE INSTANCE mysqld13 test-bad=' \ ';
SHOW INSTANCES;
--echo --------------------------------------------------------------------
--exec grep '^test-1[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
--exec grep '^test-2[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
--exec grep '^test-3[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
--exec grep '^test-4[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
--exec grep '^test-5[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
--exec grep '^test-6[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
--exec grep '^test-7[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
--exec grep '^test-bad' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
# Check that CREATE INSTANCE allows to create instances only with properly
# formed names (mysqld*).
--error 3014 # ER_MALFORMED_INSTANCE_NAME
CREATE INSTANCE qqq1;
let $UTIL=$MYSQL_TEST_DIR/suite/im/t;
###########################################################################
#
# This file contains test for (1.1) test suite.
#
# Consult WL#2789 for more information.
#
###########################################################################
--source suite/im/t/im_check_env.inc
###########################################################################
#
# 1.1.2. Check 'START INSTANCE' command:
# - start the second instance;
# - check that it is reported as online;
# - execute some SQL-statement on mysqld2 to ensure that it is really up and
# running;
#
###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.2.
--echo --------------------------------------------------------------------
START INSTANCE mysqld2;
# FIXME: START INSTANCE should be synchronous.
--exec $UTIL/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_life_cycle
# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
# its pid file is not enough, because it is unknown when IM detects that
# mysqld has started.
# SHOW INSTANCES;
--connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD2_PORT,$IM_MYSQLD2_SOCK)
--connection mysql_con
--replace_result $IM_MYSQLD2_PORT IM_MYSQLD2_PORT
SHOW VARIABLES LIKE 'port';
--connection default
--disconnect mysql_con
###########################################################################
#
# 1.1.3. Check 'STOP INSTANCE' command:
# - stop the second instance;
# - check that it is reported as offline;
# - TODO: try to execute some SQL-statement to ensure that it is really down;
#
###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.3.
--echo --------------------------------------------------------------------
STOP INSTANCE mysqld2;
# FIXME: STOP INSTANCE should be synchronous.
--exec $UTIL/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_life_cycle
# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
# its pid file is not enough, because it is unknown when IM detects that
# mysqld has started.
# SHOW INSTANCES;
###########################################################################
#
# 1.1.4. Check that Instance Manager reports correct errors for 'START
# INSTANCE' command:
# - if the client tries to start unregistered instance;
# - if the client tries to start already started instance;
# - if the client submits invalid arguments;
#
###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.4.
--echo --------------------------------------------------------------------
--error 3000 # ER_BAD_INSTANCE_NAME
START INSTANCE mysqld3;
--error 3002 # ER_INSTANCE_ALREADY_STARTED
START INSTANCE mysqld1;
###########################################################################
#
# 1.1.5. Check that Instance Manager reports correct errors for
# 'STOP INSTANCE' command:
# - if the client tries to start unregistered instance;
# - if the client tries to start already stopped instance;
# - if the client submits invalid arguments;
#
###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.5.
--echo --------------------------------------------------------------------
--error 3000 # ER_BAD_INSTANCE_NAME
STOP INSTANCE mysqld3;
# TODO: IM should be fixed.
# BUG#12673: Instance Manager allows to stop the instance many times
# --error 3002 # ER_INSTANCE_ALREADY_STARTED
# STOP INSTANCE mysqld2;
###########################################################################
#
# 1.1.6. Check that Instance Manager is able to restart guarded instances.
#
###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.6.
--echo --------------------------------------------------------------------
--exec $UTIL/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30 im_life_cycle
# Give some time to IM to detect that mysqld was restarted. It should be
# longer than monitoring interval.
--sleep 3
SHOW INSTANCES;
###########################################################################
#
# 1.1.7. Check that Instance Manager does not restart non-guarded instance.
#
###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.7.
--echo --------------------------------------------------------------------
START INSTANCE mysqld2;
# FIXME: START INSTANCE should be synchronous.
--exec $UTIL/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_life_cycle
# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
# its pid file is not enough, because it is unknown when IM detects that
# mysqld has started.
# SHOW INSTANCES;
--exec $UTIL/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10 im_life_cycle
# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
# its pid file is not enough, because it is unknown when IM detects that
# mysqld has started.
# SHOW INSTANCES;
###########################################################################
#
# 1.1.8. Check that Instance Manager returns an error on
# incomplete SHOW INSTANCE STATUS command.
#
###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.8.
--echo --------------------------------------------------------------------
--error ER_SYNTAX_ERROR
SHOW INSTANCE STATUS;
#
# Tests for bug fixes
#
#
# Bug #12813 Instance Manager: START/STOP INSTANCE commands accept
# a list as argument.
#
--echo
--echo --------------------------------------------------------------------
--echo -- BUG#12813
--echo --------------------------------------------------------------------
--error ER_SYNTAX_ERROR
START INSTANCE mysqld1,mysqld2,mysqld3;
--error ER_SYNTAX_ERROR
STOP INSTANCE mysqld1,mysqld2,mysqld3;
#
# Bug #12673: Instance Manager: allows to stop the instance many times
#
--error 3001
STOP INSTANCE mysqld2;
--echo End of 5.0 tests
###########################################################################
#
# This test suite checks the following statements:
# - SET <instance id>.<option name> = <option value>;
# - UNSET <instance id>.<option name> = <option value>;
# - FLUSH INSTANCES;
#
# For SET/UNSET we check that:
# - SET ignores spaces correctly;
# - UNSET does not allow option-value part (= <option value>);
# - SET/UNSET can be applied several times w/o error;
# - SET/UNSET is allowed only for stopped instances;
# - SET/UNSET updates both the configuration cache in IM and
# the configuration file;
#
# For FLUSH INSTANCES we check that:
# - FLUSH INSTANCES is allowed only when all instances are stopped;
#
# According to the IM implementation details, we should play at least with the
# following options:
# - server_id
# - port
# - nonguarded
#
# Let's test SET statement on the option 'server_id'. It's expected that
# originally the instances have the following server ids and states:
# - mysqld1: server_id: 1; running (online)
# - mysqld2: server_id: 2; stopped (offline)
#
# NOTE: each CREATE INSTANCE statement must specify socket-file-name, otherwise
# this results of the test can be affected by another running test suite.
#
###########################################################################
--source suite/im/t/im_check_env.inc
###########################################################################
#
# Check that SET/UNSET is allowed only for stopped instances.
#
###########################################################################
# - check that SET/UNSET is denied for running instances;
--error 3015 # ER_INSTANCE_IS_ACTIVE
UNSET mysqld1.server_id;
--error 3015 # ER_INSTANCE_IS_ACTIVE
SET mysqld1.server_id = 11;
# - check that SET/UNSET is denied for active instances:
# - create dummy misconfigured instance;
# - start it;
# - try to set/unset options;
CREATE INSTANCE mysqld3
datadir = '/',
server_id = 3,
socket = "$MYSQL_TMP_DIR/mysqld_3.sock";
START INSTANCE mysqld3;
# FIXME: START INSTANCE should be synchronous.
--sleep 3
# should be longer than monitoring interval and enough to start instance.
# NOTE: We can not analyze state of the instance here -- it can be Failed or
# Starting because Instance Manager is trying to start the misconfigured
# instance several times.
--error 3015 # ER_INSTANCE_IS_ACTIVE
UNSET mysqld3.server_id;
--error 3015 # ER_INSTANCE_IS_ACTIVE
SET mysqld3.server_id = 11;
STOP INSTANCE mysqld3;
# FIXME: STOP INSTANCE should be synchronous.
--sleep 3
# should be longer than monitoring interval and enough to stop instance.
--replace_column 3 VERSION_NUMBER 4 VERSION
SHOW INSTANCE STATUS mysqld3;
# - check that SET/UNSET succeed for stopped instances;
# - check that SET/UNSET can be applied multiple times;
UNSET mysqld2.server_id;
UNSET mysqld2.server_id;
--replace_column 2 option_value
SHOW INSTANCE OPTIONS mysqld2;
SET mysqld2.server_id = 2;
SET mysqld2.server_id = 2;
--replace_column 2 option_value
SHOW INSTANCE OPTIONS mysqld2;
# - check that UNSET does not allow option-value part (= <option value>);
--error ER_SYNTAX_ERROR
UNSET mysqld2.server_id = 11;
# - check that SET/UNSET working properly with multiple options;
SET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc = 0010, mysqld3.ddd = 0020;
--echo --------------------------------------------------------------------
--exec grep "^aaa\$" $MYSQLTEST_VARDIR/im.cnf ;
--echo --------------------------------------------------------------------
--exec grep "^bbb\$" $MYSQLTEST_VARDIR/im.cnf ;
--echo --------------------------------------------------------------------
--exec grep '^ccc[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf ;
--echo --------------------------------------------------------------------
--exec grep '^ddd[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf ;
--echo --------------------------------------------------------------------
UNSET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc, mysqld3.ddd;
--echo --------------------------------------------------------------------
--exec grep "^aaa\$" $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep "^bbb\$" $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^ccc[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^ddd[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
# - check that if some instance name is invalid or the active is active,
# whole SET-statement will not be executed;
--error 3000 # ER_BAD_INSTANCE_NAME
SET mysqld2.aaa, mysqld3.bbb, mysqld.ccc = 0010;
--echo --------------------------------------------------------------------
--exec grep "^aaa\$" $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep "^bbb\$" $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^ccc[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--error 3015 # ER_INSTANCE_IS_ACTIVE
SET mysqld2.aaa, mysqld3.bbb, mysqld1.ccc = 0010;
--echo --------------------------------------------------------------------
--exec grep "^aaa\$" $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep "^bbb\$" $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep '^ccc[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
# - check that if some instance name is invalid or the active is active,
# whole UNSET-statement will not be executed;
--error 3000 # ER_BAD_INSTANCE_NAME
UNSET mysqld2.server_id, mysqld3.server_id, mysqld.ccc;
--echo --------------------------------------------------------------------
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
--error 3015 # ER_INSTANCE_IS_ACTIVE
UNSET mysqld2.server_id, mysqld3.server_id, mysqld1.ccc;
--echo --------------------------------------------------------------------
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
--echo --------------------------------------------------------------------
DROP INSTANCE mysqld3;
# - check that spaces are handled correctly;
SET mysqld2.server_id=222;
SET mysqld2.server_id = 222;
SET mysqld2.server_id = 222 ;
SET mysqld2 . server_id = 222 ;
SET mysqld2 . server_id = 222 , mysqld2 . aaa , mysqld2 . bbb ;
--echo --------------------------------------------------------------------
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf ;
--echo --------------------------------------------------------------------
--exec grep "^aaa\$" $MYSQLTEST_VARDIR/im.cnf ;
--echo --------------------------------------------------------------------
--exec grep "^bbb\$" $MYSQLTEST_VARDIR/im.cnf ;
--echo --------------------------------------------------------------------
UNSET mysqld2 . aaa , mysqld2 . bbb ;
--echo --------------------------------------------------------------------
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf ;
--echo --------------------------------------------------------------------
--exec grep "^aaa\$" $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
--exec grep "^bbb\$" $MYSQLTEST_VARDIR/im.cnf || true;
--echo --------------------------------------------------------------------
###########################################################################
#
# Check that SET/UNSET updates both the configuration cache in IM and
# the configuration file.
#
###########################################################################
# - check that the configuration file has been updated (i.e. contains
# server_id=SERVER_ID for mysqld2);
--echo --------------------------------------------------------------------
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf ;
--echo --------------------------------------------------------------------
# - (for mysqld1) check that the running instance has not been affected:
# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
# returns zero;
--connection mysql1_con
SHOW VARIABLES LIKE 'server_id';
--connection default
# - check that internal cache of Instance Manager has been affected;
# TODO: we should check only server_id option here.
# SHOW INSTANCE OPTIONS mysqld2;
###########################################################################
#
# Check that FLUSH INSTANCES is allowed only when all instances are stopped.
#
###########################################################################
SHOW INSTANCES;
--error 3016 # ER_THERE_IS_ACTIVE_INSTACE
FLUSH INSTANCES;
STOP INSTANCE mysqld1;
# FIXME: STOP INSTANCE should be synchronous.
--sleep 3
# should be longer than monitoring interval and enough to stop instance.
SHOW INSTANCES;
FLUSH INSTANCES;
###########################################################################
#
# This file contains test for (2) test suite.
#
# Consult WL#2789 for more information.
#
###########################################################################
--source suite/im/t/im_check_env.inc
let $UTIL=$MYSQL_TEST_DIR/suite/im/t;
###########################################################################
#
# Check 'SHOW INSTANCE OPTIONS' command.
#
# Since configuration of an mysqld-instance contains directories, we should
# completely ignore the second column (values) in order to make the test
# case produce the same results on different installations;
# TODO: ignore values of only directory-specific options.
#
--replace_column 2 VALUE
SHOW INSTANCE OPTIONS mysqld1;
--replace_column 2 VALUE
SHOW INSTANCE OPTIONS mysqld2;
#
# Before checking log files, we should start the second instance (mysqld2) to
# give it a chance to create log files.
#
START INSTANCE mysqld2;
--exec $UTIL/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_utils
STOP INSTANCE mysqld2;
--exec $UTIL/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_utils
#
# Check 'SHOW LOG FILES' command:
# - check that log files of both offline and online instances are accessible;
# - since placement of the log files is installation-specific, we should
# ignore it in comparisson;
# - also, we should ignore log file size, since it may depend on the version
# being tested;
#
--replace_column 2 PATH 3 FILE_SIZE
SHOW mysqld1 LOG FILES;
--replace_column 2 PATH 3 FILE_SIZE
SHOW mysqld2 LOG FILES;
#
# Check 'SHOW LOG' command:
# - check that all three kinds of logs are available for both offline and
# online instances;
# - we should ignore the value, because it is very specific and depends on
# many factors; we only check that Instance Manager is able to provide log
# files.
#
# mysqld1 (online) w/o the optional argument.
--replace_column 1 LOG_DATA
SHOW mysqld1 LOG ERROR 10;
--replace_column 1 LOG_DATA
SHOW mysqld1 LOG SLOW 10;
--replace_column 1 LOG_DATA
SHOW mysqld1 LOG GENERAL 10;
# mysqld1 (online) with the optional argument.
--replace_column 1 LOG_DATA
SHOW mysqld1 LOG ERROR 10, 2;
--replace_column 1 LOG_DATA
SHOW mysqld1 LOG SLOW 10, 2;
--replace_column 1 LOG_DATA
SHOW mysqld1 LOG GENERAL 10, 2;
# mysqld2 (offline) w/o the optional argument.
--replace_column 1 LOG_DATA
SHOW mysqld2 LOG ERROR 10;
--replace_column 1 LOG_DATA
SHOW mysqld2 LOG SLOW 10;
--replace_column 1 LOG_DATA
SHOW mysqld2 LOG GENERAL 10;
# mysqld2 (offline) with the optional argument.
--replace_column 1 LOG_DATA
SHOW mysqld2 LOG ERROR 10, 2;
--replace_column 1 LOG_DATA
SHOW mysqld2 LOG SLOW 10, 2;
--replace_column 1 LOG_DATA
SHOW mysqld2 LOG GENERAL 10, 2;
#!/bin/sh
###########################################################################
# NOTE: this script returns 0 (success) even in case of failure (except for
# usage-error). 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.
###########################################################################
basename=`basename "$0"`
dirname=`dirname "$0"`
###########################################################################
. "$dirname/utils.sh"
###########################################################################
check_restart()
{
if [ ! -r "$pid_path" ]; then
log_debug "No '$pid_path' found."
user_msg='the process was killed'
return 1
fi
new_pid=`cat "$pid_path" 2>/dev/null`
err_code=$?
log_debug "err_code: $err_code; original_pid: $original_pid; new_pid: $new_pid."
if [ $err_code -eq 0 -a "$original_pid" = "$new_pid" ]; then
log_debug "The process was not restarted."
user_msg='the process was not restarted'
return 1
fi
log_debug "The process was restarted."
user_msg='the process was restarted'
return 0
}
###########################################################################
if [ $# -ne 4 ]; then
echo "Usage: $basename <pid file path> killed|restarted <timeout> <test id>"
exit 1
fi
pid_path="$1"
expected_result="$2"
total_timeout="$3"
test_id="$4"
log_file="$MYSQLTEST_VARDIR/log/$test_id.script.log"
log_debug "-- $basename: starting --"
log_debug "pid_path: '$pid_path'"
log_debug "expected_result: '$expected_result'"
log_debug "total_timeout: '$total_timeout'"
log_debug "test_id: '$test_id'"
log_debug "log_file: '$log_file'"
###########################################################################
if [ "$expected_result" != 'killed' -a \
"$expected_result" != 'restarted' ]; then
log_error "Invalid second argument ($expected_result): 'killed' or 'restarted' expected."
quit 0
fi
if [ -z "$pid_path" ]; then
log_error "Invalid PID path ($pid_path)."
quit 0
fi
if [ ! -r "$pid_path" ]; then
log_error "PID file ($pid_path) does not exist."
quit 0
fi
if [ -z "$total_timeout" ]; then
log_error "Timeout is not specified."
quit 0
fi
###########################################################################
original_pid=`cat "$pid_path"`
log_debug "original_pid: $original_pid."
log_info "Killing the process..."
kill -9 $original_pid
###########################################################################
log_info "Waiting..."
if [ "$expected_result" = "restarted" ]; then
# Wait for the process to restart.
cur_attempt=1
while true; do
log_debug "cur_attempt: $cur_attempt."
if check_restart; then
log_info "Success: $user_msg."
quit 0
fi
[ $cur_attempt -ge $total_timeout ] && break
log_debug "Sleeping for 1 second..."
sleep 1
cur_attempt=`expr $cur_attempt + 1`
done
log_error "$user_msg."
quit 0
else # $expected_result == killed
# Here we have to sleep for some long time to ensure that the process will
# not be restarted.
log_debug "Sleeping for $total_timeout seconds..."
sleep $total_timeout
new_pid=`cat "$pid_path" 2>/dev/null`
log_debug "new_pid: $new_pid."
if [ "$new_pid" -a "$new_pid" -ne "$original_pid" ]; then
log_error "The process was restarted."
else
log_info "Success: the process was killed."
fi
quit 0
fi
#!/bin/sh
###########################################################################
basename=`basename "$0"`
dirname=`dirname "$0"`
###########################################################################
. "$dirname/utils.sh"
###########################################################################
if [ $# -lt 2 ]; then
echo "Usage: $basename <test id> log message ..."
exit 1
fi
test_id="$1"
log_file="$MYSQLTEST_VARDIR/log/$test_id.script.log"
shift
log_debug "$*"
###########################################################################
#
# This file provides utility functions and is included by other scripts.
#
# The following global variables must be set before calling functions from this
# file:
# - basename -- base name of the calling script (main application);
# - log_file -- where to store log records;
#
###########################################################################
log()
{
[ -z "$log_file" ] && return;
log_level="$1"
log_msg="$2"
ts=`date`
echo "[$ts] [$basename] [$log_level] $log_msg" >> "$log_file";
}
###########################################################################
log_debug()
{
log 'DEBUG' "$1"
}
###########################################################################
log_info()
{
log 'INFO' "$1"
echo "$1"
}
###########################################################################
log_error()
{
log 'ERROR' "$1"
echo "Error: $1"
}
###########################################################################
quit()
{
exit_status="$1"
log_debug "-- $basename: finished (exit_status: $exit_status) --"
exit $exit_status
}
#!/bin/sh
###########################################################################
# NOTE: this script returns 0 (success) even in case of failure (except for
# usage-error). 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.
###########################################################################
basename=`basename "$0"`
dirname=`dirname "$0"`
###########################################################################
. "$dirname/utils.sh"
###########################################################################
check_started()
{
if [ ! -r "$pid_path" ]; then
log_debug "No PID-file ($pid_path) found -- not started."
return 1
fi
new_pid=`cat "$pid_path" 2>/dev/null`
err_code=$?
log_debug "err_code: $err_code; new_pid: $new_pid."
if [ $? -ne 0 -o -z "$new_pid" ]; then
log_debug "The process was not started."
return 1
fi
log_debug "The process was started."
return 0
}
###########################################################################
check_stopped()
{
if [ -r "$pid_path" ]; then
log_debug "PID-file '$pid_path' exists -- not stopped."
return 1
fi
log_debug "No PID-file ($pid_path) found -- stopped."
return 0
}
###########################################################################
if [ $# -ne 4 ]; then
echo "Usage: $basename <pid file path> <total attempts> started|stopped <test id>"
exit 1
fi
pid_path="$1"
total_attempts="$2"
event="$3"
test_id="$4"
log_file="$MYSQLTEST_VARDIR/log/$test_id.script.log"
log_debug "-- $basename: starting --"
log_debug "pid_path: '$pid_path'"
log_debug "total_attempts: '$total_attempts'"
log_debug "event: '$event'"
log_debug "test_id: '$test_id'"
log_debug "log_file: '$log_file'"
###########################################################################
case "$event" in
started)
check_fn='check_started';
;;
stopped)
check_fn='check_stopped';
;;
*)
log_error "Invalid third argument ('started' or 'stopped' expected)."
quit 0
esac
###########################################################################
cur_attempt=1
while true; do
log_debug "cur_attempt: $cur_attempt."
if ( eval $check_fn ); then
log_info "Success: the process has been $event."
quit 0
fi
[ $cur_attempt -ge $total_attempts ] && break
log_debug "Sleeping for 1 second..."
sleep 1
cur_attempt=`expr $cur_attempt + 1`
done
log_error "The process has not been $event in $total_attempts secs."
quit 0
#!/bin/sh
###########################################################################
# NOTE: this script returns 0 (success) even in case of failure (except for
# usage-error). 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.
###########################################################################
basename=`basename "$0"`
dirname=`dirname "$0"`
###########################################################################
. "$dirname/utils.sh"
###########################################################################
if [ $# -ne 7 ]; then
echo "Usage: wait_for_socket.sh <executable path> <socket path> <username> <password> <db> <timeout> <test id>"
exit 1
fi
client_exe="$1"
socket_path="$2"
username="$3"
password="$4"
db="$5"
total_timeout="$6"
test_id="$7"
log_file="$MYSQLTEST_VARDIR/log/$test_id.script.log"
log_debug "-- $basename: starting --"
log_debug "client_exe: '$client_exe'"
log_debug "socket_path: '$socket_path'"
log_debug "username: '$username'"
log_debug "password: '$password'"
log_debug "db: '$db'"
log_debug "total_timeout: '$total_timeout'"
log_debug "test_id: '$test_id'"
log_debug "log_file: '$log_file'"
###########################################################################
if [ -z "$client_exe" ]; then
log_error "Invalid path to client executable ($client_exe)."
quit 0;
fi
if [ ! -x "$client_exe" ]; then
log_error "Client by path '$client_exe' is not available."
quit 0;
fi
if [ -z "$socket_path" ]; then
log_error "Invalid socket patch ($socket_path)."
quit 0
fi
###########################################################################
client_args="--no-defaults --silent --socket=$socket_path --connect_timeout=1 "
[ -n "$username" ] && client_args="$client_args --user=$username "
[ -n "$password" ] && client_args="$client_args --password=$password "
[ -n "$db" ] && client_args="$client_args $db"
log_debug "client_args: '$client_args'"
###########################################################################
cur_attempt=1
while true; do
log_debug "cur_attempt: $cur_attempt."
if ( echo 'quit' | "$client_exe" $client_args >/dev/null 2>&1 ); then
log_info "Success: server is ready to accept connection on socket."
quit 0
fi
[ $cur_attempt -ge $total_timeout ] && break
sleep 1
cur_attempt=`expr $cur_attempt + 1`
done
log_error "Server does not accept connections after $total_timeout seconds."
quit 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