mirror of
https://github.com/MariaDB/server.git
synced 2025-08-29 00:08:14 +03:00
Major replication test framework cleanup. This does the following: - Ensure that all tests clean up the replication state when they finish, by making check-testcase check the output of SHOW SLAVE STATUS. This implies: - Slave must not be running after test finished. This is good because it removes the risk for sporadic errors in subsequent tests when a test forgets to sync correctly. - Slave SQL and IO errors must be cleared when test ends. This is good because we will notice if a test gets an unexpected error in the slave threads near the end. - We no longer have to clean up before a test starts. - Ensure that all tests that wait for an error in one of the slave threads waits for a specific error. It is no longer possible to source wait_for_slave_[sql|io]_to_stop.inc when there is an error in one of the slave threads. This is good because: - If a test expects an error but there is a bug that causes another error to happen, or if it stops the slave thread without an error, then we will notice. - When developing tests, wait_for_*_to_[start|stop].inc will fail immediately if there is an error in the relevant slave thread. Before this patch, we had to wait for the timeout. - Remove duplicated and repeated code for setting up unusual replication topologies. Now, there is a single file that is capable of setting up arbitrary topologies (include/rpl_init.inc, but include/master-slave.inc is still available for the most common topology). Tests can now end with include/rpl_end.inc, which will clean up correctly no matter what topology is used. The topology can be changed with include/rpl_change_topology.inc. - Improved debug information when tests fail. This includes: - debug info is printed on all servers configured by include/rpl_init.inc - User can set $rpl_debug=1, which makes auxiliary replication files print relevant debug info. - Improved documentation for all auxiliary replication files. Now they describe purpose, usage, parameters, and side effects. - Many small code cleanups: - Made have_innodb.inc output a sensible error message. - Moved contents of rpl000017-slave.sh into rpl000017.test - Added mysqltest variables that expose the current state of disable_warnings/enable_warnings and friends. - Too many to list here: see per-file comments for details.
108 lines
3.4 KiB
Plaintext
108 lines
3.4 KiB
Plaintext
include/master-slave.inc
|
|
[connection master]
|
|
[on slave]
|
|
include/stop_slave.inc
|
|
==== Create some events on master ====
|
|
[on master]
|
|
create table t1(n int not null auto_increment primary key);
|
|
insert into t1 values (1),(2),(3),(4);
|
|
drop table t1;
|
|
create table t2(n int not null auto_increment primary key);
|
|
insert into t2 values (1),(2);
|
|
insert into t2 values (3),(4);
|
|
drop table t2;
|
|
==== Replicate one event at a time on slave ====
|
|
[on slave]
|
|
start slave until master_log_file='MASTER_LOG_FILE', master_log_pos=MASTER_LOG_POS;
|
|
include/wait_for_slave_io_to_start.inc
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
select * from t1;
|
|
n
|
|
1
|
|
2
|
|
3
|
|
4
|
|
include/check_slave_param.inc [Exec_Master_Log_Pos]
|
|
start slave until master_log_file='master-no-such-bin.000001', master_log_pos=MASTER_LOG_POS;
|
|
include/wait_for_slave_io_to_start.inc
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
select * from t1;
|
|
n
|
|
1
|
|
2
|
|
3
|
|
4
|
|
include/check_slave_param.inc [Exec_Master_Log_Pos]
|
|
start slave until relay_log_file='slave-relay-bin.000003', relay_log_pos=RELAY_LOG_POS;
|
|
include/wait_for_slave_io_to_start.inc
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
select * from t2;
|
|
n
|
|
1
|
|
2
|
|
include/check_slave_param.inc [Exec_Master_Log_Pos]
|
|
start slave;
|
|
[on master]
|
|
[on slave]
|
|
include/stop_slave.inc
|
|
start slave until master_log_file='MASTER_LOG_FILE', master_log_pos=MASTER_LOG_POS;
|
|
include/wait_for_slave_io_to_start.inc
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
include/check_slave_param.inc [Exec_Master_Log_Pos]
|
|
==== Test various error conditions ====
|
|
start slave until master_log_file='master-bin', master_log_pos=MASTER_LOG_POS;
|
|
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
|
|
start slave until master_log_file='master-bin.000001', master_log_pos=MASTER_LOG_POS, relay_log_pos=RELAY_LOG_POS;
|
|
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
|
|
start slave until master_log_file='master-bin.000001';
|
|
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
|
|
start slave until relay_log_file='slave-relay-bin.000002';
|
|
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
|
|
start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=MASTER_LOG_POS;
|
|
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
|
|
start slave sql_thread;
|
|
start slave until master_log_file='master-bin.000001', master_log_pos=MASTER_LOG_POS;
|
|
Warnings:
|
|
Note 1254 Slave is already running
|
|
include/stop_slave.inc
|
|
drop table if exists t1;
|
|
reset slave;
|
|
change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
|
|
drop table if exists t1;
|
|
reset master;
|
|
create table t1 (a int primary key auto_increment);
|
|
start slave;
|
|
include/stop_slave.inc
|
|
master and slave are in sync now
|
|
select 0 as zero;
|
|
zero
|
|
0
|
|
insert into t1 set a=null;
|
|
insert into t1 set a=null;
|
|
select count(*) as two from t1;
|
|
two
|
|
2
|
|
start slave until master_log_file='MASTER_LOG_FILE', master_log_pos= UNTIL_POS;;
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
slave stopped at the prescribed position
|
|
select 0 as zero;
|
|
zero
|
|
0
|
|
select count(*) as one from t1;
|
|
one
|
|
1
|
|
drop table t1;
|
|
start slave;
|
|
include/rpl_reset.inc
|
|
flush logs;
|
|
stop slave;
|
|
reset slave;
|
|
start slave until master_log_file='master-bin.000001', master_log_pos=294 /* to stop right before DROP */;
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
show tables /* t1 must exist */;
|
|
Tables_in_test
|
|
t1
|
|
drop table t1;
|
|
stop slave;
|
|
include/rpl_end.inc
|