Debian Codegraph @

mysql-test/suite/binlog/t/binlog_purge_binary_logs_to.test

raw
1 # === Purpose ===
2 #
3 # This test verifies that `PURGE BINARY LOGS TO` purges the binlog files
4 # that have been moved to another location and their absolute path is
5 # listed in the binlog index file.
6 #
7 # === Implementation ===
8 #
9 # 1. Generate binary logs.
10 # 2. Move the binary logs to the tmp dir.
11 # 3. Generate a new index file having the absolute path of the binlogs.
12 # 4. Verify that `PURGE BINARY LOGS TO` purges the binlogs which are
13 # not in the data directory.
14 #
15 # === References ===
16 # Bug #28284624 `PURGE BINARY LOGS TO` FAILS WHEN BINARY LOG SPECIFIED
17 # IS NOT IN BINLOG BASE DIR
18
19 --source include/have_log_bin.inc
20 # This test case is binlog_format agnostic
21 --source include/have_binlog_format_row.inc
22
23 RESET MASTER;
24
25 --let $MYSQLD_DATADIR= `select @@datadir`
26 --let $INDEX=$MYSQLD_DATADIR/binlog.index
27
28 --let $binlog_file1= query_get_value(SHOW MASTER STATUS, File, 1)
29
30 --echo # Generate binlog.000002
31 FLUSH BINARY LOGS;
32 --let $binlog_file2= query_get_value(SHOW MASTER STATUS, File, 1)
33
34 --echo # Generate binlog.000003
35 FLUSH BINARY LOGS;
36 --let $binlog_file3= query_get_value(SHOW MASTER STATUS, File, 1)
37
38 --echo # Generate binlog.000004
39 FLUSH BINARY LOGS;
40 --let $binlog_file4= query_get_value(SHOW MASTER STATUS, File, 1)
41
42 --echo # Generate binlog.000005
43 FLUSH BINARY LOGS;
44 --let $binlog_file5= query_get_value(SHOW MASTER STATUS, File, 1)
45
46 # Move the binary logs to var/tmp/ directory
47
48 --move_file $MYSQLD_DATADIR/$binlog_file1 $MYSQLTEST_VARDIR/tmp/$binlog_file1
49 --move_file $MYSQLD_DATADIR/$binlog_file2 $MYSQLTEST_VARDIR/tmp/$binlog_file2
50 --move_file $MYSQLD_DATADIR/$binlog_file3 $MYSQLTEST_VARDIR/tmp/$binlog_file3
51 --move_file $MYSQLD_DATADIR/$binlog_file4 $MYSQLTEST_VARDIR/tmp/$binlog_file4
52
53 # Generate a new index file having the absolute path of the binlogs
54 --exec echo $MYSQLTEST_VARDIR/tmp/$binlog_file1 > $MYSQLD_DATADIR/binlog.index.tmp
55 --exec echo $MYSQLTEST_VARDIR/tmp/$binlog_file2 >> $MYSQLD_DATADIR/binlog.index.tmp
56 --exec echo $MYSQLTEST_VARDIR/tmp/$binlog_file3 >> $MYSQLD_DATADIR/binlog.index.tmp
57 --exec echo $MYSQLTEST_VARDIR/tmp/$binlog_file4 >> $MYSQLD_DATADIR/binlog.index.tmp
58 --exec echo ./$binlog_file5 >> $MYSQLD_DATADIR/binlog.index.tmp
59
60 # Since the binlog index file has been opened by server, deleting/renaming
61 # the index file will fail in Windows. So, shutdown the server, move the file
62 # and restart the server.
63
64 # Stop the server
65 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
66 --shutdown_server
67 --source include/wait_until_disconnected.inc
68
69 --remove_file $INDEX
70 --move_file $MYSQLD_DATADIR/binlog.index.tmp $INDEX
71
72 # Restart the server
73 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
74 --enable_reconnect
75 --source include/wait_until_connected_again.inc
76
77 # Flush the binary log so that the index file is reopened.
78 FLUSH BINARY LOGS;
79
80 # Purge the first two binary logs
81 --eval PURGE BINARY LOGS TO '$binlog_file3'
82
83 # Verify that the purged binlogs do not exist.
84 --let $file_does_not_exist= $MYSQLTEST_VARDIR/tmp/$binlog_file1
85 --source include/file_does_not_exist.inc
86
87 --let $file_does_not_exist= $MYSQLTEST_VARDIR/tmp/$binlog_file2
88 --source include/file_does_not_exist.inc
89
90 # Purge the next two binary logs
91 --eval PURGE BINARY LOGS TO '$binlog_file5'
92
93 # Verify that the purged binlogs do not exist.
94 --let $file_does_not_exist= $MYSQLTEST_VARDIR/tmp/$binlog_file3
95 --source include/file_does_not_exist.inc
96
97 --let $file_does_not_exist= $MYSQLTEST_VARDIR/tmp/$binlog_file4
98 --source include/file_does_not_exist.inc