@@ -17,7 +17,6 @@ def setup
1717 end
1818
1919 def teardown
20- @controller . rebuild
2120 @controller . close
2221 @client . close
2322 end
@@ -90,47 +89,80 @@ def do_resharding_test(number_of_keys: 1000)
9089 class PrimaryOnly < TestingWrapper
9190 include Mixin
9291
92+ private
93+
94+ def new_test_client
95+ ::RedisClient . cluster (
96+ nodes : TEST_NODE_URIS ,
97+ fixed_hostname : TEST_FIXED_HOSTNAME ,
98+ **TEST_GENERIC_OPTIONS
99+ ) . new_client
100+ end
101+ end
102+
103+ class ScaleReadRandom < TestingWrapper
104+ include Mixin
105+
106+ def test_the_state_of_cluster_resharding
107+ keys = nil
108+ do_resharding_test { |ks | keys = ks }
109+ keys . each { |key | assert_equal ( key , @client . call ( 'GET' , key ) , "Case: GET: #{ key } " ) }
110+ end
111+
112+ def test_the_state_of_cluster_resharding_with_pipelining
113+ keys = nil
114+ do_resharding_test { |ks | keys = ks }
115+ values = @client . pipelined { |pipeline | keys . each { |key | pipeline . call ( 'GET' , key ) } }
116+ keys . each_with_index { |key , i | assert_equal ( key , values [ i ] , "Case: GET: #{ key } " ) }
117+ end
118+
119+ private
120+
93121 def new_test_client
94122 ::RedisClient . cluster (
95123 nodes : TEST_NODE_URIS ,
124+ replica : true ,
125+ replica_affinity : :random ,
96126 fixed_hostname : TEST_FIXED_HOSTNAME ,
97127 **TEST_GENERIC_OPTIONS
98128 ) . new_client
99129 end
100130 end
101131
102- # # TODO: https://github.com/redis-rb/redis-cluster-client/issues/42
103- # class ScaleReadRandom < TestingWrapper
104- # include Mixin
105- #
106- # def new_test_client
107- # ::RedisClient.cluster(
108- # nodes: TEST_NODE_URIS,
109- # replica: true,
110- # replica_affinity: :random,
111- # fixed_hostname: TEST_FIXED_HOSTNAME,
112- # **TEST_GENERIC_OPTIONS
113- # ).new_client
114- # end
115- # end
116- #
117- # class ScaleReadLatency < TestingWrapper
118- # include Mixin
119- #
120- # def new_test_client
121- # ::RedisClient.cluster(
122- # nodes: TEST_NODE_URIS,
123- # replica: true,
124- # replica_affinity: :latency,
125- # fixed_hostname: TEST_FIXED_HOSTNAME,
126- # **TEST_GENERIC_OPTIONS
127- # ).new_client
128- # end
129- # end
132+ class ScaleReadLatency < TestingWrapper
133+ include Mixin
134+
135+ def test_the_state_of_cluster_resharding
136+ keys = nil
137+ do_resharding_test { | ks | keys = ks }
138+ keys . each { | key | assert_equal ( key , @client . call ( 'GET' , key ) , "Case: GET: #{ key } " ) }
139+ end
140+
141+ def test_the_state_of_cluster_resharding_with_pipelining
142+ keys = nil
143+ do_resharding_test { | ks | keys = ks }
144+ values = @client . pipelined { | pipeline | keys . each { | key | pipeline . call ( 'GET' , key ) } }
145+ keys . each_with_index { | key , i | assert_equal ( key , values [ i ] , "Case: GET: #{ key } " ) }
146+ end
147+
148+ private
149+
150+ def new_test_client
151+ ::RedisClient . cluster (
152+ nodes : TEST_NODE_URIS ,
153+ replica : true ,
154+ replica_affinity : :latency ,
155+ fixed_hostname : TEST_FIXED_HOSTNAME ,
156+ **TEST_GENERIC_OPTIONS
157+ ) . new_client
158+ end
159+ end
130160
131161 class Pooled < TestingWrapper
132162 include Mixin
133163
164+ private
165+
134166 def new_test_client
135167 ::RedisClient . cluster (
136168 nodes : TEST_NODE_URIS ,
0 commit comments