Skip to content

Commit

Permalink
Release 0.0.8 (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
supercaracal authored Jun 21, 2022
1 parent 8662a21 commit cba2380
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion redis-cluster-client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Gem::Specification.new do |s|
s.name = 'redis-cluster-client'
s.summary = 'A Redis cluster client for Ruby'
s.version = '0.0.7'
s.version = '0.0.8'
s.license = 'MIT'
s.homepage = 'https://github.com/redis-rb/redis-cluster-client'
s.authors = ['Taishi Kasuga']
Expand Down
22 changes: 17 additions & 5 deletions test/test_against_cluster_broken.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,33 @@ def do_test_a_node_is_down(role, number_of_keys:)
number_of_keys.times { |i| @client.pipelined { |pi| pi.call('SET', "pre-pipelined-#{i}", i) } }
wait_for_replication

kill_a_node(role)
kill_a_node(role, kill_attempts: 10)
wait_for_cluster_to_be_ready(wait_attempts: 10)

assert_equal('PONG', @client.call('PING'), 'Case: PING')
do_assertions_without_pipelining(number_of_keys: number_of_keys)
do_assertions_with_pipelining(number_of_keys: number_of_keys)
end

def kill_a_node(role)
def kill_a_node(role, kill_attempts: 10)
node_key = @node_info.select { |e| e[:role] == role }.sample.fetch(:node_key)
node = @client.send(:find_node, node_key)
refute_nil(node, node_key)
node.call('SHUTDOWN')
rescue ::RedisClient::ConnectionError
# ignore

loop do
break if kill_attempts <= 0

node.call('SHUTDOWN', 'NOSAVE')
rescue ::RedisClient::CommandError => e
raise unless e.message.include?('Errors trying to SHUTDOWN')
rescue ::RedisClient::ConnectionError
break
ensure
kill_attempts -= 1
sleep 3
end

assert_raises(::RedisClient::ConnectionError) { node.call('PING') }
end

def wait_for_cluster_to_be_ready(wait_attempts: 10)
Expand Down
27 changes: 14 additions & 13 deletions test/test_against_cluster_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,20 @@ def new_test_client
end
end

class ScaleRead < TestingWrapper
include Mixin

def new_test_client
config = ::RedisClient::ClusterConfig.new(
nodes: TEST_NODE_URIS,
replica: true,
fixed_hostname: TEST_FIXED_HOSTNAME,
**TEST_GENERIC_OPTIONS
)
::RedisClient::Cluster.new(config)
end
end
# TODO: https://github.com/redis-rb/redis-cluster-client/issues/42
# class ScaleRead < TestingWrapper
# include Mixin
#
# def new_test_client
# config = ::RedisClient::ClusterConfig.new(
# nodes: TEST_NODE_URIS,
# replica: true,
# fixed_hostname: TEST_FIXED_HOSTNAME,
# **TEST_GENERIC_OPTIONS
# )
# ::RedisClient::Cluster.new(config)
# end
# end

class Pooled < TestingWrapper
include Mixin
Expand Down

0 comments on commit cba2380

Please sign in to comment.