Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/integration/instrumentation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class InstrumentationTest < ActiveSupport::TestCase
end

test "stopping a worker with claimed executions emits release_claimed events" do
StoreResultJob.perform_later(42, pause: SolidQueue.shutdown_timeout + 100.second)
StoreResultJob.perform_later(42, pause: SolidQueue.shutdown_timeout + 15.seconds)
process = nil

events = subscribed(/release.*_claimed\.solid_queue/) do
Expand Down Expand Up @@ -88,7 +88,7 @@ class InstrumentationTest < ActiveSupport::TestCase
end

test "starting and stopping a worker emits register_process and deregister_process events" do
StoreResultJob.perform_later(42, pause: SolidQueue.shutdown_timeout + 100.second)
StoreResultJob.perform_later(42, pause: SolidQueue.shutdown_timeout + 15.seconds)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to scheduler_test, but I don't think this is ever a good idea, to have a timeout that long 😅

process = nil

events = subscribed(/(register|deregister)_process\.solid_queue/) do
Expand Down
18 changes: 13 additions & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,22 @@ class ExpectedTestError < RuntimeError; end
class ActiveSupport::TestCase
include ConfigurationTestHelper, ProcessesTestHelper, JobsTestHelper

def destroy_records
SolidQueue::Job.destroy_all
SolidQueue::Process.destroy_all
SolidQueue::Semaphore.delete_all
SolidQueue::RecurringTask.delete_all
JobResult.delete_all
end

setup do
@_on_thread_error = SolidQueue.on_thread_error
SolidQueue.on_thread_error = silent_on_thread_error_for(ExpectedTestError, @_on_thread_error)
ActiveJob::QueueAdapters::SolidQueueAdapter.stopping = false

unless self.class.use_transactional_tests
destroy_records
end
Copy link
Contributor Author

@p-schlickmann p-schlickmann Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, destroy_records will always run in teardown, even if a test fails.

But I also added it in setup to be extra sure records aren't leaking between tests, if for some reason teardown can't run because of a deadlock or a :KILL signal

end

teardown do
Expand All @@ -45,11 +57,7 @@ class ActiveSupport::TestCase
end

unless self.class.use_transactional_tests
SolidQueue::Job.destroy_all
SolidQueue::Process.destroy_all
SolidQueue::Semaphore.delete_all
SolidQueue::RecurringTask.delete_all
JobResult.delete_all
destroy_records
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/scheduler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SchedulerTest < ActiveSupport::TestCase
end

schedulers.each(&:start)
sleep 2
wait_while_with_timeout(2.5.seconds) { SolidQueue::RecurringExecution.count != 2 }
schedulers.each(&:stop)

assert_equal SolidQueue::Job.count, SolidQueue::RecurringExecution.count
Expand Down