mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
09c80e12c5
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.
118 lines
3.2 KiB
PHP
118 lines
3.2 KiB
PHP
# ==== Purpose ====
|
|
#
|
|
# Diff the output of a statement on all configured servers (usually
|
|
# master and slave).
|
|
#
|
|
#
|
|
# ==== Usage =====
|
|
#
|
|
# --let $rpl_diff_statement= SELECT * FROM t1 WHERE a < 100
|
|
# [--let $rpl_diff_servers= <server1>,<server2>,...<serverN>]
|
|
# --source include/rpl_diff.inc
|
|
#
|
|
# Parameters:
|
|
# $rpl_diff_statement
|
|
# Statement to check. For each compared server, this script will
|
|
# start a new client and pass this statement to the client.
|
|
# Note: This string will be evaluated as a single-quote-escaped
|
|
# SQL string and hence must be quoted as such. In particular, any
|
|
# single quotes in this string must be escaped.
|
|
#
|
|
# $rpl_diff_servers
|
|
# By default, this file compares all servers configured by
|
|
# rpl_init.inc. You can set $diff_servers to a comma-separated
|
|
# list of numbers: only the servers identified by these numbers
|
|
# will be compared.
|
|
#
|
|
# $rpl_diff_database
|
|
# By default, the statement will be executed on the database
|
|
# 'test'. If $rpl_diff_database is set, the statement will be
|
|
# executed on the database named $rpl_diff_database instead.
|
|
|
|
|
|
--let $include_filename= rpl_diff.inc
|
|
--source include/begin_include_file.inc
|
|
|
|
|
|
if (!$rpl_diff_statement)
|
|
{
|
|
--die ERROR IN TEST: you must set $rpl_diff_statement before you source include/rpl_diff.inc
|
|
}
|
|
|
|
|
|
# Sync.
|
|
--source include/rpl_sync.inc
|
|
|
|
|
|
# Get database name.
|
|
--let $_rpl_diff_database= $rpl_diff_database
|
|
if (`SELECT '$_rpl_diff_database' = ''`)
|
|
{
|
|
--let $_rpl_diff_database= test
|
|
}
|
|
|
|
|
|
# Generate list of servers.
|
|
--let $_rpl_diff_servers= $rpl_diff_servers
|
|
if (!$_rpl_diff_servers)
|
|
{
|
|
--let $_rpl_server_i= $rpl_server_count
|
|
--let $_rpl_diff_servers=
|
|
while ($_rpl_server_i)
|
|
{
|
|
--let $_rpl_diff_servers= $_rpl_server_i,$_rpl_diff_servers
|
|
--dec $_rpl_server_i
|
|
}
|
|
}
|
|
if ($rpl_debug)
|
|
{
|
|
--echo \$rpl_diff_servers= '$_rpl_diff_servers'
|
|
}
|
|
|
|
|
|
if (!$rpl_debug)
|
|
{
|
|
--disable_query_log
|
|
}
|
|
|
|
|
|
# Generate file containing $rpl_diff_statement. We don't pass the
|
|
# statement on the command line, because it would be subject to shell
|
|
# substitutions.
|
|
--let $write_to_file= GENERATE
|
|
--let $write_var= $rpl_diff_statement
|
|
--source include/write_var_to_file.inc
|
|
--let $_rpl_diff_statement_file= $write_to_file
|
|
|
|
|
|
# Compare all servers.
|
|
--let $_rpl_diff_first= 1
|
|
while ($_rpl_diff_servers)
|
|
{
|
|
# Set $_rpl_diff_server_i to the first number in the list
|
|
--let $_rpl_diff_server_i= `SELECT SUBSTRING_INDEX('$_rpl_diff_servers', ',', 1)`
|
|
# Remove $_rpl_diff_server_i from the list
|
|
--let $_rpl_diff_servers= `SELECT SUBSTRING('$_rpl_diff_servers', LENGTH('$_rpl_diff_server_i') + 2)`
|
|
|
|
# Execute statement
|
|
--let $_rpl_diff_file= $MYSQLTEST_VARDIR/tmp/_rpl_diff_server-$_rpl_diff_server_i.tmp
|
|
--exec $MYSQL --defaults-group-suffix=.$_rpl_diff_server_i $_rpl_diff_database < $_rpl_diff_statement_file > $_rpl_diff_file
|
|
|
|
# Compare
|
|
if (!$_rpl_diff_first)
|
|
{
|
|
if ($rpl_debug)
|
|
{
|
|
--echo diffing $_rpl_diff_file and $_rpl_diff_prev_file
|
|
}
|
|
--diff_files $_rpl_diff_file $_rpl_diff_prev_file
|
|
--remove_file $_rpl_diff_prev_file
|
|
}
|
|
--let $_rpl_diff_prev_file= $_rpl_diff_file
|
|
--let $_rpl_diff_first= 0
|
|
}
|
|
--remove_file $_rpl_diff_prev_file
|
|
|
|
|
|
--let $include_filename= rpl_diff.inc
|
|
--source include/end_include_file.inc
|