mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
WL#2789 "Instance Manager: test using mysql-test-run testing framework"
Add Instance Manager tests. mysql-test/include/im_check_os.inc: Currently Instance Manager tests are known to work only on UNIX platform. This header file is included in each IM-test in order to skip the test on Windows. mysql-test/r/im_daemon_life_cycle.result: Results file for Instance Manager daemon test. mysql-test/r/im_life_cycle.result: Results file for Instance Manager life cycle test. mysql-test/r/im_options_set.result: Results file for Instance Manager SET statement test. mysql-test/r/im_options_unset.result: Results file for Instance Manager UNSET statement test. mysql-test/r/im_utils.result: Results file for Instance Manager utils test. mysql-test/t/im_daemon_life_cycle-im.opt: Options file for Instance Manager daemon test. mysql-test/t/im_daemon_life_cycle.imtest: Instance Manager daemon test (mysqltestrun-part). mysql-test/t/im_life_cycle.imtest: Instance Manager life cycle test. mysql-test/t/im_options_set.imtest: Instance Manager SET statement test. mysql-test/t/im_options_unset.imtest: Instance Manager UNSET statement test. mysql-test/t/im_utils.imtest: Instance Manager utils test. mysql-test/t/kill_n_check.sh: The helper script. Its main idea is to kill some process and check that the process will (or will not) be restarted.
This commit is contained in:
7
mysql-test/include/im_check_os.inc
Normal file
7
mysql-test/include/im_check_os.inc
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
--connect (dflt_server_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
|
||||||
|
--connection dflt_server_con
|
||||||
|
|
||||||
|
--source include/not_windows.inc
|
||||||
|
|
||||||
|
--connection default
|
||||||
|
--disconnect dflt_server_con
|
7
mysql-test/r/im_daemon_life_cycle.result
Normal file
7
mysql-test/r/im_daemon_life_cycle.result
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
SHOW INSTANCES;
|
||||||
|
instance_name status
|
||||||
|
mysqld1 online
|
||||||
|
mysqld2 offline
|
||||||
|
Killing the process...
|
||||||
|
Sleeping...
|
||||||
|
Success: the process was restarted.
|
64
mysql-test/r/im_life_cycle.result
Normal file
64
mysql-test/r/im_life_cycle.result
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
SHOW INSTANCES;
|
||||||
|
instance_name status
|
||||||
|
mysqld1 online
|
||||||
|
mysqld2 offline
|
||||||
|
SHOW INSTANCE STATUS mysqld1;
|
||||||
|
instance_name status version
|
||||||
|
mysqld1 online VERSION
|
||||||
|
SHOW INSTANCE STATUS mysqld2;
|
||||||
|
instance_name status version
|
||||||
|
mysqld2 offline VERSION
|
||||||
|
START INSTANCE mysqld2;
|
||||||
|
SHOW INSTANCES;
|
||||||
|
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';
|
||||||
|
Variable_name Value
|
||||||
|
port 9312
|
||||||
|
STOP INSTANCE mysqld2;
|
||||||
|
SHOW INSTANCES;
|
||||||
|
instance_name status
|
||||||
|
mysqld1 online
|
||||||
|
mysqld2 offline
|
||||||
|
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;
|
||||||
|
ERROR HY000: Bad instance name. Check that the instance with such a name exists
|
||||||
|
START INSTANCE mysqld1;
|
||||||
|
ERROR HY000: The instance is already started
|
||||||
|
STOP INSTANCE mysqld3;
|
||||||
|
ERROR HY000: Bad instance name. Check that the instance with such a name exists
|
||||||
|
SHOW INSTANCES;
|
||||||
|
instance_name status
|
||||||
|
mysqld1 online
|
||||||
|
mysqld2 offline
|
||||||
|
Killing the process...
|
||||||
|
Sleeping...
|
||||||
|
Success: the process was restarted.
|
||||||
|
SHOW INSTANCES;
|
||||||
|
instance_name status
|
||||||
|
mysqld1 online
|
||||||
|
mysqld2 offline
|
||||||
|
START INSTANCE mysqld2;
|
||||||
|
SHOW INSTANCES;
|
||||||
|
instance_name status
|
||||||
|
mysqld1 online
|
||||||
|
mysqld2 online
|
||||||
|
Killing the process...
|
||||||
|
Sleeping...
|
||||||
|
Success: the process was killed.
|
||||||
|
SHOW INSTANCES;
|
||||||
|
instance_name status
|
||||||
|
mysqld1 online
|
||||||
|
mysqld2 offline
|
20
mysql-test/r/im_options_set.result
Normal file
20
mysql-test/r/im_options_set.result
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
server_id =1
|
||||||
|
server_id =2
|
||||||
|
SHOW VARIABLES LIKE 'server_id';
|
||||||
|
Variable_name Value
|
||||||
|
server_id 1
|
||||||
|
SET mysqld1.server_id = 11;
|
||||||
|
server_id =11
|
||||||
|
server_id =2
|
||||||
|
SHOW VARIABLES LIKE 'server_id';
|
||||||
|
Variable_name Value
|
||||||
|
server_id 1
|
||||||
|
SET mysqld2.server_id = 12;
|
||||||
|
server_id =11
|
||||||
|
server_id =12
|
||||||
|
FLUSH INSTANCES;
|
||||||
|
server_id =11
|
||||||
|
server_id =12
|
||||||
|
SHOW VARIABLES LIKE 'server_id';
|
||||||
|
Variable_name Value
|
||||||
|
server_id 1
|
15
mysql-test/r/im_options_unset.result
Normal file
15
mysql-test/r/im_options_unset.result
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
server_id =1
|
||||||
|
server_id =2
|
||||||
|
SHOW VARIABLES LIKE 'server_id';
|
||||||
|
Variable_name Value
|
||||||
|
server_id 1
|
||||||
|
UNSET mysqld1.server_id;
|
||||||
|
server_id =2
|
||||||
|
SHOW VARIABLES LIKE 'server_id';
|
||||||
|
Variable_name Value
|
||||||
|
server_id 1
|
||||||
|
UNSET mysqld2.server_id;
|
||||||
|
FLUSH INSTANCES;
|
||||||
|
SHOW VARIABLES LIKE 'server_id';
|
||||||
|
Variable_name Value
|
||||||
|
server_id 1
|
91
mysql-test/r/im_utils.result
Normal file
91
mysql-test/r/im_utils.result
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
SHOW INSTANCES;
|
||||||
|
instance_name status
|
||||||
|
mysqld1 online
|
||||||
|
mysqld2 offline
|
||||||
|
SHOW INSTANCE OPTIONS mysqld1;
|
||||||
|
option_name value
|
||||||
|
instance_name VALUE
|
||||||
|
mysqld-path 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
|
||||||
|
skip-stack-trace VALUE
|
||||||
|
skip-innodb VALUE
|
||||||
|
skip-bdb VALUE
|
||||||
|
skip-ndbcluster VALUE
|
||||||
|
SHOW INSTANCE OPTIONS mysqld2;
|
||||||
|
option_name value
|
||||||
|
instance_name VALUE
|
||||||
|
mysqld-path VALUE
|
||||||
|
nonguarded 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
|
||||||
|
skip-stack-trace VALUE
|
||||||
|
skip-innodb VALUE
|
||||||
|
skip-bdb VALUE
|
||||||
|
skip-ndbcluster VALUE
|
||||||
|
START INSTANCE mysqld2;
|
||||||
|
STOP INSTANCE mysqld2;
|
||||||
|
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
|
2
mysql-test/t/im_daemon_life_cycle-im.opt
Normal file
2
mysql-test/t/im_daemon_life_cycle-im.opt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
--run-as-service
|
||||||
|
--log=$MYSQL_TEST_DIR/var/log/im.log
|
15
mysql-test/t/im_daemon_life_cycle.imtest
Normal file
15
mysql-test/t/im_daemon_life_cycle.imtest
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# This file contains test for (1.2) test suite.
|
||||||
|
#
|
||||||
|
# Consult WL#2789 for more information.
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
--source include/im_check_os.inc
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
SHOW INSTANCES;
|
||||||
|
|
||||||
|
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted
|
141
mysql-test/t/im_life_cycle.imtest
Normal file
141
mysql-test/t/im_life_cycle.imtest
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# This file contains test for (1.1) test suite.
|
||||||
|
#
|
||||||
|
# Consult WL#2789 for more information.
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
--source include/im_check_os.inc
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# 1.1.1. Check that Instance Manager is able:
|
||||||
|
# - to read definitions of two mysqld-instances;
|
||||||
|
# - to start the first instance;
|
||||||
|
# - to understand 'nonguarded' option and keep the second instance down;
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
SHOW INSTANCES;
|
||||||
|
--replace_column 3 VERSION
|
||||||
|
SHOW INSTANCE STATUS mysqld1;
|
||||||
|
--replace_column 3 VERSION
|
||||||
|
SHOW INSTANCE STATUS mysqld2;
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# 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;
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
START INSTANCE mysqld2;
|
||||||
|
# FIXME
|
||||||
|
--sleep 3
|
||||||
|
|
||||||
|
SHOW INSTANCES;
|
||||||
|
--replace_column 3 VERSION
|
||||||
|
SHOW INSTANCE STATUS mysqld1;
|
||||||
|
--replace_column 3 VERSION
|
||||||
|
SHOW INSTANCE STATUS mysqld2;
|
||||||
|
|
||||||
|
--connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
|
||||||
|
--connection mysql_con
|
||||||
|
|
||||||
|
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;
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
STOP INSTANCE mysqld2;
|
||||||
|
# FIXME
|
||||||
|
--sleep 3
|
||||||
|
|
||||||
|
SHOW INSTANCES;
|
||||||
|
--replace_column 3 VERSION
|
||||||
|
SHOW INSTANCE STATUS mysqld1;
|
||||||
|
--replace_column 3 VERSION
|
||||||
|
SHOW INSTANCE STATUS mysqld2;
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# 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;
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
--error 3000
|
||||||
|
START INSTANCE mysqld3;
|
||||||
|
|
||||||
|
--error 3002
|
||||||
|
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'
|
||||||
|
# command:
|
||||||
|
# - if the client tries to start unregistered instance;
|
||||||
|
# - if the client tries to start already stopped instance;
|
||||||
|
# - if the client submits invalid arguments;
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
--error 3000
|
||||||
|
STOP INSTANCE mysqld3;
|
||||||
|
|
||||||
|
# TODO: IM should be fixed.
|
||||||
|
# BUG#12673: Instance Manager allows to stop the instance many times
|
||||||
|
# --error 3002
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
SHOW INSTANCES;
|
||||||
|
|
||||||
|
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# 1.1.7. Check that Instance Manager does not restart non-guarded instance.
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
SHOW INSTANCES;
|
||||||
|
|
||||||
|
START INSTANCE mysqld2;
|
||||||
|
# FIXME
|
||||||
|
--sleep 3
|
||||||
|
|
||||||
|
SHOW INSTANCES;
|
||||||
|
|
||||||
|
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed
|
||||||
|
|
||||||
|
SHOW INSTANCES;
|
142
mysql-test/t/im_options_set.imtest
Normal file
142
mysql-test/t/im_options_set.imtest
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# This file contains test for (3) test suite.
|
||||||
|
#
|
||||||
|
# Consult WL#2789 for more information.
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check the options-management commands:
|
||||||
|
# - SET;
|
||||||
|
# - FLUSH INSTANCES;
|
||||||
|
#
|
||||||
|
# Let's test the commands on the option 'server_id'. It's expected that
|
||||||
|
# originally the instances have the following server ids:
|
||||||
|
# - mysqld1: 1
|
||||||
|
# - mysqld2: 2
|
||||||
|
#
|
||||||
|
# 1. SET <instance_id>.server_id= SERVER_ID); where SERVER_ID is 11 or 12.
|
||||||
|
# 1.1. check that the configuration file has been updated (i.e. contains
|
||||||
|
# server_id=SERVER_ID for the instance);
|
||||||
|
# 1.2. (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;
|
||||||
|
# 1.3. check that internal cache of Instance Manager has not been affected
|
||||||
|
# (i.e. SHOW INSTANCE OPTIONS <instance> does not contain updated value).
|
||||||
|
#
|
||||||
|
# 2. FLUSH INSTANCES;
|
||||||
|
# 2.1. check that the configuration file has not been updated;
|
||||||
|
# 2.2. (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 value;
|
||||||
|
# 2.3. check that internal cache of Instance Manager has been updated (i.e.
|
||||||
|
# SHOW INSTANCE OPTIONS <instance> contains 'server_id=SERVER_ID' line).
|
||||||
|
#
|
||||||
|
# 3. Restore options.
|
||||||
|
#
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
--source include/im_check_os.inc
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# 0. Check starting conditions.
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
# - check the configuration file;
|
||||||
|
|
||||||
|
--exec grep server_id $MYSQL_TEST_DIR/var/im.cnf ;
|
||||||
|
|
||||||
|
# - check the running instances.
|
||||||
|
|
||||||
|
--connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
|
||||||
|
|
||||||
|
--connection mysql1_con
|
||||||
|
|
||||||
|
SHOW VARIABLES LIKE 'server_id';
|
||||||
|
|
||||||
|
--connection default
|
||||||
|
|
||||||
|
# - check the internal cache.
|
||||||
|
# TODO: we should check only server_id option here.
|
||||||
|
|
||||||
|
# SHOW INSTANCE OPTIONS mysqld1;
|
||||||
|
# SHOW INSTANCE OPTIONS mysqld2;
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# 1. SET <instance_id>.server_id= SERVER_ID); where SERVER_ID is 11 or 12.
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
# * mysqld1
|
||||||
|
|
||||||
|
SET mysqld1.server_id = 11;
|
||||||
|
|
||||||
|
# - check that the configuration file has been updated (i.e. contains
|
||||||
|
# server_id=SERVER_ID for the instance);
|
||||||
|
|
||||||
|
--exec grep server_id $MYSQL_TEST_DIR/var/im.cnf ;
|
||||||
|
|
||||||
|
# - (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 not been affected
|
||||||
|
# (i.e. SHOW INSTANCE OPTIONS <instance> does not contain updated value).
|
||||||
|
# TODO: we should check only server_id option here.
|
||||||
|
|
||||||
|
# SHOW INSTANCE OPTIONS mysqld1;
|
||||||
|
|
||||||
|
# * mysqld2
|
||||||
|
|
||||||
|
SET mysqld2.server_id = 12;
|
||||||
|
|
||||||
|
# - check that the configuration file has been updated (i.e. contains
|
||||||
|
# server_id=SERVER_ID for the instance);
|
||||||
|
|
||||||
|
--exec grep server_id $MYSQL_TEST_DIR/var/im.cnf ;
|
||||||
|
|
||||||
|
# - check that internal cache of Instance Manager has not been affected
|
||||||
|
# (i.e. SHOW INSTANCE OPTIONS <instance> does not contain updated value).
|
||||||
|
# TODO: we should check only server_id option here.
|
||||||
|
|
||||||
|
# SHOW INSTANCE OPTIONS mysqld2;
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# 2. FLUSH INSTANCES;
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
FLUSH INSTANCES;
|
||||||
|
|
||||||
|
# - check that the configuration file has not been updated;
|
||||||
|
|
||||||
|
--exec grep server_id $MYSQL_TEST_DIR/var/im.cnf ;
|
||||||
|
|
||||||
|
# - (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 value;
|
||||||
|
|
||||||
|
--connection mysql1_con
|
||||||
|
|
||||||
|
SHOW VARIABLES LIKE 'server_id';
|
||||||
|
|
||||||
|
--connection default
|
||||||
|
|
||||||
|
# - check that internal cache of Instance Manager has been updated (i.e.
|
||||||
|
# SHOW INSTANCE OPTIONS <instance> contains 'server_id=' line).
|
||||||
|
# TODO: we should check only server_id option here.
|
||||||
|
|
||||||
|
# SHOW INSTANCE OPTIONS mysqld1;
|
||||||
|
# SHOW INSTANCE OPTIONS mysqld2;
|
150
mysql-test/t/im_options_unset.imtest
Normal file
150
mysql-test/t/im_options_unset.imtest
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# This file contains test for (3) test suite.
|
||||||
|
#
|
||||||
|
# Consult WL#2789 for more information.
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check the options-management commands:
|
||||||
|
# - UNSET;
|
||||||
|
# - FLUSH INSTANCES;
|
||||||
|
#
|
||||||
|
# Let's test the commands on the option 'server_id'. It's expected that
|
||||||
|
# originally the instances have the following server ids:
|
||||||
|
# - mysqld1: 1
|
||||||
|
# - mysqld2: 2
|
||||||
|
#
|
||||||
|
# The test case:
|
||||||
|
#
|
||||||
|
# 1. UNSET <instance_id>.server_id;
|
||||||
|
#
|
||||||
|
# Do the step for both instances.
|
||||||
|
#
|
||||||
|
# 1.1. check that the configuration file has been updated (i.e. does not
|
||||||
|
# contain 'server_id=' line for the instance);
|
||||||
|
# 1.2. (for mysqld1) check that the running instance has not been affected:
|
||||||
|
# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
|
||||||
|
# returns non-zero value;
|
||||||
|
# 1.3. check that internal cache of Instance Manager is not affected (i.e.
|
||||||
|
# SHOW INSTANCE OPTIONS <instance> contains non-zero value for server_id);
|
||||||
|
#
|
||||||
|
# 2. FLUSH INSTANCES;
|
||||||
|
#
|
||||||
|
# Do the step for both instances.
|
||||||
|
#
|
||||||
|
# 2.1. check that the configuration file has not been updated (i.e. does not
|
||||||
|
# contain 'server_id=' for the instance);
|
||||||
|
# 2.2. (for mysqld1) check that the running instance has not been affected:
|
||||||
|
# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
|
||||||
|
# returns non-zero value;
|
||||||
|
# 2.3. check that internal cache of Instance Manager has been updated (i.e.
|
||||||
|
# SHOW INSTANCE OPTIONS <instance> does not contain 'server_id=' line).
|
||||||
|
#
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
--source include/im_check_os.inc
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# 0. Check starting conditions.
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
# - check the configuration file;
|
||||||
|
|
||||||
|
--exec grep server_id $MYSQL_TEST_DIR/var/im.cnf ;
|
||||||
|
|
||||||
|
# - check the running instances.
|
||||||
|
|
||||||
|
--connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
|
||||||
|
|
||||||
|
--connection mysql1_con
|
||||||
|
|
||||||
|
SHOW VARIABLES LIKE 'server_id';
|
||||||
|
|
||||||
|
--connection default
|
||||||
|
|
||||||
|
# - check the internal cache.
|
||||||
|
# TODO: we should check only server_id option here.
|
||||||
|
|
||||||
|
# SHOW INSTANCE OPTIONS mysqld1;
|
||||||
|
# SHOW INSTANCE OPTIONS mysqld2;
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# 1. UNSET <instance_id>.server_id;
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
# * mysqld1
|
||||||
|
|
||||||
|
UNSET mysqld1.server_id;
|
||||||
|
|
||||||
|
# - check that the configuration file has been updated (i.e. does not
|
||||||
|
# contain 'server_id=' line for the instance);
|
||||||
|
|
||||||
|
--exec grep server_id $MYSQL_TEST_DIR/var/im.cnf ;
|
||||||
|
|
||||||
|
# - check that the running instance has not been affected: connect to the
|
||||||
|
# instance and check that 'SHOW VARIABLES LIKE 'server_id'' returns non-zero
|
||||||
|
# value;
|
||||||
|
|
||||||
|
--connection mysql1_con
|
||||||
|
|
||||||
|
SHOW VARIABLES LIKE 'server_id';
|
||||||
|
|
||||||
|
--connection default
|
||||||
|
|
||||||
|
# - check that internal cache of Instance Manager is not affected (i.e. SHOW
|
||||||
|
# INSTANCE OPTIONS <instance> contains non-zero value for server_id);
|
||||||
|
# TODO: we should check only server_id option here.
|
||||||
|
|
||||||
|
# SHOW INSTANCE OPTIONS mysqld1;
|
||||||
|
|
||||||
|
# * mysqld2
|
||||||
|
|
||||||
|
UNSET mysqld2.server_id;
|
||||||
|
|
||||||
|
# - check that the configuration file has been updated (i.e. does not
|
||||||
|
# contain 'server_id=' line for the instance);
|
||||||
|
|
||||||
|
--exec grep server_id $MYSQL_TEST_DIR/var/im.cnf || true;
|
||||||
|
|
||||||
|
# - check that internal cache of Instance Manager is not affected (i.e. SHOW
|
||||||
|
# INSTANCE OPTIONS <instance> contains non-zero value for server_id);
|
||||||
|
# TODO: we should check only server_id option here.
|
||||||
|
|
||||||
|
# SHOW INSTANCE OPTIONS mysqld2;
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# 2. FLUSH INSTANCES;
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
FLUSH INSTANCES;
|
||||||
|
|
||||||
|
# - check that the configuration file has not been updated (i.e. does not
|
||||||
|
# contain 'server_id=' for the instance);
|
||||||
|
|
||||||
|
--exec grep server_id $MYSQL_TEST_DIR/var/im.cnf || true;
|
||||||
|
|
||||||
|
# - (for mysqld1) check that the running instance has not been affected:
|
||||||
|
# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
|
||||||
|
# returns non-zero value;
|
||||||
|
|
||||||
|
--connection mysql1_con
|
||||||
|
|
||||||
|
SHOW VARIABLES LIKE 'server_id';
|
||||||
|
|
||||||
|
--connection default
|
||||||
|
|
||||||
|
# - check that internal cache of Instance Manager has been updated (i.e.
|
||||||
|
# SHOW INSTANCE OPTIONS <instance> does not contain 'server_id=' line).
|
||||||
|
# TODO: we should check only server_id option here.
|
||||||
|
|
||||||
|
# SHOW INSTANCE OPTIONS mysqld1;
|
||||||
|
# SHOW INSTANCE OPTIONS mysqld2;
|
115
mysql-test/t/im_utils.imtest
Normal file
115
mysql-test/t/im_utils.imtest
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# This file contains test for (2) test suite.
|
||||||
|
#
|
||||||
|
# Consult WL#2789 for more information.
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
--source include/im_check_os.inc
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check starting conditions. This test case assumes that:
|
||||||
|
# - two mysqld-instances are registered;
|
||||||
|
# - the first instance is online;
|
||||||
|
# - the second instance is offline;
|
||||||
|
#
|
||||||
|
|
||||||
|
SHOW INSTANCES;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check 'SHOW INSTANCE OPTIONS' command:
|
||||||
|
# - check that options of both offline and online instances are accessible;
|
||||||
|
# - 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;
|
||||||
|
|
||||||
|
# FIXME
|
||||||
|
-- sleep 3
|
||||||
|
|
||||||
|
STOP INSTANCE mysqld2;
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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;
|
66
mysql-test/t/kill_n_check.sh
Executable file
66
mysql-test/t/kill_n_check.sh
Executable file
@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ $# -ne 2 ]; then
|
||||||
|
echo "Usage: kill_n_check.sh <pid file path> killed|restarted"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
pid_path="$1"
|
||||||
|
expected_result="$2"
|
||||||
|
|
||||||
|
if [ -z "$pid_path" -o ! -r "$pid_path" ]; then
|
||||||
|
echo "Error: invalid PID path ($pid_path) or PID file does not exist."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$expected_result" != "killed" -a \
|
||||||
|
"$expected_result" != "restarted" ]; then
|
||||||
|
echo "Error: expected result must be either 'killed' or 'restarted'."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# echo "PID path: '$pid_path'"
|
||||||
|
|
||||||
|
original_pid=`cat "$pid_path"`
|
||||||
|
|
||||||
|
# echo "Original PID: $original_pid"
|
||||||
|
|
||||||
|
echo "Killing the process..."
|
||||||
|
|
||||||
|
kill -9 $original_pid
|
||||||
|
|
||||||
|
echo "Sleeping..."
|
||||||
|
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
new_pid=""
|
||||||
|
|
||||||
|
[ -r "$pid_path" ] && new_pid=`cat "$pid_path"`
|
||||||
|
|
||||||
|
# echo "New PID: $new_pid"
|
||||||
|
|
||||||
|
if [ "$expected_result" == "restarted" ]; then
|
||||||
|
|
||||||
|
if [ -z "$new_pid" ]; then
|
||||||
|
echo "Error: the process was killed."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$original_pid" -eq "$new_pid" ]; then
|
||||||
|
echo "Error: the process was not restarted."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Success: the process was restarted."
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
else # $expected_result == killed
|
||||||
|
|
||||||
|
if [ "$new_pid" -a "$new_pid" -ne "$original_pid" ]; then
|
||||||
|
echo "Error: the process was restarted."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Success: the process was killed."
|
||||||
|
exit 0
|
||||||
|
fi
|
Reference in New Issue
Block a user