Skip to content

Commit 3b3d3eb

Browse files
author
Mohit Joshi
committed
WL#10928 - MTR: Improvements to --check-testcases option
Description: =========== This WL focuses on improving check-testcases logic in MTR. MTR check-testcases perform checks just before and after the test execution to ensure there are no changes in the internal state of the Database. Multiple scenarios were seen where the test does not perform cleanup after itself eg - (check for persisted variables, check for leftover files in var/tmp dir) etc Solution: ======== Below are the new checks introduced as part of WL#10928: 1. check for persisted variables. 2. check for any left behind tablespaces. 3. check for any active/open connection. 4. check for any left-over files. 5. check for installed plugins/components. 6. check for new plugin/component variables. 7. check for new UDFs. Reviewed by: =========== Pavan Naik <[email protected]> Srikanth B.R <[email protected]> Narendra Chauhan <[email protected]>
1 parent 484cd1c commit 3b3d3eb

File tree

91 files changed

+410
-71
lines changed

Some content is hidden

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

91 files changed

+410
-71
lines changed

mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test

+3
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,9 @@ CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
662662
drop trigger trg_del_t2;
663663
drop table t1,t2,t3,t4,t5;
664664
drop function bug27417;
665+
if (`SELECT @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`) {
666+
--remove_file $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
667+
}
665668

666669

667670
--echo end of tests

mysql-test/extra/rpl_tests/rpl_mixing_engines.test

+2
Original file line numberDiff line numberDiff line change
@@ -1813,5 +1813,7 @@ if (`select @@session.binlog_direct_non_transactional_updates = 0 || @@session.b
18131813
--echo ###################################################################################
18141814
--echo # CLEAN
18151815
--echo ###################################################################################
1816+
--remove_file $MYSQLTEST_VARDIR/tmp/test-nmt-master.sql
1817+
--remove_file $MYSQLTEST_VARDIR/tmp/test-nmt-slave.sql
18161818
--let $commands= clean
18171819
--source extra/rpl_tests/rpl_mixing_engines.inc

mysql-test/extra/rpl_tests/rpl_replication_observers_example_plugin_server_startup.inc

+5
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,8 @@ DROP TABLE t1;
7171

7272
--let $include_filename= rpl_replication_observers_example_plugin_server_startup.inc
7373
--source include/end_include_file.inc
74+
75+
--echo #
76+
--echo # Re-installing the Plugin
77+
--echo #
78+
INSTALL PLUGIN replication_observers_example SONAME 'replication_observers_example_plugin.so';

mysql-test/extra/rpl_tests/rpl_row_UUID.test

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ diff_files $MYSQLTEST_VARDIR/tmp/rpl_row_UUID_master.sql $MYSQLTEST_VARDIR/tmp/r
7474
# Long-term "system rm" is not portable; we could live without
7575
# this cleanup as no other test will use these files and they'll
7676
# be removed at next testsuite run.
77-
77+
--remove_file $MYSQLTEST_VARDIR/tmp/rpl_row_UUID_master.sql
78+
--remove_file $MYSQLTEST_VARDIR/tmp/rpl_row_UUID_slave.sql

mysql-test/extra/rpl_tests/rpl_row_blob.test

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ connection master;
160160
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/rpl_row_blob_slave.sql
161161

162162
diff_files $MYSQLTEST_VARDIR/tmp/rpl_row_blob_master.sql $MYSQLTEST_VARDIR/tmp/rpl_row_blob_slave.sql;
163+
--remove_file $MYSQLTEST_VARDIR/tmp/rpl_row_blob_master.sql
164+
--remove_file $MYSQLTEST_VARDIR/tmp/rpl_row_blob_slave.sql
163165

164166
DROP TABLE IF EXISTS test.t1;
165167
DROP TABLE IF EXISTS test.t2;

mysql-test/extra/rpl_tests/rpl_row_sp006.test

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ DROP PROCEDURE p2;
7979

8080
diff_files $MYSQLTEST_VARDIR/tmp/sp006_master.sql $MYSQLTEST_VARDIR/tmp/sp006_slave.sql;
8181

82+
# Cleanup
83+
--remove_file $MYSQLTEST_VARDIR/tmp/sp006_master.sql
84+
--remove_file $MYSQLTEST_VARDIR/tmp/sp006_slave.sql
8285
--source include/sync_slave_sql_with_master.inc
8386

8487
# End of 5.1 test case

mysql-test/include/assert_grep.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,6 @@ if ($_ag_outcome != 'assert_grep.inc ok')
153153
--die assert_grep.inc failed.
154154
}
155155

156-
156+
--remove_file $_AG_OUT
157157
--let $include_filename= include/assert_grep.inc [$assert_text]
158158
--source include/end_include_file.inc

mysql-test/include/check-testcase.test

+126-5
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@
2020
# no error, and a few other invariants. So we issue SHOW SLAVE
2121
# STATUS, and if it returns no rows we fake the result.
2222
--let $tmp= 0
23-
if (`SELECT @@server_id <> 0`)
24-
{
23+
if (`SELECT @@server_id <> 0`) {
2524
--let $tmp= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1)
2625
--let $tmp= `SELECT '$tmp' = 'No such row'`
2726
}
28-
if ($tmp)
29-
{
27+
28+
if ($tmp) {
3029
# Note: after WL#5177, fields 13-18 shall not be filtered-out.
3130
--echo Slave_IO_State
3231
--echo Master_Host 127.0.0.1
@@ -95,6 +94,128 @@ if (!$tmp) {
9594
SHOW SLAVE STATUS;
9695
}
9796

98-
call mtr.check_testcase();
97+
# There might be more than one server used by a test and check-testcase.test
98+
# will be run for each server. The file lists for each server needs to be
99+
# uniquely identified. This can be achieved by appending the @@server_id with
100+
# the filename.
101+
--let $infile = `SELECT CONCAT('$MYSQLTEST_VARDIR_ABS/file_list_', @@server_id,'.flist')`
102+
103+
# There may be restrictions on paths usable for import/export operations
104+
# on a server due to the --secure-file-priv setting.
105+
#
106+
# Example 1: sys_vars.secure_file_priv2.test
107+
# - The server gets started with --secure_file_priv=$SECURE_LOAD_PATH
108+
# --> LOAD DATA INFILE '$MYSQLTEST_VARDIR_ABS/...' gets rejected in this case
109+
# if $SECURE_LOAD_PATH <> $MYSQLTEST_VARDIR_ABS
110+
# Hence, we do not run check-testcase in this case.
111+
#
112+
# Example 2: auth_sec.secure_file_priv_null.test
113+
# - The server gets started with --secure_file_priv=null
114+
# Hence, we do not run check-testcase in this case.
115+
#
116+
# Example 3: sys_vars.secure_file_priv.test
117+
# - The server gets started with --secure_file_priv=''
118+
# Default location for import/export operation is $MYSQLTEST_VARDIR_ABS
119+
# Note: $MYSQLTEST_VARDIR_ABS returns the absolute path of the vardir in-case
120+
# symbolic links are used (e.g --mem) option.
121+
122+
# There might be a problem with "--innodb-force-recovery > 0"
123+
# When --innodb-force-recovery ranges between [1,3], it prevents all
124+
# INSERT, UPDATE or DELETE
125+
# When --innodb-force-recovery=4 (or greater), it places InnoDB in
126+
# READONLY mode
127+
# Example: innodb-force-recovery-4.test
128+
# Hence, check-testcase will not work in these cases.
129+
130+
--let $secure_file_priv = `SELECT @@global.secure_file_priv`
131+
--let $proceed_with_check_of_files = `SELECT @@global.innodb_force_recovery = 0 AND '$secure_file_priv' = '$MYSQLTEST_VARDIR_ABS/'`
132+
if ($proceed_with_check_of_files) {
133+
# Ensure that we have no impact on the content of the binary log.
134+
#
135+
# Some (CREATE TABLE, ...) statements within the current routine would be
136+
# usually written into the binary log. This must be avoided.
137+
# Otherwise tests processing the content of the binary log like
138+
# "rpl.rpl_extra_row_data" will fail.
139+
SET @sql_log_bin_save = @@sql_log_bin;
140+
SET SESSION sql_log_bin = 0;
141+
142+
--write_file $infile
143+
# These are the files, directory etc. found in some important directories.
144+
EOF
145+
#
146+
147+
--append_file $infile
148+
#---------------- MYSQLTEST_VARDIR ----------------
149+
EOF
150+
--list_files_append_file $infile $MYSQLTEST_VARDIR *
151+
#
152+
153+
# MYSQLTEST_VARDIR/log contains
154+
# bootstrap.log
155+
# current_test
156+
# <testcase>.log
157+
# timer
158+
# We do not list the content of this directory because
159+
# - the name of the testcase is currently not available
160+
# - it's rather unusual to create files there via a test script
161+
#
162+
163+
--append_file $infile
164+
#-------------- MYSQLTEST_VARDIR/run --------------
165+
EOF
166+
--list_files_append_file $infile $MYSQLTEST_VARDIR/run *
167+
#
168+
169+
--append_file $infile
170+
#-------------- MYSQLTEST_VARDIR/tmp --------------
171+
EOF
172+
--list_files_append_file $infile $MYSQLTEST_VARDIR/tmp *
173+
#
174+
175+
--append_file $infile
176+
#------------- MYSQLTEST_VARDIR/std_data ------------
177+
EOF
178+
--list_files_append_file $infile $MYSQLTEST_VARDIR/std_data *
179+
#
180+
181+
USE test;
182+
183+
CREATE TEMPORARY TABLE file_tbl (filename varchar(1024));
184+
185+
# In case of binlog_killed_simulate the LOAD DATA fails with "query got an
186+
# interrupt". Important characteristics of binlog_killed_simulate is the server
187+
# system variable "debug" with a content <> "".
188+
# On the other hand it is quite thinkable that LOAD DATA fails because of a non
189+
# foreseen weakness of the current routine.
190+
# Conclusion:
191+
# - use disable abort on error
192+
# - automatic abort of the test if LOAD DATA fails and "debug" = 0
193+
# - ignoring errors if LOAD DATA fails and "debug" <> 0
194+
195+
--let $debug_condition = query_get_value(SHOW VARIABLES LIKE 'debug',Value, 1)
196+
--let $debug_condition_check = `SELECT '$debug_condition' <> ''`
197+
if ($debug_condition_check == 1) {
198+
--disable_abort_on_error
199+
}
200+
201+
--eval LOAD DATA INFILE '$infile' INTO TABLE file_tbl
202+
203+
if ($debug_condition_check == 1) {
204+
--enable_abort_on_error
205+
}
206+
207+
SELECT filename FROM file_tbl
208+
WHERE filename NOT LIKE 'check-mysqld_%'
209+
AND filename NOT LIKE 'mysql%.sock%'
210+
AND filename NOT LIKE 'file_list_%.flist'
211+
AND filename NOT LIKE 'mysqld%.expect'
212+
AND filename NOT LIKE 'bootstrap.log';
213+
214+
DROP TABLE test.file_tbl;
215+
SET @@sql_log_bin = @sql_log_bin_save;
216+
--remove_file $infile
217+
99218
--enable_query_log
219+
}
100220

221+
call mtr.check_testcase();

mysql-test/include/check_plugin_dir.inc

+1
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ EOF
6161
if ($skip) {
6262
--skip Plugins present in different folders
6363
}
64+
--remove_file $MYSQL_TMP_DIR/skip_status.txt

mysql-test/include/escape_sql.inc

+2
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,5 @@ if ($escape_string != '')
5656
5757
--let $escape_string= `SELECT LOAD_FILE('$_output_filename')`
5858
}
59+
# Cleanup
60+
--remove_file $_output_filename

mysql-test/include/mtr_check.sql

+52-15
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ BEGIN
5252
-- Leave the objects setup in the same state
5353
SELECT * from performance_schema.setup_objects
5454
order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
55+
56+
-- Leave the prepared statement instances in the same state
57+
SELECT * from performance_schema.prepared_statements_instances;
58+
59+
-- Leave the user defined functions in the same state
60+
SELECT * from performance_schema.user_defined_functions;
5561
END;
5662
END IF;
5763
END||
@@ -70,32 +76,37 @@ BEGIN
7076
SELECT * FROM performance_schema.global_variables
7177
WHERE variable_name NOT IN ('timestamp', 'server_uuid',
7278
'gtid_executed', 'gtid_purged',
73-
'group_replication_group_name')
79+
'group_replication_group_name',
80+
'keyring_file_data')
81+
ORDER BY VARIABLE_NAME;
82+
83+
-- Dump all persisted variables, those that may change.
84+
SELECT * FROM performance_schema.persisted_variables
7485
ORDER BY VARIABLE_NAME;
7586

7687
-- Dump all databases, there should be none
7788
-- except those that was created during bootstrap
7889
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA ORDER BY SCHEMA_NAME;
7990

8091
-- Dump all tablespaces, there should be none
81-
SELECT * FROM INFORMATION_SCHEMA.FILES WHERE
82-
FILE_TYPE !='TEMPORARY' AND TABLE_SCHEMA='test' ORDER BY FILE_ID;
92+
SELECT FILE_NAME, FILE_TYPE, TABLESPACE_NAME, ENGINE FROM INFORMATION_SCHEMA.FILES
93+
WHERE FILE_TYPE !='TEMPORARY' ORDER BY FILE_ID;
8394

8495
-- The test database should not contain any tables
8596
SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES
8697
WHERE table_schema='test'
87-
ORDER BY TABLE_NAME;
98+
ORDER BY TABLE_NAME;
8899

89100
-- Show "mysql" database, tables and columns
90101
SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql
91102
FROM INFORMATION_SCHEMA.TABLES
92103
WHERE table_schema='mysql' AND table_name != 'ndb_apply_status'
93104
ORDER BY tables_in_mysql;
94105
SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql,
95-
column_name, ordinal_position, column_default, is_nullable,
96-
data_type, character_maximum_length, character_octet_length,
97-
numeric_precision, numeric_scale, character_set_name,
98-
collation_name, column_type, column_key, extra, column_comment
106+
column_name, ordinal_position, column_default, is_nullable,
107+
data_type, character_maximum_length, character_octet_length,
108+
numeric_precision, numeric_scale, character_set_name,
109+
collation_name, column_type, column_key, extra, column_comment
99110
FROM INFORMATION_SCHEMA.COLUMNS
100111
WHERE table_schema='mysql' AND table_name != 'ndb_apply_status'
101112
ORDER BY columns_in_mysql, column_name;
@@ -110,7 +121,7 @@ BEGIN
110121
ACTION_REFERENCE_OLD_ROW, ACTION_REFERENCE_NEW_ROW, SQL_MODE, DEFINER CHARACTER_SET_CLIENT,
111122
COLLATION_CONNECTION, DATABASE_COLLATION
112123
FROM INFORMATION_SCHEMA.TRIGGERS
113-
WHERE TRIGGER_NAME NOT IN ('gs_insert', 'ts_insert');
124+
WHERE TRIGGER_NAME NOT IN ('gs_insert', 'ts_insert');
114125
-- Dump all created procedures, only those in the sys schema should exist
115126
-- do not select the CREATED or LAST_ALTERED columns however, as tests like mysqldump.test / mysql_ugprade.test update this
116127
SELECT SPECIFIC_NAME,ROUTINE_CATALOG,ROUTINE_SCHEMA,ROUTINE_NAME,ROUTINE_TYPE,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,
@@ -122,30 +133,56 @@ BEGIN
122133
-- Dump all views, only those in the sys schema should exist
123134
SELECT * FROM INFORMATION_SCHEMA.VIEWS
124135
ORDER BY TABLE_SCHEMA, TABLE_NAME;
136+
-- Dump all plugins, loaded with plugin-loading options or through
137+
-- INSTALL/UNINSTALL command
138+
SELECT * FROM INFORMATION_SCHEMA.PLUGINS;
125139

126140
SHOW GLOBAL STATUS LIKE 'slave_open_temp_tables';
127141

142+
-- Check for number of active connections before & after the test run.
143+
-- It is observed that several rpl tests fails due to mismatch in Threads
144+
-- count when we use SHOW GLOBAL STATUS LIKE 'Threads_Connected':
145+
-- Variable_name Value
146+
-- -Threads_connected 1
147+
-- +Threads_connected 2
148+
-- This is due to the default value of MASTER_HEARTBEAT_PERIOD which is equal
149+
-- to slave_net_timeout/2 = 60secs.
150+
-- Due to this, even after the slave is stopped, the master will not close
151+
-- the client session until MASTER_HEARTBEAT_PERIOD is reached.
152+
-- Hence, excluding the 'Binlog Dump' thread.
153+
SELECT USER, HOST, DB, COMMAND, INFO FROM INFORMATION_SCHEMA.PROCESSLIST
154+
WHERE COMMAND NOT IN ('Binlog Dump','Binlog Dump GTID','Sleep')
155+
ORDER BY COMMAND;
156+
128157
-- Checksum system tables to make sure they have been properly
129-
-- restored after test
130-
-- skip mysql.proc however, as created timestamps may have been updated by mysqldump.test / mysql_ugprade.test
131-
-- the above SELECT on I_S.ROUTINES ensures consistency across runs instead
158+
-- restored after test.
159+
-- skip mysql.proc however, as created timestamps may have been updated by
160+
-- mysqldump.test / mysql_ugprade.test the above SELECT on I_S.ROUTINES
161+
-- ensures consistency across runs instead
162+
-- We are skipping mysql.plugin from the checksum table list, as it does not
163+
-- register plugin-loading options like (--plugin-load,--plugin-load-add ..)
164+
-- instead we will use I_S.PLUGINS to ensure consistency across runs.
132165
checksum table
133166
mysql.columns_priv,
167+
mysql.component,
168+
mysql.default_roles,
134169
mysql.db,
135170
mysql.func,
171+
mysql.global_grants,
136172
mysql.help_category,
137173
mysql.help_keyword,
138174
mysql.help_relation,
139-
mysql.host,
175+
mysql.help_topic,
140176
mysql.procs_priv,
177+
mysql.proxies_priv,
178+
mysql.role_edges,
141179
mysql.tables_priv,
142180
mysql.time_zone,
143181
mysql.time_zone_leap_second,
144182
mysql.time_zone_name,
145183
mysql.time_zone_transition,
146184
mysql.time_zone_transition_type,
147-
mysql.user,
148-
mysql.global_grants;
185+
mysql.user;
149186

150187
END||
151188

mysql-test/include/mysqlbinlog.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ if (!$mysqlbinlog_skip_replace)
9090
replace_regex
9191
/TIMESTAMP=[0-9]*/TIMESTAMP=#/
9292
/#[0-9]*[ ]*[0-9]*:[0-9]*:[0-9]* server id [0-9]*/# # server id #/
93-
/SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
93+
/SQL_LOAD_MB-[a-f0-9]-[a-f0-9]/SQL_LOAD_MB-#-#/
9494
/exec_time=[0-9]*/exec_time=#/
9595
/last_committed=[0-9]*/last_committed=#/
9696
/sequence_number=[0-9]*/sequence_number=#/

mysql-test/include/mysqlbinlog_have_debug.inc

+5-3
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ close FILE_INC;
2525
EOF
2626
--source $temp_inc
2727

28+
--remove_file $temp_out_help_file
29+
--remove_file $temp_inc
30+
--enable_query_log
31+
2832
if (!$is_debug)
2933
{
3034
--skip mysqlbinlog needs to be debug compiled
3135
}
32-
--remove_file $temp_out_help_file
33-
--remove_file $temp_inc
34-
--enable_query_log
36+

mysql-test/include/mysqld--help.inc

+1
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@ perl;
8080
close F;
8181
EOF
8282

83+
--remove_file $MYSQL_TMP_DIR/mysqld--help.txt
8384
--rmdir $TMP_DATADIR
8485
--rmdir $MYDIR

mysql-test/include/rand.inc

+2
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,5 @@ if ($rand_type != decide)
109109
--let $rand= `SELECT ($_rand_min) + ($rand * (($_rand_max) - ($_rand_min)) / (1 << 32))`
110110
}
111111
}
112+
--error 0,1
113+
--remove_file $MYSQLTEST_VARDIR/tmp/rand_seed

mysql-test/include/rpl_diff.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ while ($_rpl_diff_servers)
129129
--let $_rpl_diff_first= 0
130130
}
131131
--remove_file $_rpl_diff_prev_file
132-
132+
--remove_file $_rpl_diff_statement_file
133133

134134
--let $include_filename= rpl_diff.inc
135135
--source include/end_include_file.inc

0 commit comments

Comments
 (0)