From f32289c253b7029c89e1c162b61d05f5912c5309 Mon Sep 17 00:00:00 2001 From: Taishi Kasuga Date: Sun, 21 Jun 2020 20:24:41 +0900 Subject: [PATCH 1/5] Wait for ready to sentinel tests --- makefile | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/makefile b/makefile index 80fc6062e..e9ec2af9e 100644 --- a/makefile +++ b/makefile @@ -11,6 +11,7 @@ PORT := 6381 SLAVE_PORT := 6382 SLAVE_PID_PATH := ${BUILD_DIR}/redis_slave.pid SLAVE_SOCKET_PATH := ${BUILD_DIR}/redis_slave.sock +HA_GROUP_NAME := master1 SENTINEL_PORTS := 6400 6401 6402 SENTINEL_PID_PATHS := $(addprefix ${TMP}/redis,$(addsuffix .pid,${SENTINEL_PORTS})) CLUSTER_PORTS := 7000 7001 7002 7003 7004 7005 @@ -24,7 +25,7 @@ endef all: start_all test stop_all -start_all: start start_slave start_sentinel start_cluster create_cluster +start_all: start start_slave start_sentinel wait_for_sentinel start_cluster create_cluster stop_all: stop_sentinel stop_slave stop stop_cluster @@ -67,10 +68,10 @@ start_sentinel: ${BINARY} conf=${TMP}/sentinel$$port.conf;\ touch $$conf;\ echo '' > $$conf;\ - echo 'sentinel monitor master1 127.0.0.1 ${PORT} 2' >> $$conf;\ - echo 'sentinel down-after-milliseconds master1 5000' >> $$conf;\ - echo 'sentinel failover-timeout master1 30000' >> $$conf;\ - echo 'sentinel parallel-syncs master1 1' >> $$conf;\ + echo 'sentinel monitor ${HA_GROUP_NAME} 127.0.0.1 ${PORT} 2' >> $$conf;\ + echo 'sentinel down-after-milliseconds ${HA_GROUP_NAME} 5000' >> $$conf;\ + echo 'sentinel failover-timeout ${HA_GROUP_NAME} 30000' >> $$conf;\ + echo 'sentinel parallel-syncs ${HA_GROUP_NAME} 1' >> $$conf;\ ${BINARY} $$conf\ --daemonize yes\ --pidfile ${TMP}/redis$$port.pid\ @@ -78,6 +79,17 @@ start_sentinel: ${BINARY} --sentinel;\ done +wait_for_sentinel: + @for port in ${SENTINEL_PORTS}; do\ + while : ; do\ + if [ $$(${REDIS_CLIENT} -p $${port} SENTINEL SLAVES ${HA_GROUP_NAME} | wc -l) -gt 1 ]; then\ + break;\ + fi;\ + echo 'waiting for ready to sentinel tests...';\ + sleep 1;\ + done;\ + done + stop_cluster: @$(call kill-redis,${CLUSTER_PID_PATHS}) @rm -f appendonly.aof || true From 4373b2c095bfc89faad970aa36977ff1a8371442 Mon Sep 17 00:00:00 2001 From: Taishi Kasuga Date: Sun, 21 Jun 2020 20:30:10 +0900 Subject: [PATCH 2/5] Increase timeout sec for stability of blocking tests in JRuby --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 98bf21aa0..7a3793461 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -92,7 +92,7 @@ jobs: env: VERBOSE: true TIMEOUT: 30 - LOW_TIMEOUT: 0.07 + LOW_TIMEOUT: 0.14 DRIVER: ${{ matrix.driver }} REDIS_BRANCH: ${{ matrix.redis }} steps: From 4b9c3f47e6169436233be03d58fbc1c0fccc757e Mon Sep 17 00:00:00 2001 From: Taishi Kasuga Date: Sun, 21 Jun 2020 22:57:54 +0900 Subject: [PATCH 3/5] Get rid of duplicate prefix channel name used by PSUBSCRIBE test on cluster because it tends to remain after another test case. --- test/cluster_commands_on_pub_sub_test.rb | 25 +++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/test/cluster_commands_on_pub_sub_test.rb b/test/cluster_commands_on_pub_sub_test.rb index 1599dd798..66c166d96 100644 --- a/test/cluster_commands_on_pub_sub_test.rb +++ b/test/cluster_commands_on_pub_sub_test.rb @@ -56,13 +56,13 @@ def test_publish_psubscribe_punsubscribe_pubsub messages = {} wire = Wire.new do - redis.psubscribe('cha*', 'her*') do |on| + redis.psubscribe('guc*', 'her*') do |on| on.psubscribe { |_c, t| sub_cnt = t } on.punsubscribe { |_c, t| sub_cnt = t } on.pmessage do |_ptn, chn, msg| messages[chn] = msg # FIXME: blocking occurs when `unsubscribe` method was called with channel arguments - redis.punsubscribe if messages.size == 3 + redis.punsubscribe if messages.size == 2 end end end @@ -72,30 +72,27 @@ def test_publish_psubscribe_punsubscribe_pubsub publisher = build_another_client assert_equal [], publisher.pubsub(:channels) - assert_equal [], publisher.pubsub(:channels, 'cha*') - assert_equal [], publisher.pubsub(:channels, 'her*') + assert_equal [], publisher.pubsub(:channels, 'bur*') assert_equal [], publisher.pubsub(:channels, 'guc*') + assert_equal [], publisher.pubsub(:channels, 'her*') assert_equal({}, publisher.pubsub(:numsub)) - assert_equal({ 'channel1' => 0, 'channel2' => 0, 'hermes3' => 0, 'gucci4' => 0 }, - publisher.pubsub(:numsub, 'channel1', 'channel2', 'hermes3', 'gucci4')) + assert_equal({ 'burberry1' => 0, 'gucci2' => 0, 'hermes3' => 0 }, publisher.pubsub(:numsub, 'burberry1', 'gucci2', 'hermes3')) assert_equal 2, publisher.pubsub(:numpat) - publisher.publish('chanel1', 'one') - publisher.publish('chanel2', 'two') + publisher.publish('burberry1', 'one') + publisher.publish('gucci2', 'two') publisher.publish('hermes3', 'three') - publisher.publish('gucci4', 'four') wire.join - assert_equal({ 'chanel1' => 'one', 'chanel2' => 'two', 'hermes3' => 'three' }, messages.sort.to_h) + assert_equal({ 'gucci2' => 'two', 'hermes3' => 'three' }, messages.sort.to_h) assert_equal [], publisher.pubsub(:channels) - assert_equal [], publisher.pubsub(:channels, 'cha*') - assert_equal [], publisher.pubsub(:channels, 'her*') + assert_equal [], publisher.pubsub(:channels, 'bur*') assert_equal [], publisher.pubsub(:channels, 'guc*') + assert_equal [], publisher.pubsub(:channels, 'her*') assert_equal({}, publisher.pubsub(:numsub)) - assert_equal({ 'channel1' => 0, 'channel2' => 0, 'hermes3' => 0, 'gucci4' => 0 }, - publisher.pubsub(:numsub, 'channel1', 'channel2', 'hermes3', 'gucci4')) + assert_equal({ 'burberry1' => 0, 'gucci2' => 0, 'hermes3' => 0 }, publisher.pubsub(:numsub, 'burberry1', 'gucci2', 'hermes3')) assert_equal 0, publisher.pubsub(:numpat) end end From 797418b26b221a2bd2790ef226777f7b90adcad3 Mon Sep 17 00:00:00 2001 From: Taishi Kasuga Date: Sun, 21 Jun 2020 23:19:51 +0900 Subject: [PATCH 4/5] Fix fragile test case --- test/cluster_commands_on_keys_test.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/cluster_commands_on_keys_test.rb b/test/cluster_commands_on_keys_test.rb index 124a28709..011bbfadd 100644 --- a/test/cluster_commands_on_keys_test.rb +++ b/test/cluster_commands_on_keys_test.rb @@ -49,8 +49,7 @@ def test_object assert_equal 1, redis.object('refcount', 'mylist') expected_encoding = version < '3.2.0' ? 'ziplist' : 'quicklist' assert_equal expected_encoding, redis.object('encoding', 'mylist') - expected_instance_type = RUBY_VERSION < '2.4.0' ? Fixnum : Integer - assert_instance_of expected_instance_type, redis.object('idletime', 'mylist') + assert(redis.object('idletime', 'mylist') >= 0) redis.set('foo', 1000) assert_equal 'int', redis.object('encoding', 'foo') From 898c8a6109a6677a4bde9d241b9c959849ef8b35 Mon Sep 17 00:00:00 2001 From: Taishi Kasuga Date: Mon, 22 Jun 2020 10:55:30 +0900 Subject: [PATCH 5/5] Fix bad English sentence --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index e9ec2af9e..307e75c30 100644 --- a/makefile +++ b/makefile @@ -85,7 +85,7 @@ wait_for_sentinel: if [ $$(${REDIS_CLIENT} -p $${port} SENTINEL SLAVES ${HA_GROUP_NAME} | wc -l) -gt 1 ]; then\ break;\ fi;\ - echo 'waiting for ready to sentinel tests...';\ + echo 'Waiting for Redis sentinel to be ready...';\ sleep 1;\ done;\ done