Debian Codegraph @

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

raw
1 #
2 # Validate that a managed connection with two groups is able to do failover
3 # between both groups and is members
4 #
5 # Test:
6 # 0. The test requires 5 servers:
7 # server1: group A primary
8 # server2: group A secondary
9 # server3: group B primary
10 # server4: group B secondary
11 # server5: single server
12 # 1. Deploy a 2 members group A in single primary mode.
13 # 2. Deploy a 2 members group B in single primary mode.
14 # 3. Configure replica to manage the asynchronous connection
15 # to groups A and B.
16 # 4. Create and start the managed channel.
17 # 5. Stop primary from group A (server1) and IO thread shall connect to
18 # new primary server2
19 # 6. Stop new elected primary from group A (server2) and IO thread
20 # should connect to primary from group B (server3)
21 # 7. Stop primary from group B (server3) and IO thread should connect to
22 # new elected primary from group B (server4)
23 # 8. Stop primary from group B (server4) and IO thread should stop
24 # 9. Assert Server2 and Server4 last members of the groups are on
25 # replication_connection_status table
26 # 10. Clean up.
27 #
28 --source include/big_test.inc
29 --source include/have_group_replication_plugin.inc
30 --let $rpl_skip_group_replication_start= 1
31 --let $rpl_server_count= 5
32 --source include/group_replication.inc
33
34 #check which stack are we using
35 --let $have_xcom_stack= `SELECT @@group_replication_communication_stack LIKE 'XCOM'`
36
37
38 --echo
39 --echo # 1. Deploy a 2 members group A in single primary mode.
40 --echo
41 --let $rpl_connection_name= server1
42 --source include/rpl_connection.inc
43 --let $server1_uuid= `SELECT @@server_uuid`
44 --let $group_replication_group_name= aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
45 --let $group_a= $group_replication_group_name
46 --disable_query_log
47
48 if ($have_xcom_stack){
49 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_1,localhost:$SERVER_GR_PORT_2"
50 }
51
52 if (!$have_xcom_stack){
53 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_1,localhost:$SERVER_MYPORT_2"
54 }
55
56 --enable_query_log
57 --source include/start_and_bootstrap_group_replication.inc
58
59 --let $rpl_connection_name= server2
60 --source include/rpl_connection.inc
61 --let $server2_uuid= `SELECT @@server_uuid`
62 --disable_query_log
63 if ($have_xcom_stack){
64 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_1,localhost:$SERVER_GR_PORT_2"
65 }
66
67 if (!$have_xcom_stack){
68 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_1,localhost:$SERVER_MYPORT_2"
69 }
70 --enable_query_log
71 --source include/start_group_replication.inc
72
73
74 --echo
75 --echo # 2. Deploy a 2 members group B in single primary mode.
76 --echo
77 --let $rpl_connection_name= server3
78 --source include/rpl_connection.inc
79 --let $server3_uuid= `SELECT @@server_uuid`
80 --let $group_replication_group_name= bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb
81 --let $group_b= $group_replication_group_name
82 --disable_query_log
83 if ($have_xcom_stack){
84 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_3,localhost:$SERVER_GR_PORT_4"
85 }
86 if (!$have_xcom_stack){
87 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_3,localhost:$SERVER_MYPORT_4"
88 }
89 --enable_query_log
90 --source include/start_and_bootstrap_group_replication.inc
91
92 --let $rpl_connection_name= server4
93 --source include/rpl_connection.inc
94 --let $server4_uuid= `SELECT @@server_uuid`
95 --disable_query_log
96 if ($have_xcom_stack){
97 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_3,localhost:$SERVER_GR_PORT_4"
98 }
99 if (!$have_xcom_stack){
100 --eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_3,localhost:$SERVER_MYPORT_4"
101 }
102 --enable_query_log
103 --source include/start_group_replication.inc
104
105
106 --echo
107 --echo # 3. Configure replica to manage the asynchronous connection
108 --echo # to groups A and B.
109 --echo
110 --let $rpl_connection_name= server5
111 --source include/rpl_connection.inc
112
113 --replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 $group_a GROUP_A
114 --eval SELECT asynchronous_connection_failover_add_managed('ch1', 'GroupReplication', '$group_a', '127.0.0.1', $SERVER_MYPORT_1, '', 90, 70);
115
116 --replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3 $group_b GROUP_B
117 --eval SELECT asynchronous_connection_failover_add_managed('ch1', 'GroupReplication', '$group_b', '127.0.0.1', $SERVER_MYPORT_3, '', 85, 65);
118
119 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server1'
120 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_1, count, 1] = 1
121 --source include/assert.inc
122
123 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server3'
124 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_3, count, 1] = 1
125 --source include/assert.inc
126
127 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for group A'
128 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_a", count, 1] = 1
129 --source include/assert.inc
130
131 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for group B'
132 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_b", count, 1] = 1
133 --source include/assert.inc
134
135
136 --echo
137 --echo # 4. Create and start the managed channel.
138 --echo
139 --let $rpl_connection_name= server5
140 --source include/rpl_connection.inc
141 --replace_result $SERVER_MYPORT_1 SERVER_1_PORT
142 --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'
143
144 --let $rpl_channel_name='ch1'
145 --source include/start_slave.inc
146 --let $rpl_channel_name=
147
148 --let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server1
149 --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"
150 --source include/assert.inc
151
152 --let $wait_condition= SELECT COUNT(*)=4 FROM performance_schema.replication_asynchronous_connection_failover
153 --source include/wait_condition.inc
154
155 --echo
156 --echo # 5. Stop primary from group A (server1) and IO thread shall connect to
157 --echo # new primary server2
158 --echo
159
160 --let $rpl_connection_name= server1
161 --source include/rpl_connection.inc
162 --source include/stop_group_replication.inc
163
164 --let $rpl_connection_name= server5
165 --source include/rpl_connection.inc
166 --let $wait_condition= SELECT COUNT(*)=3 FROM performance_schema.replication_asynchronous_connection_failover
167 --source include/wait_condition.inc
168 --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE channel_name='ch1' AND source_uuid='$server2_uuid';
169 --source include/wait_condition.inc
170
171 --echo
172 --echo # 6. Stop new elected primary from group A (server2) and IO thread
173 --echo # should connect to primary from group B (server3)
174 --echo
175 --let $rpl_connection_name= server2
176 --source include/rpl_connection.inc
177 --source include/stop_group_replication.inc
178
179 --let $rpl_connection_name= server5
180 --source include/rpl_connection.inc
181 --let $wait_condition= SELECT COUNT(*)=3 FROM performance_schema.replication_asynchronous_connection_failover
182 --source include/wait_condition.inc
183 --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE channel_name='ch1' AND source_uuid='$server3_uuid';
184 --source include/wait_condition.inc
185
186 --echo
187 --echo # 7. Stop primary from group B (server3) and IO thread should connect to
188 --echo # new elected primary from group B (server4)
189 --echo
190
191 --let $rpl_connection_name= server3
192 --source include/rpl_connection.inc
193 --source include/stop_group_replication.inc
194
195 --let $rpl_connection_name= server5
196 --source include/rpl_connection.inc
197 --let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_asynchronous_connection_failover
198 --source include/wait_condition.inc
199 --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE channel_name='ch1' AND source_uuid='$server4_uuid';
200 --source include/wait_condition.inc
201
202 --echo
203 --echo # 8. Stop primary from group B (server4) and IO thread should stop
204
205 --let $rpl_connection_name= server4
206 --source include/rpl_connection.inc
207 --source include/stop_group_replication.inc
208
209 --let $rpl_connection_name= server5
210 --source include/rpl_connection.inc
211 --let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_asynchronous_connection_failover
212 --source include/wait_condition.inc
213 --let $wait_condition= SELECT COUNT(*)=0 FROM performance_schema.replication_connection_status WHERE channel_name='ch1' AND service_state='OFF';
214 --source include/wait_condition.inc
215
216 --echo
217 --echo # 9. Assert Server2 and Server4 last members of the groups are on
218 --echo # replication_connection_status table
219 --echo
220
221 --let $assert_text= 'Last member from group A Server2 is one row in performance_schema.replication_asynchronous_connection_failover'
222 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_2, count, 1] = 1
223 --source include/assert.inc
224
225 --let $assert_text= 'Last member from group B Server4 is one row in performance_schema.replication_asynchronous_connection_failover'
226 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_4, count, 1] = 1
227 --source include/assert.inc
228
229 --echo
230 --echo # 10. Clean up.
231 --echo
232 --let $rpl_connection_name= server5
233 --source include/rpl_connection.inc
234
235 SET SESSION sql_log_bin = 0;
236 call mtr.add_suppression("The source .* for channel 'ch1' has joined the group .*, and so added its entry into replication_asynchronous_connection_failover table.");
237 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.");
238 call mtr.add_suppression("The source .* for channel 'ch1' has left the group .*, and so removed its entry from replication_asynchronous_connection_failover table.");
239 call mtr.add_suppression("The group .* for the channel .* has been removed, and so removed its entry from replication_asynchronous_connection_failover_managed and all the group members from replication_asynchronous_connection_failover table.");
240 call mtr.add_suppression("The group .* for the channel .* has been added, and so added its entry in replication_asynchronous_connection_failover_managed and source to replication_asynchronous_connection_failover table.");
241 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.");
242 call mtr.add_suppression("The Monitor IO thread failed to detect if the source belongs to the group majority on the source .* for channel 'ch1'.");
243 SET SESSION sql_log_bin = 1;
244
245 --let $rpl_channel_name='ch1'
246 --source include/stop_slave.inc
247
248 --let $rpl_reset_slave_all= 1
249 --let $rpl_multi_source= 1
250 --source include/rpl_reset_slave.inc
251 --let $rpl_channel_name=
252 --let $rpl_reset_slave_all=
253 --let $rpl_multi_source=
254
255 --replace_result $group_a GROUP_A
256 --eval SELECT asynchronous_connection_failover_delete_managed('ch1', '$group_a')
257
258 --replace_result $group_b GROUP_B
259 --eval SELECT asynchronous_connection_failover_delete_managed('ch1', '$group_b')
260
261 --source include/group_replication_end.inc