1010class RedisClient
1111 class Cluster
1212 class Node
13- class TestConfig < Minitest :: Test
13+ class TestConfig < TestingWrapper
1414 def test_connection_prelude
1515 [
1616 { params : { scale_read : true } , want : [ %w[ HELLO 3 ] , %w[ READONLY ] ] } ,
@@ -24,7 +24,7 @@ def test_connection_prelude
2424 end
2525 end
2626
27- class TestNode < Minitest :: Test
27+ class TestNode < TestingWrapper
2828 def setup
2929 @test_config = ::RedisClient ::ClusterConfig . new (
3030 nodes : TEST_NODE_URIS ,
@@ -232,22 +232,22 @@ def test_call_primary
232232
233233 def test_call_replica
234234 want = ( 1 ..( @test_node_info . count { |info | info [ :role ] == 'master' } ) ) . map { |_ | 'PONG' }
235+
235236 got = @test_node . call_replica ( :call , 'PING' )
236237 assert_equal ( want , got , 'Case: primary only' )
237238
238- want = ( 1 ..( @test_node_info . count { |info | info [ :role ] == 'slave' } ) ) . map { |_ | 'PONG' }
239239 got = @test_node_with_scale_read . call_replica ( :call , 'PING' )
240240 assert_equal ( want , got , 'Case: scale read' )
241241 end
242242
243- def test_scale_reading_clients
243+ def test_scale_reading_clients # rubocop:disable Metrics/CyclomaticComplexity
244244 want = @test_node_info . select { |info | info [ :role ] == 'master' } . map { |info | info [ :node_key ] } . sort
245245 got = @test_node . scale_reading_clients . map { |client | "#{ client . config . host } :#{ client . config . port } " }
246246 assert_equal ( want , got , 'Case: primary only' )
247247
248- want = @test_node_info . select { |info | info [ :role ] == 'slave' } . map { |info | info [ :node_key ] } . sort
248+ want = @test_node_info . select { |info | info [ :role ] == 'slave' } . map { |info | info [ :node_key ] }
249249 got = @test_node_with_scale_read . scale_reading_clients . map { |client | "#{ client . config . host } :#{ client . config . port } " }
250- assert_equal ( want , got , 'Case: scale read' )
250+ got . each { | e | assert_includes ( want , e , 'Case: scale read' ) }
251251 end
252252
253253 def test_slot_exists?
@@ -271,11 +271,12 @@ def test_find_node_key_of_replica
271271 got = @test_node . find_node_key_of_replica ( sample_slot )
272272 assert_equal ( sample_node [ :node_key ] , got , 'Case: primary only' )
273273
274- sample_replica = @test_node_info . find { |info | info [ :role ] == 'slave' }
275- sample_primary = @test_node_info . find { |info | info [ :id ] == sample_replica [ :primary_id ] }
274+ sample_replicas = @test_node_info . select { |info | info [ :role ] == 'slave' }
275+ sample_primary = @test_node_info . find { |info | info [ :id ] == sample_replicas . first [ :primary_id ] }
276276 sample_slot = sample_primary [ :slots ] . first . first
277277 got = @test_node_with_scale_read . find_node_key_of_replica ( sample_slot )
278- assert_equal ( sample_replica [ :node_key ] , got , 'Case: scale read' )
278+ want = sample_replicas . map { |info | info [ :node_key ] }
279+ assert_includes ( want , got , 'Case: scale read' )
279280 end
280281
281282 def test_update_slot
0 commit comments