mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / suite / binlog / t / binlog_index.test
blob086c0842b209112f86ea6ffe7fe787bbf75dc34d
2 # testing of purging of binary log files bug#18199/Bug#18453
4 source include/have_log_bin.inc;
5 source include/not_embedded.inc;
6 # Don't test this under valgrind, memory leaks will occur
7 --source include/not_valgrind.inc
8 source include/have_debug.inc;
9 # Avoid CrashReporter popup on Mac
10 --source include/not_crashrep.inc
11 call mtr.add_suppression('Attempting backtrace');
12 call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to process registered files that would be purged.');
13 call mtr.add_suppression('MSYQL_BIN_LOG::open failed to sync the index file');
14 call mtr.add_suppression('Turning logging off for the whole duration of the MySQL server process.');
15 call mtr.add_suppression('Could not open .*');
16 call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to clean registers before purging logs.');
17 let $old=`select @@debug`;
19 RESET MASTER;
21 let $MYSQLD_DATADIR= `select @@datadir`;
22 let $INDEX=$MYSQLD_DATADIR/master-bin.index;
25 # testing purge binary logs TO
28 flush logs;
29 flush logs;
30 flush logs;
32 source include/show_binary_logs.inc;
33 remove_file $MYSQLD_DATADIR/master-bin.000001;
35 # there must be a warning with file names
36 replace_regex /\.[\\\/]master/master/;
37 purge binary logs TO 'master-bin.000004';
39 --echo *** must show a list starting from the 'TO' argument of PURGE ***
40 source include/show_binary_logs.inc;
43 # testing purge binary logs BEFORE
46 reset master;
48 flush logs;
49 flush logs;
50 flush logs;
51 remove_file $MYSQLD_DATADIR/master-bin.000001;
53 --echo *** must be a warning master-bin.000001 was not found ***
54 let $date=`select NOW()  +  INTERVAL 1 MINUTE`;
55 --disable_query_log
56 replace_regex /\.[\\\/]master/master/;
57 eval purge binary logs BEFORE '$date';
58 --enable_query_log
60 --echo *** must show one record, of the active binlog, left in the index file after PURGE ***
61 source include/show_binary_logs.inc;
64 # testing a fatal error
65 # Turning a binlog file into a directory must be a portable setup
66
68 reset master;
70 flush logs;
71 flush logs;
72 flush logs;
74 remove_file $MYSQLD_DATADIR/master-bin.000001;
75 mkdir $MYSQLD_DATADIR/master-bin.000001;
77 --error ER_BINLOG_PURGE_FATAL_ERR
78 purge binary logs TO 'master-bin.000002';
79 replace_regex /\.[\\\/]master/master/;
80 show warnings;
81 rmdir $MYSQLD_DATADIR/master-bin.000001;
82 --disable_warnings
83 reset master;
84 --enable_warnings
86 --echo # crash_purge_before_update_index
87 flush logs;
89 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
90 SET SESSION debug="+d,crash_purge_before_update_index";
91 --error 2013
92 purge binary logs TO 'master-bin.000002';
94 --enable_reconnect
95 --source include/wait_until_connected_again.inc
97 file_exists $MYSQLD_DATADIR/master-bin.000001;
98 file_exists $MYSQLD_DATADIR/master-bin.000002;
99 file_exists $MYSQLD_DATADIR/master-bin.000003;
100 --chmod 0644 $INDEX
101 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
102 -- eval SET @index=LOAD_FILE('$index')
103 -- replace_regex /\.[\\\/]master/master/
104 SELECT @index;
106 --echo # crash_purge_non_critical_after_update_index
107 flush logs;
109 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
110 SET SESSION debug="+d,crash_purge_non_critical_after_update_index";
111 --error 2013
112 purge binary logs TO 'master-bin.000004';
114 --enable_reconnect
115 --source include/wait_until_connected_again.inc
117 --error 1
118 file_exists $MYSQLD_DATADIR/master-bin.000001;
119 --error 1
120 file_exists $MYSQLD_DATADIR/master-bin.000002;
121 --error 1
122 file_exists $MYSQLD_DATADIR/master-bin.000003;
123 --chmod 0644 $INDEX
124 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
125 -- eval SET @index=LOAD_FILE('$index')
126 -- replace_regex /\.[\\\/]master/master/
127 SELECT @index;
129 --echo # crash_purge_critical_after_update_index
130 flush logs;
132 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
133 SET SESSION debug="+d,crash_purge_critical_after_update_index";
134 --error 2013
135 purge binary logs TO 'master-bin.000006';
137 --enable_reconnect
138 --source include/wait_until_connected_again.inc
140 --error 1
141 file_exists $MYSQLD_DATADIR/master-bin.000004;
142 --error 1
143 file_exists $MYSQLD_DATADIR/master-bin.000005;
144 file_exists $MYSQLD_DATADIR/master-bin.000006;
145 file_exists $MYSQLD_DATADIR/master-bin.000007;
146 --error 1
147 file_exists $MYSQLD_DATADIR/master-bin.000008;
148 --chmod 0644 $INDEX
149 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
150 -- eval SET @index=LOAD_FILE('$index')
151 -- replace_regex /\.[\\\/]master/master/
152 SELECT @index;
154 --echo # crash_create_non_critical_before_update_index
155 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
156 SET SESSION debug="+d,crash_create_non_critical_before_update_index";
157 --error 2013
158 flush logs;
160 --enable_reconnect
161 --source include/wait_until_connected_again.inc
163 file_exists $MYSQLD_DATADIR/master-bin.000008;
164 --error 1
165 file_exists $MYSQLD_DATADIR/master-bin.000009;
166 --chmod 0644 $INDEX
167 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
168 -- eval SET @index=LOAD_FILE('$index')
169 -- replace_regex /\.[\\\/]master/master/
170 SELECT @index;
172 --echo # crash_create_critical_before_update_index
173 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
174 SET SESSION debug="+d,crash_create_critical_before_update_index";
175 --error 2013
176 flush logs;
178 --enable_reconnect
179 --source include/wait_until_connected_again.inc
181 file_exists $MYSQLD_DATADIR/master-bin.000009;
182 --error 1
183 file_exists $MYSQLD_DATADIR/master-bin.000010;
184 --error 1
185 file_exists $MYSQLD_DATADIR/master-bin.000011;
186 --chmod 0644 $INDEX
187 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
188 -- eval SET @index=LOAD_FILE('$index')
189 -- replace_regex /\.[\\\/]master/master/
190 SELECT @index;
192 --echo # crash_create_after_update_index
193 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
194 SET SESSION debug="+d,crash_create_after_update_index";
195 --error 2013
196 flush logs;
198 --enable_reconnect
199 --source include/wait_until_connected_again.inc
201 file_exists $MYSQLD_DATADIR/master-bin.000010;
202 file_exists $MYSQLD_DATADIR/master-bin.000011;
203 --chmod 0644 $INDEX
204 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
205 -- eval SET @index=LOAD_FILE('$index')
206 -- replace_regex /\.[\\\/]master/master/
207 SELECT @index;
209 --echo #
210 --echo # This should put the server in unsafe state and stop
211 --echo # accepting any command. If we inject a fault at this
212 --echo # point and continue the execution the server crashes.
213 --echo #
215 --chmod 0644 $INDEX
216 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
217 -- eval SET @index=LOAD_FILE('$index')
218 -- replace_regex /\.[\\\/]master/master/
219 SELECT @index;
221 --echo # fault_injection_registering_index
222 SET SESSION debug="+d,fault_injection_registering_index";
223 -- replace_regex /\.[\\\/]master/master/
224 -- error ER_CANT_OPEN_FILE
225 flush logs;
227 --chmod 0644 $INDEX
228 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
229 -- eval SET @index=LOAD_FILE('$index')
230 -- replace_regex /\.[\\\/]master/master/
231 SELECT @index;
233 --source include/restart_mysqld.inc
235 --chmod 0644 $INDEX
236 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
237 -- eval SET @index=LOAD_FILE('$index')
238 -- replace_regex /\.[\\\/]master/master/
239 SELECT @index;
241 --echo # fault_injection_updating_index
242 SET SESSION debug="+d,fault_injection_updating_index";
243 -- replace_regex /\.[\\\/]master/master/
244 -- error ER_CANT_OPEN_FILE
245 flush logs;
247 --chmod 0644 $INDEX
248 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
249 -- eval SET @index=LOAD_FILE('$index')
250 -- replace_regex /\.[\\\/]master/master/
251 SELECT @index;
253 --source include/restart_mysqld.inc
255 --chmod 0644 $INDEX
256 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
257 -- eval SET @index=LOAD_FILE('$index')
258 -- replace_regex /\.[\\\/]master/master/
259 SELECT @index;
261 eval SET SESSION debug="$old";
263 --echo End of tests