Debian Codegraph @

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

raw
1 ################################################################################
2 # This test validates that Group Replication can have members with different
3 # binlog_checksum configuration.
4 #
5 # Test:
6 # 0. The test requires two servers: M1 and M2.
7 #
8 # Check that a member with binlog_checksum= NONE can join a group
9 # with binlog_checksum= CRC32.
10 # 1. Set binlog_checksum to CRC32 and start GR on server1.
11 # 2. Set binlog_checksum to NONE and start GR on server2.
12 # 3. Commit data on both members, all is OK.
13 # 4. Validate that server1 binary log has checksums.
14 # 5. Validate that server2 binary log does not have checksums.
15 #
16 # Check that a member with binlog_checksum= CRC32 can join a group
17 # with binlog_checksum= NONE.
18 # 6. Set binlog_checksum to NONE and start GR on server1.
19 # 7. Set binlog_checksum to CRC32 and start GR on server2.
20 # 8. Commit data on both members, all is OK.
21 # 9. Validate that server1 binary log does not have checksums.
22 # 10. Validate that server2 binary log has checksums.
23 #
24 # 11. Clean up.
25 ################################################################################
26 --source include/have_group_replication_plugin.inc
27 --let $rpl_skip_group_replication_start= 1
28 --source include/group_replication.inc
29 --let $output_file = $MYSQLTEST_VARDIR/tmp/gr-checksum-dump-file
30 --let $_binlog_compression_enable= `SELECT @@GLOBAL.binlog_transaction_compression`
31
32
33 --echo
34 --echo ############################################################
35 --echo # 1. Set binlog_checksum to CRC32 and start GR on server1.
36 --let $rpl_connection_name= server1
37 --source include/rpl_connection.inc
38 SET @binlog_checksum_saved= @@GLOBAL.binlog_checksum;
39 SET @@GLOBAL.binlog_checksum= CRC32;
40
41 --source include/start_and_bootstrap_group_replication.inc
42 # This will be sent to server2 through recovery.
43 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY);
44
45
46 --echo
47 --echo ############################################################
48 --echo # 2. Set binlog_checksum to NONE and start GR on server2.
49 --let $rpl_connection_name= server2
50 --source include/rpl_connection.inc
51 SET @binlog_checksum_saved= @@GLOBAL.binlog_checksum;
52 SET @@GLOBAL.binlog_checksum= NONE;
53
54 --source include/start_group_replication.inc
55
56
57 --echo
58 --echo ############################################################
59 --echo # 3. Commit data on both members, all is OK.
60 --let $rpl_connection_name= server1
61 --source include/rpl_connection.inc
62 INSERT INTO t1 VALUES (1);
63
64 --let $rpl_connection_name= server2
65 --source include/rpl_connection.inc
66 INSERT INTO t1 VALUES (2);
67
68 --source include/rpl_sync.inc
69 --let $assert_text= 'There are 2 rows in table t1'
70 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 2
71 --source include/assert.inc
72
73 --let $diff_tables=server1:t1, server2:t1
74 --source include/diff_tables.inc
75
76
77 --echo ############################################################
78 --echo # 4. Validate that server1 binary log has checksums.
79 --let $rpl_connection_name= server1
80 --source include/rpl_connection.inc
81 --let $datadir= `SELECT @@datadir`
82 --let $mysqlbinlog_parameters= $datadir/server-binary-log.000002
83 --let $mysqlbinlog_pipe= > $output_file 2>&1
84 --source include/mysqlbinlog.inc
85
86 --let $assert_file= $output_file
87 --let $assert_count = 22
88 if ($_binlog_compression_enable == 1) {
89 --let $assert_count = 24
90 }
91 --let $assert_select = .*CRC32 0x\w+.*
92 --let $assert_text = binary log have checksums
93 --source include/assert_grep.inc
94
95 --source include/stop_group_replication.inc
96
97
98 --echo
99 --echo ############################################################
100 --echo # 5. Validate that server2 binary log does not have checksums.
101 --let $rpl_connection_name= server2
102 --source include/rpl_connection.inc
103 --let $datadir= `SELECT @@datadir`
104 --let $mysqlbinlog_parameters= $datadir/server-binary-log.000002
105 --let $mysqlbinlog_pipe= > $output_file 2>&1
106 --source include/mysqlbinlog.inc
107
108 --let $assert_file= $output_file
109 --let $assert_count = 0
110 --let $assert_select = .*CRC32 0x\w+.*
111 --let $assert_text = binary log does not have checksums
112 --source include/assert_grep.inc
113
114 --source include/stop_group_replication.inc
115
116
117 --echo
118 --echo ############################################################
119 --echo # 6. Set binlog_checksum to NONE and start GR on server1.
120 --let $rpl_connection_name= server1
121 --source include/rpl_connection.inc
122 SET @@GLOBAL.binlog_checksum= NONE;
123
124 --source include/start_and_bootstrap_group_replication.inc
125 # This will be sent to server2 through recovery.
126 CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY);
127
128
129 --echo
130 --echo ############################################################
131 --echo # 7. Set binlog_checksum to CRC32 and start GR on server2.
132 --let $rpl_connection_name= server2
133 --source include/rpl_connection.inc
134 SET @@GLOBAL.binlog_checksum= CRC32;
135
136 --source include/start_group_replication.inc
137
138
139 --echo
140 --echo ############################################################
141 --echo # 8. Commit data on both members, all is OK.
142 --let $rpl_connection_name= server1
143 --source include/rpl_connection.inc
144 INSERT INTO t2 VALUES (1);
145
146 --let $rpl_connection_name= server2
147 --source include/rpl_connection.inc
148 INSERT INTO t2 VALUES (2);
149
150 --source include/rpl_sync.inc
151 --let $assert_text= 'There are 2 rows in table t2'
152 --let $assert_cond= [SELECT COUNT(*) AS count FROM t2, count, 1] = 2
153 --source include/assert.inc
154
155 --let $diff_tables=server1:t1, server2:t1
156 --source include/diff_tables.inc
157
158
159 --echo ############################################################
160 --echo # 9. Validate that server1 binary log does not have checksums.
161 --let $rpl_connection_name= server1
162 --source include/rpl_connection.inc
163 --let $datadir= `SELECT @@datadir`
164 --let $mysqlbinlog_parameters= $datadir/server-binary-log.000003
165 --let $mysqlbinlog_pipe= > $output_file 2>&1
166 --source include/mysqlbinlog.inc
167
168 --let $assert_file= $output_file
169 --let $assert_count = 0
170 --let $assert_select = .*CRC32 0x\w+.*
171 --let $assert_text = binary log does not have checksums
172 --source include/assert_grep.inc
173
174
175 --echo
176 --echo ############################################################
177 --echo # 10. Validate that server2 binary log has checksums.
178 --let $rpl_connection_name= server2
179 --source include/rpl_connection.inc
180 --let $datadir= `SELECT @@datadir`
181 --let $mysqlbinlog_parameters= $datadir/server-binary-log.000003
182 --let $mysqlbinlog_pipe= > $output_file 2>&1
183 --source include/mysqlbinlog.inc
184
185 --let $assert_file= $output_file
186 --let $assert_count = 22
187 if ($_binlog_compression_enable == 1) {
188 --let $assert_count = 24
189 }
190 --let $assert_select = .*CRC32 0x\w+.*
191 --let $assert_text = binary log have checksums
192 --source include/assert_grep.inc
193
194
195 --echo
196 --echo ############################################################
197 --echo # 11. Clean up.
198 --let $rpl_connection_name= server1
199 --source include/rpl_connection.inc
200 SET @@GLOBAL.binlog_checksum = @binlog_checksum_saved;
201
202 --let $rpl_connection_name= server2
203 --source include/rpl_connection.inc
204 SET @@GLOBAL.binlog_checksum = @binlog_checksum_saved;
205
206 --remove_file $output_file
207 DROP TABLE t1;
208 DROP TABLE t2;
209 --source include/group_replication_end.inc