Debian Codegraph @

mysql-test/suite/group_replication/t/gr_acf_msr_2groups_failover.test

raw
1 ###########################################################
2 # Validate that the we can have several managed channels.
3 #
4 # Test:
5 # 0. The test requires 7 servers:
6 # server1: group A primary
7 # server2: group A secondary
8 # server3: group A secondary
9 # server4: group B primary
10 # server5: group B secondary
11 # server6: group B secondary
12 # server7: replica server
13 # 1. Deploy a 3 members group A in single primary mode.
14 # 2. Deploy a 3 members group B in single primary mode.
15 # 3. Configure replica to manage the asynchronous connection
16 # to groups A and B.
17 # 4. Create and start the managed channels.
18 # 5. Stop primary from group A (server1) and the replica
19 # shall connect to new primary server2.
20 # 6. Stop primary from group B (server4) and the replica
21 # shall connect to new primary server5.
22 # 7. Validate that channel ch1 did not reconnect to ch2 sources.
23 # 8. Validate that channel ch2 did not reconnect to ch1 sources.
24 # 9. Clean up.
25 ###########################################################
26 --source include/big_test.inc
27 --source include/have_group_replication_plugin.inc
28 --let $rpl_skip_group_replication_start= 1
29 --let $rpl_server_count= 7
30 --source include/group_replication.inc
31
32 #check which stack are we using
33 --let $have_xcom_stack= `SELECT @@group_replication_communication_stack LIKE 'XCOM'`
34
35 --echo
36 --echo ############################################################
37 --echo # 1. Deploy a 3 members group A in single primary mode.
38 --let $rpl_connection_name= server1
39 --source include/rpl_connection.inc
40 --let $server1_uuid= `SELECT @@server_uuid`
41 --let $group_replication_group_name= aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
42 --let $group_a= $group_replication_group_name
43 --disable_query_log
44 if ($have_xcom_stack){
45 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_1,localhost:$SERVER_GR_PORT_2,localhost:$SERVER_GR_PORT_3"
46 }
47 if (!$have_xcom_stack){
48 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_1,localhost:$SERVER_MYPORT_2,localhost:$SERVER_MYPORT_3"
49 }
50 --enable_query_log
51 --source include/start_and_bootstrap_group_replication.inc
52
53 --let $rpl_connection_name= server2
54 --source include/rpl_connection.inc
55 --let $server2_uuid= `SELECT @@server_uuid`
56 --disable_query_log
57 if ($have_xcom_stack){
58 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_1,localhost:$SERVER_GR_PORT_2,localhost:$SERVER_GR_PORT_3"
59 }
60 if (!$have_xcom_stack){
61 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_1,localhost:$SERVER_MYPORT_2,localhost:$SERVER_MYPORT_3"
62 }
63 --enable_query_log
64 SET GLOBAL group_replication_member_weight=99;
65 --source include/start_group_replication.inc
66
67 --let $rpl_connection_name= server3
68 --source include/rpl_connection.inc
69 --let $server3_uuid= `SELECT @@server_uuid`
70 --disable_query_log
71 if ($have_xcom_stack){
72 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_1,localhost:$SERVER_GR_PORT_2,localhost:$SERVER_GR_PORT_3"
73 }
74 if (!$have_xcom_stack){
75 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_1,localhost:$SERVER_MYPORT_2,localhost:$SERVER_MYPORT_3"
76 }
77 --enable_query_log
78 --source include/start_group_replication.inc
79
80
81 --echo
82 --echo ############################################################
83 --echo # 2. Deploy a 3 members group B in single primary mode.
84 --let $rpl_connection_name= server4
85 --source include/rpl_connection.inc
86 --let $server4_uuid= `SELECT @@server_uuid`
87 --let $group_replication_group_name= bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb
88 --let $group_b= $group_replication_group_name
89 --disable_query_log
90 if ($have_xcom_stack){
91 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_4,localhost:$SERVER_GR_PORT_5,localhost:$SERVER_GR_PORT_6"
92 }
93 if (!$have_xcom_stack){
94 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_4,localhost:$SERVER_MYPORT_5,localhost:$SERVER_MYPORT_6"
95 }
96 --enable_query_log
97 --source include/start_and_bootstrap_group_replication.inc
98
99 --let $rpl_connection_name= server5
100 --source include/rpl_connection.inc
101 --let $server5_uuid= `SELECT @@server_uuid`
102 --disable_query_log
103 if ($have_xcom_stack){
104 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_4,localhost:$SERVER_GR_PORT_5,localhost:$SERVER_GR_PORT_6"
105 }
106 if (!$have_xcom_stack){
107 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_4,localhost:$SERVER_MYPORT_5,localhost:$SERVER_MYPORT_6"
108 }
109 --enable_query_log
110 SET GLOBAL group_replication_member_weight=99;
111 --source include/start_group_replication.inc
112
113 --let $rpl_connection_name= server6
114 --source include/rpl_connection.inc
115 --let $server6_uuid= `SELECT @@server_uuid`
116 --disable_query_log
117 if ($have_xcom_stack){
118 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_4,localhost:$SERVER_GR_PORT_5,localhost:$SERVER_GR_PORT_6"
119 }
120 if (!$have_xcom_stack){
121 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_4,localhost:$SERVER_MYPORT_5,localhost:$SERVER_MYPORT_6"
122 }
123 --enable_query_log
124 --source include/start_group_replication.inc
125
126
127 --echo
128 --echo ############################################################
129 --echo # 3. Configure replica to manage the asynchronous connection
130 --echo # to groups A and B.
131 --let $rpl_connection_name= server7
132 --source include/rpl_connection.inc
133
134 --replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2 $group_a GROUP_A
135 --eval SELECT asynchronous_connection_failover_add_managed('ch1', 'GroupReplication', '$group_a', '127.0.0.1', $SERVER_MYPORT_2, '', 90, 70);
136
137 --replace_result $SERVER_MYPORT_5 SERVER_MYPORT_5 $group_b GROUP_B
138 --eval SELECT asynchronous_connection_failover_add_managed('ch2', 'GroupReplication', '$group_b', '127.0.0.1', $SERVER_MYPORT_5, '', 85, 65);
139
140 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server2'
141 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_2, count, 1] = 1
142 --source include/assert.inc
143
144 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server5'
145 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_5, count, 1] = 1
146 --source include/assert.inc
147
148 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for group A'
149 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_a", count, 1] = 1
150 --source include/assert.inc
151
152 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for group B'
153 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_b", count, 1] = 1
154 --source include/assert.inc
155
156
157 --echo
158 --echo ############################################################
159 --echo # 4. Create and start the managed channels.
160 --let $rpl_connection_name= server7
161 --source include/rpl_connection.inc
162 --replace_result $SERVER_MYPORT_1 SERVER_1_PORT
163 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_USER='root', SOURCE_AUTO_POSITION=1, SOURCE_CONNECTION_AUTO_FAILOVER=1, SOURCE_PORT=$SERVER_MYPORT_1, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=1 FOR CHANNEL 'ch1'
164
165 --replace_result $SERVER_MYPORT_4 SERVER_4_PORT
166 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_USER='root', SOURCE_AUTO_POSITION=1, SOURCE_CONNECTION_AUTO_FAILOVER=1, SOURCE_PORT=$SERVER_MYPORT_4, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=1 FOR CHANNEL 'ch2'
167
168
169 --let $rpl_channel_name='ch1'
170 --source include/start_slave.inc
171 --let $rpl_channel_name=
172
173 --let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server1
174 --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name=\'ch1\' AND source_uuid=\'$server1_uuid\', SERVICE_STATE, 1]" = "ON"
175 --source include/assert.inc
176
177 --let $wait_condition= SELECT COUNT(*)=6 FROM performance_schema.replication_asynchronous_connection_failover
178 --source include/wait_condition.inc
179
180
181 --let $rpl_channel_name='ch2'
182 --source include/start_slave.inc
183 --let $rpl_channel_name=
184
185 --let $assert_text= Verify channel ch2 IO_THREAD is ON and connected to server4
186 --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name=\'ch2\' AND source_uuid=\'$server4_uuid\', SERVICE_STATE, 1]" = "ON"
187 --source include/assert.inc
188
189 --let $wait_condition= SELECT COUNT(*)=6 FROM performance_schema.replication_asynchronous_connection_failover
190 --source include/wait_condition.inc
191
192
193 --echo
194 --echo ############################################################
195 --echo # 5. Stop primary from group A (server1) and the replica
196 --echo # shall connect to new primary server2.
197 --let $rpl_connection_name= server1
198 --source include/rpl_connection.inc
199 --source include/stop_group_replication.inc
200
201 --let $rpl_connection_name= server7
202 --source include/rpl_connection.inc
203 --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE channel_name='ch1' AND source_uuid='$server2_uuid';
204 --source include/wait_condition.inc
205
206
207 --echo
208 --echo ############################################################
209 --echo # 6. Stop primary from group B (server4) and the replica
210 --echo # shall connect to new primary server5.
211 --let $rpl_connection_name= server4
212 --source include/rpl_connection.inc
213 --source include/stop_group_replication.inc
214
215 --let $rpl_connection_name= server7
216 --source include/rpl_connection.inc
217 --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE channel_name='ch2' AND source_uuid='$server5_uuid';
218 --source include/wait_condition.inc
219
220
221 --echo
222 --echo ############################################################
223 --echo # 7. Validate that channel ch1 did not reconnect to ch2 sources.
224 --let $rpl_connection_name= server7
225 --source include/rpl_connection.inc
226
227 --let $assert_only_after = CURRENT_TEST: group_replication.gr_acf_msr_2groups_failover
228 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.7.err
229 --let $assert_select=Replica I/O thread for channel 'ch1': connected to source '[email protected]:$SERVER_MYPORT_4'.*
230 --let $assert_count= 0
231 --let $assert_text= ch1 did not reconnect to server4
232 --source include/assert_grep.inc
233
234 --let $assert_only_after = CURRENT_TEST: group_replication.gr_acf_msr_2groups_failover
235 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.7.err
236 --let $assert_select=Replica I/O thread for channel 'ch1': connected to source '[email protected]:$SERVER_MYPORT_5'.*
237 --let $assert_count= 0
238 --let $assert_text= ch1 did not reconnect to server5
239 --source include/assert_grep.inc
240
241 --let $assert_only_after = CURRENT_TEST: group_replication.gr_acf_msr_2groups_failover
242 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.7.err
243 --let $assert_select=Replica I/O thread for channel 'ch1': connected to source '[email protected]:$SERVER_MYPORT_6'.*
244 --let $assert_count= 0
245 --let $assert_text= ch1 did not reconnect to server6
246 --source include/assert_grep.inc
247
248
249 --echo
250 --echo ############################################################
251 --echo # 8. Validate that channel ch2 did not reconnect to ch1 sources.
252 --let $rpl_connection_name= server7
253 --source include/rpl_connection.inc
254
255 --let $assert_only_after = CURRENT_TEST: group_replication.gr_acf_msr_2groups_failover
256 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.7.err
257 --let $assert_select=Replica I/O thread for channel 'ch2': connected to source '[email protected]:$SERVER_MYPORT_1'.*
258 --let $assert_count= 0
259 --let $assert_text= ch2 did not reconnect to server1
260 --source include/assert_grep.inc
261
262 --let $assert_only_after = CURRENT_TEST: group_replication.gr_acf_msr_2groups_failover
263 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.7.err
264 --let $assert_select=Replica I/O thread for channel 'ch2': connected to source '[email protected]:$SERVER_MYPORT_2'.*
265 --let $assert_count= 0
266 --let $assert_text= ch2 did not reconnect to server2
267 --source include/assert_grep.inc
268
269 --let $assert_only_after = CURRENT_TEST: group_replication.gr_acf_msr_2groups_failover
270 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.7.err
271 --let $assert_select=Replica I/O thread for channel 'ch2': connected to source '[email protected]:$SERVER_MYPORT_3'.*
272 --let $assert_count= 0
273 --let $assert_text= ch2 did not reconnect to server3
274 --source include/assert_grep.inc
275
276
277 --echo
278 --echo ############################################################
279 --echo # 9. Clean up.
280 --let $rpl_connection_name= server7
281 --source include/rpl_connection.inc
282
283 SET SESSION sql_log_bin = 0;
284 call mtr.add_suppression("The IO thread detected that the source .* does not belong to the group majority, thence the channel .* will try to connect to another source.");
285 call mtr.add_suppression("The Monitor IO thread detected that the source .* does not belong to the group majority, thence the channel .* will try to connect to another source.");
286 SET SESSION sql_log_bin = 1;
287
288 --let $rpl_channel_name='ch1'
289 --source include/stop_slave.inc
290 --let $rpl_reset_slave_all= 1
291 --let $rpl_multi_source= 1
292 --source include/rpl_reset_slave.inc
293 --let $rpl_channel_name=
294 --let $rpl_reset_slave_all=
295 --let $rpl_multi_source=
296
297 --let $rpl_channel_name='ch2'
298 --source include/stop_slave.inc
299 --let $rpl_reset_slave_all= 1
300 --let $rpl_multi_source= 1
301 --source include/rpl_reset_slave.inc
302 --let $rpl_channel_name=
303 --let $rpl_reset_slave_all=
304 --let $rpl_multi_source=
305
306 --replace_result $group_a GROUP_A
307 --eval SELECT asynchronous_connection_failover_delete_managed('ch1', '$group_a')
308
309 --replace_result $group_b GROUP_B
310 --eval SELECT asynchronous_connection_failover_delete_managed('ch2', '$group_b')
311
312 --let $rpl_connection_name= server6
313 --source include/rpl_connection.inc
314 --source include/stop_group_replication.inc
315
316 --let $rpl_connection_name= server5
317 --source include/rpl_connection.inc
318 --source include/stop_group_replication.inc
319 SET GLOBAL group_replication_member_weight= DEFAULT;
320
321 --let $rpl_connection_name= server3
322 --source include/rpl_connection.inc
323 --source include/stop_group_replication.inc
324
325 --let $rpl_connection_name= server2
326 --source include/rpl_connection.inc
327 --source include/stop_group_replication.inc
328 SET GLOBAL group_replication_member_weight= DEFAULT;
329
330 --source include/group_replication_end.inc