Skip to content

Commit

Permalink
Fix benchmark for older versions of Sidekiq
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlogic committed Dec 4, 2023
1 parent eb2b14a commit f5c749b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
17 changes: 10 additions & 7 deletions judoscale-sidekiq/test/benchmarks/collect_benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ def with_isolated_redis(n, &block)
# n is in powers of 10, but we want to use a database number in the range 1-9
db_number = Math.log10(n).to_i

# `new_redis_pool` will use the configuration from Sidekiq.default_configuration
Sidekiq.default_configuration.redis = {db: db_number}
pool = Sidekiq.default_configuration.new_redis_pool 10, "bench-#{n}"
Sidekiq::Client.via(pool, &block)

# For older (pre-capsule) versions of Sidekiq
# Sidekiq.redis = {db: db_number}
if Sidekiq.respond_to?(:default_configuration)
# `new_redis_pool` will use the configuration from Sidekiq.default_configuration
Sidekiq.default_configuration.redis = {db: db_number}
pool = Sidekiq.default_configuration.new_redis_pool 10, "bench-#{n}"
Sidekiq::Client.via(pool, &block)
else
# For older (pre-capsule) versions of Sidekiq
Sidekiq.redis = {db: db_number}
block.call
end
end
end
1 change: 0 additions & 1 deletion judoscale-sidekiq/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

require "minitest/autorun"
require "minitest/spec"
require "debug"

module Judoscale::Test
end
Expand Down

0 comments on commit f5c749b

Please sign in to comment.