summaryrefslogtreecommitdiff
path: root/tests/sentinel/tests
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-06-23 14:04:09 +0200
committerantirez <antirez@gmail.com>2014-06-23 14:07:47 +0200
commite21e0ba3dcd67d9048ecea9be5398b2a791e7bc5 (patch)
tree7b000ed73e76c72e68ee052c3c00a088bb462fe2 /tests/sentinel/tests
parente3bae84606389dadaff03c495d4ec37c306af3a1 (diff)
downloadredis-e21e0ba3dcd67d9048ecea9be5398b2a791e7bc5.tar.gz
Sentinel test: more correct sentinels config reset.
In the initialization test for each instance we used to unregister the old master and register it again to clear the config. However there is a race condition doing this: as soon as we unregister and re-register "mymaster", another Sentinel can update the new configuration with the old state because of gossip "hello" messages. So the correct procedure is instead, unregister "mymaster" from all the sentinel instances, and re-register it everywhere again.
Diffstat (limited to 'tests/sentinel/tests')
-rw-r--r--tests/sentinel/tests/includes/init-tests.tcl7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/sentinel/tests/includes/init-tests.tcl b/tests/sentinel/tests/includes/init-tests.tcl
index c48fb5379..c8165dcfa 100644
--- a/tests/sentinel/tests/includes/init-tests.tcl
+++ b/tests/sentinel/tests/includes/init-tests.tcl
@@ -12,6 +12,12 @@ test "(init) Restart killed instances" {
}
}
+test "(init) Remove old master entry from sentinels" {
+ foreach_sentinel_id id {
+ catch {S $id SENTINEL REMOVE mymaster}
+ }
+}
+
set redis_slaves 4
test "(init) Create a master-slaves cluster of [expr $redis_slaves+1] instances" {
create_redis_master_slave_cluster [expr {$redis_slaves+1}]
@@ -22,7 +28,6 @@ test "(init) Sentinels can start monitoring a master" {
set sentinels [llength $::sentinel_instances]
set quorum [expr {$sentinels/2+1}]
foreach_sentinel_id id {
- catch {S $id SENTINEL REMOVE mymaster}
S $id SENTINEL MONITOR mymaster \
[get_instance_attrib redis $master_id host] \
[get_instance_attrib redis $master_id port] $quorum