File: gr_singlewriter_enabled_on_mode_switch.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (440 lines) | stat: -rw-r--r-- 24,828 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
################################################################################
#
# Starting from communication protocol version 8.0.22, XCom will use a single
# leader consensus algorithm based on Multi-Paxos when running GR in SPM.
#
# This test shall verify that, upon switching the group mode from MPM to SPM,
# when on communication protocol v8.0.22, a single leader is used. It will also
# test that when switching from MPM to SPM while using a previous communication
# protocol, the previous consensus algorithm is used (i.e. all members as
# leaders).
#
# Test:
# 0) The test requires three servers.
# 1) Switch to SPM on every member. For each member that was elected as primary
# in SPM, the WRITE_CONSENSUS_LEADERS_MEMBER_ID_PREFERRED and
# WRITE_CONSENSUS_LEADERS_MEMBER_ID_ACTIVE fields of the
# performance_schema.replication_group_communication_information PFS table
# should contain *only* the UUID of that member.
# 2) Change the communication protocol to 8.0.21.
# 3) Switch to SPM on every member. For each member that was elected as primary
# in SPM the WRITE_CONSENSUS_LEADERS_MEMBER_ID_PREFERRED and
# WRITE_CONSENSUS_LEADERS_MEMBER_ID_ACTIVE fields of the
# performance_schema.replication_group_communication_information PFS table
# should contain the UUIDs of *all* the members in the group.
# 4) Cleanup.
#
################################################################################
--source include/big_test.inc
--source include/have_group_replication_plugin.inc

--echo
--echo ####
--echo # 0) The test requires three servers.
--echo ####
--echo
--let $rpl_server_count = 3
--let $rpl_group_replication_single_primary_mode=0
--source include/group_replication.inc

SET SESSION sql_log_bin = 0;
call mtr.add_suppression("A member is joining the group while a group configuration operation is occurring*");
SET SESSION sql_log_bin = 1;

--let $rpl_connection_name= server2
--source include/rpl_connection.inc
SET SESSION sql_log_bin = 0;
call mtr.add_suppression("A member is joining the group while a group configuration operation is occurring*");
SET SESSION sql_log_bin = 1;

--let $rpl_connection_name= server3
--source include/rpl_connection.inc
SET SESSION sql_log_bin = 0;
call mtr.add_suppression("A member is joining the group while a group configuration operation is occurring*");
SET SESSION sql_log_bin = 1;

--echo
--echo ####
--echo # 1) Switch to SPM on every member. For each member that was elected as
--echo # primary in SPM, the WRITE_CONSENSUS_LEADERS_MEMBER_ID_PREFERRED and
--echo # WRITE_CONSENSUS_LEADERS_MEMBER_ID_ACTIVE fields of the
--echo # performance_schema.replication_group_communication_information PFS
--echo # table should contain *only* the UUID of that member.
--echo ####
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

# Elect member 1
--let $server1_uuid = `SELECT @@server_uuid`
--replace_result $server1_uuid MEMBER1_UUID
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid")

# Verify preferred and active members of member 1
--let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED FROM performance_schema.replication_group_communication_information]" = "$server1_uuid"
--source include/assert.inc
--let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server1_uuid"
--source include/assert.inc
--let $assert_text = Single Leader must be enabled
--let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "1"
--source include/assert.inc

# Verify preferred and active members of member 2
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server1_uuid"
--source include/assert.inc
--let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server1_uuid"
--source include/assert.inc
--let $assert_text = Single Leader must be enabled
--let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "1"
--source include/assert.inc

# Verify preferred and active members of member 3
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server1_uuid"
--source include/assert.inc
--let $assert_text = The first server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server1_uuid"
--source include/assert.inc
--let $assert_text = Single Leader must be enabled
--let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "1"
--source include/assert.inc

--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--source include/stop_group_replication.inc

--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/stop_group_replication.inc

--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/stop_group_replication.inc

--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/start_and_bootstrap_group_replication.inc

--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/start_group_replication.inc

--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--source include/start_group_replication.inc

# Elect member 2
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $server2_uuid = `SELECT @@server_uuid`

--eval SELECT group_replication_switch_to_multi_primary_mode()
--replace_result $server2_uuid MEMBER2_UUID
--eval SELECT group_replication_switch_to_single_primary_mode("$server2_uuid")

--let $wait_condition = SELECT COUNT(*)=1 FROM performance_schema.replication_group_members WHERE MEMBER_ID = "$server2_uuid" AND MEMBER_ROLE = 'PRIMARY'
--source include/wait_condition.inc

# Verify preferred and active members of member 2
--let $assert_text = The second server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server2_uuid"
--source include/assert.inc
--let $assert_text = The second server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server2_uuid"
--source include/assert.inc

# Verify preferred and active members of member 1
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $assert_text = The second server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server2_uuid"
--source include/assert.inc
--let $assert_text = The second server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server2_uuid"
--source include/assert.inc

# Verify preferred and active members of member 3
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $assert_text = The second server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server2_uuid"
--source include/assert.inc
--let $assert_text = The second server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server2_uuid"
--source include/assert.inc

# Elect member 3
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $server3_uuid = `SELECT @@server_uuid`

--eval SELECT group_replication_switch_to_multi_primary_mode()
--replace_result $server3_uuid MEMBER3_UUID
--eval SELECT group_replication_switch_to_single_primary_mode("$server3_uuid")

--let $wait_condition = SELECT COUNT(*)=1 FROM performance_schema.replication_group_members WHERE MEMBER_ID = "$server3_uuid" AND MEMBER_ROLE = 'PRIMARY'
--source include/wait_condition.inc

# Verify preferred and active members of member 3
--let $assert_text = The third server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server3_uuid"
--source include/assert.inc
--let $assert_text = The third server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server3_uuid"
--source include/assert.inc

# Verify preferred and active members of member 1
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $assert_text = The third server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server3_uuid"
--source include/assert.inc
--let $assert_text = The third server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server3_uuid"
--source include/assert.inc

# Verify preferred and active members of member 2
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $assert_text = The third server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_PREFERRED from performance_schema.replication_group_communication_information]" = "$server3_uuid"
--source include/assert.inc
--let $assert_text = The third server's UUID should be the only UUID in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $assert_cond = "[SELECT WRITE_CONSENSUS_LEADERS_ACTUAL from performance_schema.replication_group_communication_information]" = "$server3_uuid"
--source include/assert.inc

--echo
--echo ####
--echo # 2) Change the communication protocol to 8.0.21. Must restart the group.
--echo ####
--echo

--let $rpl_connection_name= server3
--source include/rpl_connection.inc

--source include/stop_group_replication.inc
--eval SET GLOBAL group_replication_paxos_single_leader = "OFF"

--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--source include/stop_group_replication.inc
--eval SET GLOBAL group_replication_paxos_single_leader = "OFF"

--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--source include/stop_group_replication.inc
--eval SET GLOBAL group_replication_paxos_single_leader = "OFF"

--source include/start_and_bootstrap_group_replication.inc

--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--source include/start_group_replication.inc

--let $rpl_connection_name= server3
--source include/rpl_connection.inc

--source include/start_group_replication.inc

--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--eval SELECT group_replication_set_communication_protocol("8.0.21")

--echo
--echo ####
--echo # 3) Switch to SPM on every member. For each member that was elected as
--echo # primary in SPM the WRITE_CONSENSUS_LEADERS_MEMBER_ID_PREFERRED and
--echo # WRITE_CONSENSUS_LEADERS_MEMBER_ID_ACTIVE fields of the
--echo # performance_schema.replication_group_communication_information PFS
--echo # table should contain the UUIDs of *all* the members in the group.
--echo ####
--echo

# Elect member 1
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

# Wait until the communication protocol change is effective on this member,
# only one group action can run at a time.
# When changing to 8.0.21, the protocol will change to 8.0.16.
--let $wait_condition = SELECT COUNT(*)=1 FROM performance_schema.replication_group_communication_information WHERE PROTOCOL_VERSION = '8.0.16'
--source include/wait_condition_or_abort.inc

--eval SELECT group_replication_switch_to_multi_primary_mode()
--replace_result $server1_uuid MEMBER1_UUID
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid")

--let $wait_condition = SELECT COUNT(*)=1 FROM performance_schema.replication_group_members WHERE MEMBER_ID = "$server1_uuid" AND MEMBER_ROLE = 'PRIMARY'
--source include/wait_condition.inc

# Verify preferred and active members of member 1
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc
--let $assert_text = Single Leader must be disabled
--let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "0"
--source include/assert.inc

# Verify preferred and active members of member 2
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc
--let $assert_text = Single Leader must be disabled
--let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "0"
--source include/assert.inc

# Verify preferred and active members of member 3
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc
--let $assert_text = Single Leader must be disabled
--let $assert_cond = "[SELECT WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE from performance_schema.replication_group_communication_information]" = "0"
--source include/assert.inc

# Elect member 2
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $server2_uuid = `SELECT @@server_uuid`

--eval SELECT group_replication_switch_to_multi_primary_mode()
--replace_result $server2_uuid MEMBER2_UUID
--eval SELECT group_replication_switch_to_single_primary_mode("$server2_uuid")

--let $wait_condition = SELECT COUNT(*)=1 FROM performance_schema.replication_group_members WHERE MEMBER_ID = "$server2_uuid" AND MEMBER_ROLE = 'PRIMARY'
--source include/wait_condition.inc

# Verify preferred and active members of member 2
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc

# Verify preferred and active members of member 1
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc

# Verify preferred and active members of member 3
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc

# Elect member 3
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $server3_uuid = `SELECT @@server_uuid`

--eval SELECT group_replication_switch_to_multi_primary_mode()
--replace_result $server3_uuid MEMBER3_UUID
--eval SELECT group_replication_switch_to_single_primary_mode("$server3_uuid")

--let $wait_condition = SELECT COUNT(*)=1 FROM performance_schema.replication_group_members WHERE MEMBER_ID = "$server3_uuid" AND MEMBER_ROLE = 'PRIMARY'
--source include/wait_condition.inc

# Verify preferred and active members of member 3
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc

# Verify preferred and active members of member 1
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc

# Verify preferred and active members of member 2
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_PREFERRED
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_PREFERRED LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc
--let $assert_text = All members should be in WRITE_CONSENSUS_LEADERS_ACTUAL
--let $num_rows = `SELECT COUNT(*) FROM performance_schema.replication_group_communication_information WHERE WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server1_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server2_uuid%' AND WRITE_CONSENSUS_LEADERS_ACTUAL LIKE '%$server3_uuid%'`
--let $assert_cond = "$num_rows" = "1"
--source include/assert.inc

--echo
--echo ####
--echo # 4) Cleanup.
--echo ####
--echo

--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--eval SET GLOBAL group_replication_paxos_single_leader = "ON"

--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--eval SET GLOBAL group_replication_paxos_single_leader = "ON"

--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--eval SET GLOBAL group_replication_paxos_single_leader = "ON"

--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/stop_group_replication.inc
--let $rpl_group_replication_single_primary_mode=1
--let $rpl_group_replication_reset_persistent_vars=1
--source include/group_replication_end.inc