From 693155695a531d5c940949eb7e00d33c55125701 Mon Sep 17 00:00:00 2001 From: Diogo Vernier <10981831+diogovernier@users.noreply.github.com> Date: Thu, 9 Apr 2026 10:40:57 -0300 Subject: [PATCH] Fix flaky concurrency controls test Replace fixed sleeps with deterministic waits in the "don't block claimed executions that get released" test. The test was using sleep(0.2) to wait for claiming and sleep(shutdown_timeout + 0.6) to wait for shutdown, both of which are timing sensitive and unreliable on slow CI. Instead, use wait_for to wait for the job to be claimed, and terminate_process to wait for the supervisor to actually exit. --- test/integration/concurrency_controls_test.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/integration/concurrency_controls_test.rb b/test/integration/concurrency_controls_test.rb index a12c48e42..4323865f2 100644 --- a/test/integration/concurrency_controls_test.rb +++ b/test/integration/concurrency_controls_test.rb @@ -166,12 +166,11 @@ class ConcurrencyControlsTest < ActiveSupport::TestCase NonOverlappingUpdateResultJob.perform_later(@result, name: "I'll be released to ready", pause: SolidQueue.shutdown_timeout + 10.seconds) job = SolidQueue::Job.last - sleep(0.2) - assert job.claimed? + wait_for(timeout: 2.seconds) { job.reload.claimed? } - # This won't leave time to the job to finish - signal_process(@pid, :TERM, wait: 0.1.second) - sleep(SolidQueue.shutdown_timeout + 0.6.seconds) + # This won't leave time to the job to finish, so the worker should + # release it back to ready during shutdown. + terminate_process(@pid) assert_not job.reload.finished? assert job.reload.ready?