mirror of
https://github.com/MariaDB/server.git
synced 2025-08-26 01:44:06 +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.
140 lines
4.7 KiB
Plaintext
140 lines
4.7 KiB
Plaintext
include/master-slave.inc
|
|
[connection master]
|
|
use test;
|
|
CREATE TABLE test.regular_tbl(id MEDIUMINT NOT NULL AUTO_INCREMENT,
|
|
dt TIMESTAMP, user CHAR(255), uuidf LONGBLOB,
|
|
fkid MEDIUMINT, filler VARCHAR(255),
|
|
PRIMARY KEY(id)) ENGINE='innodb';
|
|
CREATE TABLE test.bykey_tbl(id MEDIUMINT NOT NULL AUTO_INCREMENT,
|
|
dt TIMESTAMP, user CHAR(255), uuidf LONGBLOB,
|
|
fkid MEDIUMINT, filler VARCHAR(255),
|
|
PRIMARY KEY(id)) ENGINE='innodb'
|
|
PARTITION BY KEY(id) partitions 5;
|
|
CREATE TABLE test.byrange_tbl(id MEDIUMINT NOT NULL AUTO_INCREMENT,
|
|
dt TIMESTAMP, user CHAR(255), uuidf LONGBLOB,
|
|
fkid MEDIUMINT, filler VARCHAR(255),
|
|
PRIMARY KEY(id)) ENGINE='innodb'
|
|
PARTITION BY RANGE(id)
|
|
SUBPARTITION BY hash(id) subpartitions 2
|
|
(PARTITION pa1 values less than (10),
|
|
PARTITION pa2 values less than (20),
|
|
PARTITION pa3 values less than (30),
|
|
PARTITION pa4 values less than (40),
|
|
PARTITION pa5 values less than (50),
|
|
PARTITION pa6 values less than (60),
|
|
PARTITION pa7 values less than (70),
|
|
PARTITION pa8 values less than (80),
|
|
PARTITION pa9 values less than (90),
|
|
PARTITION pa10 values less than (100),
|
|
PARTITION pa11 values less than MAXVALUE);
|
|
CREATE PROCEDURE test.proc_norm()
|
|
BEGIN
|
|
DECLARE ins_count INT DEFAULT 1000;
|
|
DECLARE del_count INT;
|
|
DECLARE cur_user VARCHAR(255);
|
|
DECLARE local_uuid VARCHAR(255);
|
|
DECLARE local_time TIMESTAMP;
|
|
SET local_time= NOW();
|
|
SET cur_user= CURRENT_USER();
|
|
SET local_uuid= UUID();
|
|
WHILE ins_count > 0 DO
|
|
INSERT INTO test.regular_tbl VALUES (NULL, NOW(), USER() , UUID(),
|
|
ins_count,'Going to test MBR for MySQL');
|
|
SET ins_count = ins_count - 1;
|
|
END WHILE;
|
|
SELECT MAX(id) FROM test.regular_tbl INTO del_count;
|
|
WHILE del_count > 0 DO
|
|
DELETE FROM test.regular_tbl WHERE id = del_count;
|
|
SET del_count = del_count - 2;
|
|
END WHILE;
|
|
END|
|
|
CREATE PROCEDURE test.proc_bykey()
|
|
BEGIN
|
|
DECLARE ins_count INT DEFAULT 1000;
|
|
DECLARE del_count INT;
|
|
DECLARE cur_user VARCHAR(255);
|
|
DECLARE local_uuid VARCHAR(255);
|
|
DECLARE local_time TIMESTAMP;
|
|
SET local_time= NOW();
|
|
SET cur_user= CURRENT_USER();
|
|
SET local_uuid= UUID();
|
|
WHILE ins_count > 0 DO
|
|
INSERT INTO test.bykey_tbl VALUES (NULL, NOW(), USER() , UUID(),
|
|
ins_count,'Going to test MBR for MySQL');
|
|
SET ins_count = ins_count - 1;
|
|
END WHILE;
|
|
SELECT MAX(id) FROM test.bykey_tbl INTO del_count;
|
|
WHILE del_count > 0 DO
|
|
DELETE FROM test.bykey_tbl WHERE id = del_count;
|
|
SET del_count = del_count - 2;
|
|
END WHILE;
|
|
END|
|
|
CREATE PROCEDURE test.proc_byrange()
|
|
BEGIN
|
|
DECLARE ins_count INT DEFAULT 1000;
|
|
DECLARE del_count INT;
|
|
DECLARE cur_user VARCHAR(255);
|
|
DECLARE local_uuid VARCHAR(255);
|
|
DECLARE local_time TIMESTAMP;
|
|
SET local_time= NOW();
|
|
SET cur_user = CURRENT_USER();
|
|
SET local_uuid=UUID();
|
|
WHILE ins_count > 0 DO
|
|
INSERT INTO test.byrange_tbl VALUES (NULL, NOW(), USER(), UUID(),
|
|
ins_count,'Going to test MBR for MySQL');
|
|
SET ins_count = ins_count - 1;
|
|
END WHILE;
|
|
SELECT MAX(id) FROM test.byrange_tbl INTO del_count;
|
|
WHILE del_count > 0 DO
|
|
DELETE FROM test.byrange_tbl WHERE id = del_count;
|
|
SET del_count = del_count - 2;
|
|
END WHILE;
|
|
END|
|
|
CALL test.proc_norm();
|
|
SELECT count(*) as "Master regular" FROM test.regular_tbl;
|
|
Master regular 500
|
|
CALL test.proc_bykey();
|
|
SELECT count(*) as "Master bykey" FROM test.bykey_tbl;
|
|
Master bykey 500
|
|
CALL test.proc_byrange();
|
|
SELECT count(*) as "Master byrange" FROM test.byrange_tbl;
|
|
Master byrange 500
|
|
show create table test.byrange_tbl;
|
|
Table byrange_tbl
|
|
Create Table CREATE TABLE `byrange_tbl` (
|
|
`id` mediumint(9) NOT NULL AUTO_INCREMENT,
|
|
`dt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
`user` char(255) DEFAULT NULL,
|
|
`uuidf` longblob,
|
|
`fkid` mediumint(9) DEFAULT NULL,
|
|
`filler` varchar(255) DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=latin1
|
|
/*!50100 PARTITION BY RANGE (id)
|
|
SUBPARTITION BY HASH (id)
|
|
SUBPARTITIONS 2
|
|
(PARTITION pa1 VALUES LESS THAN (10) ENGINE = InnoDB,
|
|
PARTITION pa2 VALUES LESS THAN (20) ENGINE = InnoDB,
|
|
PARTITION pa3 VALUES LESS THAN (30) ENGINE = InnoDB,
|
|
PARTITION pa4 VALUES LESS THAN (40) ENGINE = InnoDB,
|
|
PARTITION pa5 VALUES LESS THAN (50) ENGINE = InnoDB,
|
|
PARTITION pa6 VALUES LESS THAN (60) ENGINE = InnoDB,
|
|
PARTITION pa7 VALUES LESS THAN (70) ENGINE = InnoDB,
|
|
PARTITION pa8 VALUES LESS THAN (80) ENGINE = InnoDB,
|
|
PARTITION pa9 VALUES LESS THAN (90) ENGINE = InnoDB,
|
|
PARTITION pa10 VALUES LESS THAN (100) ENGINE = InnoDB,
|
|
PARTITION pa11 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
|
|
SELECT count(*) "Slave norm" FROM test.regular_tbl;
|
|
Slave norm 500
|
|
SELECT count(*) "Slave bykey" FROM test.bykey_tbl;
|
|
Slave bykey 500
|
|
SELECT count(*) "Slave byrange" FROM test.byrange_tbl;
|
|
Slave byrange 500
|
|
DROP PROCEDURE test.proc_norm;
|
|
DROP PROCEDURE test.proc_bykey;
|
|
DROP PROCEDURE test.proc_byrange;
|
|
DROP TABLE test.regular_tbl;
|
|
DROP TABLE test.bykey_tbl;
|
|
DROP TABLE test.byrange_tbl;
|
|
include/rpl_end.inc
|