Commit d3a3ef0b authored by antirez's avatar antirez
Browse files

Sentinel test: more stuff mored from 00-base to init.

The area a number of mandatory tests to craete a stable setup for
testing that is not too sensitive to timing issues. All those tests
moved to includes/init-tests, and marked as (init).
parent b15411df
...@@ -2,27 +2,6 @@ ...@@ -2,27 +2,6 @@
source "../sentinel-tests/includes/init-tests.tcl" source "../sentinel-tests/includes/init-tests.tcl"
test "Sentinels are able to auto-discover other sentinels" {
set sentinels [llength $::sentinel_instances]
foreach_sentinel_id id {
wait_for_condition 100 50 {
[dict get [S $id SENTINEL MASTER mymaster] num-other-sentinels] == ($sentinels-1)
} else {
fail "At least some sentinel can't detect some other sentinel"
}
}
}
test "Sentinels are able to auto-discover slaves" {
foreach_sentinel_id id {
wait_for_condition 100 50 {
[dict get [S $id SENTINEL MASTER mymaster] num-slaves] == $redis_slaves
} else {
fail "At least some sentinel can't detect some slave"
}
}
}
test "Basic failover works if the master is down" { test "Basic failover works if the master is down" {
set old_port [RI $master_id tcp_port] set old_port [RI $master_id tcp_port]
set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster]
......
# Initialization tests -- most units will start including this. # Initialization tests -- most units will start including this.
set redis_slaves 4 set redis_slaves 4
test "Create a master-slaves cluster of [expr $redis_slaves+1] instances" { test "(init) Create a master-slaves cluster of [expr $redis_slaves+1] instances" {
create_redis_master_slave_cluster [expr {$redis_slaves+1}] create_redis_master_slave_cluster [expr {$redis_slaves+1}]
} }
set master_id 0 set master_id 0
test "Sentinels can start monitoring a master" { test "(init) Sentinels can start monitoring a master" {
set sentinels [llength $::sentinel_instances] set sentinels [llength $::sentinel_instances]
set quorum [expr {$sentinels/2+1}] set quorum [expr {$sentinels/2+1}]
foreach_sentinel_id id { foreach_sentinel_id id {
...@@ -21,7 +21,7 @@ test "Sentinels can start monitoring a master" { ...@@ -21,7 +21,7 @@ test "Sentinels can start monitoring a master" {
} }
} }
test "Sentinels can talk with the master" { test "(init) Sentinels can talk with the master" {
foreach_sentinel_id id { foreach_sentinel_id id {
wait_for_condition 100 50 { wait_for_condition 100 50 {
[catch {S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster}] == 0 [catch {S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster}] == 0
...@@ -30,3 +30,24 @@ test "Sentinels can talk with the master" { ...@@ -30,3 +30,24 @@ test "Sentinels can talk with the master" {
} }
} }
} }
test "(init) Sentinels are able to auto-discover other sentinels" {
set sentinels [llength $::sentinel_instances]
foreach_sentinel_id id {
wait_for_condition 100 50 {
[dict get [S $id SENTINEL MASTER mymaster] num-other-sentinels] == ($sentinels-1)
} else {
fail "At least some sentinel can't detect some other sentinel"
}
}
}
test "(init) Sentinels are able to auto-discover slaves" {
foreach_sentinel_id id {
wait_for_condition 100 50 {
[dict get [S $id SENTINEL MASTER mymaster] num-slaves] == $redis_slaves
} else {
fail "At least some sentinel can't detect some slave"
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment