Debian Codegraph @

mysql-test/suite/rpl_gtid/t/rpl_mysqlbinlog_gtid_on.test

raw
1 # ==== Purpose ====
2 #
3 # Verify that mysqlbinlog produces the correct output for combinations
4 # of include-gtids, exclude-gtids, skip-gtids,
5 # read-from-remote-server=X, and raw.
6 #
7 # Currently, the following combinations are implemented:
8 #
9 # - include-gtids
10 # - exclude-gtids
11 # - exclude-gtids + skip-gtids
12 # - skip-gtids
13 # - read-from-remote-server
14 # - read-from-remote-source=BINLOG-DUMP-GTID
15 # - read-from-remote-source=BINLOG-DUMP-NON-GTID
16 # - read-from-remote-server + raw
17 # - read-from-remote-source=BINLOG-DUMP-GTID + raw
18 # - read-from-remote-source=BINLOG-DUMP-NON-GTID + raw
19 # - include-gtids + read-from-remote-source=BINLOG-DUMP-GTID
20 # - include-gtids + read-from-remote-source=BINLOG-DUMP-NON-GTID
21 # - exclude-gtids + read-from-remote-maste=BINLOG-DUMP-GTID + raw
22 # - exclude-gtids + read-from-remote-source=BINLOG-DUMP-NON-GTID + raw
23 #
24 # TODO: implement all combinations and make it more uniform and
25 # maintainable, like:
26 #
27 # for opt1 in (include-gtids, exclude-gtids, ''):
28 # for opt2 in (skip-gtids, ''):
29 # for opt3 in (read-from-remote-server,
30 # read-from-remote-source=BINLOG-DUMP-GTID,
31 # read-from-remote-source=BINLOG-DUMP-NON-GTID,
32 # ''):
33 # for opt4 in (raw, ''):
34 # mysqlbinlog $opt1 $opt2 $opt3 $opt4
35 #
36 # ==== References ====
37 #
38 # WL#3584 Global Transaction Identifiers (GTIDs)
39
40 # Output from mysqlbinlog is replayed on the slave server.
41 --source include/not_have_privilege_checks_user.inc
42 --source include/master-slave.inc
43 --source include/have_binlog_format_mixed.inc
44
45 --connection slave
46 --source include/stop_slave.inc
47
48 --connection master
49 ### Generate some data on the master ###
50
51 # example of a DDL
52 CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) engine=Innodb;
53
54 # Single-statement transaction
55 SET @@SESSION.AUTOCOMMIT= ON;
56 INSERT INTO t1 VALUES (NULL);
57
58 # Multi-statement transaction
59 BEGIN;
60 INSERT INTO t1 VALUES (NULL);
61 INSERT INTO t1 VALUES (NULL);
62 COMMIT;
63
64 #
65 # Verification actions include
66 # restoring t1 from binlog and checking data consistency
67 #
68
69 --let $server_uuid= `SELECT @@GLOBAL.SERVER_UUID`
70 --let $datadir= `SELECT @@datadir`
71 --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
72
73 --echo ==== FULL FILE ====
74 --exec $MYSQL_BINLOG $datadir/$binlog_file | $MYSQL --user=root --host=127.0.0.1 --port=$SLAVE_MYPORT
75 --let $diff_tables= master:t1, slave:t1
76 --source include/diff_tables.inc
77
78
79
80 --echo ==== --include-gtids ====
81
82 INSERT INTO t1 VALUES (NULL) /* 4 */;
83 INSERT INTO t1 VALUES (NULL);
84 INSERT INTO t1 VALUES (NULL);
85
86 --exec $MYSQL_BINLOG --include-gtids=$server_uuid:4-6 $datadir/$binlog_file | $MYSQL --user=root --host=127.0.0.1 --port=$SLAVE_MYPORT
87
88 --let $diff_tables= master:t1, slave:t1
89 --source include/diff_tables.inc
90
91
92 --echo ==== --skip-gtids + --exclude-gtids ====
93
94 INSERT INTO t1 VALUES (NULL) /* 7 */;
95 INSERT INTO t1 VALUES (NULL);
96
97 --exec $MYSQL_BINLOG --skip-gtids --exclude-gtids=$server_uuid:1-6 $datadir/$binlog_file | $MYSQL --user=root --host=127.0.0.1 --port=$SLAVE_MYPORT
98
99 --let $diff_tables= master:t1, slave:t1
100 --source include/diff_tables.inc
101
102 --echo ==== --exclude-gtids ====
103
104 INSERT INTO t1 VALUES (NULL) /* 9 */;
105
106 --exec $MYSQL_BINLOG --exclude-gtids=$server_uuid:1-8 $datadir/$binlog_file | $MYSQL --user=root --host=127.0.0.1 --port=$SLAVE_MYPORT
107
108 --let $diff_tables= master:t1, slave:t1
109 --source include/diff_tables.inc
110
111 --echo ==== --skip-gtids ====
112
113 FLUSH LOGS;
114 --let $server_uuid= `SELECT @@GLOBAL.SERVER_UUID`
115 --let $datadir= `SELECT @@datadir`
116 --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
117
118 INSERT INTO t1 VALUES (NULL) /* 10 */;
119
120 --exec $MYSQL_BINLOG --skip-gtids $datadir/$binlog_file | $MYSQL --user=root --host=127.0.0.1 --port=$SLAVE_MYPORT
121
122 --let $diff_tables= master:t1, slave:t1
123 --source include/diff_tables.inc
124
125 #
126 # In what follows we are going to check if a dump file created with
127 # --read-from-remote-source={BINLOG-DUMP-NON-GTID, BINLOG-DUMP-GTID}
128 # is equal to a dump file created with --read-from-remote-server or
129 # an empty option (i.e. without neiter --read-from-remote-source nor
130 # --read-from-remote-server).
131 #
132 # The --raw option is combined with the aforementioned options to
133 # create additional dump files.
134 #
135 # Finally we use the options --include-gtids and --exclude-gtids to
136 # also create additional files.
137 #
138
139 --echo ==== --read-from-remote-source ====
140 --connection master
141 FLUSH LOGS;
142
143 let $MYSQLD_DATADIR= `SELECT @@DATADIR`;
144 let $UUID= `SELECT @@SERVER_UUID`;
145
146 --exec $MYSQL_BINLOG $MYSQLD_DATADIR/$binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/output.000001
147
148 # read-from-remote-server
149 --exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/output.000002
150
151 # read-from-remote-server=BINLOG-DUMP-NON-GTID
152 --exec $MYSQL_BINLOG --read-from-remote-source=BINLOG-DUMP-NON-GTID --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/output.000003
153
154 # read-from-remote-server=BINLOG-DUMP-GTID
155 --exec $MYSQL_BINLOG --read-from-remote-source=BINLOG-DUMP-GTID --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/output.000004
156
157 # read-from-remote-server + raw
158 --exec $MYSQL_BINLOG --raw --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/
159 --exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/tmp/$binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/output.000005
160
161 # read-from-remote-server=BINLOG-DUMP-NON-GTID + raw
162 --exec $MYSQL_BINLOG --raw --read-from-remote-source=BINLOG-DUMP-NON-GTID --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/
163 --exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/tmp/$binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/output.000006
164
165 # read-from-remote-server=BINLOG-DUMP-GTID + raw
166 --exec $MYSQL_BINLOG --raw --read-from-remote-source=BINLOG-DUMP-GTID --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/
167 --exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/tmp/$binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/output.000007
168
169 --diff_files $MYSQLTEST_VARDIR/tmp/output.000002 $MYSQLTEST_VARDIR/tmp/output.000001
170 --diff_files $MYSQLTEST_VARDIR/tmp/output.000003 $MYSQLTEST_VARDIR/tmp/output.000001
171 --diff_files $MYSQLTEST_VARDIR/tmp/output.000004 $MYSQLTEST_VARDIR/tmp/output.000001
172 --diff_files $MYSQLTEST_VARDIR/tmp/output.000005 $MYSQLTEST_VARDIR/tmp/output.000001
173 --diff_files $MYSQLTEST_VARDIR/tmp/output.000006 $MYSQLTEST_VARDIR/tmp/output.000001
174 --diff_files $MYSQLTEST_VARDIR/tmp/output.000007 $MYSQLTEST_VARDIR/tmp/output.000001
175 --remove_file $MYSQLTEST_VARDIR/tmp/output.000001
176 --remove_file $MYSQLTEST_VARDIR/tmp/output.000002
177 --remove_file $MYSQLTEST_VARDIR/tmp/output.000003
178 --remove_file $MYSQLTEST_VARDIR/tmp/output.000004
179 --remove_file $MYSQLTEST_VARDIR/tmp/output.000005
180 --remove_file $MYSQLTEST_VARDIR/tmp/output.000006
181 --remove_file $MYSQLTEST_VARDIR/tmp/output.000007
182 --remove_file $MYSQLTEST_VARDIR/tmp/$binlog_file
183
184 --echo ==== --read-from-remote-source with --exclude-gtids ====
185
186 --exec $MYSQL_BINLOG $MYSQLD_DATADIR/$binlog_file --exclude-gtids=$UUID:1-3 --result-file=$MYSQLTEST_VARDIR/tmp/output.000001
187 --exec $MYSQL_BINLOG --read-from-remote-source=BINLOG-DUMP-NON-GTID --exclude-gtids=$UUID:1-3 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/output.000002
188
189 --exec $MYSQL_BINLOG --read-from-remote-source=BINLOG-DUMP-GTID --exclude-gtids=$UUID:1-3 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/output.000003
190 --error 1
191 --exec $MYSQL_BINLOG --raw --read-from-remote-source=BINLOG-DUMP-NON-GTID --exclude-gtids=$UUID:1-3 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/
192 --exec $MYSQL_BINLOG --raw --read-from-remote-source=BINLOG-DUMP-GTID --exclude-gtids=$UUID:1-3 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/
193 --exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/tmp/$binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/output.000004
194
195 #
196 # Strange but filtering on master and on the client procudes different positions.
197 # For that reason, we do not compare all outputs.
198 #
199 --diff_files $MYSQLTEST_VARDIR/tmp/output.000001 $MYSQLTEST_VARDIR/tmp/output.000002
200 --diff_files $MYSQLTEST_VARDIR/tmp/output.000003 $MYSQLTEST_VARDIR/tmp/output.000004
201 --remove_file $MYSQLTEST_VARDIR/tmp/output.000001
202 --remove_file $MYSQLTEST_VARDIR/tmp/output.000002
203 --remove_file $MYSQLTEST_VARDIR/tmp/output.000003
204 --remove_file $MYSQLTEST_VARDIR/tmp/output.000004
205 --remove_file $MYSQLTEST_VARDIR/tmp/$binlog_file
206
207 --echo ==== --read-from-remote-source with --include-gtids ====
208
209 --exec $MYSQL_BINLOG --read-from-remote-source=BINLOG-DUMP-NON-GTID --include-gtids=$UUID:1-3 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/output.000001
210 --exec $MYSQL_BINLOG --read-from-remote-source=BINLOG-DUMP-GTID --include-gtids=$UUID:1-3 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/output.000002
211 --error 1
212 --exec $MYSQL_BINLOG --raw --read-from-remote-source=BINLOG-DUMP-NON-GTID --include-gtids=$UUID:1-3 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/
213 --error 1
214 --exec $MYSQL_BINLOG --raw --read-from-remote-source=BINLOG-DUMP-GTID --include-gtids=$UUID:1-3 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/
215 --diff_files $MYSQLTEST_VARDIR/tmp/output.000002 $MYSQLTEST_VARDIR/tmp/output.000001
216 --remove_file $MYSQLTEST_VARDIR/tmp/output.000001
217 --remove_file $MYSQLTEST_VARDIR/tmp/output.000002
218
219 --echo ==== Error cases ====
220
221 --error 1
222 --exec $MYSQL_BINLOG --read-from-remote-server --read-from-remote-source=BINLOG-DUMP-GTID $binlog_file 2>&1
223
224 --error 1
225 --exec $MYSQL_BINLOG --raw $binlog_file 2>&1
226
227 --error 1
228 --exec $MYSQL_BINLOG --read-from-remote-server --raw --exclude-gtids= $binlog_file 2>&1
229
230 --error 1
231 --exec $MYSQL_BINLOG --read-from-remote-source=BINLOG-DUMP-NON-GTID --raw --exclude-gtids= $binlog_file 2>&1
232
233 --error 1
234 --exec $MYSQL_BINLOG --read-from-remote-server --raw --include-gtids= $binlog_file 2>&1
235
236 #
237 # cleanup
238 #
239
240 --connection master
241
242 FLUSH LOGS;
243 DROP TABLE t1;
244 --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
245 --exec $MYSQL_BINLOG $datadir/$binlog_file | $MYSQL --user=root --host=127.0.0.1 --port=$SLAVE_MYPORT
246 connection slave;
247 CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION=0;