Skip to content

Commit

Permalink
More sleep, more errors, more thread concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon committed Mar 1, 2023
1 parent 4aa9e4b commit b1d310a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions spec/integration/batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,16 @@ def perform(*_args, **_kwargs)

describe 'aggressive async batching' do
it 'can execute multiple jobs' do
allow(GoodJob.configuration).to receive(:max_threads).and_return(10)
allow(GoodJob.configuration).to receive(:max_threads).and_return(20)
ActiveJob::Base.queue_adapter = GoodJob::Adapter.new(execution_mode: :async_all)
expect(ActiveJob::Base.queue_adapter.execute_async?).to be true

stub_const 'TestJob', (Class.new(ActiveJob::Base) do
discard_on 'ExpectedError'
retry_on('ExpectedError', wait: 0, attempts: 2) { nil }

def perform(id)
sleep(0.1 * rand(10))
sleep(1)
raise ExpectedError if rand(10) == 1
raise ExpectedError if id == 25
end
end)
Expand All @@ -260,7 +262,7 @@ def perform(id)
50.times { |i| TestJob.perform_later(i) }
end

wait_until { expect(GoodJob::Job.finished.count).to eq 52 }
wait_until(max: 30) { expect(GoodJob::Job.finished.count).to eq 52 }
end
end
end

0 comments on commit b1d310a

Please sign in to comment.