Debian Codegraph @

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

raw
1 ###############################################################################
2 #
3 # When changing to single primary mode with no appointed primary,
4 # the new primary member shall be elected using weights or
5 # lexicographic order when all weights are equal.
6 #
7 # Test:
8 # 0. This test needs two servers
9 # 1. Store uuid from server1 and set election weight to 50
10 # 2. Store uuid from server2 and set election weight to 90
11 # 3. Execute action switch to single primary mode and confirm server2 is
12 # the primary
13 # 4. Execute action switch to multiple primary mode
14 # 5. Set election weight on server2 to 50
15 # 6. Execute action switch to single primary mode
16 # 7. Confirm server with lower lexical uuid is the new primary server
17 # 8. Cleanup
18 #
19 ###############################################################################
20
21 --source include/have_group_replication_plugin.inc
22 --source include/group_replication.inc
23
24 --echo
25 --echo # 1. Store uuid from server1 and set election weight to 50
26
27 --let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
28 SET @@GLOBAL.group_replication_member_weight= 50;
29
30 --echo
31 --echo # 2. Store uuid from server2 and set election weight to 90
32
33 --let $rpl_connection_name= server2
34 --source include/rpl_connection.inc
35
36 --let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
37 SET @@GLOBAL.group_replication_member_weight= 90;
38
39 --echo
40 --echo # 3. Execute action switch to single primary mode and confirm server2 is
41 --echo # the primary
42
43 SELECT group_replication_switch_to_single_primary_mode();
44
45 --source include/gr_assert_primary_member.inc
46
47 --let $rpl_connection_name= server1
48 --source include/rpl_connection.inc
49
50 --source include/gr_assert_secondary_member.inc
51
52 --echo
53 --echo # 4. Execute action switch to multiple primary mode
54
55 SELECT group_replication_switch_to_multi_primary_mode();
56
57 --source include/gr_assert_multi_primary_mode.inc
58
59 --echo
60 --echo # 5. Set election weight on server2 to 50
61
62 --let $rpl_connection_name= server2
63 --source include/rpl_connection.inc
64
65 # Wait for the action to be declared as not running on server2
66 --let $wait_condition=SELECT COUNT(*)=0 FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%"
67 --source include/wait_condition.inc
68
69 SET @@GLOBAL.group_replication_member_weight= 50;
70
71 --echo
72 --echo # 6. Execute action switch to single primary mode
73
74 SELECT group_replication_switch_to_single_primary_mode();
75
76 --echo
77 --echo # 7. Confirm server with lower lexical uuid is the new primary server
78
79 --let $server_conn= server1
80 --let $server_conn2= server2
81
82 if(`SELECT "$server1_uuid" > "$server2_uuid"`)
83 {
84 --let $server_conn= server2
85 --let $server_conn2= server1
86 }
87
88 --connection $server_conn
89
90 --source include/gr_assert_primary_member.inc
91
92 --connection $server_conn2
93
94 --source include/gr_assert_secondary_member.inc
95
96 --echo
97 --echo # 8. Cleanup
98
99 --let $rpl_group_replication_single_primary_mode=1
100 --let $rpl_group_replication_reset_persistent_vars=1
101 --source include/group_replication_end.inc