Skip to content

Commit 9bcc2ac

Browse files
author
KJ Tsanaktsidis
committed
Allow passing extra opts to #with_test_client
This is needed so we can write shorter timeouts in for some tests which will otherwise sleep for ~10 seconds waiting for timeouts to elsapse!
1 parent 4f578b8 commit 9bcc2ac

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

test/redis_client/test_cluster.rb

+15-10
Original file line numberDiff line numberDiff line change
@@ -541,13 +541,14 @@ def hiredis_used?
541541
class PrimaryOnly < TestingWrapper
542542
include Mixin
543543

544-
def new_test_client(capture_buffer: @captured_commands)
544+
def new_test_client(capture_buffer: @captured_commands, **opts)
545545
config = ::RedisClient::ClusterConfig.new(
546546
nodes: TEST_NODE_URIS,
547547
fixed_hostname: TEST_FIXED_HOSTNAME,
548548
middlewares: [CommandCaptureMiddleware],
549549
custom: { captured_commands: capture_buffer },
550-
**TEST_GENERIC_OPTIONS
550+
**TEST_GENERIC_OPTIONS,
551+
**opts
551552
)
552553
::RedisClient::Cluster.new(config)
553554
end
@@ -556,15 +557,16 @@ def new_test_client(capture_buffer: @captured_commands)
556557
class ScaleReadRandom < TestingWrapper
557558
include Mixin
558559

559-
def new_test_client(capture_buffer: @captured_commands)
560+
def new_test_client(capture_buffer: @captured_commands, **opts)
560561
config = ::RedisClient::ClusterConfig.new(
561562
nodes: TEST_NODE_URIS,
562563
replica: true,
563564
replica_affinity: :random,
564565
fixed_hostname: TEST_FIXED_HOSTNAME,
565566
middlewares: [CommandCaptureMiddleware],
566567
custom: { captured_commands: capture_buffer },
567-
**TEST_GENERIC_OPTIONS
568+
**TEST_GENERIC_OPTIONS,
569+
**opts
568570
)
569571
::RedisClient::Cluster.new(config)
570572
end
@@ -573,15 +575,16 @@ def new_test_client(capture_buffer: @captured_commands)
573575
class ScaleReadRandomWithPrimary < TestingWrapper
574576
include Mixin
575577

576-
def new_test_client(capture_buffer: @captured_commands)
578+
def new_test_client(capture_buffer: @captured_commands, **opts)
577579
config = ::RedisClient::ClusterConfig.new(
578580
nodes: TEST_NODE_URIS,
579581
replica: true,
580582
replica_affinity: :random_with_primary,
581583
fixed_hostname: TEST_FIXED_HOSTNAME,
582584
middlewares: [CommandCaptureMiddleware],
583585
custom: { captured_commands: capture_buffer },
584-
**TEST_GENERIC_OPTIONS
586+
**TEST_GENERIC_OPTIONS,
587+
**opts
585588
)
586589
::RedisClient::Cluster.new(config)
587590
end
@@ -590,15 +593,16 @@ def new_test_client(capture_buffer: @captured_commands)
590593
class ScaleReadLatency < TestingWrapper
591594
include Mixin
592595

593-
def new_test_client(capture_buffer: @captured_commands)
596+
def new_test_client(capture_buffer: @captured_commands, **opts)
594597
config = ::RedisClient::ClusterConfig.new(
595598
nodes: TEST_NODE_URIS,
596599
replica: true,
597600
replica_affinity: :latency,
598601
fixed_hostname: TEST_FIXED_HOSTNAME,
599602
middlewares: [CommandCaptureMiddleware],
600603
custom: { captured_commands: capture_buffer },
601-
**TEST_GENERIC_OPTIONS
604+
**TEST_GENERIC_OPTIONS,
605+
**opts
602606
)
603607
::RedisClient::Cluster.new(config)
604608
end
@@ -607,13 +611,14 @@ def new_test_client(capture_buffer: @captured_commands)
607611
class Pooled < TestingWrapper
608612
include Mixin
609613

610-
def new_test_client(capture_buffer: @captured_commands)
614+
def new_test_client(capture_buffer: @captured_commands, **opts)
611615
config = ::RedisClient::ClusterConfig.new(
612616
nodes: TEST_NODE_URIS,
613617
fixed_hostname: TEST_FIXED_HOSTNAME,
614618
middlewares: [CommandCaptureMiddleware],
615619
custom: { captured_commands: capture_buffer },
616-
**TEST_GENERIC_OPTIONS
620+
**TEST_GENERIC_OPTIONS,
621+
**opts
617622
)
618623
::RedisClient::Cluster.new(config, pool: { timeout: TEST_TIMEOUT_SEC, size: 2 })
619624
end

0 commit comments

Comments
 (0)