mirror of
https://github.com/MariaDB/server.git
synced 2025-08-27 13:04:36 +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.
54 lines
2.0 KiB
Plaintext
54 lines
2.0 KiB
Plaintext
include/master-slave.inc
|
|
[connection master]
|
|
CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
|
|
create table t1(id int, i int, r1 int, r2 int, p varchar(100));
|
|
insert into t1 values(1, connection_id(), 0, 0, "");
|
|
insert into t1 values(2, 0, rand()*1000, rand()*1000, "");
|
|
set sql_log_bin=0;
|
|
insert into t1 values(6, 0, rand(), rand(), "");
|
|
delete from t1 where id=6;
|
|
set sql_log_bin=1;
|
|
insert into t1 values(3, 0, 0, 0, password('does_this_work?'));
|
|
insert into t1 values(4, connection_id(), rand()*1000, rand()*1000, password('does_this_still_work?'));
|
|
select * into outfile 'rpl_misc_functions.outfile' from t1;
|
|
create temporary table t2 like t1;
|
|
load data local infile 'MYSQLD_DATADIR/test/rpl_misc_functions.outfile' into table t2;
|
|
select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p);
|
|
id i r1 r2 p id i r1 r2 p
|
|
drop table t1;
|
|
DROP TABLE IF EXISTS t1;
|
|
CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
col_a DOUBLE DEFAULT NULL);
|
|
CREATE PROCEDURE test_replication_sp1()
|
|
BEGIN
|
|
INSERT INTO t1 (col_a) VALUES (rand()), (rand());
|
|
INSERT INTO t1 (col_a) VALUES (rand());
|
|
END|
|
|
CREATE PROCEDURE test_replication_sp2()
|
|
BEGIN
|
|
CALL test_replication_sp1();
|
|
CALL test_replication_sp1();
|
|
END|
|
|
CREATE FUNCTION test_replication_sf() RETURNS DOUBLE DETERMINISTIC
|
|
BEGIN
|
|
RETURN (rand() + rand());
|
|
END|
|
|
CALL test_replication_sp1();
|
|
CALL test_replication_sp2();
|
|
INSERT INTO t1 (col_a) VALUES (test_replication_sf());
|
|
INSERT INTO t1 (col_a) VALUES (test_replication_sf());
|
|
INSERT INTO t1 (col_a) VALUES (test_replication_sf());
|
|
select * from t1 into outfile "../../tmp/t1_slave.txt";
|
|
create temporary table t1_slave select * from t1 where 1=0;
|
|
load data infile '../../tmp/t1_slave.txt' into table t1_slave;
|
|
select count(*) into @aux from t1 join t1_slave using (id)
|
|
where ABS(t1.col_a - t1_slave.col_a) < 0.0000001 ;
|
|
SELECT @aux;
|
|
@aux
|
|
12
|
|
DROP TABLE t1, t1_slave;
|
|
DROP PROCEDURE test_replication_sp1;
|
|
DROP PROCEDURE test_replication_sp2;
|
|
DROP FUNCTION test_replication_sf;
|
|
include/rpl_end.inc
|