@@ -123,25 +123,22 @@ class ProcessesLifecycleTest < ActiveSupport::TestCase
123123 no_pause = enqueue_store_result_job ( "no pause" )
124124 pause = enqueue_store_result_job ( "pause" , pause : SolidQueue . shutdown_timeout + 10 . second )
125125
126- wait_while_with_timeout ( 1 . second ) { SolidQueue ::ReadyExecution . count > 0 }
126+ wait_while_with_timeout ( 1 . second ) { SolidQueue ::ReadyExecution . count > 1 }
127127
128- signal_process ( @pid , :TERM , wait : 0.5 )
128+ signal_process ( @pid , :TERM , wait : 0.5 . second )
129+ wait_for_jobs_to_finish_for ( 2 . seconds , except : pause )
129130
130- sleep ( SolidQueue . shutdown_timeout + 0.5 . second )
131+ wait_while_with_timeout! ( SolidQueue . shutdown_timeout + 1 . second ) { process_exists? ( @pid ) }
132+ assert_not process_exists? ( @pid )
131133
132134 assert_completed_job_results ( "no pause" )
133135 assert_job_status ( no_pause , :finished )
134136
135- # This job was left claimed as the worker was shutdown without
136- # a chance to terminate orderly
137137 assert_started_job_result ( "pause" )
138- assert_job_status ( pause , :claimed )
139-
140- # The process running the long job couldn't deregister, the other did
141- assert_registered_workers_for ( :background )
142-
143- # Now wait until the supervisor finishes for real, which will complete the cleanup
144- wait_for_process_termination_with_timeout ( @pid , timeout : 1 . second )
138+ # Workers were shutdown without a chance to terminate orderly, but
139+ # since they're linked to the supervisor, the supervisor deregistering
140+ # also deregistered them and released claimed jobs
141+ assert_job_status ( pause , :ready )
145142 assert_clean_termination
146143 end
147144
0 commit comments