1 start_server
{tags
{"repl"}} {
3 test
{First server should have role slave
after SLAVEOF
} {
4 r
-1 slaveof
[srv
0 host
] [srv
0 port
]
9 test
{BRPOPLPUSH replication
, when blocking against empty
list} {
10 set rd
[redis_deferring_client
]
13 wait_for_condition
50 100 {
14 [r debug digest
] eq
[r
-1 debug digest
]
16 fail
"Master and slave have different digest: [r debug digest] VS [r -1 debug digest]"
20 test
{BRPOPLPUSH replication
, list exists
} {
21 set rd
[redis_deferring_client
]
27 assert_equal
[r debug digest
] [r
-1 debug digest
]
32 start_server
{tags
{"repl"}} {
36 test
{Second server should have role master at first
} {
40 test
{SLAVEOF should start with link status
"down"} {
41 r slaveof
[srv
-1 host
] [srv
-1 port
]
45 test
{The role should immediately be changed to
"slave"} {
50 test
{Sync should have transferred keys from master
} {
54 test
{The link status should be up
} {
58 test
{SET on the master should immediately propagate
} {
60 if {$::valgrind} {after 2000}
64 test
{FLUSHALL should replicate
} {
66 if {$::valgrind} {after 2000}
67 list [r
-1 dbsize
] [r
0 dbsize
]
72 proc start_write_load
{host port seconds
} {
73 exec tclsh8.5 tests
/helpers
/gen_write_load.tcl
$host $port $seconds &
76 proc stop_write_load
{handle
} {
77 catch {exec /bin
/kill
-9 $handle}
80 start_server
{tags
{"repl"}} {
81 set master
[srv
0 client
]
82 set master_host
[srv
0 host
]
83 set master_port
[srv
0 port
]
85 set load_handle0
[start_write_load
$master_host $master_port 3]
86 set load_handle1
[start_write_load
$master_host $master_port 5]
87 set load_handle2
[start_write_load
$master_host $master_port 20]
88 set load_handle3
[start_write_load
$master_host $master_port 8]
89 set load_handle4
[start_write_load
$master_host $master_port 4]
91 lappend slaves
[srv
0 client
]
93 lappend slaves
[srv
0 client
]
95 lappend slaves
[srv
0 client
]
96 test
"Connect multiple slaves at the same time (issue #141)" {
97 # Send SALVEOF commands to slaves
98 [lindex $slaves 0] slaveof
$master_host $master_port
99 [lindex $slaves 1] slaveof
$master_host $master_port
100 [lindex $slaves 2] slaveof
$master_host $master_port
102 # Wait for all the three slaves to reach the "online" state
106 if {[string match
{*slave0
:*,online
*slave1
:*,online
*slave2
:*,online
*} $info]} {
114 error "assertion:Slaves not correctly synchronized"
117 # Stop the write load
118 stop_write_load
$load_handle0
119 stop_write_load
$load_handle1
120 stop_write_load
$load_handle2
121 stop_write_load
$load_handle3
122 stop_write_load
$load_handle4
124 # Wait that slaves exit the "loading" state
125 wait_for_condition
500 100 {
126 ![string match
{*loading
:1*} [[lindex $slaves 0] info]] &&
127 ![string match
{*loading
:1*} [[lindex $slaves 1] info]] &&
128 ![string match
{*loading
:1*} [[lindex $slaves 2] info]]
130 fail
"Slaves still loading data after too much time"
133 # Make sure that slaves and master have same number of keys
134 wait_for_condition
500 100 {
135 [$master dbsize
] == [[lindex $slaves 0] dbsize
] &&
136 [$master dbsize
] == [[lindex $slaves 1] dbsize
] &&
137 [$master dbsize
] == [[lindex $slaves 2] dbsize
]
139 fail
"Different number of keys between masted and slave after too long time."
143 set digest
[$master debug digest
]
144 set digest0
[[lindex $slaves 0] debug digest
]
145 set digest1
[[lindex $slaves 1] debug digest
]
146 set digest2
[[lindex $slaves 2] debug digest
]
147 assert
{$digest ne
0000000000000000000000000000000000000000}
148 assert
{$digest eq
$digest0}
149 assert
{$digest eq
$digest1}
150 assert
{$digest eq
$digest2}