Skip to content

Commit

Permalink
Found and killed the test suite instability.
Browse files Browse the repository at this point in the history
Manager#processor_died test was spinning up a Processor in the background which ate jobs created in other tests!
  • Loading branch information
mperham committed Oct 21, 2015
1 parent 9736321 commit 58b2696
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -4,12 +4,12 @@ gemspec
gem 'rails', '~> 4.2'
gem 'simplecov'
gem 'minitest'
gem 'minitest-utils'
gem 'toxiproxy'

platforms :rbx do
gem 'rubysl', '~> 2.0' # if using anything in the ruby standard library
gem 'psych' # if using yaml
gem 'minitest' # if using minitest
gem 'rubinius-developer_tools' # if using any of coverage, debugger, profiler
end

Expand Down
14 changes: 13 additions & 1 deletion test/helper.rb
@@ -1,4 +1,7 @@
$TESTING = true
# disable minitest/parallel threads
ENV["N"] = "0"

if ENV["COVERAGE"]
require 'simplecov'
SimpleCov.start do
Expand Down Expand Up @@ -33,7 +36,6 @@
end

require 'minitest/autorun'
require 'minitest/pride'

require 'sidekiq'
require 'sidekiq/util'
Expand Down Expand Up @@ -62,3 +64,13 @@ def capture_logging(lvl=Logger::INFO)
Sidekiq.logger = old
end
end

def with_logging(lvl=Logger::DEBUG)
old = Sidekiq.logger.level
begin
Sidekiq.logger.level = lvl
yield
ensure
Sidekiq.logger.level = old
end
end
14 changes: 9 additions & 5 deletions test/test_actors.rb
Expand Up @@ -5,7 +5,7 @@
require 'sidekiq/processor'

class TestActors < Sidekiq::Test
class SomeWorker
class JoeWorker
include Sidekiq::Worker
def perform(slp)
raise "boom" if slp == "boom"
Expand All @@ -30,7 +30,7 @@ def perform(slp)
ss = Sidekiq::ScheduledSet.new
q = Sidekiq::Queue.new

SomeWorker.perform_in(0.01, 0)
JoeWorker.perform_in(0.01, 0)

assert_equal 0, q.size
assert_equal 1, ss.size
Expand Down Expand Up @@ -82,7 +82,7 @@ def options
mgr = Mgr.new

p = Sidekiq::Processor.new(mgr)
SomeWorker.perform_async(0)
JoeWorker.perform_async(0)

a = $count
p.process_one
Expand All @@ -94,7 +94,9 @@ def options
mgr = Mgr.new

p = Sidekiq::Processor.new(mgr)
SomeWorker.perform_async("boom")
JoeWorker.perform_async("boom")
q = Sidekiq::Queue.new
assert_equal 1, q.size

a = $count
mgr.mutex.synchronize do
Expand All @@ -115,7 +117,9 @@ def options
mgr = Mgr.new

p = Sidekiq::Processor.new(mgr)
SomeWorker.perform_async(1)
JoeWorker.perform_async(1)
q = Sidekiq::Queue.new
assert_equal 1, q.size

a = $count
p.start
Expand Down
12 changes: 8 additions & 4 deletions test/test_manager.rb
Expand Up @@ -26,10 +26,14 @@ def new_manager(opts)
mgr = new_manager(options)
init_size = mgr.workers.size
processor = mgr.workers.first
mgr.processor_died(processor, 'ignored')

assert_equal init_size, mgr.workers.size
refute mgr.workers.include?(processor)
begin
mgr.processor_died(processor, 'ignored')

assert_equal init_size, mgr.workers.size
refute mgr.workers.include?(processor)
ensure
mgr.workers.each {|p| p.terminate(true) }
end
end

it 'does not support invalid concurrency' do
Expand Down

0 comments on commit 58b2696

Please sign in to comment.