diff options
author | antirez <antirez@gmail.com> | 2013-05-30 18:54:28 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-05-30 18:54:39 +0200 |
commit | 9a7ea3dae9d3249ceea9204a62775ae3d428f42b (patch) | |
tree | b558de205fb379a7b2cf3d9136d28afcf1a2ed4d /tests | |
parent | 4333e6ce201a137da667133434cdbb4db5dcbfd0 (diff) | |
download | redis-9a7ea3dae9d3249ceea9204a62775ae3d428f42b.tar.gz |
Tests added for min-slaves feature.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/replication-4.tcl | 42 | ||||
-rw-r--r-- | tests/support/redis.tcl | 4 |
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/integration/replication-4.tcl b/tests/integration/replication-4.tcl index 29ab48fc2..7a3b0822f 100644 --- a/tests/integration/replication-4.tcl +++ b/tests/integration/replication-4.tcl @@ -54,3 +54,45 @@ start_server {tags {"repl"}} { } } } + +start_server {tags {"repl"}} { + start_server {} { + set master [srv -1 client] + set master_host [srv -1 host] + set master_port [srv -1 port] + set slave [srv 0 client] + + test {First server should have role slave after SLAVEOF} { + $slave slaveof $master_host $master_port + wait_for_condition 50 100 { + [s 0 master_link_status] eq {up} + } else { + fail "Replication not started." + } + } + + test {With min-slaves-to-write (1,3): master should be writable} { + $master config set min-slaves-max-lag 3 + $master config set min-slaves-to-write 1 + $master set foo bar + } {OK} + + test {With min-slaves-to-write (2,3): master should not be writable} { + $master config set min-slaves-max-lag 3 + $master config set min-slaves-to-write 2 + catch {$master set foo bar} e + set e + } {NOREPLICAS*} + + test {With min-slaves-to-write: master not writable with lagged slave} { + $master config set min-slaves-max-lag 2 + $master config set min-slaves-to-write 1 + assert {[$master set foo bar] eq {OK}} + $slave deferred 1 + $slave debug sleep 4 + after 3000 + catch {$master set foo bar} e + set e + } {NOREPLICAS*} + } +} diff --git a/tests/support/redis.tcl b/tests/support/redis.tcl index 99415b640..36b005a17 100644 --- a/tests/support/redis.tcl +++ b/tests/support/redis.tcl @@ -115,6 +115,10 @@ proc ::redis::__method__channel {id fd} { return $fd } +proc ::redis::__method__deferred {id fd val} { + set ::redis::deferred($id) $val +} + proc ::redis::redis_write {fd buf} { puts -nonewline $fd $buf } |