@@ -94,20 +94,20 @@ class ConcurrencyControlsTest < ActiveSupport::TestCase
94
94
assert SolidQueue ::Semaphore . wait ( job )
95
95
end
96
96
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
99
98
assert_difference -> { SolidQueue ::BlockedExecution . count } , +10 do
100
99
( "B" .."K" ) . each do |name |
101
100
SequentialUpdateResultJob . perform_later ( @result , name : name )
102
101
end
103
102
end
104
103
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 )
107
107
assert SolidQueue ::Semaphore . signal ( job )
108
108
109
109
# 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 )
111
111
assert_no_pending_jobs
112
112
113
113
# 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
133
133
end
134
134
end
135
135
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
+
136
140
# 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 )
138
142
assert_no_pending_jobs
139
143
140
144
# We can't ensure the order between B and C, because it depends on which worker wins when
0 commit comments