Debian Codegraph @

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

raw
1 ################################################################################
2 # WL#6833: GCS Replication: Read-set free Certification
3 # Module (DBSM Snapshot Isolation)
4 #
5 # Scenario 3: Replay a binary log into a group
6 #
7 # Verify Group Replication behavior when we replay a binary
8 # log to a group.
9 #
10 # Test:
11 # 0. The test requires three servers: M1, M2 and M3.
12 # 1. Execute some transactions on M3, which doesn't belong to the group.
13 # 2. Setup Group Replication on M1 and M2.
14 # 3. Replay M3 binary log into group (M2).
15 # 4. Validate data on M3.
16 # 5. GTID_EXECUTED on M1 must contain GTID_EXECUTED from M3. Validate data on M1.
17 # 6. GTID_EXECUTED on M2 must contain GTID_EXECUTED from M3. Validate data on M2.
18 # 7. Stop and start Group Replication on M1 to validate that recovery is working
19 # working properly.
20 # 8. Clean up.
21 # 9. Stop Group Replication on M1 and M2.
22 ################################################################################
23
24 --let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9420001
25 --source include/have_group_replication_plugin.inc
26 --let $rpl_skip_group_replication_start= 1
27 --let $rpl_server_count= 3
28 --source include/group_replication.inc
29
30
31 --echo
32 --echo ############################################################
33 --echo # 1. Execute some transactions on server 3, which doesn't
34 --echo # belong to the group.
35 --connection server3
36
37 # Force empty binary log.
38 RESET MASTER;
39
40 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
41 INSERT INTO t1 VALUES (0);
42 INSERT INTO t1 VALUES (1);
43 UPDATE t1 SET c1=2 WHERE c1=0;
44
45 SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1';
46 BEGIN;
47 COMMIT;
48 SET GTID_NEXT= 'AUTOMATIC';
49
50 --let $server3_datadir= `SELECT @@DATADIR`
51 --let $server3_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
52
53
54 --echo
55 --echo ############################################################
56 --echo # 2. Setup Group Replication on server 1 and 2.
57 --connection server1
58 --source include/start_and_bootstrap_group_replication.inc
59
60 --connection server2
61 --source include/start_group_replication.inc
62
63 --let $group_replication_number_of_members= 2
64 --source include/gr_wait_for_number_of_members.inc
65
66
67 --echo
68 --echo ############################################################
69 --echo # 3. Replay server 3 binary log into group (server 2).
70 --connection server2
71 --let $server2_connection_args= --user=root --host=127.0.0.1 --port=$SLAVE_MYPORT
72 --exec $MYSQL_BINLOG $server3_datadir/$server3_binlog_file | $MYSQL $server2_connection_args
73 --source include/rpl_sync.inc
74
75
76 --echo
77 --echo ############################################################
78 --echo # 4. Validate data on server 3.
79 --connection server3
80 --let $server3_gtid_executed= `SELECT @@GLOBAL.GTID_EXECUTED`
81
82 --let $assert_text= 'There is a value 1 in table t1'
83 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
84 --source include/assert.inc
85 --let $assert_text= 'There is a value 2 in table t1'
86 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1
87 --source include/assert.inc
88
89
90 --echo
91 --echo ############################################################
92 --echo # 5. GTID_EXECUTED on server 1 must contain GTID_EXECUTED
93 --echo # from server 3.
94 --echo # Validate data on server 1.
95 --connection server1
96 --let $assert_text= GTID_EXECUTED must contain server 3 GTID_EXECUTED
97 --let $assert_cond= [SELECT GTID_SUBSET("$server3_gtid_executed", @@GLOBAL.GTID_EXECUTED)] = 1
98 --source include/assert.inc
99
100 --let $assert_text= 'There is a value 1 in table t1'
101 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
102 --source include/assert.inc
103 --let $assert_text= 'There is a value 2 in table t1'
104 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1
105 --source include/assert.inc
106
107
108 --echo
109 --echo ############################################################
110 --echo # 6. GTID_EXECUTED on server 2 must contain GTID_EXECUTED
111 --echo # from server 3.
112 --echo # Validate data on server 2.
113 --connection server2
114 --let $assert_text= GTID_EXECUTED must contain server 3 GTID_EXECUTED
115 --let $assert_cond= [SELECT GTID_SUBSET("$server3_gtid_executed", @@GLOBAL.GTID_EXECUTED)] = 1
116 --source include/assert.inc
117
118 --let $assert_text= 'There is a value 1 in table t1'
119 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
120 --source include/assert.inc
121 --let $assert_text= 'There is a value 2 in table t1'
122 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1
123 --source include/assert.inc
124
125
126 --echo
127 --echo ############################################################
128 --echo # 7. Stop and start Group Replication on server 1 to
129 --echo # validate that recovery is working properly.
130 --connection server1
131 --source include/stop_group_replication.inc
132
133 --connection server2
134 INSERT INTO t1 VALUES (9);
135
136 --connection server1
137 --source include/start_group_replication.inc
138
139 --let $assert_text= 'There is a value 9 in table t1 on server 1'
140 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 9, count, 1] = 1
141 --source include/assert.inc
142
143
144 --echo
145 --echo ############################################################
146 --echo # 8. Clean data.
147 --connection server3
148 DROP TABLE t1;
149
150 --connection server1
151 DROP TABLE t1;
152 --source include/rpl_sync.inc
153
154
155 --echo
156 --echo ############################################################
157 --echo # 9. Stop Group Replication on server 1 and 2.
158 --connection server1
159 --source include/stop_group_replication.inc
160
161 --connection server2
162 --source include/stop_group_replication.inc
163
164 --source include/group_replication_end.inc