mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 22:12:30 +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.
84 lines
2.9 KiB
PHP
84 lines
2.9 KiB
PHP
# ==== Purpose ====
|
|
#
|
|
# Setup replication from an existing relay log in the current
|
|
# connection.
|
|
#
|
|
# ==== Usage ====
|
|
#
|
|
# Make sure the slave is not running and issue:
|
|
#
|
|
# let $fake_relay_log= /path/to/fake-relay-log-file.000001
|
|
# source include/setup_fake_relay_log.inc;
|
|
# START SLAVE SQL_THREAD; # setup_fake_relay_log doesn't start slave
|
|
# ...
|
|
# source include/cleanup_fake_relay_log.inc
|
|
#
|
|
# You must run the server with --relay-log=FILE. You probably want to
|
|
# run with --replicate-same-server-id too.
|
|
#
|
|
# ==== Implementation ====
|
|
#
|
|
# First makes a sanity check, ensuring that the slave threads are not
|
|
# running. Then copies the $fake_relay_log to RELAY_BIN-fake.000001,
|
|
# where RELAY_BIN is the basename of the relay log, and updates
|
|
# RELAY_BIN.index. Finally issues CHANGE MASTER so that it uses the
|
|
# given files.
|
|
#
|
|
# ==== Side effects ====
|
|
#
|
|
# Creates a binlog file and a binlog index file, and sets
|
|
# @@global.relay_log_purge=1. All this is restored when you call
|
|
# cleanup_fake_relay_log.inc.
|
|
|
|
|
|
--let $include_filename= setup_fake_relay_log.inc
|
|
--source include/begin_include_file.inc
|
|
|
|
if (!$rpl_debug)
|
|
{
|
|
--disable_query_log
|
|
}
|
|
|
|
# Print message.
|
|
let $_fake_relay_log_printable= `SELECT REPLACE('$fake_relay_log', '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`;
|
|
--echo Setting up fake replication from $_fake_relay_log_printable
|
|
|
|
# Sanity check.
|
|
let $_sql_running= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
|
|
let $_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1);
|
|
if (`SELECT "$_sql_running" = "Yes" OR "$_io_running" = "Yes"`) {
|
|
--echo Error: Slave was running when test case sourced
|
|
--echo include/setup_fake_replication.inc
|
|
--echo Slave_IO_Running = $_io_running; Slave_SQL_Running = $_sql_running
|
|
--source include/show_rpl_debug_info.inc
|
|
--die
|
|
}
|
|
|
|
# Read server variables.
|
|
let $_fake_datadir= `SELECT @@datadir`;
|
|
let $_fake_filename= query_get_value(SHOW VARIABLES LIKE 'relay_log', Value, 1);
|
|
if (!$_fake_filename) {
|
|
--die ERROR IN TEST: relay_log variable is empty. Please use the server option --relay-log=FILE.
|
|
}
|
|
let $_fake_relay_log= $_fake_datadir/$_fake_filename-fake.000001;
|
|
let $_fake_relay_index= $_fake_datadir/$_fake_filename.index;
|
|
# Need to restore relay_log_purge in cleanup_fake_relay_log.inc, since
|
|
# CHANGE MASTER modifies it (see the manual for CHANGE MASTER).
|
|
let $_fake_relay_log_purge= `SELECT @@global.relay_log_purge`;
|
|
|
|
# Create relay log file.
|
|
copy_file $fake_relay_log $_fake_relay_log;
|
|
# Create relay log index.
|
|
--let $write_var= $_fake_filename-fake.000001\n
|
|
--let $write_to_file= $_fake_relay_index
|
|
--source include/write_var_to_file.inc
|
|
|
|
# Remember old settings.
|
|
--let $_fake_old_master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1)
|
|
|
|
# Setup replication from existing relay log.
|
|
eval CHANGE MASTER TO MASTER_HOST='dummy.localdomain', RELAY_LOG_FILE='$_fake_filename-fake.000001', RELAY_LOG_POS=4;
|
|
|
|
|
|
--let $include_filename= setup_fake_relay_log.inc
|
|
--source include/end_include_file.inc
|