mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Made rpl_flushlog_loop use wait_slave_status instead of sleep.
This to save 5 seconds of test time. More test to follow. :-) mysql-test/r/rpl_flushlog_loop.result: Updated result file mysql-test/t/rpl_flushlog_loop.test: Make test use wait_slave_status instead of sleep
This commit is contained in:
158
mysql-test/include/wait_slave_status.inc
Normal file
158
mysql-test/include/wait_slave_status.inc
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
# include/wait_slave_status.inc
|
||||||
|
#
|
||||||
|
# Created by Matthias Leich
|
||||||
|
#
|
||||||
|
# SUMMARY
|
||||||
|
#
|
||||||
|
# Waits until slave has reached certain state or maximum time reached.
|
||||||
|
#
|
||||||
|
# (This script will not work, when the SHOW command delivers more than one
|
||||||
|
# result record, because only the first record will be caught.)
|
||||||
|
#
|
||||||
|
# USAGE
|
||||||
|
#
|
||||||
|
# Set $result_pattern in test file and source this file:
|
||||||
|
#
|
||||||
|
# let $result_pattern= <pattern used for LIKE on the result of
|
||||||
|
# SHOW STATUS SLAVE>
|
||||||
|
# --include wait_slave_status.inc
|
||||||
|
#
|
||||||
|
# EXAMPLE
|
||||||
|
#
|
||||||
|
# The script rpl_until.test:
|
||||||
|
# ...
|
||||||
|
# --replace_result $MASTER_MYPORT MASTER_MYPORT
|
||||||
|
# --replace_column 1 # 9 # 23 # 33 #
|
||||||
|
# --vertical_results show slave status;
|
||||||
|
#
|
||||||
|
# outputs
|
||||||
|
# show slave status;
|
||||||
|
# Slave_IO_State #
|
||||||
|
# Master_Host 127.0.0.1
|
||||||
|
# Master_User root
|
||||||
|
# Master_Port MASTER_MYPORT
|
||||||
|
# Connect_Retry 1
|
||||||
|
# Master_Log_File master-bin.000001
|
||||||
|
# Read_Master_Log_Pos 776
|
||||||
|
# Relay_Log_File slave-relay-bin.000004
|
||||||
|
# Relay_Log_Pos #
|
||||||
|
# Relay_Master_Log_File master-bin.000001
|
||||||
|
# Slave_IO_Running Yes
|
||||||
|
# Slave_SQL_Running No
|
||||||
|
# Replicate_Do_DB
|
||||||
|
# Replicate_Ignore_DB
|
||||||
|
# Replicate_Do_Table
|
||||||
|
# Replicate_Ignore_Table
|
||||||
|
# Replicate_Wild_Do_Table
|
||||||
|
# Replicate_Wild_Ignore_Table
|
||||||
|
# Last_Errno 0
|
||||||
|
# Last_Error
|
||||||
|
# Skip_Counter 0
|
||||||
|
# Exec_Master_Log_Pos 319
|
||||||
|
# Relay_Log_Space #
|
||||||
|
# Until_Condition Master
|
||||||
|
# Until_Log_File master-bin.000001
|
||||||
|
# Until_Log_Pos 319
|
||||||
|
# Master_SSL_Allowed No
|
||||||
|
# Master_SSL_CA_File
|
||||||
|
# Master_SSL_CA_Path
|
||||||
|
# Master_SSL_Cert
|
||||||
|
# Master_SSL_Cipher
|
||||||
|
# Master_SSL_Key
|
||||||
|
# Seconds_Behind_Master #
|
||||||
|
#
|
||||||
|
# The main problem with the "show slave status;" in rpl_until is, that
|
||||||
|
# depending on the total test engine power and the current load caused by
|
||||||
|
# other processes, the expected slave status might be not reached though
|
||||||
|
# it will happen in maybe some seconds.
|
||||||
|
#
|
||||||
|
# The typical problem with rpl_until is that Slave_IO_Running is "No"
|
||||||
|
# instead of "Yes".
|
||||||
|
#
|
||||||
|
# The expected result follows the LIKE pattern:
|
||||||
|
#
|
||||||
|
# let $result_pattern= '%127.0.0.1%root%1%master-bin.000001%776%slave-relay-bin.000004%master-bin.000001%Yes%No%0%0%319%Master%master-bin.000001%319%No%';
|
||||||
|
#
|
||||||
|
# The Slave_IO_Running value is the "Yes" just after the "master-bin.000001".
|
||||||
|
#
|
||||||
|
# How to get this pattern ?
|
||||||
|
#
|
||||||
|
# Any lines "--replace_result ..." and "--replace_colum ..." just before
|
||||||
|
# the SHOW TABLE STATUS and of course the expected result itself
|
||||||
|
# show us columns where the content must be unified, because it is non
|
||||||
|
# deterministic or it depends on the current test environment.
|
||||||
|
#
|
||||||
|
# Unfortunately "--replace_result ..." and "--replace_colum ..." do not
|
||||||
|
# affect the result of our assignment let $my_val= `SHOW SLAVE STATUS`;
|
||||||
|
# Therefore such content must be covered by '%'.
|
||||||
|
#
|
||||||
|
# Please be careful. A more simple pattern might be dangerous, because we
|
||||||
|
# might get "wrong" matches. Example: There might be several "Yes" and "No"
|
||||||
|
# within one result row.
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
# We do not want to print the auxiliary commands, because they are not of
|
||||||
|
# interest and their amount will vary depending how fast we get the
|
||||||
|
# desired state.
|
||||||
|
--disable_query_log
|
||||||
|
|
||||||
|
# The protocol should show
|
||||||
|
# - the setting of $result_pattern and
|
||||||
|
# - that this file is sourced ,
|
||||||
|
# because this increases the chance to use the protocol as replay script.
|
||||||
|
eval SELECT "let \$result_pattern= $result_pattern ;" AS "";
|
||||||
|
SELECT '--source include/wait_slave_status.inc' AS "";
|
||||||
|
|
||||||
|
# We accept to wait in maximum 30 seconds.
|
||||||
|
let $max_wait= 30;
|
||||||
|
while ($max_wait)
|
||||||
|
{
|
||||||
|
let $my_val= `SHOW SLAVE STATUS`;
|
||||||
|
# Now we have the first record of the SHOW result set as one fat string
|
||||||
|
# within the variable $my_val.
|
||||||
|
|
||||||
|
eval SET @my_val = '$my_val';
|
||||||
|
# DEBUG eval SELECT @my_val AS "response to SHOW SLAVE STATUS";
|
||||||
|
|
||||||
|
eval SELECT @my_val LIKE $result_pattern INTO @success;
|
||||||
|
# @success is '1' if we have a match
|
||||||
|
# '0' if we have no match
|
||||||
|
# DEBUG SELECT @success;
|
||||||
|
|
||||||
|
let $success= `SELECT @success`;
|
||||||
|
let $no_success= `SELECT @success = 0`;
|
||||||
|
if ($success)
|
||||||
|
{
|
||||||
|
# We reached the expected result and want to jump out of the loop
|
||||||
|
# without unneeded sleeps.
|
||||||
|
# Attention: Do not set $max_wait to 0, because "while" with negative value
|
||||||
|
# does not work.
|
||||||
|
let $max_wait= 1;
|
||||||
|
}
|
||||||
|
if ($no_success)
|
||||||
|
{
|
||||||
|
# We did not reach the expected result and will have to sleep again
|
||||||
|
# or jump out of the loop, when max_wait is exhausted.
|
||||||
|
sleep 1;
|
||||||
|
}
|
||||||
|
dec $max_wait;
|
||||||
|
}
|
||||||
|
--enable_query_log
|
||||||
|
if ($no_success)
|
||||||
|
{
|
||||||
|
let $message= ! Attention: Timeout in wait_slave_status.inc.
|
||||||
|
| Possible reasons with decreasing probability:
|
||||||
|
| - The LIKE pattern ($result_pattern) is wrong, because the
|
||||||
|
| testcase was altered or the layout of the
|
||||||
|
| SHOW SLAVE STATUS result set changed.
|
||||||
|
| - There is a new bug within the replication.
|
||||||
|
| - We met an extreme testing environment and $max_wait is
|
||||||
|
| too small.;
|
||||||
|
--source include/show_msg80.inc
|
||||||
|
--echo DEBUG INFO START (wait_slave_status.inc):
|
||||||
|
--echo $result_pattern
|
||||||
|
--vertical_results
|
||||||
|
show slave status;
|
||||||
|
--echo DEBUG INFO END
|
||||||
|
}
|
@ -12,7 +12,42 @@ stop slave;
|
|||||||
change master to master_host='127.0.0.1',master_user='root',
|
change master to master_host='127.0.0.1',master_user='root',
|
||||||
master_password='',master_port=SLAVE_PORT;
|
master_password='',master_port=SLAVE_PORT;
|
||||||
start slave;
|
start slave;
|
||||||
|
|
||||||
|
let $result_pattern= '%127.0.0.1%root%slave-bin.000001%slave-bin.000001%Yes%Yes%0%0%None%' ;
|
||||||
|
|
||||||
|
--source include/wait_slave_status.inc
|
||||||
flush logs;
|
flush logs;
|
||||||
show slave status;
|
SHOW SLAVE STATUS;
|
||||||
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
|
Slave_IO_State #
|
||||||
# 127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 212 # # slave-bin.000001 Yes Yes # 0 0 212 # None 0 No #
|
Master_Host 127.0.0.1
|
||||||
|
Master_User root
|
||||||
|
Master_Port SLAVE_PORT
|
||||||
|
Connect_Retry 60
|
||||||
|
Master_Log_File slave-bin.000001
|
||||||
|
Read_Master_Log_Pos 212
|
||||||
|
Relay_Log_File #
|
||||||
|
Relay_Log_Pos #
|
||||||
|
Relay_Master_Log_File slave-bin.000001
|
||||||
|
Slave_IO_Running Yes
|
||||||
|
Slave_SQL_Running Yes
|
||||||
|
Replicate_Do_DB
|
||||||
|
Replicate_Ignore_DB
|
||||||
|
Replicate_Do_Table
|
||||||
|
Replicate_Ignore_Table #
|
||||||
|
Replicate_Wild_Do_Table
|
||||||
|
Replicate_Wild_Ignore_Table
|
||||||
|
Last_Errno 0
|
||||||
|
Last_Error
|
||||||
|
Skip_Counter 0
|
||||||
|
Exec_Master_Log_Pos 212
|
||||||
|
Relay_Log_Space #
|
||||||
|
Until_Condition None
|
||||||
|
Until_Log_File
|
||||||
|
Until_Log_Pos 0
|
||||||
|
Master_SSL_Allowed No
|
||||||
|
Master_SSL_CA_File
|
||||||
|
Master_SSL_CA_Path
|
||||||
|
Master_SSL_Cert
|
||||||
|
Master_SSL_Cipher
|
||||||
|
Master_SSL_Key
|
||||||
|
Seconds_Behind_Master #
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
# in case of bi-directional replication
|
# in case of bi-directional replication
|
||||||
-- source include/master-slave.inc
|
-- source include/master-slave.inc
|
||||||
|
|
||||||
# This test is dependent on the actual events written to the binary
|
#
|
||||||
# log. To not break statement-based testing, we only run this test
|
# Start replication master -> slave
|
||||||
# under statement-based logging.
|
#
|
||||||
|
|
||||||
connection slave;
|
connection slave;
|
||||||
--disable_warnings
|
--disable_warnings
|
||||||
stop slave;
|
stop slave;
|
||||||
@ -14,6 +13,10 @@ stop slave;
|
|||||||
eval change master to master_host='127.0.0.1',master_user='root',
|
eval change master to master_host='127.0.0.1',master_user='root',
|
||||||
master_password='',master_port=$MASTER_MYPORT;
|
master_password='',master_port=$MASTER_MYPORT;
|
||||||
start slave;
|
start slave;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Start replication slave -> master
|
||||||
|
#
|
||||||
connection master;
|
connection master;
|
||||||
--disable_warnings
|
--disable_warnings
|
||||||
stop slave;
|
stop slave;
|
||||||
@ -22,9 +25,23 @@ stop slave;
|
|||||||
eval change master to master_host='127.0.0.1',master_user='root',
|
eval change master to master_host='127.0.0.1',master_user='root',
|
||||||
master_password='',master_port=$SLAVE_MYPORT;
|
master_password='',master_port=$SLAVE_MYPORT;
|
||||||
start slave;
|
start slave;
|
||||||
sleep 5;
|
|
||||||
|
#
|
||||||
|
# Wait for start of slave IO and SQL threads
|
||||||
|
#
|
||||||
|
let $result_pattern= '%127.0.0.1%root%slave-bin.000001%slave-bin.000001%Yes%Yes%0%0%None%';
|
||||||
|
--source include/wait_slave_status.inc
|
||||||
|
|
||||||
|
#
|
||||||
|
# Flush logs of slave
|
||||||
|
#
|
||||||
flush logs;
|
flush logs;
|
||||||
sleep 5;
|
sleep 5;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Show status of slave
|
||||||
|
#
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
|
--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
|
||||||
show slave status;
|
--vertical_results
|
||||||
|
SHOW SLAVE STATUS;
|
||||||
|
Reference in New Issue
Block a user