1
###########################################################################
3
# This test suite checks the following statements:
4
# - SET <instance id>.<option name> = <option value>;
5
# - UNSET <instance id>.<option name> = <option value>;
8
# For SET/UNSET we check that:
9
# - SET ignores spaces correctly;
10
# - UNSET does not allow option-value part (= <option value>);
11
# - SET/UNSET can be applied several times w/o error;
12
# - SET/UNSET is allowed only for stopped instances;
13
# - SET/UNSET updates both the configuration cache in IM and
14
# the configuration file;
16
# For FLUSH INSTANCES we check that:
17
# - FLUSH INSTANCES is allowed only when all instances are stopped;
19
# According to the IM implementation details, we should play at least with the
25
# Let's test SET statement on the option 'server_id'. It's expected that
26
# originally the instances have the following server ids and states:
27
# - mysqld1: server_id: 1; running (online)
28
# - mysqld2: server_id: 2; stopped (offline)
30
# NOTE: each CREATE INSTANCE statement must specify socket-file-name, otherwise
31
# this results of the test can be affected by another running test suite.
33
###########################################################################
35
--source suite/im/t/im_check_env.inc
37
###########################################################################
39
# Check that SET/UNSET is allowed only for stopped instances.
41
###########################################################################
43
# - check that SET/UNSET is denied for running instances;
45
--error 3015 # ER_INSTANCE_IS_ACTIVE
46
UNSET mysqld1.server_id;
48
--error 3015 # ER_INSTANCE_IS_ACTIVE
49
SET mysqld1.server_id = 11;
51
# - check that SET/UNSET is denied for active instances:
52
# - create dummy misconfigured instance;
54
# - try to set/unset options;
56
CREATE INSTANCE mysqld3
59
socket = "$MYSQL_TMP_DIR/mysqld_3.sock";
60
START INSTANCE mysqld3;
62
# FIXME: START INSTANCE should be synchronous.
64
# should be longer than monitoring interval and enough to start instance.
66
# NOTE: We can not analyze state of the instance here -- it can be Failed or
67
# Starting because Instance Manager is trying to start the misconfigured
68
# instance several times.
70
--error 3015 # ER_INSTANCE_IS_ACTIVE
71
UNSET mysqld3.server_id;
73
--error 3015 # ER_INSTANCE_IS_ACTIVE
74
SET mysqld3.server_id = 11;
76
STOP INSTANCE mysqld3;
78
# FIXME: STOP INSTANCE should be synchronous.
80
# should be longer than monitoring interval and enough to stop instance.
82
--replace_column 3 VERSION_NUMBER 4 VERSION
83
SHOW INSTANCE STATUS mysqld3;
85
# - check that SET/UNSET succeed for stopped instances;
86
# - check that SET/UNSET can be applied multiple times;
88
UNSET mysqld2.server_id;
89
UNSET mysqld2.server_id;
91
--replace_column 2 option_value
92
SHOW INSTANCE OPTIONS mysqld2;
94
SET mysqld2.server_id = 2;
95
SET mysqld2.server_id = 2;
97
--replace_column 2 option_value
98
SHOW INSTANCE OPTIONS mysqld2;
100
# - check that UNSET does not allow option-value part (= <option value>);
102
--error ER_SYNTAX_ERROR
103
UNSET mysqld2.server_id = 11;
105
# - check that SET/UNSET working properly with multiple options;
107
SET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc = 0010, mysqld3.ddd = 0020;
109
--echo --------------------------------------------------------------------
110
--exec grep "^aaa\$" $MYSQLTEST_VARDIR/im.cnf ;
111
--echo --------------------------------------------------------------------
112
--exec grep "^bbb\$" $MYSQLTEST_VARDIR/im.cnf ;
113
--echo --------------------------------------------------------------------
114
--exec grep '^ccc[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf ;
115
--echo --------------------------------------------------------------------
116
--exec grep '^ddd[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf ;
117
--echo --------------------------------------------------------------------
119
UNSET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc, mysqld3.ddd;
121
--echo --------------------------------------------------------------------
122
--exec grep "^aaa\$" $MYSQLTEST_VARDIR/im.cnf || true;
123
--echo --------------------------------------------------------------------
124
--exec grep "^bbb\$" $MYSQLTEST_VARDIR/im.cnf || true;
125
--echo --------------------------------------------------------------------
126
--exec grep '^ccc[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
127
--echo --------------------------------------------------------------------
128
--exec grep '^ddd[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
129
--echo --------------------------------------------------------------------
131
# - check that if some instance name is invalid or the active is active,
132
# whole SET-statement will not be executed;
134
--error 3000 # ER_BAD_INSTANCE_NAME
135
SET mysqld2.aaa, mysqld3.bbb, mysqld.ccc = 0010;
137
--echo --------------------------------------------------------------------
138
--exec grep "^aaa\$" $MYSQLTEST_VARDIR/im.cnf || true;
139
--echo --------------------------------------------------------------------
140
--exec grep "^bbb\$" $MYSQLTEST_VARDIR/im.cnf || true;
141
--echo --------------------------------------------------------------------
142
--exec grep '^ccc[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
143
--echo --------------------------------------------------------------------
145
--error 3015 # ER_INSTANCE_IS_ACTIVE
146
SET mysqld2.aaa, mysqld3.bbb, mysqld1.ccc = 0010;
148
--echo --------------------------------------------------------------------
149
--exec grep "^aaa\$" $MYSQLTEST_VARDIR/im.cnf || true;
150
--echo --------------------------------------------------------------------
151
--exec grep "^bbb\$" $MYSQLTEST_VARDIR/im.cnf || true;
152
--echo --------------------------------------------------------------------
153
--exec grep '^ccc[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf || true;
154
--echo --------------------------------------------------------------------
156
# - check that if some instance name is invalid or the active is active,
157
# whole UNSET-statement will not be executed;
159
--error 3000 # ER_BAD_INSTANCE_NAME
160
UNSET mysqld2.server_id, mysqld3.server_id, mysqld.ccc;
162
--echo --------------------------------------------------------------------
163
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
164
--echo --------------------------------------------------------------------
166
--error 3015 # ER_INSTANCE_IS_ACTIVE
167
UNSET mysqld2.server_id, mysqld3.server_id, mysqld1.ccc;
169
--echo --------------------------------------------------------------------
170
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
171
--echo --------------------------------------------------------------------
173
DROP INSTANCE mysqld3;
175
# - check that spaces are handled correctly;
177
SET mysqld2.server_id=222;
178
SET mysqld2.server_id = 222;
179
SET mysqld2.server_id = 222 ;
180
SET mysqld2 . server_id = 222 ;
181
SET mysqld2 . server_id = 222 , mysqld2 . aaa , mysqld2 . bbb ;
183
--echo --------------------------------------------------------------------
184
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf ;
185
--echo --------------------------------------------------------------------
186
--exec grep "^aaa\$" $MYSQLTEST_VARDIR/im.cnf ;
187
--echo --------------------------------------------------------------------
188
--exec grep "^bbb\$" $MYSQLTEST_VARDIR/im.cnf ;
189
--echo --------------------------------------------------------------------
191
UNSET mysqld2 . aaa , mysqld2 . bbb ;
193
--echo --------------------------------------------------------------------
194
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf ;
195
--echo --------------------------------------------------------------------
196
--exec grep "^aaa\$" $MYSQLTEST_VARDIR/im.cnf || true;
197
--echo --------------------------------------------------------------------
198
--exec grep "^bbb\$" $MYSQLTEST_VARDIR/im.cnf || true;
199
--echo --------------------------------------------------------------------
201
###########################################################################
203
# Check that SET/UNSET updates both the configuration cache in IM and
204
# the configuration file.
206
###########################################################################
208
# - check that the configuration file has been updated (i.e. contains
209
# server_id=SERVER_ID for mysqld2);
211
--echo --------------------------------------------------------------------
212
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf ;
213
--echo --------------------------------------------------------------------
215
# - (for mysqld1) check that the running instance has not been affected:
216
# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
219
--connection mysql1_con
221
SHOW VARIABLES LIKE 'server_id';
225
# - check that internal cache of Instance Manager has been affected;
226
# TODO: we should check only server_id option here.
228
# SHOW INSTANCE OPTIONS mysqld2;
230
###########################################################################
232
# Check that FLUSH INSTANCES is allowed only when all instances are stopped.
234
###########################################################################
238
--error 3016 # ER_THERE_IS_ACTIVE_INSTACE
241
STOP INSTANCE mysqld1;
242
# FIXME: STOP INSTANCE should be synchronous.
244
# should be longer than monitoring interval and enough to stop instance.