Skip to content

Commit

Permalink
Merge pull request #3 from cf-frameworks/master
Browse files Browse the repository at this point in the history
Add a test for race condition with multiple workers trying to pick up the same job.
  • Loading branch information
JonathanTron committed Oct 29, 2013
2 parents 23220cc + 83ef0d9 commit 9431857
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/delayed/backend/sequel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@

it_should_behave_like "a delayed_job backend"

it "does not allow more than 1 worker to grab the same job" do
expect {
10.times do
described_class.create(payload_object: SimpleJob.new)
end

20.times.map do
Thread.new { Delayed::Worker.new.work_off(4) }
end.map(&:join)
}.not_to raise_error

expect(Delayed::Job.count).to be < 10
end

context ".count" do
context "NewRelic sampler compat" do
it "allow count with conditions" do
Expand Down

0 comments on commit 9431857

Please sign in to comment.