Debian Codegraph @

mysql-test/suite/x/t/notices_gr_join_leave.test

raw
1 ################################################################################
2 #
3 # WL#10655: Global notification for GR membership changes
4 #
5 # This test case checks that enabled notices are triggered and delivered to
6 # client.
7 #
8 # This file covers the scenarios for regular bootstrap, join, leave, recovering.
9 #
10 #
11 # +----+---------------------------------------------+------------+---------|
12 # | | Scenario\Where | | |
13 # | | | Server1 | Server2 |
14 # | | | triggering | |
15 # | | | event | |
16 # +----+---------------------------------------------+------------+---------|
17 # | 1 | SERVER BOOTSTRAPS GROUP | VC,2xSC | N/A |
18 # | 2 | SERVER JOINS and STARTS RECOVERY | VC,SC | VC,SC |
19 # | 3 | SERVER RECOVERED | SC | SC |
20 # | 4 | SERVER LEAVES(ERROR), SERVER LEAVES(OFFLINE)| VC,SC | VC |
21 # +----+---------------------------------------------+------------+---------|
22 #
23 # Scenarios described inside the table will be repeated two times:
24 #
25 # * X Protocol GR notices enabled - verify delivery of the notices
26 # * X Protocol GR notices disabled - verify that X Plugin doesn't send the notices
27 #
28
29 --source include/have_debug_sync.inc
30 --source include/big_test.inc
31 --source include/count_sessions.inc
32 --source include/force_restart.inc
33 --source include/have_mysqlx_plugin.inc
34 --source include/have_group_replication_plugin.inc
35
36 ## Test starts here
37 --let $xtest=$MYSQL_TMP_DIR/group_replication_setup_and_xnotices_test.tmp
38 --write_file $xtest
39 -->import group_replication.macro
40 -->import assert_notices.macro
41 -->import assert_status_variable.macro
42
43 -->echo
44 -->echo ###
45 -->echo ### Sets up the group with two servers: server1 and server2
46 -->echo ###
47
48 callmacro Connect_to_all_mysqld_instances verify %SERVER_NUMBER%;
49 callmacro %ENABLE_NOTICES% %SERVER_NUMBER%
50 {"notice":["group_replication/membership/quorum_loss",
51 "group_replication/membership/view",
52 "group_replication/status/role_change",
53 "group_replication/status/state_change"]};
54
55 callmacro Connect_to_all_mysqld_instances server %SERVER_NUMBER%;
56 callmacro GR_clear_bootstrap_group %SERVER_NUMBER%;
57
58
59 -->echo
60 -->echo ### Scenario 1: SERVER BOOTSTRAPS GROUP
61 -->echo ### Expected:
62 -->echo ### - Myself: 1 VIEW CHANGED, 2 STATE CHANGED
63 -->echo ### - Others: N/A
64 -->echo ##########################################################################
65 callmacro GR_start_and_bootstrap %SERVER_NUMBER% %GR_NAME% ONLINE;
66
67 callmacro %ASSERT_NOTICES% view_changed verify_1;
68 callmacro %ASSERT_NOTICES% state_changed verify_1;
69 callmacro %ASSERT_NOTICES% state_changed verify_1;
70 callmacro %ASSERT_NOTICES% none verify_1;
71 callmacro %ASSERT_NOTICES% none verify_2;
72
73
74 -->echo
75 -->echo ### Scenario 2: MEMBER JOINS, but blocks recovering
76 -->echo ### Expected:
77 -->echo ### - Myself: 1 VIEW CHANGED, 1 STATE CHANGED
78 -->echo ### - Others: 1 VIEW CHANGED, 1 STATE CHANGED
79 -->echo ##########################################################################
80
81 # this will make server2 stay on recovery
82 callmacro Setsession server_2;
83 noquery_result;
84 SET @@GLOBAL.DEBUG='+d,recovery_thread_wait_before_finish';
85 query_result;
86 callmacro GR_start %GR_NAME% RECOVERING;
87
88 callmacro %ASSERT_NOTICES% view_changed verify_1;
89 callmacro %ASSERT_NOTICES% state_changed verify_1;
90 callmacro %ASSERT_NOTICES% none verify_1;
91
92 callmacro %ASSERT_NOTICES% view_changed verify_2;
93 callmacro %ASSERT_NOTICES% state_changed verify_2;
94 callmacro %ASSERT_NOTICES% none verify_2;
95
96
97 -->echo
98 -->echo ### Scenario 3: MEMBER RECOVERS JOINS
99 -->echo ### Expected:
100 -->echo ### - Myself: 1 STATE CHANGED
101 -->echo ### - Others: 1 STATE CHANGED
102 -->echo ##########################################################################
103
104 callmacro Setsession server_2;
105 noquery_result;
106 SET DEBUG_SYNC= "now WAIT_FOR signal.recovery_thread_wait_before_finish_reached";
107 SET @@GLOBAL.DEBUG='-d,recovery_thread_wait_before_finish';
108 SET DEBUG_SYNC= "now SIGNAL signal.recovery_end";
109 query_result;
110 callmacro GR_wait_for_member_state ONLINE;
111 noquery_result;
112 SET DEBUG_SYNC= 'RESET';
113 query_result;
114
115 callmacro %ASSERT_NOTICES% state_changed verify_1;
116 callmacro %ASSERT_NOTICES% none verify_1;
117 callmacro %ASSERT_NOTICES% state_changed verify_2;
118 callmacro %ASSERT_NOTICES% none verify_2;
119
120
121 -->echo
122 -->echo ### Scenario 4: SERVER LEAVES(ERROR), SERVER LEAVES(OFFLINE)
123 -->echo ### Expected:
124 -->echo ### - Myself (leaving): 1 VIEW CHANGED, 1 STATE CHANGED
125 -->echo ### - Others: 1 VIEW CHANGED
126 -->echo ##########################################################################
127
128 callmacro Setsession server_2;
129 noquery_result;
130 quiet;
131 SET SESSION sql_log_bin=0;
132 call mtr.add_suppression("Table 'tab1' already exists");
133 call mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group");
134 call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
135 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
136 call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': ... The replica coordinator and worker threads are stopped,*");
137 SET SESSION sql_log_bin=1;
138 noquiet;
139
140 SET SESSION sql_log_bin=0;
141 CREATE TABLE test.tab1 (a INT PRIMARY KEY);
142 SET SESSION sql_log_bin=1;
143
144 callmacro Setsession server_1;
145 CREATE TABLE test.tab1 (a INT PRIMARY KEY);
146 query_result;
147
148 callmacro Setsession server_2;
149 callmacro GR_wait_for_member_state ERROR;
150 callmacro GR_wait_for_number_of_members 1;
151
152 callmacro %ASSERT_NOTICES% view_changed verify_1;
153 callmacro %ASSERT_NOTICES% none verify_1;
154 callmacro %ASSERT_NOTICES% state_changed verify_2;
155 callmacro %ASSERT_NOTICES% view_changed verify_2;
156 callmacro %ASSERT_NOTICES% none verify_2;
157
158 callmacro Setsession server_2;
159 callmacro GR_stop;
160 callmacro GR_wait_for_member_state OFFLINE;
161
162 callmacro %ASSERT_NOTICES% state_changed verify_2;
163 callmacro %ASSERT_NOTICES% none verify_2;
164
165
166 -->echo
167 -->echo ### Cleanup: in xtest deallocation of GR and drop of data
168 -->echo ##########################################################################
169
170 callmacro Setsession server_1;
171 callmacro GR_stop;
172 noquery_result;
173 DROP TABLE test.tab1;
174 RESET MASTER;
175 query_result;
176 callmacro %ASSERT_NOTICES% view_changed verify_1;
177 callmacro %ASSERT_NOTICES% state_changed verify_1;
178
179 callmacro Setsession server_2;
180 noquery_result;
181 DROP TABLE test.tab1;
182 RESET MASTER;
183 query_result;
184
185 -->echo
186 -->echo ### Postcheck: Assert session status variables
187 -->echo ### Expected:
188 -->echo ### - Myself 10 global-notices (7 from the tests scenarios + 2 from cleanup + 1 from connection)
189 -->echo ### - Other 7 global-notices (6 from the tests scenarios + 1 from connection)
190 -->echo ##########################################################################
191 callmacro Setsession verify_1;
192 callmacro %ASSERT_STATUS% Mysqlx_notice_global_sent 10;
193 callmacro Assert_received_notices;
194
195 callmacro Setsession verify_2;
196 callmacro %ASSERT_STATUS% Mysqlx_notice_global_sent 7;
197 callmacro Assert_received_notices;
198 EOF
199
200 ## Setup X Plugin & GR
201 --let $dont_reset_global_status_variables=1
202 --source include/xplugin_preamble.inc
203
204 --let $rpl_skip_group_replication_start= 1
205 --source include/group_replication.inc
206
207 --let $ceiling= `SELECT $rpl_server_count + 1`
208 --let $i = 1
209
210 while ($i < $ceiling)
211 {
212 --let $rpl_connection_silent= 1
213 --let $rpl_connection_name= server$i
214 --echo [Setup XPlugin user on connection '$rpl_connection_name']
215 --source include/rpl_connection.inc
216 --let $create_user_disable_binlog=1
217 --source include/xplugin_create_user.inc
218 --inc $i
219 }
220
221 --let $rpl_connection_silent= 0
222
223
224 --echo
225 --echo ## Protocol GR notices enabled - verify delivery of the notices
226 --echo ##########################################################################
227
228 exec $MYSQLXTEST
229 -ux_root --ssl-mode=disabled --file=$xtest
230 -v %SERVER_NUMBER%=$rpl_server_count
231 -v %GR_NAME%=$group_replication_group_name
232 -v %ASSERT_NOTICES%=CHK_assert_notice
233 -v %ASSERT_STATUS%=Assert_status_variable
234 -v %ENABLE_NOTICES%=Enable_notice
235 -v %SERVER_XPORT_1%=$MASTER_X_MYPORT_1
236 -v %SERVER_XPORT_2%=$MASTER_X_MYPORT_2 2>&1;
237
238
239 --echo
240 --echo ## X Protocol GR notices disabled - verify that X Plugin doesn't send the notices
241 --echo ##########################################################################
242
243 exec $MYSQLXTEST
244 -ux_root --ssl-mode=disabled --file=$xtest
245 -v %SERVER_NUMBER%=$rpl_server_count
246 -v %GR_NAME%=$group_replication_group_name
247 -v %ASSERT_NOTICES%=CHK_assert_notice_none_ignore_args
248 -v %ASSERT_STATUS%=CHK_assert_ignore
249 -v %ENABLE_NOTICES%=Dont_enable_notice
250 -v %SERVER_XPORT_1%=$MASTER_X_MYPORT_1
251 -v %SERVER_XPORT_2%=$MASTER_X_MYPORT_2 2>&1;
252
253 --echo
254 --echo ## Assert global status variables responsible for monitoring of global notices
255 --echo ## Expected:
256 --echo ## - Global Mysqlx_notified_by_group_replication must be two times higher than
257 --echo ## the session Mysqlx_notice_global_sent (test was executed two times).
258 --echo ##########################################################################
259
260 --let $rpl_connection_name= server1
261 --source include/rpl_connection.inc
262
263 ## Assert from xtest (Mysqlx_notice_global_sent 9) + additional one notice per connection (3 conn * 2 tests)
264 --let $assert_text= Verify if the number of send global notices matches Mysqlx_notice_global_sent.
265 --let $assert_cond= [SHOW STATUS LIKE "Mysqlx_notice_global_sent", Value, 1] = 15
266 --source include/assert.inc
267
268 --let $assert_text= Verify if the number of send global notices matches Mysqlx_notified_by_group_replication.
269 --let $assert_cond= [SHOW STATUS LIKE "Mysqlx_notified_by_group_replication", Value, 1] = 18
270 --source include/assert.inc
271
272 --let $rpl_connection_name= server2
273 --source include/rpl_connection.inc
274
275 ## Assert from xtest (Mysqlx_notice_global_sent 6) + additional one notice per connection (2 conn * 2 tests)
276 --let $assert_text= Verify if the number of send global notices matches Mysqlx_notice_global_sent.
277 --let $assert_cond= [SHOW STATUS LIKE "Mysqlx_notice_global_sent", Value, 1] = 10
278 --source include/assert.inc
279
280 --let $assert_text= Verify if the number of send global notices matches Mysqlx_notified_by_group_replication.
281 --let $assert_cond= [SHOW STATUS LIKE "Mysqlx_notified_by_group_replication", Value, 1] = 12
282 --source include/assert.inc
283
284 ## Cleanup
285 --remove_file $xtest
286
287 --source include/group_replication_end.inc
288 --let $i = 1
289 --let $rpl_connection_silent=1
290 while ($i < $ceiling)
291 {
292 --let $rpl_connection_silent= 1
293 --let $rpl_connection_name= server$i
294 --source include/rpl_connection.inc
295 --source include/xplugin_drop_user.inc
296 --inc $i
297 }
298
299 # Following connections are established by group_replication.inc,
300 # still group_replication_end.inc doesn't disconnects them.
301 #
302 # Releasing the connections manually
303 #
304 --disconnect server1
305 --disconnect server2
306 --disconnect master1
307 --disconnect master
308 --disconnect slave1
309 --disconnect slave
310 --connection default
311
312 # Wait till all disconnects are completed
313 --source include/wait_until_count_sessions.inc