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
9e34e296
Commit
9e34e296
authored
Feb 25, 2014
by
antirez
Browse files
Sentinel test: kill masters instead of using DEBUG SLEEP in all tests.
parent
dfacfafc
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/sentinel-tests/00-base.tcl
View file @
9e34e296
...
...
@@ -6,7 +6,7 @@ test "Basic failover works if the master is down" {
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
}
R $master_id debug sleep 10
kill_instance redis $master_id
foreach_sentinel_id id
{
wait_for_condition 100 50
{
[
lindex
[
S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster
]
1
]
!= $old_port
...
...
@@ -14,6 +14,7 @@ test "Basic failover works if the master is down" {
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
]]
}
...
...
@@ -49,11 +50,12 @@ test "ODOWN is not possible without N (quorum) Sentinels reports" {
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
}
R $master_id debug sleep 10
kill_instance redis $master_id
# Make sure failover did not happened.
set addr
[
S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster
]
assert
{[
lindex $addr 1
]
== $old_port
}
restart_instance redis $master_id
}
test
"Failover is not possible without majority agreement"
{
...
...
@@ -66,11 +68,13 @@ test "Failover is not possible without majority agreement" {
kill_instance sentinel $id
}
R $master_id debug sleep 10
# Kill the current master
kill_instance redis $master_id
# Make sure failover did not happened.
set addr
[
S $quorum SENTINEL GET-MASTER-ADDR-BY-NAME mymaster
]
assert
{[
lindex $addr 1
]
== $old_port
}
restart_instance redis $master_id
# Cleanup: restart Sentinels to monitor the master.
for
{
set id 0
}
{
$id
< $quorum
}
{
incr id
}
{
...
...
@@ -92,7 +96,8 @@ test "Failover works if we configure for absolute agreement" {
}
}
R $master_id debug sleep 10
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
...
...
@@ -100,6 +105,7 @@ test "Failover works if we configure for absolute agreement" {
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
]]
...
...
tests/sentinel-tests/01-conf-update.tcl
View file @
9e34e296
...
...
@@ -10,7 +10,7 @@ test "We can failover with Sentinel 1 crashed" {
# Crash Sentinel 1
kill_instance sentinel 1
R $master_id debug sleep 10
kill_instance redis $master_id
foreach_sentinel_id id
{
if
{
$id
!= 1
}
{
wait_for_condition 1000 50
{
...
...
@@ -20,6 +20,7 @@ test "We can failover with Sentinel 1 crashed" {
}
}
}
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
]]
}
...
...
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