Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: no need to wait uselessly #391

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions test/test_against_cluster_broken.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class TestAgainstClusterBroken < TestingWrapper
WAIT_SEC = 0.1
MAX_ATTEMPTS = 100
NUMBER_OF_KEYS = 1600
NUMBER_OF_KEYS = 16_000
MAX_PIPELINE_SIZE = 40
HASH_TAG_GRAIN = 5
SLICED_NUMBERS = (0...NUMBER_OF_KEYS).each_slice(MAX_PIPELINE_SIZE).freeze
Expand Down Expand Up @@ -79,7 +79,7 @@ def prepare_test_data
def do_assertions(offset:)
log_info('assertions') do
log_info('assertions: single') do
(NUMBER_OF_KEYS / MAX_PIPELINE_SIZE).times do |i|
NUMBER_OF_KEYS.times do |i|
want = (i + offset).to_s
got = retryable { @clients[0].call_once('GET', "single:#{i}") }
assert_equal(want, got, 'Case: Single GET')
Expand Down Expand Up @@ -111,7 +111,7 @@ def do_assertions(offset:)
end

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

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

@cluster_down_error_count += 1
ensure
sleep wait_sec
end
end
Expand Down