Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
37260bc3
Commit
37260bc3
authored
Mar 27, 2015
by
antirez
Browse files
Test: regression for issue #2473.
parent
068d3c97
Changes
1
Show whitespace changes
Inline
Side-by-side
tests/integration/replication.tcl
View file @
37260bc3
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 S
A
LVEOF commands to slaves
# Send SL
A
VEOF 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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment