X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/0681c5ad844cefefbe62f30df6587c0cbec3272e..18aa2b87b6db7fa79b0596590aa385adcbc64e53:/tests/integration/replication.tcl?ds=inline diff --git a/tests/integration/replication.tcl b/tests/integration/replication.tcl index 0a1cd409..2c7d98de 100644 --- a/tests/integration/replication.tcl +++ b/tests/integration/replication.tcl @@ -57,5 +57,83 @@ start_server {tags {"repl"}} { if {$::valgrind} {after 2000} r 0 get mykey } {bar} + + test {FLUSHALL should replicate} { + r -1 flushall + if {$::valgrind} {after 2000} + list [r -1 dbsize] [r 0 dbsize] + } {0 0} + } +} + +proc start_write_load {host port seconds} { + exec tclsh8.5 tests/helpers/gen_write_load.tcl $host $port $seconds & +} + +proc stop_write_load {handle} { + catch {exec /bin/kill -9 $handle} +} + +start_server {tags {"repl"}} { + set master [srv 0 client] + set master_host [srv 0 host] + set master_port [srv 0 port] + set slaves {} + set load_handle0 [start_write_load $master_host $master_port 20] + set load_handle1 [start_write_load $master_host $master_port 20] + set load_handle2 [start_write_load $master_host $master_port 20] + set load_handle3 [start_write_load $master_host $master_port 20] + set load_handle4 [start_write_load $master_host $master_port 20] + after 2000 + start_server {} { + lappend slaves [srv 0 client] + start_server {} { + lappend slaves [srv 0 client] + start_server {} { + lappend slaves [srv 0 client] + test "Connect multiple slaves at the same time (issue #141)" { + [lindex $slaves 0] slaveof $master_host $master_port + [lindex $slaves 1] slaveof $master_host $master_port + [lindex $slaves 2] slaveof $master_host $master_port + + # Wait for all the three slaves to reach the "online" state + set retry 100 + while {$retry} { + set info [r -3 info] + if {[string match {*slave0:*,online*slave1:*,online*slave2:*,online*} $info]} { + break + } else { + incr retry -1 + after 100 + } + } + if {$retry == 0} { + error "assertion:Slaves not correctly synchronized" + } + stop_write_load $load_handle0 + stop_write_load $load_handle1 + stop_write_load $load_handle2 + stop_write_load $load_handle3 + stop_write_load $load_handle4 + set retry 10 + while {$retry && ([$master debug digest] ne [[lindex $slaves 0] debug digest])} { + after 1000 + incr retry -1 + } + set digest [$master debug digest] + set digest0 [[lindex $slaves 0] debug digest] + set digest1 [[lindex $slaves 1] debug digest] + set digest2 [[lindex $slaves 2] debug digest] + assert {$digest ne 0000000000000000000000000000000000000000} + assert {$digest eq $digest0} + assert {$digest eq $digest1} + assert {$digest eq $digest2} + #puts [$master dbsize] + #puts [[lindex $slaves 0] dbsize] + #puts [[lindex $slaves 1] dbsize] + #puts [[lindex $slaves 2] dbsize] + } + } + } } }