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
f33d4a6c
Commit
f33d4a6c
authored
Mar 03, 2014
by
antirez
Browse files
Sentinel test: initial tests in 03 unit.
parent
c2d99d49
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/sentinel-tests/02-slaves-reconf.tcl
View file @
f33d4a6c
...
@@ -4,3 +4,42 @@
...
@@ -4,3 +4,42 @@
# 1
)
That slaves point to the new master after failover.
# 1
)
That slaves point to the new master after failover.
# 2
)
That partitioned slaves point to new master when they are partitioned
# 2
)
That partitioned slaves point to new master when they are partitioned
# away during failover and return at a latter time.
# away during failover and return at a latter time.
source
"../sentinel-tests/includes/init-tests.tcl"
proc 03_test_slaves_replication
{}
{
uplevel 1
{
test
"Check that slaves replicate from current master"
{
set master_port
[
RI $master_id tcp_port
]
foreach_redis_id id
{
if
{
$id
== $master_id
}
continue
wait_for_condition 1000 50
{
[
RI $id master_port
]
== $master_port
}
else
{
fail
"Redis slave
$id
is replicating from wrong master"
}
}
}
}
}
03_test_slaves_replication
test
"Crash the master and force a failover"
{
set old_port
[
RI $master_id tcp_port
]
set addr
[
S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster
]
assert
{[
lindex $addr 1
]
== $old_port
}
kill_instance redis $master_id
foreach_sentinel_id id
{
wait_for_condition 1000 50
{
[
lindex
[
S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster
]
1
]
!= $old_port
}
else
{
fail
"At least one Sentinel did not received failover info"
}
}
restart_instance redis $master_id
set addr
[
S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster
]
set master_id
[
get_instance_id_by_port redis
[
lindex $addr 1
]]
}
03_test_slaves_replication
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