~ubuntu-branches/ubuntu/karmic/mysql-dfsg-5.1/karmic

« back to all changes in this revision

Viewing changes to mysql-test/suite/im/t/im_options.imtest

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-06-25 12:55:45 UTC
  • mfrom: (0.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20090625125545-v27uqh8rlsj8uh2y
Tags: upstream-5.1.34
ImportĀ upstreamĀ versionĀ 5.1.34

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
###########################################################################
2
 
#
3
 
# This test suite checks the following statements:
4
 
#   - SET <instance id>.<option name> = <option value>;
5
 
#   - UNSET <instance id>.<option name> = <option value>;
6
 
#   - FLUSH INSTANCES;
7
 
#
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;
15
 
#
16
 
# For FLUSH INSTANCES we check that:
17
 
#   - FLUSH INSTANCES is allowed only when all instances are stopped;
18
 
#
19
 
# According to the IM implementation details, we should play at least with the
20
 
# following options:
21
 
#   - server_id
22
 
#   - port
23
 
#   - nonguarded
24
 
#
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)
29
 
#
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.
32
 
#
33
 
###########################################################################
34
 
 
35
 
--source suite/im/t/im_check_env.inc
36
 
 
37
 
###########################################################################
38
 
#
39
 
# Check that SET/UNSET is allowed only for stopped instances.
40
 
#
41
 
###########################################################################
42
 
 
43
 
# - check that SET/UNSET is denied for running instances;
44
 
 
45
 
--error 3015 # ER_INSTANCE_IS_ACTIVE
46
 
UNSET mysqld1.server_id;
47
 
 
48
 
--error 3015 # ER_INSTANCE_IS_ACTIVE
49
 
SET mysqld1.server_id = 11;
50
 
 
51
 
# - check that SET/UNSET is denied for active instances:
52
 
#   - create dummy misconfigured instance;
53
 
#   - start it;
54
 
#   - try to set/unset options;
55
 
 
56
 
CREATE INSTANCE mysqld3
57
 
  datadir = '/',
58
 
  server_id = 3,
59
 
  socket = "$MYSQL_TMP_DIR/mysqld_3.sock";
60
 
START INSTANCE mysqld3;
61
 
 
62
 
# FIXME: START INSTANCE should be synchronous.
63
 
--sleep 3
64
 
# should be longer than monitoring interval and enough to start instance.
65
 
 
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.
69
 
 
70
 
--error 3015 # ER_INSTANCE_IS_ACTIVE
71
 
UNSET mysqld3.server_id;
72
 
 
73
 
--error 3015 # ER_INSTANCE_IS_ACTIVE
74
 
SET mysqld3.server_id = 11;
75
 
 
76
 
STOP INSTANCE mysqld3;
77
 
 
78
 
# FIXME: STOP INSTANCE should be synchronous.
79
 
--sleep 3
80
 
# should be longer than monitoring interval and enough to stop instance.
81
 
 
82
 
--replace_column 3 VERSION_NUMBER 4 VERSION
83
 
SHOW INSTANCE STATUS mysqld3;
84
 
 
85
 
# - check that SET/UNSET succeed for stopped instances;
86
 
# - check that SET/UNSET can be applied multiple times;
87
 
 
88
 
UNSET mysqld2.server_id;
89
 
UNSET mysqld2.server_id;
90
 
 
91
 
--replace_column 2 option_value
92
 
SHOW INSTANCE OPTIONS mysqld2;
93
 
 
94
 
SET mysqld2.server_id = 2;
95
 
SET mysqld2.server_id = 2;
96
 
 
97
 
--replace_column 2 option_value
98
 
SHOW INSTANCE OPTIONS mysqld2;
99
 
 
100
 
# - check that UNSET does not allow option-value part (= <option value>);
101
 
 
102
 
--error ER_SYNTAX_ERROR
103
 
UNSET mysqld2.server_id = 11;
104
 
 
105
 
# - check that SET/UNSET working properly with multiple options;
106
 
 
107
 
SET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc = 0010, mysqld3.ddd = 0020;
108
 
 
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 --------------------------------------------------------------------
118
 
 
119
 
UNSET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc, mysqld3.ddd;
120
 
 
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 --------------------------------------------------------------------
130
 
 
131
 
# - check that if some instance name is invalid or the active is active,
132
 
#   whole SET-statement will not be executed;
133
 
 
134
 
--error 3000 # ER_BAD_INSTANCE_NAME
135
 
SET mysqld2.aaa, mysqld3.bbb, mysqld.ccc = 0010;
136
 
 
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 --------------------------------------------------------------------
144
 
 
145
 
--error 3015 # ER_INSTANCE_IS_ACTIVE
146
 
SET mysqld2.aaa, mysqld3.bbb, mysqld1.ccc = 0010;
147
 
 
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 --------------------------------------------------------------------
155
 
 
156
 
# - check that if some instance name is invalid or the active is active,
157
 
#   whole UNSET-statement will not be executed;
158
 
 
159
 
--error 3000 # ER_BAD_INSTANCE_NAME
160
 
UNSET mysqld2.server_id, mysqld3.server_id, mysqld.ccc;
161
 
 
162
 
--echo --------------------------------------------------------------------
163
 
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
164
 
--echo --------------------------------------------------------------------
165
 
 
166
 
--error 3015 # ER_INSTANCE_IS_ACTIVE
167
 
UNSET mysqld2.server_id, mysqld3.server_id, mysqld1.ccc;
168
 
 
169
 
--echo --------------------------------------------------------------------
170
 
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf;
171
 
--echo --------------------------------------------------------------------
172
 
 
173
 
DROP INSTANCE mysqld3;
174
 
 
175
 
# - check that spaces are handled correctly;
176
 
 
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  ;
182
 
 
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 --------------------------------------------------------------------
190
 
 
191
 
UNSET mysqld2  . aaa  ,  mysqld2  .  bbb ;
192
 
 
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 --------------------------------------------------------------------
200
 
 
201
 
###########################################################################
202
 
#
203
 
# Check that SET/UNSET updates both the configuration cache in IM and
204
 
# the configuration file.
205
 
#
206
 
###########################################################################
207
 
 
208
 
#   - check that the configuration file has been updated (i.e. contains
209
 
#     server_id=SERVER_ID for mysqld2);
210
 
 
211
 
--echo --------------------------------------------------------------------
212
 
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf ;
213
 
--echo --------------------------------------------------------------------
214
 
 
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''
217
 
#     returns zero;
218
 
 
219
 
--connection mysql1_con
220
 
 
221
 
SHOW VARIABLES LIKE 'server_id';
222
 
 
223
 
--connection default
224
 
 
225
 
#   - check that internal cache of Instance Manager has been affected;
226
 
#     TODO: we should check only server_id option here.
227
 
 
228
 
# SHOW INSTANCE OPTIONS mysqld2;
229
 
 
230
 
###########################################################################
231
 
#
232
 
# Check that FLUSH INSTANCES is allowed only when all instances are stopped.
233
 
#
234
 
###########################################################################
235
 
 
236
 
SHOW INSTANCES;
237
 
 
238
 
--error 3016 # ER_THERE_IS_ACTIVE_INSTACE
239
 
FLUSH INSTANCES;
240
 
 
241
 
STOP INSTANCE mysqld1;
242
 
# FIXME: STOP INSTANCE should be synchronous.
243
 
--sleep 3
244
 
# should be longer than monitoring interval and enough to stop instance.
245
 
 
246
 
SHOW INSTANCES;
247
 
 
248
 
FLUSH INSTANCES;