diff options
author | Serge Kozlov <Serge.Kozlov@sun.com> | 2009-10-02 23:24:40 +0400 |
---|---|---|
committer | Serge Kozlov <Serge.Kozlov@sun.com> | 2009-10-02 23:24:40 +0400 |
commit | 3aae87ad9260b91361cdafefd97ba3ebe3b00b0b (patch) | |
tree | 09e465e4a58a6413c54a1b1d3555e322d8c9f7fa | |
parent | db72514486cefcbd21c80603df3b57ad1d8e696c (diff) | |
download | mariadb-git-3aae87ad9260b91361cdafefd97ba3ebe3b00b0b.tar.gz |
WL#4641 Heartbeat testing
This is backport for next-mr.
The patch adds new test cases that cover replication heartbeat testing.
-rw-r--r-- | mysql-test/include/have_ssl_communication.inc | 4 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_heartbeat_2slaves.result | 55 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_heartbeat_basic.result | 304 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_heartbeat_ssl.result | 27 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_heartbeat_2slaves.cnf | 17 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_heartbeat_2slaves.test | 142 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_heartbeat_basic.cnf | 7 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_heartbeat_basic.test | 536 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_heartbeat_ssl.test | 54 |
9 files changed, 1146 insertions, 0 deletions
diff --git a/mysql-test/include/have_ssl_communication.inc b/mysql-test/include/have_ssl_communication.inc new file mode 100644 index 00000000000..6f2d5587a75 --- /dev/null +++ b/mysql-test/include/have_ssl_communication.inc @@ -0,0 +1,4 @@ +-- require r/have_ssl.require +disable_query_log; +show variables like 'have_ssl'; +enable_query_log; diff --git a/mysql-test/suite/rpl/r/rpl_heartbeat_2slaves.result b/mysql-test/suite/rpl/r/rpl_heartbeat_2slaves.result new file mode 100644 index 00000000000..ecb7c62c488 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_heartbeat_2slaves.result @@ -0,0 +1,55 @@ +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 diff --git a/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result b/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result new file mode 100644 index 00000000000..ddb2122c631 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result @@ -0,0 +1,304 @@ +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 *** +include/stop_slave.inc +RESET SLAVE; +SET @restore_slave_net_timeout=@@global.slave_net_timeout; +RESET MASTER; +SET @restore_slave_net_timeout=@@global.slave_net_timeout; +SET @restore_event_scheduler=@@global.event_scheduler; + +*** Default value *** +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root'; +slave_net_timeout/slave_heartbeat_timeout=2.0000 +RESET SLAVE; + +*** Reset slave affect *** +SET @@global.slave_net_timeout=30; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=5; +RESET SLAVE; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 15.000 + +*** Default value if slave_net_timeout changed *** +SET @@global.slave_net_timeout=50; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root'; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 25.000 +SET @@global.slave_net_timeout=@restore_slave_net_timeout; +RESET SLAVE; + +*** Warning if updated slave_net_timeout < slave_heartbeat_timeout *** +SET @@global.slave_net_timeout=FLOOR(SLAVE_HEARTBEAT_TIMEOUT)-1; +Warnings: +Warning 1624 The currect value for master_heartbeat_period exceeds the new value of `slave_net_timeout' sec. A sensible value for the period should be less than the timeout. +SET @@global.slave_net_timeout=@restore_slave_net_timeout; +RESET SLAVE; + +*** Warning if updated slave_heartbeat_timeout > slave_net_timeout *** +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=SLAVE_NET_TIMEOUT; +Warnings: +Warning 1624 The requested value for the heartbeat period exceeds the value of `slave_net_timeout' sec. A sensible value for the period should be less than the timeout. +RESET SLAVE; + +*** CHANGE MASTER statement only updates slave_heartbeat_period *** +SET @@global.slave_net_timeout=20; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=5; +SHOW VARIABLES LIKE 'slave_net_timeout'; +Variable_name Value +slave_net_timeout 20 +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 5.000 +SET @@global.slave_net_timeout=2*@@global.slave_net_timeout; +SHOW VARIABLES LIKE 'slave_net_timeout'; +Variable_name Value +slave_net_timeout 40 +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 5.000 +SET @@global.slave_net_timeout=@restore_slave_net_timeout; +RESET SLAVE; + +*** Update slave_net_timeout on master *** +SET @@global.slave_net_timeout=500; +SET @@global.slave_net_timeout=200; +RESET SLAVE; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root'; +include/start_slave.inc +SHOW VARIABLES LIKE 'slave_net_timeout'; +Variable_name Value +slave_net_timeout 200 +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 100.000 +SET @@global.slave_net_timeout=@restore_slave_net_timeout; +include/stop_slave.inc +RESET SLAVE; +SET @@global.slave_net_timeout=@restore_slave_net_timeout; + +*** Start/stop slave *** +SET @@global.slave_net_timeout=100; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=20; +include/start_slave.inc +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 20.000 +include/stop_slave.inc +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 20.000 + +*** Reload slave *** +SET @@global.slave_net_timeout=50; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=30; +Reload slave +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 30.000 +SET @restore_slave_net_timeout=@@global.slave_net_timeout; + +*** Disable heartbeat *** +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 0.000 +SHOW STATUS LIKE 'slave_received_heartbeats'; +Variable_name Value +Slave_received_heartbeats 0 +include/start_slave.inc +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 0.000 +SHOW STATUS LIKE 'slave_received_heartbeats'; +Variable_name Value +Slave_received_heartbeats 0 +include/stop_slave.inc +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 0.000 +SHOW STATUS LIKE 'slave_received_heartbeats'; +Variable_name Value +Slave_received_heartbeats 0 +RESET SLAVE; +SELECT SLAVE_HEARTBEAT_TIMEOUT = 0 AS Result; +Result +0 + +*** Min slave_heartbeat_timeout *** +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.001; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 0.001 +RESET SLAVE; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.0009; +Warnings: +Warning 1624 The requested value for the heartbeat period is less than 1 msec. The period is reset to zero which means no heartbeats will be sending +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 0.000 +RESET SLAVE; + +*** Max slave_heartbeat_timeout *** +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=4294967; +Warnings: +Warning 1624 The requested value for the heartbeat period exceeds the value of `slave_net_timeout' sec. A sensible value for the period should be less than the timeout. +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 4294967.000 +RESET SLAVE; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=4294968; +ERROR HY000: The requested value for the heartbeat period is negative or exceeds the maximum 4294967 seconds +RESET SLAVE; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=8589935; +ERROR HY000: The requested value for the heartbeat period is negative or exceeds the maximum 4294967 seconds +RESET SLAVE; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=4294967296; +ERROR HY000: The requested value for the heartbeat period is negative or exceeds the maximum 4294967 seconds +RESET SLAVE; + +*** Misc incorrect values *** +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD='-1'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''-1'' at line 1 +RESET SLAVE; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD='123abc'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''123abc'' at line 1 +RESET SLAVE; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=''; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '''' at line 1 +RESET SLAVE; + +*** Running slave *** +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1; +include/start_slave.inc +Heartbeat event received + +*** Stopped slave *** +include/stop_slave.inc +Number of received heartbeat events while slave stopped: 0 + +*** Started slave *** +include/start_slave.inc +Heartbeat event received + +*** Stopped IO thread *** +STOP SLAVE IO_THREAD; +Number of received heartbeat events while io thread stopped: 0 + +*** Started IO thread *** +START SLAVE IO_THREAD; +Heartbeat event received + +*** Stopped SQL thread *** +STOP SLAVE SQL_THREAD; +Heartbeat events are received while sql thread stopped (1 means 'yes'): 1 + +*** Started SQL thread *** +START SLAVE SQL_THREAD; +Heartbeat event received + +*** Stopped SQL thread by error *** +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10), c LONGTEXT); +INSERT INTO t1 VALUES (1, 'on slave', NULL); +INSERT INTO t1 VALUES (1, 'on master', NULL); +Heartbeat events are received while sql thread stopped (1 means 'yes'): 1 +include/stop_slave.inc +DROP TABLE t1; + +*** Master send to slave *** +CREATE EVENT e1 +ON SCHEDULE EVERY 1 SECOND +DO +BEGIN +UPDATE test.t1 SET a = a + 1 WHERE a < 10; +END| +RESET SLAVE; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=1.5; +include/start_slave.inc +SET @@global.event_scheduler=1; +SHOW STATUS LIKE 'slave_received_heartbeats'; +Variable_name Value +Slave_received_heartbeats 0 +SHOW STATUS LIKE 'slave_received_heartbeats'; +Variable_name Value +Slave_received_heartbeats 0 +DELETE FROM t1; +DROP EVENT e1; + +*** Flush logs on slave *** +STOP SLAVE; +RESET SLAVE; +DROP TABLE t1; +DROP TABLE t1; +RESET MASTER; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.5; +include/start_slave.inc +Heartbeat events are received while rotation of relay logs (1 means 'yes'): 1 + +*** Compressed protocol *** +SET @@global.slave_compressed_protocol=1; +include/stop_slave.inc +RESET SLAVE; +SET @@global.slave_compressed_protocol=1; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1; +include/start_slave.inc +Heartbeat event received +SET @@global.slave_compressed_protocol=0; +SET @@global.slave_compressed_protocol=0; + +*** Reset master *** +STOP SLAVE; +RESET SLAVE; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1; +include/start_slave.inc +RESET MASTER; +Heartbeat events are received after reset of master (1 means 'yes'): 1 + +*** Reload master *** +STOP SLAVE; +RESET SLAVE; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1; +include/start_slave.inc +Heartbeat event received +Reload master +Heartbeat event received + +*** Circular replication *** +RESET MASTER; +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10)); +include/stop_slave.inc +RESET MASTER; +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'; +RESET SLAVE; +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=SLAVE_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=1, MASTER_LOG_FILE='SLAVE_BINLOG'; +include/start_slave.inc +INSERT INTO t1 VALUES(1, 'on master'); +include/start_slave.inc +INSERT INTO t1 VALUES(2, 'on slave'); +SELECT * FROM t1 ORDER BY a; +a b +1 on master +2 on slave +SELECT * FROM t1 ORDER BY a; +a b +1 on master +2 on slave +Heartbeat event received on master +Heartbeat event received on slave +Slave has received more events than master (1 means 'yes'): 1 + +*** Clean up *** +include/stop_slave.inc +DROP TABLE t1; +include/stop_slave.inc +SET @@global.slave_net_timeout=@restore_slave_net_timeout; + +End of 6.0 test diff --git a/mysql-test/suite/rpl/r/rpl_heartbeat_ssl.result b/mysql-test/suite/rpl/r/rpl_heartbeat_ssl.result new file mode 100644 index 00000000000..42de3c459cb --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_heartbeat_ssl.result @@ -0,0 +1,27 @@ +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 diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat_2slaves.cnf b/mysql-test/suite/rpl/t/rpl_heartbeat_2slaves.cnf new file mode 100644 index 00000000000..a3ed77c8bd2 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_heartbeat_2slaves.cnf @@ -0,0 +1,17 @@ +!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 + + + diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat_2slaves.test b/mysql-test/suite/rpl/t/rpl_heartbeat_2slaves.test new file mode 100644 index 00000000000..81737feea9e --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_heartbeat_2slaves.test @@ -0,0 +1,142 @@ +############################################################# +# 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 diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat_basic.cnf b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.cnf new file mode 100644 index 00000000000..a4a291bca79 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.cnf @@ -0,0 +1,7 @@ +!include ../my.cnf + +[mysqld.1] +log-slave-updates + +[mysqld.2] +log-slave-updates diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test new file mode 100644 index 00000000000..198f1208344 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test @@ -0,0 +1,536 @@ +############################################################# +# Author: Serge Kozlov <Serge.Kozlov@Sun.COM> +# Date: 02/19/2009 +# Purpose: Testing basic functionality of heartbeat. +# Description: +# * Testing different values for slave_heartbeat_period. +# * How to affect various statements to slave_heartbeat_period +# * Various states of slave and heartbeat +# * Various states of master and heartbeat +# * Circular replication +############################################################# +--source include/master-slave.inc +--echo + +--echo *** Preparing *** +--connection slave +--source include/stop_slave.inc +RESET SLAVE; +SET @restore_slave_net_timeout=@@global.slave_net_timeout; +let $slave_heartbeat_timeout= query_get_value(SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period', Value, 1); +--disable_query_log +eval SET @restore_slave_heartbeat_timeout=$slave_heartbeat_timeout; +--enable_query_log + +--connection master +RESET MASTER; +SET @restore_slave_net_timeout=@@global.slave_net_timeout; +SET @restore_event_scheduler=@@global.event_scheduler; +--echo + +# +# Test slave_heartbeat_period +# + +--connection slave + +# Default value of slave_heartbeat_timeout = slave_net_timeout/2 +--echo *** Default value *** +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root'; +let $slave_net_timeout= query_get_value(SHOW VARIABLES LIKE 'slave_net_timeout', Value, 1); +let $slave_heartbeat_timeout= query_get_value(SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period', Value, 1); +let $result= query_get_value(SELECT $slave_net_timeout/$slave_heartbeat_timeout AS Result, Result, 1); +--echo slave_net_timeout/slave_heartbeat_timeout=$result +RESET SLAVE; +--echo + +# Reset slave set slave_heartbeat_timeout = slave_net_timeout/2 +--echo *** Reset slave affect *** +--disable_warnings +SET @@global.slave_net_timeout=30; +--enable_warnings +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=5; +RESET SLAVE; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +--echo + +# Check default value of slave_heartbeat_timeout if slave_net_timeout is changed +--echo *** Default value if slave_net_timeout changed *** +--disable_warnings +SET @@global.slave_net_timeout=50; +--enable_warnings +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root'; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +SET @@global.slave_net_timeout=@restore_slave_net_timeout; +RESET SLAVE; +--echo + +# Set slave_net_timeout less than current value of slave_heartbeat_period +--echo *** Warning if updated slave_net_timeout < slave_heartbeat_timeout *** +let $slave_heartbeat_timeout= query_get_value(SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period', Value, 1); +--replace_result $slave_heartbeat_timeout SLAVE_HEARTBEAT_TIMEOUT +eval SET @@global.slave_net_timeout=FLOOR($slave_heartbeat_timeout)-1; +SET @@global.slave_net_timeout=@restore_slave_net_timeout; +RESET SLAVE; +--echo + +# Set value of slave_heartbeat_period greater than slave_net_timeout +--echo *** Warning if updated slave_heartbeat_timeout > slave_net_timeout *** +let $slave_net_timeout= query_get_value(SHOW VARIABLES LIKE 'slave_net_timeout', Value, 1); +inc $slave_net_timeout; +--replace_result $MASTER_MYPORT MASTER_PORT $slave_net_timeout SLAVE_NET_TIMEOUT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=$slave_net_timeout; +RESET SLAVE; +--echo + +# Changing of slave_net_timeout shouldn't affect to current value of slave_heartbeat_period +--echo *** CHANGE MASTER statement only updates slave_heartbeat_period *** +--disable_warnings +SET @@global.slave_net_timeout=20; +--enable_warnings +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=5; +SHOW VARIABLES LIKE 'slave_net_timeout'; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +SET @@global.slave_net_timeout=2*@@global.slave_net_timeout; +SHOW VARIABLES LIKE 'slave_net_timeout'; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +SET @@global.slave_net_timeout=@restore_slave_net_timeout; +RESET SLAVE; +--echo + +# Master value of slave_net_timeout shouldn't affect to slave's slave_heartbeat_period +--echo *** Update slave_net_timeout on master *** +--connection master +--disable_warnings +SET @@global.slave_net_timeout=500; +--enable_warnings +--connection slave +SET @@global.slave_net_timeout=200; +RESET SLAVE; +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root'; +--source include/start_slave.inc +--sync_with_master +SHOW VARIABLES LIKE 'slave_net_timeout'; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +SET @@global.slave_net_timeout=@restore_slave_net_timeout; +--source include/stop_slave.inc +RESET SLAVE; +--connection master +SET @@global.slave_net_timeout=@restore_slave_net_timeout; +--echo + +# Start/stop slave shouldn't change slave_heartbeat_period +--echo *** Start/stop slave *** +--connection slave +--disable_warnings +SET @@global.slave_net_timeout=100; +--enable_warnings +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=20; +--source include/start_slave.inc +--sync_with_master +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +--source include/stop_slave.inc +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +--echo + +# Reload slave shouldn't change slave_heartbeat_period +--echo *** Reload slave *** +--connection slave +--disable_warnings +SET @@global.slave_net_timeout=50; +--enable_warnings +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=30; +--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +wait +EOF +--echo Reload slave +--shutdown_server 10 +--source include/wait_until_disconnected.inc +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +restart +EOF +--enable_reconnect +--source include/wait_until_connected_again.inc +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +SET @restore_slave_net_timeout=@@global.slave_net_timeout; +--echo + +# Disable heartbeat +--echo *** Disable heartbeat *** +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +SHOW STATUS LIKE 'slave_received_heartbeats'; +--source include/start_slave.inc +--sync_with_master +--sleep 2 +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +SHOW STATUS LIKE 'slave_received_heartbeats'; +--source include/stop_slave.inc +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +SHOW STATUS LIKE 'slave_received_heartbeats'; +RESET SLAVE; +let $slave_heartbeat_timeout= query_get_value(SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period', Value, 1); +--replace_result $slave_heartbeat_timeout SLAVE_HEARTBEAT_TIMEOUT +--eval SELECT $slave_heartbeat_timeout = 0 AS Result +--echo + +# +# Check limits for slave_heartbeat_timeout +# + +--echo *** Min slave_heartbeat_timeout *** +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.001; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +RESET SLAVE; +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.0009; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +RESET SLAVE; +--echo + +--echo *** Max slave_heartbeat_timeout *** +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=4294967; +SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period'; +RESET SLAVE; +--replace_result $MASTER_MYPORT MASTER_PORT +--error ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=4294968; +RESET SLAVE; +# Check double size of max allowed value for master_heartbeat_period +--replace_result $MASTER_MYPORT MASTER_PORT +--error ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=8589935; +RESET SLAVE; +# Check 2^32 +--replace_result $MASTER_MYPORT MASTER_PORT +--error ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=4294967296; +RESET SLAVE; +--echo + +--echo *** Misc incorrect values *** +--replace_result $MASTER_MYPORT MASTER_PORT +--error ER_PARSE_ERROR +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD='-1'; +RESET SLAVE; +--replace_result $MASTER_MYPORT MASTER_PORT +--error ER_PARSE_ERROR +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD='123abc'; +RESET SLAVE; +--replace_result $MASTER_MYPORT MASTER_PORT +--error ER_PARSE_ERROR +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=''; +RESET SLAVE; +--echo + +# +# Testing heartbeat +# + +# Check received heartbeat events for running slave +--echo *** Running slave *** +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1; +--source include/start_slave.inc +--sync_with_master +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 received +--echo + +# Check received heartbeat events for stopped slave +--echo *** Stopped slave *** +--source include/stop_slave.inc +let $rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +sleep 2; +let $rcvd_heartbeats_after= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +let $result= query_get_value(SELECT ($rcvd_heartbeats_after - $rcvd_heartbeats_before) AS Result, Result, 1); +--echo Number of received heartbeat events while slave stopped: $result +--echo + +# Check received heartbeat events for started slave +--echo *** Started slave *** +--source include/start_slave.inc +let $status_var_value= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +--source include/wait_for_status_var.inc +--echo Heartbeat event received +--echo + +# Check received heartbeat events for stopped IO thread +--echo *** Stopped IO thread *** +STOP SLAVE IO_THREAD; +--source include/wait_for_slave_io_to_stop.inc +let $rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +sleep 2; +let $rcvd_heartbeats_after= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +let $result= query_get_value(SELECT ($rcvd_heartbeats_after - $rcvd_heartbeats_before) AS Result, Result, 1); +--echo Number of received heartbeat events while io thread stopped: $result +--echo + +# Check received heartbeat events for started IO thread +--echo *** Started IO thread *** +START SLAVE IO_THREAD; +--source include/wait_for_slave_io_to_start.inc +let $status_var_value= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +--source include/wait_for_status_var.inc +--echo Heartbeat event received +--echo + +# Check received heartbeat events for stopped SQL thread +--echo *** Stopped SQL thread *** +STOP SLAVE SQL_THREAD; +--source include/wait_for_slave_sql_to_stop.inc +let $rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +sleep 2; +let $rcvd_heartbeats_after= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +let $result= query_get_value(SELECT ($rcvd_heartbeats_after - $rcvd_heartbeats_before) > 0 AS Result, Result, 1); +--echo Heartbeat events are received while sql thread stopped (1 means 'yes'): $result +--echo + +# Check received heartbeat events for started SQL thread +--echo *** Started SQL thread *** +START SLAVE SQL_THREAD; +--source include/wait_for_slave_sql_to_start.inc +let $status_var_value= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +--source include/wait_for_status_var.inc +--echo Heartbeat event received +--echo + +# Check received heartbeat event for stopped SQL thread by error +--echo *** Stopped SQL thread by error *** +--connection master +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10), c LONGTEXT); +--sync_slave_with_master +INSERT INTO t1 VALUES (1, 'on slave', NULL); +--connection master +INSERT INTO t1 VALUES (1, 'on master', NULL); +--connection slave +let $slave_errno= ER_DUP_ENTRY +--source include/wait_for_slave_sql_error.inc +let $rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +sleep 2; +let $rcvd_heartbeats_after= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +let $result= query_get_value(SELECT ($rcvd_heartbeats_after - $rcvd_heartbeats_before) > 0 AS Result, Result, 1); +--echo Heartbeat events are received while sql thread stopped (1 means 'yes'): $result +--source include/stop_slave.inc +DROP TABLE t1; +--echo + +# Check received heartbeat events while master send events to slave +--echo *** Master send to slave *** +--connection master +# Create the event that will update table t1 every second +DELIMITER |; +CREATE EVENT e1 + ON SCHEDULE EVERY 1 SECOND + DO + BEGIN + UPDATE test.t1 SET a = a + 1 WHERE a < 10; + END| +DELIMITER ;| +--connection slave +RESET SLAVE; +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=1.5; +--source include/start_slave.inc +--connection master +# Enable scheduler +SET @@global.event_scheduler=1; +--connection slave +SHOW STATUS LIKE 'slave_received_heartbeats'; +--sync_with_master +# Wait some updates for table t1 from master +let $wait_condition= SELECT COUNT(*)=1 FROM t1 WHERE a > 5; +--source include/wait_condition.inc +SHOW STATUS LIKE 'slave_received_heartbeats'; +--connection master +DELETE FROM t1; +DROP EVENT e1; +--echo + +# Check received heartbeat events while logs flushed on slave +--connection slave +--echo *** Flush logs on slave *** +STOP SLAVE; +RESET SLAVE; +DROP TABLE t1; +--connection master +DROP TABLE t1; +RESET MASTER; +--connection slave +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.5; +let $slave_param_comparison= =; +--source include/start_slave.inc +let $rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +# Flush logs every 0.1 second during 5 sec +--disable_query_log +let $i=50; +while ($i) { + FLUSH LOGS; + dec $i; + sleep 0.1; +} +--enable_query_log +let $rcvd_heartbeats_after= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +let $result= query_get_value(SELECT ($rcvd_heartbeats_after - $rcvd_heartbeats_before) > 0 AS Result, Result, 1); +--echo Heartbeat events are received while rotation of relay logs (1 means 'yes'): $result +--echo + +# Use compressed protocol between master and slave +--echo *** Compressed protocol *** +--connection master +SET @@global.slave_compressed_protocol=1; +--connection slave +--source include/stop_slave.inc +RESET SLAVE; +SET @@global.slave_compressed_protocol=1; +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1; +--source include/start_slave.inc +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 received +SET @@global.slave_compressed_protocol=0; +--connection master +SET @@global.slave_compressed_protocol=0; +--echo + + +# Check received heartbeat events after reset of master +--echo *** Reset master *** +--connection slave +STOP SLAVE; +RESET SLAVE; +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1; +--source include/start_slave.inc +let $rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +--connection master +RESET MASTER; +--enable_query_log +--sync_slave_with_master +--sleep 2 +let $rcvd_heartbeats_after= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +let $result= query_get_value(SELECT ($rcvd_heartbeats_after - $rcvd_heartbeats_before) > 0 AS Result, Result, 1); +--echo Heartbeat events are received after reset of master (1 means 'yes'): $result +--echo + +# Reloaded master should restore heartbeat +--echo *** Reload master *** +--connection slave +STOP SLAVE; +RESET SLAVE; +--replace_result $MASTER_MYPORT MASTER_PORT +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1; +--source include/start_slave.inc +# Wait until slave_received_heartbeats will be incremented +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 received +--connection master +--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +wait +EOF +--echo Reload master +--shutdown_server 10 +--source include/wait_until_disconnected.inc +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +restart +EOF +--enable_reconnect +--source include/wait_until_connected_again.inc +--connection slave +# Wait until slave_received_heartbeats will be incremented +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 received +--echo + +# Circular replication +--echo *** Circular replication *** +# Configure circular replication +--connection master +RESET MASTER; +let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1); +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10)); +--sync_slave_with_master +--source include/stop_slave.inc +RESET MASTER; +let $slave_binlog= query_get_value(SHOW MASTER STATUS, File, 1); +RESET SLAVE; +--replace_result $MASTER_MYPORT MASTER_PORT $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'; +--connection master +RESET SLAVE; +--replace_result $SLAVE_MYPORT SLAVE_PORT $slave_binlog SLAVE_BINLOG +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$SLAVE_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=1, MASTER_LOG_FILE='$slave_binlog'; +--source include/start_slave.inc +# Insert data on master and on slave and make sure that it replicated for both directions +INSERT INTO t1 VALUES(1, 'on master'); +--save_master_pos +--connection slave +--source include/start_slave.inc +--sync_with_master +INSERT INTO t1 VALUES(2, 'on slave'); +--save_master_pos +--connection master +--sync_with_master +SELECT * FROM t1 ORDER BY a; +let $master_rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +--connection slave +SELECT * FROM t1 ORDER BY a; +# Wait heartbeat event on master +--connection master +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 Heartbeat event received on master +let $master_rcvd_heartbeats= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +# Wait heartbeat event on slave +--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 Heartbeat event received on slave +let $slave_rcvd_heartbeats= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1); +# Heartbeat period on slave less than on master therefore number of received events on slave +# should be greater than on master +let $result= query_get_value(SELECT ($slave_rcvd_heartbeats DIV $master_rcvd_heartbeats) > 1 AS Result, Result, 1); +--echo Slave has received more events than master (1 means 'yes'): $result +--echo + +# +# Clean up and restore system variables +# +--echo *** Clean up *** +--connection master +--source include/stop_slave.inc +DROP TABLE t1; +--sync_slave_with_master +--source include/stop_slave.inc +SET @@global.slave_net_timeout=@restore_slave_net_timeout; +--echo + +# End of 6.0 test +--echo End of 6.0 test diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat_ssl.test b/mysql-test/suite/rpl/t/rpl_heartbeat_ssl.test new file mode 100644 index 00000000000..6460b157b52 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_heartbeat_ssl.test @@ -0,0 +1,54 @@ +############################################################# +# 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 |