Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
supercaracal committed Sep 26, 2024
1 parent b14944d commit e9e3a96
Showing 1 changed file with 6 additions and 41 deletions.
47 changes: 6 additions & 41 deletions test/test_against_cluster_scale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,55 +223,20 @@ def self.test_order
end

def do_test_after_scaled_out
NUMBER_OF_KEYS.times.group_by { |i| i / HASH_TAG_GRAIN }.each do |group, numbers|
channels = numbers.map { |i| "{group#{group}}:channel#{i}" }
NUMBER_OF_KEYS.times do |i|
pubsub = @client.pubsub
pubsub.call('SSUBSCRIBE', *channels)

channels.each_with_index do |c, i|
event = pubsub.next_event(0.01)
break if event.nil?

assert_equal(['ssubscribe', c, i + 1], event)
end

channels.each_with_index do |c, i| # rubocop:disable Style/CombinableLoops
event = pubsub.next_event(0.01)
break if event.nil?

assert_equal(['ssubscribe', c, i + 1], event)
end

pubsub.call('SSUBSCRIBE', "chan#{i}")
event = pubsub.next_event(0.01)
event = pubsub.next_event(0.01) if event.nil? # state changed
assert_equal(['ssubscribe', "chan#{i}", 1], event)
assert_nil(pubsub.next_event(0.01))
ensure
pubsub&.close
end
end

def do_test_after_scaled_in
NUMBER_OF_KEYS.times.group_by { |i| i / HASH_TAG_GRAIN }.each do |group, numbers|
channels = numbers.map { |i| "{group#{group}}:channel#{i}" }
pubsub = @client.pubsub
pubsub.call('SSUBSCRIBE', *channels)

channels.each_with_index do |c, i|
event = pubsub.next_event(0.01)
break if event.nil?

assert_equal(['ssubscribe', c, i + 1], event)
end

channels.each_with_index do |c, i| # rubocop:disable Style/CombinableLoops
event = pubsub.next_event(0.01)
break if event.nil?

assert_equal(['ssubscribe', c, i + 1], event)
end

assert_nil(pubsub.next_event(0.01))
ensure
pubsub&.close
end
do_test_after_scaled_out # auto retry
end
end
end
Expand Down

0 comments on commit e9e3a96

Please sign in to comment.