mirror of
https://github.com/MariaDB/server.git
synced 2025-08-31 22:22:30 +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.
168 lines
4.2 KiB
Plaintext
168 lines
4.2 KiB
Plaintext
include/master-slave.inc
|
|
[connection master]
|
|
DROP DATABASE IF EXISTS d1;
|
|
DROP DATABASE IF EXISTS d2;
|
|
DROP DATABASE IF EXISTS d3;
|
|
DROP DATABASE IF EXISTS d4;
|
|
DROP EVENT IF EXISTS e1;
|
|
DROP EVENT IF EXISTS e2;
|
|
DROP EVENT IF EXISTS e3;
|
|
DROP EVENT IF EXISTS e4;
|
|
DROP FUNCTION IF EXISTS f1;
|
|
DROP FUNCTION IF EXISTS f2;
|
|
DROP FUNCTION IF EXISTS f3;
|
|
DROP FUNCTION IF EXISTS f4;
|
|
DROP SERVER IF EXISTS s1;
|
|
DROP SERVER IF EXISTS s2;
|
|
DROP SERVER IF EXISTS s3;
|
|
DROP SERVER IF EXISTS s4;
|
|
DROP TABLE IF EXISTS t1;
|
|
DROP TABLE IF EXISTS t2;
|
|
DROP TABLE IF EXISTS t3;
|
|
DROP TABLE IF EXISTS t4;
|
|
DROP PROCEDURE IF EXISTS p1;
|
|
DROP PROCEDURE IF EXISTS p2;
|
|
DROP PROCEDURE IF EXISTS p3;
|
|
DROP PROCEDURE IF EXISTS p4;
|
|
DROP TRIGGER IF EXISTS tr1;
|
|
DROP TRIGGER IF EXISTS tr2;
|
|
DROP TRIGGER IF EXISTS tr3;
|
|
DROP TRIGGER IF EXISTS tr4;
|
|
CREATE DATABASE d1;
|
|
CREATE EVENT e1
|
|
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
|
|
DO INSERT INTO test.t1 VALUES (1);
|
|
CREATE FUNCTION f1 () RETURNS INT DETERMINISTIC
|
|
RETURN 1;
|
|
CREATE PROCEDURE p1 (OUT rows INT)
|
|
BEGIN
|
|
SELECT COUNT(*) INTO rows FROM t1;
|
|
END;
|
|
//
|
|
CREATE SERVER s1
|
|
FOREIGN DATA WRAPPER mysql
|
|
OPTIONS (USER 'user1', HOST '192.168.1.106', DATABASE 'test');
|
|
CREATE TABLE t1 (a int);
|
|
CREATE TABLE t3 (a int);
|
|
CREATE TRIGGER tr1 BEFORE INSERT ON t1
|
|
FOR EACH ROW BEGIN
|
|
DELETE FROM t4 WHERE a=NEW.a;
|
|
END;
|
|
//
|
|
CREATE INDEX i1 ON t1 (a);
|
|
CREATE VIEW v1 AS SELECT a FROM t1 WHERE a < 100;
|
|
[on master]
|
|
[on master1]
|
|
CREATE DATABASE d2;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP DATABASE d1;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP DATABASE IF EXISTS d2;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
CREATE EVENT e2
|
|
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
|
|
DO INSERT INTO test.t1 VALUES (2);
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP EVENT e1;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP EVENT IF EXISTS e2;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
CREATE FUNCTION f2 () RETURNS INT DETERMINISTIC
|
|
RETURN 1;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
ALTER FUNCTION f1 SQL SECURITY INVOKER;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP FUNCTION f1;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
CREATE PROCEDURE p2 (OUT rows INT)
|
|
BEGIN
|
|
SELECT COUNT(*) INTO rows FROM t2;
|
|
END;
|
|
//
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
ALTER PROCEDURE p1 SQL SECURITY INVOKER COMMENT 'return rows of table t1';
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP PROCEDURE p1;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
CREATE TABLE t2 (b int);
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
ALTER TABLE t1 ADD (d int);
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
RENAME TABLE t3 TO t4;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
CREATE INDEX i2 on t1 (a);
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP INDEX i1 on t1;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
CREATE TABLE IF NOT EXISTS t4 (a int);
|
|
CREATE TRIGGER tr2 BEFORE INSERT ON t4
|
|
FOR EACH ROW BEGIN
|
|
DELETE FROM t1 WHERE a=NEW.a;
|
|
END;
|
|
//
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP TRIGGER tr1;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP TRIGGER IF EXISTS tr2;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
CREATE VIEW v2 AS SELECT a FROM t1 WHERE a > 100;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP VIEW v1;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP VIEW IF EXISTS v2;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP TABLE t1;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP TABLE IF EXISTS t2;
|
|
source include/kill_query.inc;
|
|
include/rpl_diff.inc
|
|
DROP DATABASE IF EXISTS d1;
|
|
DROP DATABASE IF EXISTS d2;
|
|
DROP DATABASE IF EXISTS d3;
|
|
DROP DATABASE IF EXISTS d4;
|
|
DROP EVENT IF EXISTS e1;
|
|
DROP EVENT IF EXISTS e2;
|
|
DROP EVENT IF EXISTS e3;
|
|
DROP EVENT IF EXISTS e4;
|
|
DROP FUNCTION IF EXISTS f1;
|
|
DROP FUNCTION IF EXISTS f2;
|
|
DROP FUNCTION IF EXISTS f3;
|
|
DROP FUNCTION IF EXISTS f4;
|
|
DROP SERVER IF EXISTS s1;
|
|
DROP SERVER IF EXISTS s2;
|
|
DROP SERVER IF EXISTS s3;
|
|
DROP SERVER IF EXISTS s4;
|
|
DROP TABLE IF EXISTS t1;
|
|
DROP TABLE IF EXISTS t2;
|
|
DROP TABLE IF EXISTS t3;
|
|
DROP TABLE IF EXISTS t4;
|
|
DROP PROCEDURE IF EXISTS p1;
|
|
DROP PROCEDURE IF EXISTS p2;
|
|
DROP PROCEDURE IF EXISTS p3;
|
|
DROP PROCEDURE IF EXISTS p4;
|
|
include/rpl_end.inc
|