Debian Codegraph @

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

raw
1 ################################################################################
2 #
3 # WL#10412: GR: notify listener services on relevant group events
4 #
5 # This test case checks that the correct notifications are
6 # triggered to the listeners registered in the service registry.
7 #
8 # For that it relies on a table that is updated by a listener
9 # through the SQL service API.
10 #
11 # This file covers a few scenarios specific to Single Primary mode.
12 #
13 # |------------+----+---------------------------------------------+------------+--------|
14 # | Tested | | Scenario\Where | | |
15 # | in this | | | Server | Others |
16 # | file | | | triggering | |
17 # | | | | event | |
18 # |------------+----+---------------------------------------------+------------+--------|
19 # | | 1 | SERVER BOOTSTRAPS GROUP | VC,2xSC | N/A |
20 # | | 2 | SERVER JOINS and STARTS RECOVERY | VC,SC | VC,SC |
21 # | | 3 | SERVER RECOVERED | SC | SC |
22 # | | 4 | SERVER LEAVES(ERROR), SERVER LEAVES(OFFLINE)| VC,SC | VC |
23 # |------------+----+---------------------------------------------+------------+--------|
24 # | x | 5 | SERVER BOOTSTRAPS+RECOVERS+PRIMARY ELECTION | VC,RC,2xSC | |
25 # | x | 6 | PRIMARY LEAVES | VC,SC,RC | VC,RC |
26 # |------------+----+---------------------------------------------+------------+--------|
27 # | | 7 | A SERVER BECOMES UNREACHABLE | SC, VC | N/A |
28 # | | 8 | MAJORITY UNREACHABLE | QL, SC | N/A |
29 # | | 9 | MAJORITY UNREACHABLE+FORCE MEMBERS | VC | N/A |
30 # | | 10 | MAJORITY UNREACHABLE+STOP | VC, SC | N/A |
31 # |------------+----+---------------------------------------------+------------+--------|
32 #
33 # Legend:
34 # - QL - Quorum Lost event
35 # - VC - View Changed event
36 # - RC - Role Changed event
37 # - SC - State Changed event
38 #
39 # To test the cases above, the test sets up a group of
40 # 3 servers in multi-master mode and proceeds to testing
41 # the different scenarios. These are highlighted in the
42 # test file.
43 ################################################################################
44
45 --source include/have_debug.inc
46 --source include/force_restart.inc
47 --source include/big_test.inc
48 --source include/not_have_privilege_checks_user.inc
49 --source include/have_group_replication_plugin.inc
50
51 ###
52 ### Sets up the group with three servers: server1, server2 and server3
53 ###
54
55 --let $rpl_server_count= 3
56 --let $rpl_skip_group_replication_start= 1
57 --source include/group_replication.inc
58
59 # server 1
60
61 --let $rpl_connection_name= server1
62 --source include/rpl_connection.inc
63
64 --let $debug_point= register_gms_listener_example
65 --source include/add_debug_point.inc
66
67 SET SQL_LOG_BIN=0;
68 CREATE TABLE test.gms_listener_example(log_message TEXT);
69 SET SQL_LOG_BIN=1;
70
71 SET GLOBAL group_replication_enforce_update_everywhere_checks= OFF;
72 SET GLOBAL group_replication_single_primary_mode= ON;
73 SET GLOBAL group_replication_force_members='';
74
75 # server 2
76
77 --let $rpl_connection_name= server2
78 --source include/rpl_connection.inc
79
80 --let $debug_point= register_gms_listener_example
81 --source include/add_debug_point.inc
82
83 SET SQL_LOG_BIN=0;
84 CREATE TABLE test.gms_listener_example(log_message TEXT);
85 SET SQL_LOG_BIN=1;
86
87 SET GLOBAL group_replication_enforce_update_everywhere_checks= OFF;
88 SET GLOBAL group_replication_single_primary_mode= ON;
89 SET GLOBAL group_replication_force_members='';
90
91 # server 3
92
93 --let $rpl_connection_name= server3
94 --source include/rpl_connection.inc
95
96 --let $debug_point= register_gms_listener_example
97 --source include/add_debug_point.inc
98
99 SET SQL_LOG_BIN=0;
100 CREATE TABLE test.gms_listener_example(log_message TEXT);
101 SET SQL_LOG_BIN=1;
102
103 SET GLOBAL group_replication_enforce_update_everywhere_checks= OFF;
104 SET GLOBAL group_replication_single_primary_mode= ON;
105 SET GLOBAL group_replication_force_members='';
106
107
108 --echo ### Scenario 5: SERVER BOOTSTRAPS+RECOVERS+PRIMARY ELECTION
109 --echo ### Expected:
110 --echo ### - Myself: 1 VIEW CHANGE, 2 STATE CHANGED, 1 ROLE CHANGED
111 --echo ### - Others: N/A
112 --echo ##################################################################
113
114 # start the group
115 --let $rpl_connection_name= server1
116 --source include/rpl_connection.inc
117 --source include/start_and_bootstrap_group_replication.inc
118
119 # view change + server moved from recovering to online
120 --let $expected_notifications= 1,VIEW %:1|2,STATE %:1|1,ROLE %:1
121 --source ../include/assert_notifications.inc
122
123 --echo ### Scenario 6: PRIMARY LEAVES the GROUP
124 --echo ### Expected:
125 --echo ### - Myself (old primary): 1 VIEW CHANGED, 1 STATE CHANGED, 1 ROLE CHANGED
126 --echo ### - Others (new primary): 1 VIEW CHANGED, 1 ROLE CHANGED
127 --echo ### - Others (secondary): 1 VIEW CHANGED, 1 ROLE CHANGED
128 --echo ##################################################################
129
130 # server2
131
132 --let $rpl_connection_name= server2
133 --source include/rpl_connection.inc
134
135 --source include/start_group_replication.inc
136
137 # server2 joins and as such, it changes its state to online
138 --let $expected_notifications= 1,VIEW %:2|2,STATE %:2
139 --source ../include/assert_notifications.inc
140
141 # server3
142
143 --let $rpl_connection_name= server3
144 --source include/rpl_connection.inc
145
146 --source include/start_group_replication.inc
147
148 # server3 joins and as such, it changes its state to online
149 --let $expected_notifications= 1,VIEW %:3|2,STATE %:3
150 --source ../include/assert_notifications.inc
151
152 # server1
153
154 --let $rpl_connection_name= server1
155 --source include/rpl_connection.inc
156
157 --let $expected_notifications= 1,VIEW %2|1,VIEW %:3|2,STATE %:2|2,STATE %:3
158 --source ../include/assert_notifications.inc
159
160 --disable_query_log
161 TRUNCATE gms_listener_example;
162 --source include/rpl_sync.inc
163 --enable_query_log
164
165 # this will cause the primary to switch
166 --source include/stop_group_replication.inc
167
168 # server1 installs leave view, its state change and its
169 # role changed as well.
170 --let $expected_notifications= 1,VIEW %: |1,STATE %: |1,ROLE %:%
171 --source ../include/assert_notifications.inc
172
173 # server2
174 --let $rpl_connection_name= server2
175 --source include/rpl_connection.inc
176
177 # wait for the group to rearrange itself
178 --let $group_replication_number_of_members= 2
179 --source include/gr_wait_for_number_of_members.inc
180
181 # server2 installs new view and a notification about
182 # primary change and the notifications about server3
183 # joining as well
184 --let $expected_notifications= 1,VIEW %:4|1,ROLE %:4
185 --source ../include/assert_notifications.inc
186
187 # server3
188 --let $rpl_connection_name= server3
189 --source include/rpl_connection.inc
190
191 # wait for the group to rearrange itself
192 --let $group_replication_number_of_members= 2
193 --source include/gr_wait_for_number_of_members.inc
194
195 # server3 installs new view and a notification about
196 # primary change
197 --let $expected_notifications= 1,VIEW %:4|1,ROLE %:4
198 --source ../include/assert_notifications.inc
199
200 ###
201 ### Clean up and bail out
202 ###
203
204 # server2
205
206 --let $rpl_connection_name= server2
207 --source include/rpl_connection.inc
208 --source include/stop_group_replication.inc
209
210 #server3
211
212 --let $rpl_connection_name= server3
213 --source include/rpl_connection.inc
214 --source include/stop_group_replication.inc
215
216 # server1
217
218 --let $rpl_connection_name= server1
219 --source include/rpl_connection.inc
220
221 --let $debug_point= register_gms_listener_example
222 --source include/remove_debug_point.inc
223
224 --source include/start_and_bootstrap_group_replication.inc
225
226 # server2
227
228 --let $rpl_connection_name= server2
229 --source include/rpl_connection.inc
230
231 --let $debug_point= register_gms_listener_example
232 --source include/remove_debug_point.inc
233
234 --source include/start_group_replication.inc
235
236 # server3
237
238 --let $rpl_connection_name= server3
239 --source include/rpl_connection.inc
240
241 --let $debug_point= register_gms_listener_example
242 --source include/remove_debug_point.inc
243
244 --source include/start_group_replication.inc
245
246 --let $rpl_connection_name= server1
247 --source include/rpl_connection.inc
248
249 DROP TABLE gms_listener_example;
250 --source include/rpl_sync.inc
251
252 --source include/group_replication_end.inc