~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/t/rpl_heartbeat.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Testing master to slave heartbeat protocol
 
2
 
3
# Including:
 
4
# - user interface, grammar, checking the range and warnings about 
 
5
#   unreasonable values for the heartbeat period;
 
6
# - no rotation of relay log if heartbeat is less that slave_net_timeout
 
7
# - SHOW STATUS like 'Slave_received_heartbeats' action
 
8
# - SHOW STATUS like 'Slave_heartbeat_period' report
 
9
 
 
10
-- source include/have_log_bin.inc
 
11
 
 
12
connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
 
13
connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK);
 
14
 
 
15
connection master;
 
16
reset master;
 
17
 
 
18
connection slave;
 
19
 
 
20
# there can be a warning if mtr set the global init value bigger than
 
21
# the following assignment. The warning is a grace for the user
 
22
# to warn her that the new value of the global var is bigger than
 
23
# the current value of the hb period, i.e the sanity condition
 
24
# 0 < hb < slave_net_timeout does not hold.
 
25
# The warning has to be disabled as mtr can change the init value
 
26
# for slave_net_timeout
 
27
--disable_warnings
 
28
set @@global.slave_net_timeout= 10;
 
29
--enable_warnings
 
30
###
 
31
### Checking the range
 
32
###
 
33
 
 
34
#
 
35
# default period slave_net_timeout/2
 
36
#
 
37
--replace_result $MASTER_MYPORT MASTER_PORT
 
38
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
 
39
--query_vertical show status like 'Slave_heartbeat_period';
 
40
 
 
41
#
 
42
# the max for the period is ULONG_MAX/1000; an attempt to exceed it is  denied
 
43
#
 
44
--replace_result $MASTER_MYPORT MASTER_PORT
 
45
--error ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE
 
46
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 4294968;
 
47
--query_vertical show status like 'Slave_heartbeat_period';
 
48
 
 
49
#
 
50
# the min value for the period is 1 millisecond an attempt to assign a
 
51
# lesser will be warned with treating the value as zero
 
52
#
 
53
connection slave;
 
54
--replace_result $MASTER_MYPORT MASTER_PORT
 
55
#--warning ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE
 
56
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 0.0009999;
 
57
--query_vertical show status like 'Slave_heartbeat_period';
 
58
 
 
59
#
 
60
# the actual max and min must be accepted
 
61
#
 
62
--replace_result $MASTER_MYPORT MASTER_PORT
 
63
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 4294967;
 
64
--query_vertical show status like 'Slave_heartbeat_period';
 
65
 
 
66
--replace_result $MASTER_MYPORT MASTER_PORT
 
67
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 0.001;
 
68
--query_vertical show status like 'Slave_heartbeat_period';
 
69
 
 
70
reset slave;
 
71
 
 
72
#
 
73
# A warning if period greater than slave_net_timeout
 
74
#
 
75
set @@global.slave_net_timeout= 5;
 
76
--replace_result $MASTER_MYPORT MASTER_PORT
 
77
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 5.001;
 
78
--query_vertical show status like 'Slave_heartbeat_period';
 
79
 
 
80
reset slave;
 
81
 
 
82
#
 
83
# A warning if slave_net_timeout is set to less than the current HB period
 
84
#
 
85
set @@global.slave_net_timeout= 5;
 
86
--replace_result $MASTER_MYPORT MASTER_PORT
 
87
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 4;
 
88
--query_vertical show status like 'Slave_heartbeat_period';
 
89
set @@global.slave_net_timeout= 3 /* must be a warning */;
 
90
 
 
91
reset slave;
 
92
 
 
93
 
 
94
###
 
95
### checking no rotation
 
96
###
 
97
 
 
98
connection master;
 
99
--disable_warnings
 
100
drop table if exists t1;
 
101
--enable_warnings
 
102
#
 
103
# Even though master_heartbeat_period= 0.5 is 20 times less than
 
104
# @@global.slave_net_timeout= 10 in some circumstances master will
 
105
# not be able to send any heartbeat during the slave's net timeout
 
106
# and slave's relay log will rotate.
 
107
# The probability for such a scenario is pretty small so the following
 
108
# part is almost deterministic.
 
109
#
 
110
 
 
111
connection slave;
 
112
set @@global.slave_net_timeout= 10;
 
113
--replace_result $MASTER_MYPORT MASTER_PORT
 
114
# no error this time but rather a warning
 
115
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 0.5;
 
116
--query_vertical show status like 'Slave_heartbeat_period';
 
117
 
 
118
start slave;
 
119
 
 
120
connection master;
 
121
create table t1 (f1 int);
 
122
 
 
123
#connection slave;
 
124
sync_slave_with_master;
 
125
source include/show_slave_status.inc;
 
126
 
 
127
# there is an explicit sleep lasting longer than slave_net_timeout
 
128
# to ensure that nothing will come to slave from master for that period.
 
129
# That would cause reconnecting and relaylog rotation w/o the fix i.e
 
130
# without a heartbeat received.
 
131
 
 
132
real_sleep 15;
 
133
 
 
134
# check (compare with the previous show's results) that no rotation happened
 
135
source include/show_slave_status.inc;
 
136
 
 
137
###
 
138
### SHOW STATUS like 'Slave_heartbeat_period' and 'Slave_received_heartbeats'
 
139
###
 
140
 
 
141
--query_vertical show status like 'Slave_heartbeat_period';
 
142
 
 
143
#
 
144
# proof that there has been received at least one heartbeat;
 
145
# The exact number of received heartbeat is an indeterministic value
 
146
# and therefore it's not recorded into results.
 
147
#
 
148
 
 
149
let $slave_wait_param_counter= 300;
 
150
let $slave_value= query_get_value("SHOW STATUS like 'Slave_received_heartbeats'", Value, 1);
 
151
# Checking the fact that at least one heartbeat is received
 
152
while (`select $slave_value = 0`)
 
153
{
 
154
  dec $slave_wait_param_counter;
 
155
  if (!$slave_wait_param_counter)
 
156
  {
 
157
    --echo ERROR: failed while waiting for slave parameter $slave_param: $slave_param_value
 
158
    query_vertical show slave status;
 
159
    SHOW STATUS like 'Slave_received_heartbeats';
 
160
    exit;
 
161
  }
 
162
  sleep 0.1;
 
163
  let $slave_value= query_get_value("SHOW STATUS like 'Slave_received_heartbeats'", Value, 1);
 
164
}
 
165
--echo A heartbeat has been received by the slave
 
166
# cleanup
 
167
 
 
168
connection master;
 
169
drop table t1;
 
170
 
 
171
#connection slave;
 
172
sync_slave_with_master;
 
173
 
 
174
 
 
175
--echo End of tests