@@ -94,20 +94,20 @@ class ConcurrencyControlsTest < ActiveSupport::TestCase
9494 assert SolidQueue ::Semaphore . wait ( job )
9595 end
9696
97- # Now enqueue more jobs under that same key. They'll be all locked. Use priorities
98- # to ensure order.
97+ # Now enqueue more jobs under that same key. They'll be all locked
9998 assert_difference -> { SolidQueue ::BlockedExecution . count } , +10 do
10099 ( "B" .."K" ) . each do |name |
101100 SequentialUpdateResultJob . perform_later ( @result , name : name )
102101 end
103102 end
104103
105- # Then unlock the semaphore: this would be as if the first job had released
106- # the semaphore but hadn't unblocked any jobs
104+ # Then unlock the semaphore and expire the jobs: this would be as if the first job had
105+ # released the semaphore but hadn't unblocked any jobs
106+ SolidQueue ::BlockedExecution . update_all ( expires_at : 15 . minutes . ago )
107107 assert SolidQueue ::Semaphore . signal ( job )
108108
109109 # And wait for the scheduler to release the jobs
110- wait_for_jobs_to_finish_for ( 5 . seconds )
110+ wait_for_jobs_to_finish_for ( 3 . seconds )
111111 assert_no_pending_jobs
112112
113113 # We can't ensure the order between B and C, because it depends on which worker wins when
@@ -133,8 +133,12 @@ class ConcurrencyControlsTest < ActiveSupport::TestCase
133133 end
134134 end
135135
136+ # Simulate expiration of semaphore and executions
137+ SolidQueue ::Semaphore . where ( key : job . concurrency_key ) . update_all ( expires_at : 15 . minutes . ago )
138+ SolidQueue ::BlockedExecution . update_all ( expires_at : 15 . minutes . ago )
139+
136140 # And wait for scheduler to release the jobs
137- wait_for_jobs_to_finish_for ( 5 . seconds )
141+ wait_for_jobs_to_finish_for ( 3 . seconds )
138142 assert_no_pending_jobs
139143
140144 # We can't ensure the order between B and C, because it depends on which worker wins when
0 commit comments