From d3a3ef0bc1f993661de83bca07256902aff8ecab Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 24 Feb 2014 17:21:50 +0100 Subject: [PATCH] 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). --- tests/sentinel-tests/00-base.tcl | 21 --------------- tests/sentinel-tests/includes/init-tests.tcl | 27 +++++++++++++++++--- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/sentinel-tests/00-base.tcl b/tests/sentinel-tests/00-base.tcl index b8dfa70ca..d036922c9 100644 --- a/tests/sentinel-tests/00-base.tcl +++ b/tests/sentinel-tests/00-base.tcl @@ -2,27 +2,6 @@ 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" { set old_port [RI $master_id tcp_port] set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] diff --git a/tests/sentinel-tests/includes/init-tests.tcl b/tests/sentinel-tests/includes/init-tests.tcl index 82beeea4f..cea437a83 100644 --- a/tests/sentinel-tests/includes/init-tests.tcl +++ b/tests/sentinel-tests/includes/init-tests.tcl @@ -1,12 +1,12 @@ # Initialization tests -- most units will start including this. 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}] } 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 quorum [expr {$sentinels/2+1}] foreach_sentinel_id id { @@ -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 { wait_for_condition 100 50 { [catch {S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster}] == 0 @@ -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" + } + } +}