config root man

Current Path : /home/usr.opt/mysql57/mysql-test/suite/rpl/t/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //home/usr.opt/mysql57/mysql-test/suite/rpl/t/rpl_rotate_logs.test

# This test uses chmod, can't be run with root permissions
-- source include/not_as_root.inc
-- source include/not_group_replication_plugin.inc
-- source include/have_log_bin.inc
-- source include/not_master_info_table.inc
-- source include/not_gtid_enabled.inc

#
# Test is run with max_binlog_size=2048 to force automatic rotation of the
# binary log
# Tests done:
# - Check that slaves reports correct failures if master.info has strange
#   modes/information
# - Automatic binary log rotation
# - Ensure that temporary tables works over flush logs and binary log
#   changes
# - Test creating a duplicate key error and recover from it

# Requires statement logging
-- source include/have_binlog_format_mixed_or_statement.inc

# Double connections to allow the correct debug information to be shown
# when using assert.inc without rpl_init.inc
--let $rpl_server_count= 2
connect (server_2,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connect (server_1,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK);
connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK);

# Create empty file
let $MYSQLD_SLAVE_DATADIR= `select @@datadir`;
write_file $MYSQLD_SLAVE_DATADIR/master.info;
EOF
chmod 0000 $MYSQLD_SLAVE_DATADIR/master.info;
connection slave;

--disable_result_log
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
CALL mtr.add_suppression("Failed to open the existing info file");
CALL mtr.add_suppression("Error while reading from master info file");
CALL mtr.add_suppression("Failed to create a new info file");
CALL mtr.add_suppression("The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
--enable_result_log

# START SLAVE will fail because it can't read the file (mode 000)
# (system error 13)
--replace_result $MYSQL_TEST_DIR TESTDIR
--error ER_MASTER_INFO, 29
start slave;
chmod 0600  $MYSQLD_SLAVE_DATADIR/master.info;
# It will fail again because the file is empty so the slave cannot get valuable
# info about how to connect to the master from it (failure in
# init_strvar_from_file() in init_master_info()).
--error ER_MASTER_INFO
start slave;
--replace_result $MASTER_MYPORT MASTER_PORT

# CHANGE MASTER will fail because it first parses master.info before changing
# it (so when master.info is bad, people have to use RESET SLAVE first).
--replace_column 2 ####
--error ER_MASTER_INFO
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
reset slave;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 2 ####
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root'; 
connection master;
reset master;
connection slave;
start slave;
--source include/wait_for_slave_to_start.inc
connection master;

#
# Test FLUSH LOGS
#
create temporary table temp_table (a char(80) not null);
insert into temp_table values ("testing temporary tables");
create table t1 (s text);
insert into t1 values('Could not break slave'),('Tried hard');
--source include/sync_slave_sql_with_master.inc
let $status_items= Master_Log_File, Relay_Master_Log_File;
source include/show_slave_status.inc;
source include/check_slave_is_running.inc;

--let $assert_text= Table t1 should contain the first inserted line
--let $query_result= query_get_value(select * from t1, "s", 1)
--let $assert_cond= "$query_result" = "Could not break slave"
--source include/assert.inc

--let $assert_text= Table t1 should contain the second inserted line
--let $query_result= query_get_value(select * from t1, "s", 2)
--let $assert_cond= "$query_result" = "Tried hard"
--source include/assert.inc

connection master;
flush logs;
create table t2(m int not null auto_increment primary key);
insert into t2 values (34),(67),(123);
flush logs;
source include/show_binary_logs.inc;
create table t3 select * from temp_table;

--source include/sync_slave_sql_with_master.inc

--let $query_result= query_get_value(select * from t3, "a", 1)
--let $assert_text= Data in t3 should be equal to temp_table
--let $assert_cond= "$query_result"  = "testing temporary tables"
--source include/assert.inc

connection master;
drop table temp_table, t3;

#
# Now lets make some duplicate key mess and see if we can recover from it
#

# First insert a value on the slave
connection slave;
insert into t2 values(1234);

#same value on the master
connection master;
set insert_id=1234;
insert into t2 values(NULL);
connection slave;
# 1062 = ER_DUP_ENTRY
call mtr.add_suppression("Slave SQL.*Error .Duplicate entry .1234. for key .PRIMARY.. on query.* Error_code: 1062");
--let $slave_sql_errno= 1062
--source include/wait_for_slave_sql_error_and_skip.inc

connection master;

#let slave catch up
--source include/sync_slave_sql_with_master.inc
connection master;
purge master logs to 'master-bin.000002';
source include/show_master_logs.inc;
# we just tests if synonyms are accepted
purge binary logs to 'master-bin.000002';
source include/show_binary_logs.inc;

# Set the purge time 1 second after the last modify time of master-bin.000002.
perl;
open F, ">>".$ENV{'MYSQLTEST_VARDIR'}.'/tmp/rpl_rotate_logs.tmp' or die "Tmp file rpl_rotate_logs.tmp not found";
my $binlogpath = $ENV{'MYSQLTEST_VARDIR'}.'/mysqld.1/data/master-bin.000002';
my @array = stat($binlogpath);
my $filemodifytime = $array[9];
my @t = localtime $filemodifytime;
my $modifytime = sprintf "%04u-%02u-%02u %02u:%02u:%02u",$t[5]+1900,$t[4]+1,$t[3],$t[2],$t[1],$t[0];
printf F ("let \$tmpval = %s;",$modifytime);
close F;
EOF

--source $MYSQLTEST_VARDIR/tmp/rpl_rotate_logs.tmp
remove_file $MYSQLTEST_VARDIR/tmp/rpl_rotate_logs.tmp;

--disable_result_log
--replace_result $tmpval tmpval
--eval SELECT @time_for_purge:=DATE_ADD('$tmpval', INTERVAL 1 SECOND)
--enable_result_log

replace_regex /\.[\\\/]master/master/;
purge master logs before (@time_for_purge);
source include/show_binary_logs.inc;
insert into t2 values (65);
--source include/sync_slave_sql_with_master.inc
source include/show_slave_status.inc;
source include/check_slave_is_running.inc;

--let $assert_text= Table t2 should still contain the first inserted line after creation
--let $assert_cond= [select * from t2, m, 1] = 34
--source include/assert.inc

--let $assert_text= Table t2 should contain the line inserted after the purge
--let $assert_cond= [select * from t2, m, 2] = 65
--source include/assert.inc

--let $assert_text= Table t2 should still contain the second insert line after creation
--let $assert_cond= [select * from t2, m, 3] = 67
--source include/assert.inc

--let $assert_text= Table t2 should still contain the third inserted line after creation
--let $assert_cond= [select * from t2, m, 4] = 123
--source include/assert.inc

--let $assert_text= Table t2 should still contain the line from the duplicated key test
--let $assert_cond= [select * from t2, m, 5] = 1234
--source include/assert.inc

#
# Test forcing the replication log to rotate
#

connection master;
create temporary table temp_table (a char(80) not null);
insert into temp_table values ("testing temporary tables part 2");

# Generate some number of logs and prove rotation by comparing the first and the last
let $1=90;

let $first=query_get_value("SHOW MASTER STATUS", "File", 1);
create table t3 (n int);
disable_query_log;
while ($1)
{
#eval means expand $ expressions
 eval insert into t3 values($1 + 4);
 dec $1;
}
enable_query_log;

--let $assert_text= Table t3 should contain 90 lines on the master
--let $assert_cond= [select count(*) from t3 where n >= 4] = 90
--source include/assert.inc

create table t4 select * from temp_table;
let $last=query_get_value("SHOW MASTER STATUS", "File", 1);
if (`select '$first' like '$last'`)
{
  --die No expected logs rotation
} 
--source include/sync_slave_sql_with_master.inc

--let $query_result= query_get_value(select * from t4, "a", 1)
--let $assert_text= Data in t4 should be equal to temp_table
--let $assert_cond= "$query_result" = "testing temporary tables part 2"
--source include/assert.inc

source include/check_slave_is_running.inc;
# because of concurrent insert, the table may not be up to date
# if we do not lock
lock tables t3 read;

--let $assert_text= Table t3 should contain 90 lines on the slave
--let $assert_cond= [select count(*) from t3 where n >= 4] = 90
--source include/assert.inc

unlock tables;
#clean up
connection master;
drop table if exists t1,t2,t3,t4;
drop temporary table temp_table;
--source include/sync_slave_sql_with_master.inc

--echo End of 4.1 tests

#
# Bug #29420: crash with show and purge binlogs
#
--error ER_ERROR_WHEN_EXECUTING_COMMAND
show binlog events in 'non existing_binlog_file';
replace_regex /\.[\\\/]slave/slave/;
purge master logs before now();
--error ER_ERROR_WHEN_EXECUTING_COMMAND
show binlog events in '';
replace_regex /\.[\\\/]slave/slave/;
purge master logs before now();

--echo End of 5.0 tests
--source include/stop_slave.inc

Man Man