mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00

* Initial work on Sidekiq::Config * Initial work on Sidekiq::Config * reduce dependencies in deploy marks * bare sidekiq and webapp * Modify runtime to work with Capsules * Cleanup * Rename test files to remove test_ prefix * Update test suite and standard rules to be more compliant * Move constant definition outside code, per standard formatting * Loads of changes for introduction of Capsules * Remove Redis adapter abstraction * update capsule overview * Ensure Sidekiq.redis uses the correct pool for jobs running within a Capsule * Use default_capsule for safety * Slow down the beat to halve its Redis overhead * move config fixtures into cfg/ * Add capsule middleware test * use accessor
60 lines
1.2 KiB
Ruby
60 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "bundler/setup"
|
|
Bundler.require(:default, :test)
|
|
|
|
require "minitest/pride"
|
|
require "minitest/autorun"
|
|
|
|
$TESTING = true
|
|
# disable minitest/parallel threads
|
|
ENV["MT_CPU"] = "0"
|
|
ENV["N"] = "0"
|
|
# Disable any stupid backtrace cleansers
|
|
ENV["BACKTRACE"] = "1"
|
|
|
|
if ENV["COVERAGE"]
|
|
require "simplecov"
|
|
SimpleCov.start do
|
|
enable_coverage :branch
|
|
add_filter "/test/"
|
|
add_filter "/myapp/"
|
|
minimum_coverage 90
|
|
end
|
|
end
|
|
|
|
ENV["REDIS_URL"] ||= "redis://localhost/15"
|
|
|
|
def reset!
|
|
RedisClient.new(url: ENV["REDIS_URL"]).call("flushall")
|
|
cfg = Sidekiq::Config.new
|
|
cfg.logger = ::Logger.new("/dev/null")
|
|
cfg.logger.level = Logger::WARN
|
|
Sidekiq.instance_variable_set :@config, cfg
|
|
cfg
|
|
end
|
|
|
|
def capture_logging(cfg, lvl = Logger::INFO)
|
|
old = cfg.logger
|
|
begin
|
|
out = StringIO.new
|
|
logger = ::Logger.new(out)
|
|
logger.level = lvl
|
|
cfg.logger = logger
|
|
yield logger
|
|
out.string
|
|
ensure
|
|
cfg.logger = old
|
|
end
|
|
end
|
|
|
|
Signal.trap("TTIN") do
|
|
Thread.list.each do |thread|
|
|
puts "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread.name}"
|
|
if thread.backtrace
|
|
puts thread.backtrace.join("\n")
|
|
else
|
|
puts "<no backtrace available>"
|
|
end
|
|
end
|
|
end
|