Skip to content

Commit 5ad1397

Browse files
authored
test: no need to wait uselessly (#391)
1 parent c4270ff commit 5ad1397

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/test_against_cluster_broken.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class TestAgainstClusterBroken < TestingWrapper
88
WAIT_SEC = 0.1
99
MAX_ATTEMPTS = 100
10-
NUMBER_OF_KEYS = 1600
10+
NUMBER_OF_KEYS = 16_000
1111
MAX_PIPELINE_SIZE = 40
1212
HASH_TAG_GRAIN = 5
1313
SLICED_NUMBERS = (0...NUMBER_OF_KEYS).each_slice(MAX_PIPELINE_SIZE).freeze
@@ -79,7 +79,7 @@ def prepare_test_data
7979
def do_assertions(offset:)
8080
log_info('assertions') do
8181
log_info('assertions: single') do
82-
(NUMBER_OF_KEYS / MAX_PIPELINE_SIZE).times do |i|
82+
NUMBER_OF_KEYS.times do |i|
8383
want = (i + offset).to_s
8484
got = retryable { @clients[0].call_once('GET', "single:#{i}") }
8585
assert_equal(want, got, 'Case: Single GET')
@@ -111,7 +111,7 @@ def do_assertions(offset:)
111111
end
112112

113113
log_info('assertions: transaction') do
114-
(NUMBER_OF_KEYS / (MAX_PIPELINE_SIZE / HASH_TAG_GRAIN)).times.group_by { |i| i / HASH_TAG_GRAIN }.each do |group, numbers|
114+
NUMBER_OF_KEYS.times.group_by { |i| i / HASH_TAG_GRAIN }.each do |group, numbers|
115115
want = numbers.map { 'OK' }
116116
keys = numbers.map { |i| "{group#{group}}:transaction:#{i}" }
117117
got = retryable do
@@ -179,17 +179,18 @@ def retryable(attempts: MAX_ATTEMPTS, wait_sec: WAIT_SEC)
179179
break yield
180180
rescue ::RedisClient::ConnectionError, ::RedisClient::Cluster::NodeMightBeDown
181181
@cluster_down_error_count += 1
182+
sleep wait_sec
182183
rescue ::RedisClient::CommandError => e
183184
raise unless e.message.start_with?('CLUSTERDOWN')
184185

185186
@cluster_down_error_count += 1
187+
sleep wait_sec
186188
rescue ::RedisClient::Cluster::ErrorCollection => e
187189
raise unless e.errors.values.all? do |err|
188190
err.message.start_with?('CLUSTERDOWN') || err.is_a?(::RedisClient::ConnectionError)
189191
end
190192

191193
@cluster_down_error_count += 1
192-
ensure
193194
sleep wait_sec
194195
end
195196
end

0 commit comments

Comments
 (0)