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 20]
86 set load_handle1
[start_write_load
$master_host $master_port 20]
87 set load_handle2
[start_write_load
$master_host $master_port 20]
88 set load_handle3
[start_write_load
$master_host $master_port 20]
89 set load_handle4
[start_write_load
$master_host $master_port 20]
92 lappend slaves
[srv
0 client
]
94 lappend slaves
[srv
0 client
]
96 lappend slaves
[srv
0 client
]
97 test
"Connect multiple slaves at the same time (issue #141)" {
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"
116 stop_write_load
$load_handle0
117 stop_write_load
$load_handle1
118 stop_write_load
$load_handle2
119 stop_write_load
$load_handle3
120 stop_write_load
$load_handle4
122 while {$retry && ([$master debug digest
] ne
[[lindex $slaves 0] debug digest
])} {
126 set digest
[$master debug digest
]
127 set digest0
[[lindex $slaves 0] debug digest
]
128 set digest1
[[lindex $slaves 1] debug digest
]
129 set digest2
[[lindex $slaves 2] debug digest
]
130 assert
{$digest ne
0000000000000000000000000000000000000000}
131 assert
{$digest eq
$digest0}
132 assert
{$digest eq
$digest1}
133 assert
{$digest eq
$digest2}
134 #puts [$master dbsize]
135 #puts [[lindex $slaves 0] dbsize]
136 #puts [[lindex $slaves 1] dbsize]
137 #puts [[lindex $slaves 2] dbsize]