Debian Codegraph @

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

raw
1 ##############################################################################
2 #
3 # This test checks the basic functionality of group replication plugin along
4 # with mysqlx plugin (x mode).
5 #
6 # NOTE : All the queries through mysqlx plugin is passed using mysqlxtest.
7 #
8 # Steps involved in this test :
9 # 0. This test requires 3 servers.
10 # 1. Start 3 servers loaded with both mysqlx and group replication plugin.
11 # 2. Start group replication on server1 as bootstrap server through mysqlx.
12 # 3. Start group replication on other two servers as non bootstrap servers through mysqlx.
13 # 4. Wait until all three servers come online.
14 # 5. Perform ddl and dml operations on all the three servers.
15 # a) server1 : Create table T1 and perform ddl on T1 using x protocol.
16 # b) server2 : Create table T2 and perform ddl on T1 & T2 using x protocol.
17 # c) server3 : Create table T3 and perform ddl on T1,T2 & T3 using x protocol.
18 # 6. Assert for values on three tables from different servers.
19 # 7. Stop group replication on all the servers through mysqlx
20 # 8. Uninstall mysqlx on the servers.
21 # 9. Clean-Up
22 ##############################################################################
23
24 --source include/big_test.inc
25 --source include/have_mysqlx_plugin.inc
26 --source include/have_group_replication_plugin_base.inc
27
28 --let plugins= GROUP_REPLICATION
29 --source include/check_plugin_dir.inc
30
31 # This initial setup starts three servers with all the prerequisites required
32 # for GR to start
33
34 --source include/have_group_replication_plugin.inc
35 --let $rpl_skip_group_replication_start= 1
36 --let $rpl_server_count= 3
37 --source include/group_replication.inc
38
39 # Install Mysqlx plugin on all servers.
40 --let $rpl_connection_name= server1
41 --source include/rpl_connection.inc
42 --source include/xplugin_wait_for_interfaces.inc
43
44 --let $rpl_connection_name= server2
45 --source include/rpl_connection.inc
46 --source include/xplugin_wait_for_interfaces.inc
47
48 --let $rpl_connection_name= server3
49 --source include/rpl_connection.inc
50 --source include/xplugin_wait_for_interfaces.inc
51
52 # File for starting GR through X-protocol
53 # Bootstrap-server
54 --write_file $MYSQL_TMP_DIR/bootstrap_server.tmp
55 -->sql
56 SET GLOBAL GROUP_REPLICATION_GROUP_NAME = 'aaaaaaaa-cccc-aaaa-aaaa-aaaaaaaaaaaa';
57 SET GLOBAL GROUP_REPLICATION_BOOTSTRAP_GROUP=1;
58 START GROUP_REPLICATION;
59 SET GLOBAL GROUP_REPLICATION_BOOTSTRAP_GROUP=0;
60 -->endsql
61 EOF
62
63 # Temp file for starting group replication as non bootstrap server.
64 --write_file $MYSQL_TMP_DIR/non_bootstrap_server.tmp
65 -->sql
66 SET GLOBAL GROUP_REPLICATION_GROUP_NAME = 'aaaaaaaa-cccc-aaaa-aaaa-aaaaaaaaaaaa';
67 CHANGE REPLICATION SOURCE TO SOURCE_USER='root' FOR CHANNEL 'group_replication_recovery';
68 START GROUP_REPLICATION;
69 -->endsql
70 EOF
71
72 # Starting GR on all the servers through mysqlx
73 --echo Starting GR on server 1
74 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_1 --file=$MYSQL_TMP_DIR/bootstrap_server.tmp 2>&1
75 --echo Starting GR on server 2
76 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_2 --file=$MYSQL_TMP_DIR/non_bootstrap_server.tmp 2>&1
77 --echo Starting GR on server 3
78 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_3 --file=$MYSQL_TMP_DIR/non_bootstrap_server.tmp 2>&1
79
80 --echo Waiting for GR members to come online.
81 --let $wait_condition=SELECT COUNT(*)=3 FROM performance_schema.replication_group_members where MEMBER_STATE="ONLINE"
82 --source include/wait_condition.inc
83
84 # creating some macros in this file.
85
86 --write_file $MYSQL_TMP_DIR/macro.tmp
87
88 # Macro to insert values into Table T1
89 -->macro insert_t1 %VALUE1% %VALUE2%
90 Mysqlx.Crud.Insert {
91 collection {
92 name: "T1"
93 schema: "test"
94 }
95 data_model: TABLE
96 projection {
97 name: "C1"
98 }
99 projection {
100 name: "C2"
101 }
102 row {
103 field {
104 type: LITERAL
105 literal {
106 type: V_SINT
107 v_signed_int: %VALUE1%
108 }
109 }
110 field {
111 type: LITERAL
112 literal {
113 type: V_SINT
114 v_signed_int: %VALUE2%
115 }
116 }
117 }
118 }
119 -->endmacro
120
121 # Macro to insert values into Table T2
122 -->macro insert_t2 %VALUE1% %VALUE2%
123 Mysqlx.Crud.Insert {
124 collection {
125 name: "T2"
126 schema: "test"
127 }
128 data_model: TABLE
129 projection {
130 name: "C1"
131 }
132 projection {
133 name: "C2"
134 }
135 row {
136 field {
137 type: LITERAL
138 literal {
139 type: V_STRING
140 v_string {
141 value: "%VALUE1%"
142 }
143 }
144 }
145 field {
146 type: LITERAL
147 literal {
148 type: V_SINT
149 v_signed_int: %VALUE2%
150 }
151 }
152 }
153 }
154 -->endmacro
155
156 # Macro to insert values into Table T3
157 -->macro insert_t3 %VALUE1% %VALUE2%
158 Mysqlx.Crud.Insert {
159 collection {
160 name: "T3"
161 schema: "test"
162 }
163 data_model: TABLE
164 projection {
165 name: "C1"
166 }
167 projection {
168 name: "C2"
169 }
170 row {
171 field {
172 type: LITERAL
173 literal {
174 type: V_SINT
175 v_signed_int: %VALUE1%
176 }
177 }
178 field {
179 type: LITERAL
180 literal {
181 type:V_STRING
182 v_string {
183 value: "%VALUE1%"
184 }
185 }
186 }
187 }
188 }
189 -->endmacro
190 EOF
191
192 # Temp file for performing ddl and dml on server1.
193 # Copying the contents of the "macro.tmp" so that the macros available can be
194 # reused
195
196 --copy_file $MYSQL_TMP_DIR/macro.tmp $MYSQL_TMP_DIR/ddl_dml_on_server1.tmp
197 --append_file $MYSQL_TMP_DIR/ddl_dml_on_server1.tmp
198 -->stmtsql USE test
199 -->recvresult
200 -->stmtsql CREATE TABLE T1 (C1 INT PRIMARY KEY, C2 INT );
201 -->recvresult
202 -->callmacro insert_t1 1 12
203 -->recvresult
204 -->callmacro insert_t1 2 1234
205 -->recvresult
206 -->callmacro insert_t1 3 98765
207 -->recvresult
208 Mysqlx.Crud.Update {
209 collection {
210 name: "T1"
211 schema: "test"
212 }
213 data_model: TABLE
214 operation {
215 source {
216 name: "c1"
217 }
218 operation: SET
219 value {
220 type: OPERATOR
221 operator {
222 name: "+"
223 param {
224 type: IDENT
225 identifier {
226 name: "c1"
227 }
228 }
229 param {
230 type: LITERAL
231 literal {
232 type: V_UINT
233 v_unsigned_int: 10
234 }
235 }
236 }
237 }
238 }
239 }
240 -->recvresult
241 Mysqlx.Crud.Delete {
242 collection {
243 name: "T1"
244 schema: "test"
245 }
246 data_model: TABLE
247 criteria {
248 type: OPERATOR
249 operator {
250 name: "=="
251 param {
252 type: IDENT
253 identifier {
254 name: "C2"
255 }
256 }
257 param {
258 type: LITERAL
259 literal {
260 type: V_UINT
261 v_unsigned_int: 0
262 }
263 }
264 }
265 }
266 }
267 -->recvresult
268 EOF
269
270 --echo Performing DDL/DML operations on server 1
271 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_1 --file=$MYSQL_TMP_DIR/ddl_dml_on_server1.tmp 2>&1
272 --source include/rpl_sync.inc
273
274 # Temp file for performing ddl and dml on server2
275 # Copying the contents of the "macro.tmp" so that the macros available can be
276 # reused
277 --copy_file $MYSQL_TMP_DIR/macro.tmp $MYSQL_TMP_DIR/ddl_dml_on_server2.tmp
278 --append_file $MYSQL_TMP_DIR/ddl_dml_on_server2.tmp
279 -->stmtsql USE test
280 -->recvresult
281 -->stmtsql CREATE TABLE T2 (C1 CHAR(20) PRIMARY KEY, C2 INT );
282 -->recvresult
283 -->callmacro insert_t2 ABC 23
284 -->recvresult
285
286 Mysqlx.Crud.Update {
287 collection {
288 name: "T2"
289 schema: "test"
290 }
291 data_model: TABLE
292 operation {
293 source {
294 name: "C2"
295 }
296 operation: SET
297 value {
298 type: OPERATOR
299 operator {
300 name: "+"
301 param {
302 type: IDENT
303 identifier {
304 name: "C2"
305 }
306 }
307 param {
308 type: LITERAL
309 literal {
310 type: V_UINT
311 v_unsigned_int: 27
312 }
313 }
314 }
315 }
316 }
317 }
318 -->recvresult
319
320 -->callmacro insert_t1 4 34
321 -->recvresult
322 -->callmacro insert_t2 ABCDEF 23
323 -->recvresult
324 -->callmacro insert_t1 5 1234
325 -->recvresult
326 -->callmacro insert_t2 ABCDEFGHIJ 23
327 -->recvresult
328
329 Mysqlx.Crud.Delete {
330 collection {
331 name: "T2"
332 schema: "test"
333 }
334 data_model: TABLE
335 criteria {
336 type: OPERATOR
337 operator {
338 name: "=="
339 param {
340 type: IDENT
341 identifier {
342 name: "C1"
343 }
344 }
345 param {
346 type: LITERAL
347 literal {
348 type: V_OCTETS
349 v_octets {
350 value: "ABC"
351 }
352 }
353 }
354 }
355 }
356 }
357 -->recvresult
358 EOF
359
360 --echo Performing DDL/DML operations on server 2
361 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_2 --file=$MYSQL_TMP_DIR/ddl_dml_on_server2.tmp 2>&1
362 --source include/rpl_sync.inc
363
364 # Temp file for performing ddl and dml on server3
365 # Copying the contents of the "macro.tmp" so that the macros available can be
366 # reused
367
368 --copy_file $MYSQL_TMP_DIR/macro.tmp $MYSQL_TMP_DIR/ddl_dml_on_server3.tmp
369 --append_file $MYSQL_TMP_DIR/ddl_dml_on_server3.tmp
370 -->stmtsql USE test;
371 -->recvresult
372 -->stmtsql CREATE TABLE T3 (C1 INT PRIMARY KEY, C2 VARCHAR(20) );
373 -->recvresult
374
375 Mysqlx.Crud.Delete {
376 collection {
377 name: "T1"
378 schema: "test"
379 }
380 data_model: TABLE
381 }
382 -->recvresult
383
384 -->callmacro insert_t1 1 12345
385 -->recvresult
386 -->callmacro insert_t3 1 1234
387 -->recvresult
388 -->callmacro insert_t2 1234 1234
389 -->recvresult
390 -->callmacro insert_t1 7 98765
391 -->recvresult
392 -->callmacro insert_t2 XYZ 23
393 -->recvresult
394
395 Mysqlx.Crud.Update {
396 collection {
397 name: "T2"
398 schema: "test"
399 }
400 data_model: TABLE
401 criteria {
402 type: OPERATOR
403 operator {
404 name: "=="
405 param {
406 type: IDENT
407 identifier {
408 name: "C1"
409 }
410 }
411 param {
412 type: LITERAL
413 literal {
414 type: V_OCTETS
415 v_octets {
416 value: "XYZ"
417 }
418 }
419 }
420 }
421 }
422 operation {
423 source {
424 name: "C1"
425 }
426 operation: SET
427 value {
428 type: LITERAL
429 literal {
430 type: V_STRING
431 v_string {
432 value: "ABC"
433 }
434 }
435 }
436 }
437 }
438 -->recvresult
439
440 -->callmacro insert_t3 2 23
441 -->recvresult
442 -->callmacro insert_t3 3 234
443 -->recvresult
444 Mysqlx.Crud.Delete {
445 collection {
446 name: "T3"
447 schema: "test"
448 }
449 data_model: TABLE
450 criteria {
451 type: OPERATOR
452 operator {
453 name: ">"
454 param {
455 type: IDENT
456 identifier {
457 name: "C1"
458 }
459 }
460 param {
461 type: LITERAL
462 literal {
463 type: V_UINT
464 v_unsigned_int: 0
465 }
466 }
467 }
468 }
469 }
470 -->recvresult
471 EOF
472
473 --echo Performing DDL/DML operations on server 3
474 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_3 --file=$MYSQL_TMP_DIR/ddl_dml_on_server3.tmp 2>&1
475
476 # Wait for synchronization between the nodes.
477
478 --source include/rpl_sync.inc
479
480 # Asserts for values on each table.
481
482 --let $rpl_connection_name= server2
483 --source include/rpl_connection.inc
484 --let $assert_text= 'Checking the Value on T1'
485 --let $assert_cond= [SELECT C2 FROM test.T1 WHERE C1=1, C2, 1] = 12345
486 --source include/assert.inc
487
488 --let $assert_text= 'Checking the Value on T2'
489 --let $assert_cond= [SELECT C2 FROM test.T2 WHERE C1="ABC", C2, 1] = 23
490 --source include/assert.inc
491
492 --let $wait_condition=SELECT COUNT(*)=0 FROM test.T3
493 --source include/wait_condition.inc
494
495 # Creating temp file to delete tables
496
497 --copy_file $MYSQL_TMP_DIR/macro.tmp $MYSQL_TMP_DIR/delete_tables.tmp
498 --append_file $MYSQL_TMP_DIR/delete_tables.tmp
499 -->stmtsql USE test;
500 -->recvresult
501 -->stmtsql DROP TABLE T1;
502 -->recvresult
503 -->stmtsql DROP TABLE T2;
504 -->recvresult
505 -->stmtsql DROP TABLE T3;
506 -->recvresult
507 EOF
508
509 # Deleting tables
510 --echo Deleting all the tables.
511 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_3 --file=$MYSQL_TMP_DIR/delete_tables.tmp 2>&1
512 --source include/rpl_sync.inc
513
514 # Creating temp file to stop GR.
515 --write_file $MYSQL_TMP_DIR/stop_group_replication.tmp
516 -->stmtsql STOP GROUP_REPLICATION;
517 -->recvresult
518 EOF
519
520 # Stopping GR on all the servers
521 --echo Stopping GR on server 1
522 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_1 --file=$MYSQL_TMP_DIR/stop_group_replication.tmp 2>&1
523 --echo Stopping GR on server 2
524 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_2 --file=$MYSQL_TMP_DIR/stop_group_replication.tmp 2>&1
525 --echo Stopping GR on server 3
526 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_3 --file=$MYSQL_TMP_DIR/stop_group_replication.tmp 2>&1
527
528 # Uninstall mysqlx on all servers
529 --let $rpl_connection_name= server1
530 --source include/rpl_connection.inc
531 --source include/stop_group_replication.inc
532
533 --let $rpl_connection_name= server2
534 --source include/rpl_connection.inc
535 --source include/stop_group_replication.inc
536
537 --let $rpl_connection_name= server3
538 --source include/rpl_connection.inc
539 --source include/stop_group_replication.inc
540
541 # clean-up
542 --remove_file $MYSQL_TMP_DIR/bootstrap_server.tmp
543 --remove_file $MYSQL_TMP_DIR/non_bootstrap_server.tmp
544 --remove_file $MYSQL_TMP_DIR/ddl_dml_on_server1.tmp
545 --remove_file $MYSQL_TMP_DIR/ddl_dml_on_server2.tmp
546 --remove_file $MYSQL_TMP_DIR/ddl_dml_on_server3.tmp
547 --remove_file $MYSQL_TMP_DIR/delete_tables.tmp
548 --remove_file $MYSQL_TMP_DIR/macro.tmp
549 --remove_file $MYSQL_TMP_DIR/stop_group_replication.tmp
550
551 --source include/group_replication_end.inc