1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

BUG#11745230

Refactored the test case: hardened and extended it. Created test inc file
to abstract the task of relocating binlogs.

Also, disabled it on windows for not cluttering the test case any further, 
as it depends heavily on doing filesystem operations and path handling.

mysql-test/include/relocate_binlogs.inc:
  Auxiliar include file that performs the relocation of binary logs
  listed in an index file.
This commit is contained in:
Luis Soares
2011-12-01 00:54:54 +00:00
parent 2228d5a8b3
commit a899a4050b
3 changed files with 227 additions and 34 deletions

View File

@ -21,12 +21,20 @@ source include/master-slave.inc;
# There is no need to run this test case on all binlog format
source include/have_binlog_format_row.inc;
# Since this test relies heavily on filesystem operations (like
# moving files around, backslashes and so forth) we avoid messing
# around with windows access violations for not cluttering the
# test case any further. It is prepared to support windows, but
# it is not 100% compliant.
--source include/not_windows.inc
connection master;
--let $master_datadir= `select @@datadir`
connection slave;
--let $slave_datadir= `select @@datadir`
connection master;
--let $tmpdir= $MYSQLTEST_VARDIR/tmp/rpl_binlog_index
--let $dirname= `select uuid()`
--let $tmpdir= $MYSQLTEST_VARDIR/tmp/$dirname
--mkdir $tmpdir
CREATE TABLE t1 (a INT);
@ -36,7 +44,6 @@ INSERT INTO t1 VALUES (1);
sync_slave_with_master;
#
# Test on master
#
@ -69,11 +76,11 @@ source include/rpl_start_server.inc;
--let $write_to_file= $master_datadir/master-bin.index
if ($is_windows)
{
--let $write_var= .\\master-bin.000001\n.\\master-bin.000002\n
--let $write_var= .\\\\master-bin.000001\n.\\\\master-bin.000002\n.\\\\master-bin.000003\n
}
if (!$is_windows)
{
--let $write_var= ./master-bin.000001\n./master-bin.000002\n
--let $write_var= ./master-bin.000001\n./master-bin.000002\n./master-bin.000003\n
}
--disable_query_log
source include/write_var_to_file.inc;
@ -86,6 +93,7 @@ source include/rpl_stop_server.inc;
--echo # Move back the master binlog files
--move_file $tmpdir/master-bin.000001 $master_datadir/master-bin.000001
--move_file $tmpdir/master-bin.000002 $master_datadir/master-bin.000002
--move_file $tmpdir/master-bin.000003 $master_datadir/master-bin.000003
--echo # Remove the unneeded master-bin.index file
--remove_file $tmpdir/master-bin.index
@ -99,41 +107,40 @@ source include/rpl_start_server.inc;
--echo # Master has restarted successfully
connection slave;
source include/stop_slave.inc;
--echo # stop slave
--source include/stop_slave.inc
--let $rpl_server_number= 2
--source include/rpl_stop_server.inc
--disable_query_log
# slave-relay-bin.* files can vary, so read the slave-relay-bin.index
# to figure out the slave-relay-bin.* files
CREATE TEMPORARY TABLE tmp (id INT AUTO_INCREMENT PRIMARY KEY, filename VARCHAR(1024));
# chmod to allow the following LOAD DATA
--chmod 0666 $slave_datadir/slave-relay-bin.index
--eval LOAD DATA INFILE '$slave_datadir/slave-relay-bin.index' INTO TABLE tmp (filename)
--let $count= `SELECT count(*) FROM tmp`
--echo # Move the slave binlog and relay log files and index to the new place
--move_file $slave_datadir/slave-bin.index $tmpdir/slave-bin.index
--move_file $slave_datadir/slave-bin.000001 $tmpdir/slave-bin.000001
--move_file $slave_datadir/slave-relay-bin.index $tmpdir/slave-relay-bin.index
while ($count)
{
--let $filename= `select filename from tmp where id=$count`
--move_file $slave_datadir/$filename $tmpdir/$filename
--dec $count
}
DROP TEMPORARY TABLE tmp;
--enable_query_log
# switch to master because the slave has been shutdown
# and relocate_binlogs requires a running server to do
# SQL operations
--connection master
--echo # Shutdown slave
--let $rpl_server_number=2
source include/rpl_stop_server.inc;
--let $relocate_disable_query_log= 1
--let $relocate_is_windows= $is_windows
--let $relocate_from=$slave_datadir
--let $relocate_into=$tmpdir
--echo # relocate binlogs
--let $relocate_index_file=$slave_datadir/slave-bin.index
--source include/relocate_binlogs.inc
--echo # relocate relay logs
--let $relocate_index_file=$slave_datadir/slave-relay-bin.index
--source include/relocate_binlogs.inc
--echo # Restart slave with options log-bin, relay-log set to the new paths
--let $rpl_server_parameters=--log-bin=$tmpdir/slave-bin --relay-log=$tmpdir/slave-relay-bin
--let $keep_include_silent=1
--let $rpl_server_number= 2
source include/rpl_start_server.inc;
--let $keep_include_silent=0
--echo # Slave has restarted successfully
source include/start_slave.inc;
--connection slave
--echo # Slave server has restarted successfully
--source include/start_slave.inc
--source include/stop_slave.inc
connection master;
@ -155,6 +162,48 @@ source include/diff_tables.inc;
connection master;
DROP TABLE t1;
sync_slave_with_master;
--sync_slave_with_master
--source include/stop_slave.inc
--let $rpl_server_number= 2
--source include/rpl_stop_server.inc
--connection master
--let $relocate_from=$tmpdir
--let $relocate_into=$slave_datadir
--let $relocate_recreate_index= 1
# binlogs
--let $relocate_index_file=$tmpdir/slave-bin.index
--source include/relocate_binlogs.inc
# relay logs
# since the complete fix for the relocation of logs is
# done in BUG#13428851 it does not help here to try
# to start the slave as it would fail (relay-log.info is
# tainted with the full path in the RELAY_LOG_FILE position).
# Instead, we reset the slave and let the test clean up.
--let $relocate_fix_relay_log_info= $slave_datadir/relay-log.info
--let $relocate_index_file=$tmpdir/slave-relay-bin.index
--source include/relocate_binlogs.inc
--echo # remove tmpdir
--remove_files_wildcard $tmpdir *
--rmdir $tmpdir
--echo # restarted with previous slave settings
--let $rpl_server_parameters=--log-bin=$slave_datadir/slave-bin --relay-log=$slave_datadir/slave-relay-bin
--let $keep_include_silent=1
--let $rpl_server_number= 2
--source include/rpl_start_server.inc
--let $keep_include_silent=0
--connection slave
# The slave will restart if we have fixed the relay-log.info
# correctly
--source include/start_slave.inc
--connection master
--source include/rpl_end.inc