From dbfc6cc63cf7ca96943eaa07a038526feb7e3cec Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 17 Aug 2022 15:09:34 +0200 Subject: [PATCH] Stabilize the sentinel suite --- test/sentinel/sentinel_command_test.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/sentinel/sentinel_command_test.rb b/test/sentinel/sentinel_command_test.rb index bf6372d89..e3d106932 100644 --- a/test/sentinel/sentinel_command_test.rb +++ b/test/sentinel/sentinel_command_test.rb @@ -7,6 +7,8 @@ class SentinelCommandsTest < Minitest::Test include Helper::Sentinel def test_sentinel_command_master + wait_for_quorum + redis = build_sentinel_client result = redis.sentinel('master', MASTER_NAME) @@ -33,6 +35,8 @@ def test_sentinel_command_slaves end def test_sentinel_command_sentinels + wait_for_quorum + redis = build_sentinel_client result = redis.sentinel('sentinels', MASTER_NAME) @@ -51,9 +55,25 @@ def test_sentinel_command_get_master_by_name end def test_sentinel_command_ckquorum + wait_for_quorum redis = build_sentinel_client result = redis.sentinel('ckquorum', MASTER_NAME) + assert_equal result, 'OK X usable Sentinels. Quorum and failover authorization can be reached' + end - assert_equal result, 'OK 3 usable Sentinels. Quorum and failover authorization can be reached' + private + + def wait_for_quorum + redis = build_sentinel_client + 50.times do + if redis.sentinel('ckquorum', MASTER_NAME).start_with?('OK 3 usable Sentinels') + return + else + sleep 0.1 + end + rescue + sleep 0.1 + end + raise "ckquorum timeout" end end