Debian Codegraph @

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

raw
1 ##############################################################################
2 ## WL#9053 : Group Replication: Push Group Replication Plugin to mysql-trunk
3 ##
4 ## This test checks the basic functionality(CRUD operations on doc) of group
5 ## replication plugin along with mysqlx plugin.
6 ##
7 ## NOTE : All the queries through mysqlx plugin is passed using mysqlxtest.
8 ##
9 ## Steps involved in this test :
10 ## 0. This test requires 3 servers.
11 ## 1. Start 3 servers loaded with both mysqlx and group replication plugin.
12 ## 2. Start group replication on server1 as bootstrap server through mysqlx
13 ## 3. Start group replication on other two servers as non bootstrap server.
14 ## 4. Wait until all three servers come online.
15 ## 5. Perform ddl and dml operations on all the three servers.
16 ## a) server1 : Create Collection "characters" and perform CRUD on it.
17 ## b) server2 : Perform CRUD operation on "characters"
18 ## c) server3 : Perform CRUD operation on "characters"
19 ## 6. Print the Collection onto result file so that it can be verified.
20 ## 7. Stop group replication on all the servers through mysqlx
21 # 8. Uninstall mysqlx plugin
22 # 9. clean-up
23 ##############################################################################
24
25 --source include/big_test.inc
26 --source include/have_mysqlx_plugin.inc
27 --source include/have_group_replication_plugin_base.inc
28
29 --let plugins= GROUP_REPLICATION
30 --source include/check_plugin_dir.inc
31
32 ## This initial setup starts three servers with all the prerequisites required
33 ## for GR to start
34
35 --source include/have_group_replication_plugin.inc
36 --let $rpl_skip_group_replication_start= 1
37 --let $rpl_server_count= 3
38 --source include/group_replication.inc
39
40 ## Install Mysqlx plugin on all servers.
41
42 --let $rpl_connection_name= server1
43 --source include/rpl_connection.inc
44 --source include/xplugin_wait_for_interfaces.inc
45
46 --let $rpl_connection_name= server2
47 --source include/rpl_connection.inc
48 --source include/xplugin_wait_for_interfaces.inc
49
50 --let $rpl_connection_name= server3
51 --source include/rpl_connection.inc
52 --source include/xplugin_wait_for_interfaces.inc
53
54 # File for starting GR through mysqlx
55 # Bootstrap-server
56 --write_file $MYSQL_TMP_DIR/bootstrap_server.tmp
57 -->sql
58 SET GLOBAL GROUP_REPLICATION_GROUP_NAME = 'aaaaaaaa-bbbb-aaaa-aaaa-aaaaaaaaaaaa';
59 SET GLOBAL GROUP_REPLICATION_BOOTSTRAP_GROUP=1;
60 START GROUP_REPLICATION;
61 SET GLOBAL GROUP_REPLICATION_BOOTSTRAP_GROUP=0;
62 -->endsql
63 EOF
64
65 # Temp file for starting group replication as non bootstrap server.
66 --write_file $MYSQL_TMP_DIR/non_bootstrap_server.tmp
67 -->sql
68 SET GLOBAL GROUP_REPLICATION_GROUP_NAME = 'aaaaaaaa-bbbb-aaaa-aaaa-aaaaaaaaaaaa';
69 CHANGE REPLICATION SOURCE TO SOURCE_USER='root' FOR CHANNEL 'group_replication_recovery';
70 START GROUP_REPLICATION;
71 -->endsql
72 EOF
73
74 # Starting GR on all the servers through mysqlx
75 --echo Starting GR on server 1
76 --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
77 --echo Starting GR on server 2
78 --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
79 --echo Starting GR on server 3
80 --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
81
82 --echo Waiting for GR members to come online.
83 --let $wait_condition=SELECT COUNT(*)=3 FROM performance_schema.replication_group_members where MEMBER_STATE="ONLINE"
84 --source include/wait_condition.inc
85
86 ## Temp file for performing crud operation on collection "characters" from
87 ## server1
88
89 --write_file $MYSQL_TMP_DIR/crud_on_server1.tmp
90 -->stmtadmin list_objects {"schema":"test"}
91 -->recvresult
92 -->stmtadmin create_collection {"schema":"test","name":"characters"}
93 -->recvresult
94
95 Mysqlx.Crud.Insert {
96 collection {
97 name: "characters"
98 schema: "test"
99 }
100 data_model: DOCUMENT
101 row {
102 field {
103 type: OBJECT
104 object {
105 fld {
106 key: "House"
107 value {
108 type: LITERAL
109 literal {
110 type: V_OCTETS
111 v_octets {
112 value: "Stark"
113 }
114 }
115 }
116 }
117 fld {
118 key: "_id"
119 value {
120 type: LITERAL
121 literal {
122 type: V_OCTETS
123 v_octets {
124 value: "6c706242055ae611fd36b86b23c1b9b9"
125 }
126 }
127 }
128 }
129 fld {
130 key: "name"
131 value {
132 type: LITERAL
133 literal {
134 type: V_OCTETS
135 v_octets {
136 value: "John Snow"
137 }
138 }
139 }
140 }
141 }
142 }
143 }
144 }
145 -->recvresult
146
147 Mysqlx.Crud.Insert {
148 collection {
149 name: "characters"
150 schema: "test"
151 }
152 data_model: DOCUMENT
153 row {
154 field {
155 type: OBJECT
156 object {
157 fld {
158 key: "House"
159 value {
160 type: LITERAL
161 literal {
162 type: V_OCTETS
163 v_octets {
164 value: "Stark"
165 }
166 }
167 }
168 }
169 fld {
170 key: "_id"
171 value {
172 type: LITERAL
173 literal {
174 type: V_OCTETS
175 v_octets {
176 value: "ac1fc3b0055ae611fd36b86b23c1b9b9"
177 }
178 }
179 }
180 }
181 fld {
182 key: "name"
183 value {
184 type: LITERAL
185 literal {
186 type: V_OCTETS
187 v_octets {
188 value: "Rob Stark"
189 }
190 }
191 }
192 }
193 }
194 }
195 }
196 row {
197 field {
198 type: OBJECT
199 object {
200 fld {
201 key: "House"
202 value {
203 type: LITERAL
204 literal {
205 type: V_OCTETS
206 v_octets {
207 value: "Stark"
208 }
209 }
210 }
211 }
212 fld {
213 key: "_id"
214 value {
215 type: LITERAL
216 literal {
217 type: V_OCTETS
218 v_octets {
219 value: "4261c3b0055ae611fd36b86b23c1b9b9"
220 }
221 }
222 }
223 }
224 fld {
225 key: "name"
226 value {
227 type: LITERAL
228 literal {
229 type: V_OCTETS
230 v_octets {
231 value: "Arya Stark"
232 }
233 }
234 }
235 }
236 }
237 }
238 }
239 row {
240 field {
241 type: OBJECT
242 object {
243 fld {
244 key: "House"
245 value {
246 type: LITERAL
247 literal {
248 type: V_OCTETS
249 v_octets {
250 value: "Stark"
251 }
252 }
253 }
254 }
255 fld {
256 key: "_id"
257 value {
258 type: LITERAL
259 literal {
260 type: V_OCTETS
261 v_octets {
262 value: "6e62c3b0055ae611fd36b86b23c1b9b9"
263 }
264 }
265 }
266 }
267 fld {
268 key: "name"
269 value {
270 type: LITERAL
271 literal {
272 type: V_OCTETS
273 v_octets {
274 value: "Brandon Stark"
275 }
276 }
277 }
278 }
279 }
280 }
281 }
282 }
283 -->recvresult
284
285 Mysqlx.Crud.Update {
286 collection {
287 name: "characters"
288 schema: "test"
289 }
290 data_model: DOCUMENT
291 criteria {
292 type: OPERATOR
293 operator {
294 name: "=="
295 param {
296 type: IDENT
297 identifier {
298 document_path {
299 type: MEMBER
300 value: "name"
301 }
302 }
303 }
304 param {
305 type: LITERAL
306 literal {
307 type: V_OCTETS
308 v_octets {
309 value: "John Snow"
310 }
311 }
312 }
313 }
314 }
315 operation {
316 source {
317 document_path {
318 type: MEMBER
319 value: "House"
320 }
321 }
322 operation: ITEM_SET
323 value {
324 type: LITERAL
325 literal {
326 type: V_STRING
327 v_string {
328 value: "Targaryen"
329 }
330 }
331 }
332 }
333 }
334 -->recvresult
335
336 Mysqlx.Crud.Find {
337 collection {
338 name: "characters"
339 schema: "test"
340 }
341 data_model: DOCUMENT
342 }
343 -->recvresult
344 EOF
345
346 # Crud operations for collection characters
347 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_1 --file=$MYSQL_TMP_DIR/crud_on_server1.tmp 2>&1
348
349 ## Wait for synchronization between the nodes.
350 --source include/rpl_sync.inc
351
352 ## Temp file for performing crud operation on collection "characters" from server2
353 --write_file $MYSQL_TMP_DIR/crud_on_server2.tmp
354 Mysqlx.Crud.Update {
355 collection {
356 name: "characters"
357 schema: "test"
358 }
359 data_model: DOCUMENT
360 criteria {
361 type: OPERATOR
362 operator {
363 name: "&&"
364 param {
365 type: OPERATOR
366 operator {
367 name: "=="
368 param {
369 type: IDENT
370 identifier {
371 document_path {
372 type: MEMBER
373 value: "House"
374 }
375 }
376 }
377 param {
378 type: LITERAL
379 literal {
380 type: V_OCTETS
381 v_octets {
382 value: "Targaryen"
383 }
384 }
385 }
386 }
387 }
388 param {
389 type: OPERATOR
390 operator {
391 name: "=="
392 param {
393 type: IDENT
394 identifier {
395 document_path {
396 type: MEMBER
397 value: "name"
398 }
399 }
400 }
401 param {
402 type: LITERAL
403 literal {
404 type: V_OCTETS
405 v_octets {
406 value: "John Snow"
407 }
408 }
409 }
410 }
411 }
412 }
413 }
414 operation {
415 source {
416 document_path {
417 type: MEMBER
418 value: "House"
419 }
420 }
421 operation: ARRAY_APPEND
422 value {
423 type: LITERAL
424 literal {
425 type: V_STRING
426 v_string {
427 value: "Stark"
428 }
429 }
430 }
431 }
432 }
433 -->recvresult
434
435 Mysqlx.Crud.Insert {
436 collection {
437 name: "characters"
438 schema: "test"
439 }
440 data_model: DOCUMENT
441 row {
442 field {
443 type: OBJECT
444 object {
445 fld {
446 key: "House"
447 value {
448 type: LITERAL
449 literal {
450 type: V_OCTETS
451 v_octets {
452 value: "Stark "
453 }
454 }
455 }
456 }
457 fld {
458 key: "_id"
459 value {
460 type: LITERAL
461 literal {
462 type: V_OCTETS
463 v_octets {
464 value: "1616f2480b5ae611c319b86b23c1b9b9"
465 }
466 }
467 }
468 }
469 fld {
470 key: "name"
471 value {
472 type: LITERAL
473 literal {
474 type: V_OCTETS
475 v_octets {
476 value: "Sansa Stark"
477 }
478 }
479 }
480 }
481 }
482 }
483 }
484 }
485 -->recvresult
486
487 Mysqlx.Crud.Delete {
488 collection {
489 name: "characters"
490 schema: "test"
491 }
492 data_model: DOCUMENT
493 criteria {
494 type: OPERATOR
495 operator {
496 name: "like"
497 param {
498 type: IDENT
499 identifier {
500 document_path {
501 type: MEMBER
502 value: "name"
503 }
504 }
505 }
506 param {
507 type: LITERAL
508 literal {
509 type: V_OCTETS
510 v_octets {
511 value: "Robb%"
512 }
513 }
514 }
515 }
516 }
517 }
518 -->recvresult
519
520 Mysqlx.Crud.Find {
521 collection {
522 name: "characters"
523 schema: "test"
524 }
525 data_model: DOCUMENT
526 }
527 -->recvresult
528 EOF
529 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_2 --file=$MYSQL_TMP_DIR/crud_on_server2.tmp 2>&1
530
531 ## Wait for synchronization between the nodes.
532 --source include/rpl_sync.inc
533
534 ## Temp file for performing crud operation on collection "characters" from server3
535 --write_file $MYSQL_TMP_DIR/crud_on_server3.tmp
536
537 Mysqlx.Crud.Insert {
538 collection {
539 name: "characters"
540 schema: "test"
541 }
542 data_model: DOCUMENT
543 row {
544 field {
545 type: OBJECT
546 object {
547 fld {
548 key: "House"
549 value {
550 type: LITERAL
551 literal {
552 type: V_OCTETS
553 v_octets {
554 value: "Stark"
555 }
556 }
557 }
558 }
559 fld {
560 key: "_id"
561 value {
562 type: LITERAL
563 literal {
564 type: V_OCTETS
565 v_octets {
566 value: "8cd5d2d90e5ae611e325b86b23c1b9b9"
567 }
568 }
569 }
570 }
571 fld {
572 key: "name"
573 value {
574 type: LITERAL
575 literal {
576 type: V_OCTETS
577 v_octets {
578 value: "Benjen Stark"
579 }
580 }
581 }
582 }
583 }
584 }
585 }
586 row {
587 field {
588 type: OBJECT
589 object {
590 fld {
591 key: "House"
592 value {
593 type: LITERAL
594 literal {
595 type: V_OCTETS
596 v_octets {
597 value: "Stark"
598 }
599 }
600 }
601 }
602 fld {
603 key: "_id"
604 value {
605 type: LITERAL
606 literal {
607 type: V_OCTETS
608 v_octets {
609 value: "b2d7d2d90e5ae611e325b86b23c1b9b9"
610 }
611 }
612 }
613 }
614 fld {
615 key: "name"
616 value {
617 type: LITERAL
618 literal {
619 type: V_OCTETS
620 v_octets {
621 value: "Ned Stark"
622 }
623 }
624 }
625 }
626 }
627 }
628 }
629 }
630 -->recvresult
631
632 Mysqlx.Crud.Update {
633 collection {
634 name: "characters"
635 schema: "test"
636 }
637 data_model: DOCUMENT
638 criteria {
639 type: OPERATOR
640 operator {
641 name: "=="
642 param {
643 type: IDENT
644 identifier {
645 document_path {
646 type: MEMBER
647 value: "name"
648 }
649 }
650 }
651 param {
652 type: LITERAL
653 literal {
654 type: V_OCTETS
655 v_octets {
656 value: "Arya Stark"
657 }
658 }
659 }
660 }
661 }
662 operation {
663 source {
664 document_path {
665 type: MEMBER
666 value: "name"
667 }
668 }
669 operation: ITEM_SET
670 value {
671 type: LITERAL
672 literal {
673 type: V_STRING
674 v_string {
675 value: "A girl has NoName"
676 }
677 }
678 }
679 }
680 }
681 -->recvresult
682
683 Mysqlx.Crud.Delete {
684 collection {
685 name: "characters"
686 schema: "test"
687 }
688 data_model: DOCUMENT
689 limit {
690 row_count: 3
691 }
692 }
693 -->recvresult
694
695 Mysqlx.Crud.Find {
696 collection {
697 name: "characters"
698 schema: "test"
699 }
700 data_model: DOCUMENT
701 }
702 -->recvresult
703
704 -->stmtadmin drop_collection {"schema":"test", "name":"characters"}
705 -->recvresult
706 EOF
707 --exec $MYSQLXTEST --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' -u root --port=$MASTER_X_MYPORT_3 --file=$MYSQL_TMP_DIR/crud_on_server3.tmp 2>&1
708
709 ## Cannot use diff_tables.inc because of the following warning.
710 ## Warning 1235 This version of MySQL doesn't yet support 'sorting of
711 ## non-scalar JSON values'
712
713 ## Wait for synchronization between the nodes.
714 --source include/rpl_sync.inc
715
716 # Creating temp file to stop GR.
717 --write_file $MYSQL_TMP_DIR/stop_group_replication.tmp
718 -->stmtsql STOP GROUP_REPLICATION;
719 -->recvresult
720 EOF
721
722 # Stopping GR on all the servers
723 --echo Stopping GR on server 1
724 --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
725 --echo Stopping GR on server 2
726 --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
727 --echo Stopping GR on server 3
728 --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
729
730 # Uninstall mysqlx
731 --let $rpl_connection_name= server1
732 --source include/rpl_connection.inc
733 --let $group_replication_member_state= OFFLINE
734 --source include/gr_wait_for_member_state.inc
735 --source include/assert_and_disable_read_only.inc
736
737 --let $rpl_connection_name= server2
738 --source include/rpl_connection.inc
739 --let $group_replication_member_state= OFFLINE
740 --source include/gr_wait_for_member_state.inc
741 --source include/assert_and_disable_read_only.inc
742
743 --let $rpl_connection_name= server3
744 --source include/rpl_connection.inc
745 --let $group_replication_member_state= OFFLINE
746 --source include/gr_wait_for_member_state.inc
747 --source include/assert_and_disable_read_only.inc
748
749 # clean-up
750 --remove_file $MYSQL_TMP_DIR/bootstrap_server.tmp
751 --remove_file $MYSQL_TMP_DIR/non_bootstrap_server.tmp
752 --remove_file $MYSQL_TMP_DIR/crud_on_server1.tmp
753 --remove_file $MYSQL_TMP_DIR/crud_on_server2.tmp
754 --remove_file $MYSQL_TMP_DIR/crud_on_server3.tmp
755 --remove_file $MYSQL_TMP_DIR/stop_group_replication.tmp
756
757 --source include/group_replication_end.inc