summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-03-27 12:10:46 +0100
committerantirez <antirez@gmail.com>2015-03-27 12:10:46 +0100
commit37260bc3bed5fb46649262789c65089ab7de0dc6 (patch)
tree07954b65967e5ead04843d0c02aa4e29865831f2
parent068d3c9737b368f921808e753f6f000a12ca5ae8 (diff)
downloadredis-37260bc3bed5fb46649262789c65089ab7de0dc6.tar.gz
Test: regression for issue #2473.
-rw-r--r--tests/integration/replication.tcl52
1 files changed, 44 insertions, 8 deletions
diff --git a/tests/integration/replication.tcl b/tests/integration/replication.tcl
index 71a7ec60a..bb907eba8 100644
--- a/tests/integration/replication.tcl
+++ b/tests/integration/replication.tcl
@@ -1,10 +1,17 @@
start_server {tags {"repl"}} {
+ set A [srv 0 client]
+ set A_host [srv 0 host]
+ set A_port [srv 0 port]
start_server {} {
- test {First server should have role slave after SLAVEOF} {
- r -1 slaveof [srv 0 host] [srv 0 port]
+ set B [srv 0 client]
+ set B_host [srv 0 host]
+ set B_port [srv 0 port]
+
+ test {Set instance A as slave of B} {
+ $A slaveof $B_host $B_port
wait_for_condition 50 100 {
- [s -1 role] eq {slave} &&
- [string match {*master_link_status:up*} [r -1 info replication]]
+ [lindex [$A role] 0] eq {slave} &&
+ [string match {*master_link_status:up*} [$A info replication]]
} else {
fail "Can't turn the instance into a slave"
}
@@ -15,9 +22,9 @@ start_server {tags {"repl"}} {
$rd brpoplpush a b 5
r lpush a foo
wait_for_condition 50 100 {
- [r debug digest] eq [r -1 debug digest]
+ [$A debug digest] eq [$B debug digest]
} else {
- fail "Master and slave have different digest: [r debug digest] VS [r -1 debug digest]"
+ fail "Master and slave have different digest: [$A debug digest] VS [$B debug digest]"
}
}
@@ -28,7 +35,36 @@ start_server {tags {"repl"}} {
r lpush c 3
$rd brpoplpush c d 5
after 1000
- assert_equal [r debug digest] [r -1 debug digest]
+ assert_equal [$A debug digest] [$B debug digest]
+ }
+
+ test {BLPOP followed by role change, issue #2473} {
+ set rd [redis_deferring_client]
+ $rd blpop foo 0 ; # Block while B is a master
+
+ # Turn B into master of A
+ $A slaveof no one
+ $B slaveof $A_host $A_port
+ wait_for_condition 50 100 {
+ [lindex [$B role] 0] eq {slave} &&
+ [string match {*master_link_status:up*} [$B info replication]]
+ } else {
+ fail "Can't turn the instance into a slave"
+ }
+
+ # Push elements into the "foo" list of the new slave.
+ # If the client is still attached to the instance, we'll get
+ # a desync between the two instances.
+ $A rpush foo a b c
+ after 100
+
+ wait_for_condition 50 100 {
+ [$A debug digest] eq [$B debug digest] &&
+ [$A lrange foo 0 -1] eq {a b c} &&
+ [$B lrange foo 0 -1] eq {a b c}
+ } else {
+ fail "Master and slave have different digest: [$A debug digest] VS [$B debug digest]"
+ }
}
}
}
@@ -113,7 +149,7 @@ foreach dl {no yes} {
start_server {} {
lappend slaves [srv 0 client]
test "Connect multiple slaves at the same time (issue #141), diskless=$dl" {
- # Send SALVEOF commands to slaves
+ # Send SLAVEOF commands to slaves
[lindex $slaves 0] slaveof $master_host $master_port
[lindex $slaves 1] slaveof $master_host $master_port
[lindex $slaves 2] slaveof $master_host $master_port