Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In test, shutdown schedulers/capsules before doing assertions because of race conditions; store CI logs for Dev Env tests #1129

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ jobs:
run: bin/rails db:test:prepare
- name: bin/rspec
run: bin/rspec --require ./spec/support/pre_documentation_formatter.rb --format PreDocumentationFormatter
# Archive
- name: Archive system spec screenshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: screenshots
path: |
spec/test_app/tmp/screenshots
spec/test_app/tmp/capybara
- name: Archive Rails logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: rails_logs
path: spec/test_app/log

test:
name: Test
Expand Down
5 changes: 3 additions & 2 deletions spec/integration/capsule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ def perform

LATCH.wait(10)
wait_until { expect(GoodJob::Job.finished.count).to eq(total_jobs) }
expect(GoodJob::DiscreteExecution.count).to eq(total_jobs)

perform_capsule.shutdown
enqueue_capsule.shutdown

expect(GoodJob::DiscreteExecution.count).to eq(total_jobs)
end
end
20 changes: 17 additions & 3 deletions spec/integration/complex_jobs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
require 'rails_helper'

RSpec.describe 'Complex Jobs' do
let(:inline_adapter) { GoodJob::Adapter.new(execution_mode: :inline) }
let(:async_adapter) { GoodJob::Adapter.new(execution_mode: :async_all) }
let(:capsule) { GoodJob::Capsule.new }
let(:inline_adapter) { GoodJob::Adapter.new(execution_mode: :inline, _capsule: capsule) }
let(:async_adapter) { GoodJob::Adapter.new(execution_mode: :async_all, _capsule: capsule) }

before do
GoodJob.capsule.restart
allow(GoodJob.on_thread_error).to receive(:call).and_call_original
end

after do
capsule.shutdown
end

describe 'Job without error handler / unhandled' do
after do
# This spec will intentionally raise an error on the thread.
Expand All @@ -28,6 +32,8 @@ def perform
TestJob.perform_later

wait_until { expect(GoodJob::Job.last.finished_at).to be_present }
capsule.shutdown

good_job = GoodJob::Job.last
expect(good_job).to have_attributes(
executions_count: 1,
Expand Down Expand Up @@ -64,6 +70,8 @@ def perform
TestJob.perform_later

wait_until { expect(GoodJob::Job.last.finished_at).to be_present }
capsule.shutdown

good_job = GoodJob::Job.last
expect(good_job).to have_attributes(
executions_count: 1,
Expand Down Expand Up @@ -94,6 +102,8 @@ def perform
TestJob.perform_later

wait_until { expect(GoodJob::Job.last.finished_at).to be_present }
capsule.shutdown

good_job = GoodJob::Job.last
expect(good_job).to have_attributes(
executions_count: 1,
Expand Down Expand Up @@ -124,6 +134,8 @@ def perform
TestJob.perform_later

wait_until { expect(GoodJob::Job.last.finished_at).to be_present }
capsule.shutdown

good_job = GoodJob::Job.last
expect(good_job).to have_attributes(
executions_count: 2,
Expand Down Expand Up @@ -151,6 +163,8 @@ def perform
TestJob.perform_later

wait_until { expect(GoodJob::Job.last.finished_at).to be_present }
capsule.shutdown

good_job = GoodJob::Job.last
expect(good_job).to have_attributes(
executions_count: 2,
Expand Down