Skip to content

Commit 611f916

Browse files
committed
MDEV-9038 Binlog encryption tests
- created binlog_encryption test suite and added it to the default list - moved some tests from rpl, binlog and multisource suites to extra so that they could be re-used in different suites - made minor changes in include files
1 parent 9199d72 commit 611f916

File tree

190 files changed

+18153
-8379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+18153
-8379
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#
2+
# This include file is used by more than one test suite
3+
# (currently rpl and binlog_encryption).
4+
# Please check all dependent tests after modifying it
5+
#
6+
# Usage:
7+
#
8+
# --let $use_remote_mysqlbinlog= 1 # optional
9+
# --let $binlog_start_pos= <binlog position> # optional
10+
# --let $binlog_file= <binlog filename> # optional
11+
#
12+
# --source extra/binlog_tests/binlog_incident.inc
13+
#
14+
# The script uses MYSQLBINLOG to verify certain results.
15+
# By default, it uses binary logs directly. If it is undesirable,
16+
# this behavior can be overridden by setting $use_remote_binlog
17+
# as shown above.
18+
#
19+
# All values will be unset after every execution of the script,
20+
# so if they are needed, they should be set explicitly before each call.
21+
#
22+
23+
# The purpose of this test is to provide a reference for how the
24+
# incident log event is represented in the output from the mysqlbinlog
25+
# program.
26+
27+
source include/have_log_bin.inc;
28+
source include/have_debug.inc;
29+
source include/binlog_start_pos.inc;
30+
31+
let $MYSQLD_DATADIR= `select @@datadir`;
32+
RESET MASTER;
33+
34+
CREATE TABLE t1 (a INT);
35+
36+
INSERT INTO t1 VALUES (1),(2),(3);
37+
SELECT * FROM t1;
38+
39+
# This will generate an incident log event and store it in the binary
40+
# log before the replace statement.
41+
REPLACE INTO t1 VALUES (4);
42+
43+
DROP TABLE t1;
44+
FLUSH LOGS;
45+
46+
if ($binlog_start_pos)
47+
{
48+
--let $startpos= --start-position=$binlog_start_pos
49+
--let $binlog_start_pos=
50+
}
51+
--let $filename= master-bin.000001
52+
if ($binlog_file)
53+
{
54+
--let $filename= $binlog_file
55+
--let $binlog_file=
56+
}
57+
--let $mysqlbinlog_args= $MYSQLD_DATADIR/$filename
58+
if ($use_remote_mysqlbinlog)
59+
{
60+
--let $mysqlbinlog_args= --read-from-remote-server --protocol=tcp --host=127.0.0.1 --port=$MASTER_MYPORT -uroot $filename
61+
--let $use_remote_mysqlbinlog= 0
62+
}
63+
exec $MYSQL_BINLOG $startpos $mysqlbinlog_args >$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
64+
--disable_query_log
65+
eval SELECT cont LIKE '%RELOAD DATABASE; # Shall generate syntax error%' AS `Contain RELOAD DATABASE` FROM (SELECT load_file('$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql') AS cont) AS tbl;
66+
--enable_query_log
67+
68+
remove_file $MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
#
2+
# This include file is used by more than one test suite
3+
# (currently binlog and binlog_encryption).
4+
# Please check all dependent tests after modifying it
5+
#
6+
7+
#
8+
# testing of purging of binary log files bug#18199/Bug#18453
9+
#
10+
source include/have_log_bin.inc;
11+
source include/not_embedded.inc;
12+
# Don't test this under valgrind, memory leaks will occur
13+
--source include/not_valgrind.inc
14+
source include/have_debug.inc;
15+
# Avoid CrashReporter popup on Mac
16+
--source include/not_crashrep.inc
17+
call mtr.add_suppression('Attempting backtrace');
18+
call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to process registered files that would be purged.');
19+
call mtr.add_suppression('MSYQL_BIN_LOG::open failed to sync the index file');
20+
call mtr.add_suppression('Turning logging off for the whole duration of the MySQL server process.');
21+
call mtr.add_suppression('Could not open .*');
22+
call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to clean registers before purging logs.');
23+
flush tables;
24+
25+
let $old=`select @@debug`;
26+
27+
RESET MASTER;
28+
29+
let $MYSQLD_DATADIR= `select @@datadir`;
30+
let $INDEX=$MYSQLD_DATADIR/master-bin.index;
31+
32+
#
33+
# testing purge binary logs TO
34+
#
35+
36+
flush logs;
37+
flush logs;
38+
flush logs;
39+
40+
source include/show_binary_logs.inc;
41+
remove_file $MYSQLD_DATADIR/master-bin.000001;
42+
flush tables;
43+
44+
# there must be a warning with file names
45+
replace_regex /\.[\\\/]master/master/;
46+
--source include/wait_for_binlog_checkpoint.inc
47+
purge binary logs TO 'master-bin.000004';
48+
49+
--echo *** must show a list starting from the 'TO' argument of PURGE ***
50+
source include/show_binary_logs.inc;
51+
52+
#
53+
# testing purge binary logs BEFORE
54+
#
55+
56+
reset master;
57+
58+
flush logs;
59+
flush logs;
60+
flush logs;
61+
remove_file $MYSQLD_DATADIR/master-bin.000001;
62+
63+
--echo *** must be a warning master-bin.000001 was not found ***
64+
let $date=`select NOW() + INTERVAL 1 MINUTE`;
65+
--disable_query_log
66+
replace_regex /\.[\\\/]master/master/;
67+
--source include/wait_for_binlog_checkpoint.inc
68+
eval purge binary logs BEFORE '$date';
69+
--enable_query_log
70+
71+
--echo *** must show one record, of the active binlog, left in the index file after PURGE ***
72+
source include/show_binary_logs.inc;
73+
74+
#
75+
# testing a fatal error
76+
# Turning a binlog file into a directory must be a portable setup
77+
#
78+
79+
reset master;
80+
81+
flush logs;
82+
flush logs;
83+
flush logs;
84+
85+
remove_file $MYSQLD_DATADIR/master-bin.000001;
86+
mkdir $MYSQLD_DATADIR/master-bin.000001;
87+
88+
--source include/wait_for_binlog_checkpoint.inc
89+
--error ER_BINLOG_PURGE_FATAL_ERR
90+
purge binary logs TO 'master-bin.000002';
91+
replace_regex /\.[\\\/]master/master/;
92+
show warnings;
93+
rmdir $MYSQLD_DATADIR/master-bin.000001;
94+
--disable_warnings
95+
reset master;
96+
--enable_warnings
97+
98+
--echo # crash_purge_before_update_index
99+
flush logs;
100+
101+
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
102+
SET SESSION debug_dbug="+d,crash_purge_before_update_index";
103+
--source include/wait_for_binlog_checkpoint.inc
104+
--error 2013
105+
purge binary logs TO 'master-bin.000002';
106+
107+
--enable_reconnect
108+
--source include/wait_until_connected_again.inc
109+
110+
file_exists $MYSQLD_DATADIR/master-bin.000001;
111+
file_exists $MYSQLD_DATADIR/master-bin.000002;
112+
file_exists $MYSQLD_DATADIR/master-bin.000003;
113+
--chmod 0644 $INDEX
114+
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
115+
-- eval SET @index=LOAD_FILE('$index')
116+
-- replace_regex /\.[\\\/]master/master/
117+
SELECT @index;
118+
119+
--echo # crash_purge_non_critical_after_update_index
120+
flush logs;
121+
122+
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
123+
SET SESSION debug_dbug="+d,crash_purge_non_critical_after_update_index";
124+
--source include/wait_for_binlog_checkpoint.inc
125+
--error 2013
126+
purge binary logs TO 'master-bin.000004';
127+
128+
--enable_reconnect
129+
--source include/wait_until_connected_again.inc
130+
131+
--error 1
132+
file_exists $MYSQLD_DATADIR/master-bin.000001;
133+
--error 1
134+
file_exists $MYSQLD_DATADIR/master-bin.000002;
135+
--error 1
136+
file_exists $MYSQLD_DATADIR/master-bin.000003;
137+
--chmod 0644 $INDEX
138+
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
139+
-- eval SET @index=LOAD_FILE('$index')
140+
-- replace_regex /\.[\\\/]master/master/
141+
SELECT @index;
142+
143+
--echo # crash_purge_critical_after_update_index
144+
flush logs;
145+
146+
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
147+
SET SESSION debug_dbug="+d,crash_purge_critical_after_update_index";
148+
--source include/wait_for_binlog_checkpoint.inc
149+
--error 2013
150+
purge binary logs TO 'master-bin.000006';
151+
152+
--enable_reconnect
153+
--source include/wait_until_connected_again.inc
154+
155+
--error 1
156+
file_exists $MYSQLD_DATADIR/master-bin.000004;
157+
--error 1
158+
file_exists $MYSQLD_DATADIR/master-bin.000005;
159+
file_exists $MYSQLD_DATADIR/master-bin.000006;
160+
file_exists $MYSQLD_DATADIR/master-bin.000007;
161+
--error 1
162+
file_exists $MYSQLD_DATADIR/master-bin.000008;
163+
--chmod 0644 $INDEX
164+
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
165+
-- eval SET @index=LOAD_FILE('$index')
166+
-- replace_regex /\.[\\\/]master/master/
167+
SELECT @index;
168+
169+
--echo # crash_create_non_critical_before_update_index
170+
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
171+
SET SESSION debug_dbug="+d,crash_create_non_critical_before_update_index";
172+
--error 2013
173+
flush logs;
174+
175+
--enable_reconnect
176+
--source include/wait_until_connected_again.inc
177+
178+
file_exists $MYSQLD_DATADIR/master-bin.000008;
179+
--error 1
180+
file_exists $MYSQLD_DATADIR/master-bin.000009;
181+
--chmod 0644 $INDEX
182+
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
183+
-- eval SET @index=LOAD_FILE('$index')
184+
-- replace_regex /\.[\\\/]master/master/
185+
SELECT @index;
186+
187+
--echo # crash_create_critical_before_update_index
188+
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
189+
SET SESSION debug_dbug="+d,crash_create_critical_before_update_index";
190+
--error 2013
191+
flush logs;
192+
193+
--enable_reconnect
194+
--source include/wait_until_connected_again.inc
195+
196+
file_exists $MYSQLD_DATADIR/master-bin.000009;
197+
--error 1
198+
file_exists $MYSQLD_DATADIR/master-bin.000010;
199+
--error 1
200+
file_exists $MYSQLD_DATADIR/master-bin.000011;
201+
--chmod 0644 $INDEX
202+
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
203+
-- eval SET @index=LOAD_FILE('$index')
204+
-- replace_regex /\.[\\\/]master/master/
205+
SELECT @index;
206+
207+
--echo # crash_create_after_update_index
208+
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
209+
SET SESSION debug_dbug="+d,crash_create_after_update_index";
210+
--error 2013
211+
flush logs;
212+
213+
--enable_reconnect
214+
--source include/wait_until_connected_again.inc
215+
216+
file_exists $MYSQLD_DATADIR/master-bin.000010;
217+
file_exists $MYSQLD_DATADIR/master-bin.000011;
218+
--chmod 0644 $INDEX
219+
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
220+
-- eval SET @index=LOAD_FILE('$index')
221+
-- replace_regex /\.[\\\/]master/master/
222+
SELECT @index;
223+
224+
--echo #
225+
--echo # This should put the server in unsafe state and stop
226+
--echo # accepting any command. If we inject a fault at this
227+
--echo # point and continue the execution the server crashes.
228+
--echo #
229+
230+
--chmod 0644 $INDEX
231+
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
232+
-- eval SET @index=LOAD_FILE('$index')
233+
-- replace_regex /\.[\\\/]master/master/
234+
SELECT @index;
235+
236+
--echo # fault_injection_registering_index
237+
SET SESSION debug_dbug="+d,fault_injection_registering_index";
238+
-- replace_regex /\.[\\\/]master/master/
239+
-- error ER_CANT_OPEN_FILE
240+
flush logs;
241+
242+
--chmod 0644 $INDEX
243+
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
244+
-- eval SET @index=LOAD_FILE('$index')
245+
-- replace_regex /\.[\\\/]master/master/
246+
SELECT @index;
247+
248+
--source include/restart_mysqld.inc
249+
250+
--chmod 0644 $INDEX
251+
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
252+
-- eval SET @index=LOAD_FILE('$index')
253+
-- replace_regex /\.[\\\/]master/master/
254+
SELECT @index;
255+
256+
--echo # fault_injection_updating_index
257+
SET SESSION debug_dbug="+d,fault_injection_updating_index";
258+
-- replace_regex /\.[\\\/]master/master/
259+
-- error ER_CANT_OPEN_FILE
260+
flush logs;
261+
262+
--chmod 0644 $INDEX
263+
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
264+
-- eval SET @index=LOAD_FILE('$index')
265+
-- replace_regex /\.[\\\/]master/master/
266+
SELECT @index;
267+
268+
--source include/restart_mysqld.inc
269+
270+
--chmod 0644 $INDEX
271+
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
272+
-- eval SET @index=LOAD_FILE('$index')
273+
-- replace_regex /\.[\\\/]master/master/
274+
SELECT @index;
275+
276+
eval SET SESSION debug_dbug="$old";
277+
278+
--echo End of tests
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# This include file is used by more than one test suite
3+
# (currently binlog and binlog_encryption).
4+
# Please check all dependent tests after modifying it
5+
#
6+
7+
source include/have_debug.inc;
8+
source include/have_innodb.inc;
9+
source include/have_log_bin.inc;
10+
source include/have_binlog_format_mixed_or_statement.inc;
11+
12+
CALL mtr.add_suppression("Error writing file 'master-bin'");
13+
14+
RESET MASTER;
15+
16+
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
17+
INSERT INTO t1 VALUES(0);
18+
SET SESSION debug_dbug='+d,fail_binlog_write_1';
19+
--error ER_ERROR_ON_WRITE
20+
INSERT INTO t1 VALUES(1);
21+
--error ER_ERROR_ON_WRITE
22+
INSERT INTO t1 VALUES(2);
23+
SET SESSION debug_dbug='';
24+
INSERT INTO t1 VALUES(3);
25+
SELECT * FROM t1;
26+
27+
# Actually the output from this currently shows a bug.
28+
# The injected IO error leaves partially written transactions in the binlog in
29+
# the form of stray "BEGIN" events.
30+
# These should disappear from the output if binlog error handling is improved
31+
# (see MySQL Bug#37148 and WL#1790).
32+
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
33+
--replace_column 1 BINLOG 2 POS 5 ENDPOS
34+
SHOW BINLOG EVENTS;
35+
36+
DROP TABLE t1;

0 commit comments

Comments
 (0)