Skip to content

Commit 14bb29c

Browse files
committed
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.
1 parent 176721e commit 14bb29c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

test/integration/concurrency_controls_test.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,11 @@ class ConcurrencyControlsTest < ActiveSupport::TestCase
166166
NonOverlappingUpdateResultJob.perform_later(@result, name: "I'll be released to ready", pause: SolidQueue.shutdown_timeout + 10.seconds)
167167
job = SolidQueue::Job.last
168168

169-
sleep(0.2)
170-
assert job.claimed?
169+
wait_for(timeout: 2.seconds) { job.reload.claimed? }
171170

172-
# This won't leave time to the job to finish
173-
signal_process(@pid, :TERM, wait: 0.1.second)
174-
sleep(SolidQueue.shutdown_timeout + 0.6.seconds)
171+
# Terminate the supervisor and wait for it to fully exit, so workers
172+
# have time to deregister and release their claimed executions.
173+
terminate_process(@pid)
175174

176175
assert_not job.reload.finished?
177176
assert job.reload.ready?

0 commit comments

Comments
 (0)