Commit 87a5e686 authored by Serge Kozlov's avatar Serge Kozlov

WL#4641 Heartbeat testing

This is backport for next-mr.

The patch adds new test cases that cover replication heartbeat testing.
parent d0c5656e
-- require r/have_ssl.require
disable_query_log;
show variables like 'have_ssl';
enable_query_log;
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
*** Preparing ***
[on slave]
include/stop_slave.inc
RESET SLAVE;
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1, MASTER_LOG_FILE='MASTER_BINLOG';
include/start_slave.inc
[on slave1]
STOP SLAVE;
RESET SLAVE;
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=1, MASTER_LOG_FILE='MASTER_BINLOG';
include/start_slave.inc
*** 2 slaves ***
Slave has received heartbeat event
Slave1 has received heartbeat event
Slave has received more heartbeats than Slave1 (1 means 'yes'): 1
*** Master->data->Slave1->heartbeat->Slave: ***
[on slave1]
RESET MASTER;
[on slave]
include/stop_slave.inc
RESET SLAVE;
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=SLAVE1_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.2, MASTER_LOG_FILE='SLAVE1_BINLOG';
include/start_slave.inc
Slave has received heartbeat event
[on master]
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10), c LONGTEXT);
INSERT INTO t1 VALUES (1, 'on master', '');
SHOW TABLES;
Tables_in_test
t1
[on slave1]
SHOW TABLES;
Tables_in_test
t1
[on slave]
SHOW TABLES;
Tables_in_test
[on master]
creating updates on master and send to slave1 during 5 second
[on slave]
Slave has received heartbeats (1 means 'yes'): 1
*** Clean up ***
DROP TABLE t1;
End of 6.0 test
This diff is collapsed.
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
*** Heartbeat over SSL ***
include/stop_slave.inc
RESET SLAVE;
CHANGE MASTER TO
MASTER_HOST='127.0.0.1',
MASTER_PORT=MASTER_PORT,
MASTER_USER='root',
MASTER_HEARTBEAT_PERIOD=0.1,
MASTER_LOG_FILE='MASTER_BINLOG',
MASTER_SSL=1,
MASTER_SSL_CA='MYSQL_TEST_DIR/std_data/cacert.pem',
MASTER_SSL_CERT='MYSQL_TEST_DIR/std_data/client-cert.pem',
MASTER_SSL_KEY='MYSQL_TEST_DIR/std_data/client-key.pem';
include/start_slave.inc
Master_SSL_Allowed: Yes
Heartbeat event has received
*** Clean up ***
End of 6.0 test
!include ../my.cnf
[mysqld.1]
server_id=1
[mysqld.2]
server_id=2
[mysqld.3]
server_id=3
[ENV]
SLAVE_MYPORT1= @mysqld.3.port
SLAVE_MYSOCK1= @mysqld.3.socket
#############################################################
# Author: Serge Kozlov <Serge.Kozlov@Sun.COM>
# Date: 02/19/2009
# Purpose: Testing heartbeat for schema
# 1 master and 2 slaves
#############################################################
--source include/master-slave.inc
--echo
--echo *** Preparing ***
--connection master
let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
--connection slave
--echo [on slave]
--source include/stop_slave.inc
RESET SLAVE;
--replace_result $MASTER_MYPORT MASTER_PORT $binlog_file MASTER_BINLOG
eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1, MASTER_LOG_FILE='$binlog_file';
--source include/start_slave.inc
--disconnect slave1
--connect(slave1,127.0.0.1,root,,test,$SLAVE_MYPORT1,)
--connection slave1
--echo [on slave1]
--disable_warnings
STOP SLAVE;
--enable_warnings
RESET SLAVE;
--replace_result $MASTER_MYPORT MASTER_PORT $binlog_file MASTER_BINLOG
eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=1, MASTER_LOG_FILE='$binlog_file';
--source include/start_slave.inc
--echo
#
# Testing heartbeat
#
# Check that heartbeat events sent to both slaves with correct periods
--echo *** 2 slaves ***
--connection slave
let $status_var= slave_received_heartbeats;
let $status_var_value= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
let $status_var_comparsion= >;
--source include/wait_for_status_var.inc
--echo Slave has received heartbeat event
--connection slave1
let $status_var= slave_received_heartbeats;
let $status_var_value= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
let $status_var_comparsion= >;
--source include/wait_for_status_var.inc
let $slave1_rcvd_heartbeats= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
--echo Slave1 has received heartbeat event
--connection slave
let $slave_rcvd_heartbeats= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
let $result= query_get_value(SELECT ($slave_rcvd_heartbeats DIV $slave1_rcvd_heartbeats) > 1 AS Result, Result, 1);
--echo Slave has received more heartbeats than Slave1 (1 means 'yes'): $result
--echo
# Create topology A->B->C and check that C receives heartbeat while B gets data
# Slave1 (B) started w/o --log-slave-updates because B should not send data from A to C
--echo *** Master->data->Slave1->heartbeat->Slave: ***
--connection slave1
--echo [on slave1]
RESET MASTER;
let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
--connection slave
--echo [on slave]
--source include/stop_slave.inc
RESET SLAVE;
--replace_result $SLAVE_MYPORT1 SLAVE1_PORT $binlog_file SLAVE1_BINLOG
eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$SLAVE_MYPORT1, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.2, MASTER_LOG_FILE='$binlog_file';
--source include/start_slave.inc
# Check heartbeat for new replication channel slave1->slave
let $status_var= slave_received_heartbeats;
let $status_var_value= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
let $status_var_comparsion= >;
--source include/wait_for_status_var.inc
--echo Slave has received heartbeat event
--connection master
--echo [on master]
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10), c LONGTEXT);
INSERT INTO t1 VALUES (1, 'on master', '');
--save_master_pos
SHOW TABLES;
--connection slave1
--sync_with_master 0
--echo [on slave1]
SHOW TABLES;
let $slave_pos_before= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
--save_master_pos
--connection slave
--sync_with_master 0
--echo [on slave]
SHOW TABLES;
--connection master
--echo [on master]
--echo creating updates on master and send to slave1 during 5 second
# Generate events on master and send to slave1 during 5 second
let $i= 1;
let $j= 1;
let $k= 1;
--disable_query_log
while ($i) {
eval SET @c_text=REPEAT('1234567890', $j);
eval UPDATE t1 SET a=$j, c=@c_text;
--connection slave1
let $slave_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
if (`SELECT ($k*($slave_pos - $slave_pos_before)) > 0`) {
--connection slave
let $slave_rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
let $k= 0;
let $time_before = `SELECT NOW()`;
}
if (`SELECT ((1-$k)*TIMESTAMPDIFF(SECOND,'$time_before',NOW())) > 5`) {
--connection slave
let $slave_rcvd_heartbeats_after= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
let $i= 0;
}
--connection master
inc $j;
sleep 0.1;
}
--enable_query_log
--connection slave
--echo [on slave]
let $result= query_get_value(SELECT ($slave_rcvd_heartbeats_after - $slave_rcvd_heartbeats_before) > 0 AS Result, Result, 1);
--echo Slave has received heartbeats (1 means 'yes'): $result
--echo
#
# Clean up
#
--echo *** Clean up ***
--connection master
DROP TABLE t1;
--save_master_pos
--connection slave1
--sync_with_master 0
--echo
# End of 6.0 test
--echo End of 6.0 test
!include ../my.cnf
[mysqld.1]
log-slave-updates
[mysqld.2]
log-slave-updates
This diff is collapsed.
#############################################################
# Author: Serge Kozlov <Serge.Kozlov@Sun.COM>
# Date: 02/19/2009
# Purpose: Testing basic functionality of heartbeat over SSL
#############################################################
--source include/have_ssl_communication.inc
--source include/master-slave.inc
--echo
#
# Testing heartbeat over SSL
#
# Heartbeat over SSL
--echo *** Heartbeat over SSL ***
--connection master
let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1);
--connection slave
--source include/stop_slave.inc
RESET SLAVE;
# Connect to master with SSL
--replace_result $MASTER_MYPORT MASTER_PORT $MYSQL_TEST_DIR MYSQL_TEST_DIR $master_binlog MASTER_BINLOG
eval CHANGE MASTER TO
MASTER_HOST='127.0.0.1',
MASTER_PORT=$MASTER_MYPORT,
MASTER_USER='root',
MASTER_HEARTBEAT_PERIOD=0.1,
MASTER_LOG_FILE='$master_binlog',
MASTER_SSL=1,
MASTER_SSL_CA='$MYSQL_TEST_DIR/std_data/cacert.pem',
MASTER_SSL_CERT='$MYSQL_TEST_DIR/std_data/client-cert.pem',
MASTER_SSL_KEY='$MYSQL_TEST_DIR/std_data/client-key.pem';
--source include/start_slave.inc
# Check SSL state of slave
let $slave_ssl_status= query_get_value(SHOW SLAVE STATUS, Master_SSL_Allowed, 1);
--echo Master_SSL_Allowed: $slave_ssl_status
# Wait until hearbeat event will received
let $status_var_value= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
let $status_var= slave_received_heartbeats;
let $status_var_comparsion= >;
--source include/wait_for_status_var.inc
--echo Heartbeat event has received
--echo
#
# Clean up
#
--echo *** Clean up ***
--connection master
--sync_slave_with_master
--echo
# End of 6.0 test
--echo End of 6.0 test
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment