Skip to content

Commit 09c80e1

Browse files
author
Sven Sandberg
committed
BUG#49978: Replication tests don't clean up replication state at the end
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.
1 parent 82e887e commit 09c80e1

File tree

740 files changed

+6993
-5607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

740 files changed

+6993
-5607
lines changed

client/mysqltest.cc

+64-14
Original file line numberDiff line numberDiff line change
@@ -7990,6 +7990,14 @@ int main(int argc, char **argv)
79907990
var_set_int("$VIEW_PROTOCOL", view_protocol);
79917991
var_set_int("$CURSOR_PROTOCOL", cursor_protocol);
79927992

7993+
var_set_int("$ENABLED_QUERY_LOG", 1);
7994+
var_set_int("$ENABLED_ABORT_ON_ERROR", 1);
7995+
var_set_int("$ENABLED_RESULT_LOG", 1);
7996+
var_set_int("$ENABLED_CONNECT_LOG", 0);
7997+
var_set_int("$ENABLED_WARNINGS", 1);
7998+
var_set_int("$ENABLED_INFO", 0);
7999+
var_set_int("$ENABLED_METADATA", 0);
8000+
79938001
DBUG_PRINT("info",("result_file: '%s'",
79948002
result_file_name ? result_file_name : ""));
79958003
verbose_msg("Results saved in '%s'.",
@@ -8132,20 +8140,62 @@ int main(int argc, char **argv)
81328140
case Q_RPL_PROBE: do_rpl_probe(command); break;
81338141
case Q_ENABLE_RPL_PARSE: do_enable_rpl_parse(command); break;
81348142
case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(command); break;
8135-
case Q_ENABLE_QUERY_LOG: disable_query_log=0; break;
8136-
case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
8137-
case Q_ENABLE_ABORT_ON_ERROR: abort_on_error=1; break;
8138-
case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break;
8139-
case Q_ENABLE_RESULT_LOG: disable_result_log=0; break;
8140-
case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
8141-
case Q_ENABLE_CONNECT_LOG: disable_connect_log=0; break;
8142-
case Q_DISABLE_CONNECT_LOG: disable_connect_log=1; break;
8143-
case Q_ENABLE_WARNINGS: disable_warnings=0; break;
8144-
case Q_DISABLE_WARNINGS: disable_warnings=1; break;
8145-
case Q_ENABLE_INFO: disable_info=0; break;
8146-
case Q_DISABLE_INFO: disable_info=1; break;
8147-
case Q_ENABLE_METADATA: display_metadata=1; break;
8148-
case Q_DISABLE_METADATA: display_metadata=0; break;
8143+
case Q_ENABLE_QUERY_LOG:
8144+
disable_query_log= 0;
8145+
var_set_int("$ENABLED_QUERY_LOG", 1);
8146+
break;
8147+
case Q_DISABLE_QUERY_LOG:
8148+
disable_query_log= 1;
8149+
var_set_int("$ENABLED_QUERY_LOG", 0);
8150+
break;
8151+
case Q_ENABLE_ABORT_ON_ERROR:
8152+
abort_on_error= 1;
8153+
var_set_int("$ENABLED_ABORT_ON_ERROR", 1);
8154+
break;
8155+
case Q_DISABLE_ABORT_ON_ERROR:
8156+
abort_on_error= 0;
8157+
var_set_int("$ENABLED_ABORT_ON_ERROR", 0);
8158+
break;
8159+
case Q_ENABLE_RESULT_LOG:
8160+
disable_result_log= 0;
8161+
var_set_int("$ENABLED_RESULT_LOG", 1);
8162+
break;
8163+
case Q_DISABLE_RESULT_LOG:
8164+
disable_result_log=1;
8165+
var_set_int("$ENABLED_RESULT_LOG", 0);
8166+
break;
8167+
case Q_ENABLE_CONNECT_LOG:
8168+
disable_connect_log=0;
8169+
var_set_int("$ENABLED_CONNECT_LOG", 1);
8170+
break;
8171+
case Q_DISABLE_CONNECT_LOG:
8172+
disable_connect_log=1;
8173+
var_set_int("$ENABLED_CONNECT_LOG", 0);
8174+
break;
8175+
case Q_ENABLE_WARNINGS:
8176+
disable_warnings= 0;
8177+
var_set_int("$ENABLED_WARNINGS", 1);
8178+
break;
8179+
case Q_DISABLE_WARNINGS:
8180+
disable_warnings= 1;
8181+
var_set_int("$ENABLED_WARNINGS", 0);
8182+
break;
8183+
case Q_ENABLE_INFO:
8184+
disable_info= 0;
8185+
var_set_int("$ENABLED_INFO", 1);
8186+
break;
8187+
case Q_DISABLE_INFO:
8188+
disable_info= 1;
8189+
var_set_int("$ENABLED_INFO", 0);
8190+
break;
8191+
case Q_ENABLE_METADATA:
8192+
display_metadata= 1;
8193+
var_set_int("$ENABLED_METADATA", 1);
8194+
break;
8195+
case Q_DISABLE_METADATA:
8196+
display_metadata= 0;
8197+
var_set_int("$ENABLED_METADATA", 0);
8198+
break;
81498199
case Q_SOURCE: do_source(command); break;
81508200
case Q_SLEEP: do_sleep(command, 0); break;
81518201
case Q_REAL_SLEEP: do_sleep(command, 1); break;

mysql-test/extra/rpl_tests/rpl_EE_err.test

+1-8
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
# check if START SLAVE, RESET SLAVE, CHANGE MASTER reset Last_slave_error and
1010
# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986).
1111
####################################
12-
# Change Author: JBM
13-
# Change Date: 2006-01-11
14-
# Change: Split test per lars review
15-
####################################
1612
#"REQUIREMENT: A master DROP TABLE on a table with non-existing MYI
1713
# file must be correctly replicated to the slave"
1814
####################################
@@ -23,8 +19,5 @@ flush tables;
2319
let $MYSQLD_DATADIR= `select @@datadir`;
2420
remove_file $MYSQLD_DATADIR/test/t1.MYI ;
2521
drop table if exists t1;
26-
save_master_pos;
27-
connection slave;
28-
sync_with_master;
2922

30-
# End of 4.1 tests
23+
--source include/rpl_end.inc

mysql-test/extra/rpl_tests/rpl_auto_increment.test

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
#
22
# Test of auto_increment with offset
33
#
4-
#####################################
5-
# By: JBM
6-
# Date: 2006-02-10
7-
# Change: NDB does not support auto inc
8-
# in this usage. Currently there is no
9-
# plan to implment. Skipping test when
10-
# NDB is default engine.
11-
#####################################
124
-- source include/not_ndb_default.inc
135
-- source include/master-slave.inc
146

@@ -169,7 +161,7 @@ drop table t1;
169161
# auto_increment fields if the values of them are 0. There is an inconsistency
170162
# between slave and master. When MODE_NO_AUTO_VALUE_ON_ZERO are masters treat
171163
#
172-
source include/master-slave-reset.inc;
164+
source include/rpl_reset.inc;
173165

174166
connection master;
175167
--disable_warnings
@@ -210,12 +202,10 @@ INSERT INTO t2 VALUES(4);
210202
FLUSH LOGS;
211203
sync_slave_with_master;
212204

213-
let $diff_table_1= master:test.t1;
214-
let $diff_table_2= slave:test.t1;
205+
let $diff_tables= master:t1, slave:t1;
215206
source include/diff_tables.inc;
216207

217-
let $diff_table_1= master:test.t2;
218-
let $diff_table_2= slave:test.t2;
208+
let $diff_tables= master:t2, slave:t2;
219209
source include/diff_tables.inc;
220210

221211
connection master;
@@ -228,16 +218,16 @@ let $MYSQLD_DATADIR= `SELECT @@DATADIR`;
228218
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 | $MYSQL test
229219
sync_slave_with_master;
230220

231-
let $diff_table_1= master:test.t1;
232-
let $diff_table_2= slave:test.t1;
221+
let $diff_tables= master:t1, slave:t1;
233222
source include/diff_tables.inc;
234223

235-
let $diff_table_1= master:test.t2;
236-
let $diff_table_2= slave:test.t2;
224+
let $diff_tables= master:t2, slave:t2;
237225
source include/diff_tables.inc;
238226

239227
# End cleanup
228+
--connection master
240229
DROP TABLE t1;
241230
DROP TABLE t2;
242231
SET SQL_MODE='';
243-
sync_slave_with_master;
232+
233+
--source include/rpl_end.inc

mysql-test/extra/rpl_tests/rpl_auto_increment_insert_view.test

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ commit;
2929
sync_slave_with_master;
3030
--echo #Test if the results are consistent on master and slave
3131
--echo #for 'INSERT DATA INTO VIEW WHICH INVOKES TRIGGERS'
32-
let $diff_table_1=master:test.t3;
33-
let $diff_table_2=slave:test.t3;
32+
let $diff_tables= master:t3, slave:t3;
3433
source include/diff_tables.inc;
3534

3635
connection master;

mysql-test/extra/rpl_tests/rpl_auto_increment_invoke_trigger.test

+3-6
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,11 @@ connection master;
6060
sync_slave_with_master;
6161
--echo #Test if the results are consistent on master and slave
6262
--echo #for 'INVOKES A TRIGGER with $trigger_action action'
63-
let $diff_table_1=master:test.t2;
64-
let $diff_table_2=slave:test.t2;
63+
let $diff_tables= master:t2, slave:t2;
6564
source include/diff_tables.inc;
66-
let $diff_table_1=master:test.t4;
67-
let $diff_table_2=slave:test.t4;
65+
let $diff_tables= master:t4, slave:t4;
6866
source include/diff_tables.inc;
69-
let $diff_table_1=master:test.t6;
70-
let $diff_table_2=slave:test.t6;
67+
let $diff_tables= master:t6, slave:t6;
7168
source include/diff_tables.inc;
7269

7370
connection master;

mysql-test/extra/rpl_tests/rpl_autoinc_func_invokes_trigger.test

+2-4
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ connection master;
4141
sync_slave_with_master;
4242
--echo #Test if the results are consistent on master and slave
4343
--echo #for 'CALLS A FUNCTION which INVOKES A TRIGGER with $insert_action action'
44-
let $diff_table_1=master:test.t2;
45-
let $diff_table_2=slave:test.t2;
44+
let $diff_tables= master:t2, slave:t2;
4645
source include/diff_tables.inc;
47-
let $diff_table_1=master:test.t3;
48-
let $diff_table_2=slave:test.t3;
46+
let $diff_tables= master:t3, slave:t3;
4947
source include/diff_tables.inc;
5048

5149
connection master;

mysql-test/extra/rpl_tests/rpl_charset.test

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
# This test will fail if the server/client does not support enough charsets.
33

44
source include/master-slave.inc;
5-
--disable_warnings
65
set timestamp=1000000000;
7-
drop database if exists mysqltest2;
8-
drop database if exists mysqltest3;
9-
--enable_warnings
106

117
create database mysqltest2 character set latin2;
128
set @@character_set_server=latin5;
@@ -151,6 +147,6 @@ eval create table `t1` (
151147
set @p=_latin1 'test';
152148
update t1 set pk='test' where pk=@p;
153149
drop table t1;
154-
sync_slave_with_master;
155150

156151
# End of 4.1 tests
152+
--source include/rpl_end.inc

mysql-test/extra/rpl_tests/rpl_commit_after_flush.test

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
#################################
2-
# Test updated to use a wrapper #
3-
#################################
4-
51
eval CREATE TABLE t1 (a INT) ENGINE=$engine_type;
62

73
begin;
84
insert into t1 values(1);
95
flush tables with read lock;
106
commit;
11-
save_master_pos;
12-
connection slave;
13-
sync_with_master;
7+
sync_slave_with_master;
148
# cleanup
159
connection master;
1610
unlock tables;

mysql-test/extra/rpl_tests/rpl_conflicts.test

+8-3
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,13 @@ if (`SELECT @@global.binlog_format = 'ROW' AND @@global.slave_exec_mode = 'STRIC
139139
--echo ---- Wait until slave stops with an error ----
140140
let $slave_sql_errno= 1032; # ER_KEY_NOT_FOUND
141141
source include/wait_for_slave_sql_error.inc;
142-
let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
143-
--echo Last_SQL_Error = $err (expected "can't find record" error)
142+
143+
--let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1)
144+
--replace_regex /end_log_pos [0-9]+/end_log_pos END_LOG_POS/
145+
--disable_query_log
146+
--eval SELECT "$err" as 'Last_SQL_Error (expected "duplicate key" error)'
147+
--enable_query_log
148+
144149
SELECT * FROM t1;
145150

146151
--echo ---- Resolve the conflict on the slave and restart SQL thread ----
@@ -165,4 +170,4 @@ connection master;
165170
DROP TABLE t1;
166171

167172
--echo [on slave]
168-
sync_slave_with_master;
173+
--sync_slave_with_master

mysql-test/extra/rpl_tests/rpl_ddl.test

-11
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ sync_slave_with_master;
136136
connection master;
137137
SET AUTOCOMMIT = 1;
138138
#
139-
# 1. DROP all objects, which probably already exist, but must be created here
140-
#
141-
--disable_warnings
142-
DROP DATABASE IF EXISTS mysqltest1;
143-
DROP DATABASE IF EXISTS mysqltest2;
144-
DROP DATABASE IF EXISTS mysqltest3;
145-
--enable_warnings
146-
#
147139
# 2. CREATE all objects needed
148140
# working database is mysqltest1
149141
# working table (transactional!) is mysqltest1.t1
@@ -619,6 +611,3 @@ connection master;
619611
DROP DATABASE mysqltest1;
620612
# mysqltest2 was alreday DROPPED some tests before.
621613
DROP DATABASE mysqltest3;
622-
--enable_warnings
623-
624-
-- source include/master-slave-end.inc

mysql-test/extra/rpl_tests/rpl_deadlock.test

+1
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,4 @@ sync_slave_with_master;
131131
SET global max_relay_log_size= @my_max_relay_log_size;
132132

133133
--echo End of 5.1 tests
134+
--source include/rpl_end.inc

mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test renamed to mysql-test/extra/rpl_tests/rpl_extra_col_master.test

-22
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
11
#############################################################
2-
# Author: Chuck
3-
#############################################################
42
# Purpose: To test having extra columns on the master WL#3915
53
# engine inspecific sourced part
64
#############################################################
7-
# Change Author: Jeb
8-
# Change: Cleanup and extend testing
9-
#############################################################
10-
# TODO: partition specific
11-
# -- source include/have_partition.inc
12-
# Note: Will be done in different test due to NDB using this
13-
# test case.
14-
############################################################
15-
16-
########### Clean up ################
17-
--disable_warnings
18-
--disable_query_log
19-
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t10,t11,t12,t13,t14,t15,t16,t17,t18,t31;
20-
--enable_query_log
21-
--enable_warnings
225

236
#
247
# Setup differently defined tables on master and slave
@@ -1025,8 +1008,3 @@ SELECT c1,hex(c4),c5 FROM t5 ORDER BY c1;
10251008
connection master;
10261009
DROP TABLE t5;
10271010
sync_slave_with_master;
1028-
--echo
1029-
1030-
# END of 5.1 tests case
1031-
1032-

mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test renamed to mysql-test/extra/rpl_tests/rpl_extra_col_slave.test

+7-26
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
#################################################
2-
# Author: Jeb
3-
# Date: 2006-09-07
42
# Purpose: To test having extra columns on the slave.
53
##################################################
64

75
# Some tests in here requre partitioning
86
-- source include/have_partition.inc
97

10-
########### Clean up ################
11-
--disable_warnings
12-
--disable_query_log
13-
DROP TABLE IF EXISTS t1, t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t14a,t15,t16,t17;
14-
--enable_query_log
15-
--enable_warnings
16-
178
#################################################
189
############ Different Table Def Test ###########
1910
#################################################
@@ -448,9 +439,9 @@ if (`SELECT $engine_type != 'NDB'`)
448439
}
449440

450441
#--echo *** Drop t9 ***
451-
#connection master;
452-
#DROP TABLE t9;
453-
#sync_slave_with_master;
442+
connection master;
443+
DROP TABLE t9;
444+
sync_slave_with_master;
454445

455446
############################################
456447
# More columns in slave at middle of table #
@@ -725,6 +716,10 @@ sync_slave_with_master;
725716
--replace_column 5 CURRENT_TIMESTAMP
726717
SELECT * FROM t14a ORDER BY c1;
727718

719+
--connection master
720+
DROP TABLE t14a;
721+
--sync_slave_with_master
722+
728723
####################################################
729724
# - Alter Master Dropping columns from the middle. #
730725
# Expect: columns dropped #
@@ -912,17 +907,3 @@ connection slave;
912907
connection master;
913908
DROP TABLE t17;
914909
sync_slave_with_master;
915-
916-
#### Clean Up ####
917-
--disable_warnings
918-
--disable_query_log
919-
connection master;
920-
DROP TABLE IF EXISTS t1, t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t14a,t15,t16,t17;
921-
sync_slave_with_master;
922-
connection master;
923-
--enable_query_log
924-
--enable_warnings
925-
926-
# END 5.1 Test Case
927-
928-

0 commit comments

Comments
 (0)