@@ -8,29 +8,40 @@ class LifecycleHooksTest < ActiveSupport::TestCase
88 test "run lifecycle hooks" do
99 SolidQueue . on_start { JobResult . create! ( status : :hook_called , value : :start ) }
1010 SolidQueue . on_stop { JobResult . create! ( status : :hook_called , value : :stop ) }
11+ SolidQueue . on_exit { JobResult . create! ( status : :hook_called , value : :exit ) }
1112
1213 SolidQueue . on_worker_start { JobResult . create! ( status : :hook_called , value : :worker_start ) }
1314 SolidQueue . on_worker_stop { JobResult . create! ( status : :hook_called , value : :worker_stop ) }
15+ SolidQueue . on_worker_exit { JobResult . create! ( status : :hook_called , value : :worker_exit ) }
1416
1517 SolidQueue . on_dispatcher_start { JobResult . create! ( status : :hook_called , value : :dispatcher_start ) }
1618 SolidQueue . on_dispatcher_stop { JobResult . create! ( status : :hook_called , value : :dispatcher_stop ) }
19+ SolidQueue . on_dispatcher_exit { JobResult . create! ( status : :hook_called , value : :dispatcher_exit ) }
1720
1821 SolidQueue . on_scheduler_start { JobResult . create! ( status : :hook_called , value : :scheduler_start ) }
1922 SolidQueue . on_scheduler_stop { JobResult . create! ( status : :hook_called , value : :scheduler_stop ) }
23+ SolidQueue . on_scheduler_stop { JobResult . create! ( status : :hook_called , value : :scheduler_exit ) }
2024
2125 pid = run_supervisor_as_fork ( workers : [ { queues : "*" } ] , dispatchers : [ { batch_size : 100 } ] , skip_recurring : false )
2226 wait_for_registered_processes ( 4 )
2327
2428 terminate_process ( pid )
2529 wait_for_registered_processes ( 0 )
2630
31+
2732 results = skip_active_record_query_cache do
28- assert_equal 8 , JobResult . count
29- JobResult . last ( 8 )
33+ job_results = JobResult . where ( status : :hook_called )
34+ assert_equal 12 , job_results . count
35+ job_results
3036 end
3137
32- assert_equal ( { "hook_called" => 8 } , results . map ( &:status ) . tally )
33- assert_equal %w[ start stop worker_start worker_stop dispatcher_start dispatcher_stop scheduler_start scheduler_stop ] . sort , results . map ( &:value ) . sort
38+ assert_equal ( { "hook_called" => 12 } , results . map ( &:status ) . tally )
39+ assert_equal %w[
40+ start stop exit
41+ worker_start worker_stop worker_exit
42+ dispatcher_start dispatcher_stop dispatcher_exit
43+ scheduler_start scheduler_stop scheduler_exit
44+ ] . sort , results . map ( &:value ) . sort
3445 ensure
3546 SolidQueue ::Supervisor . clear_hooks
3647 SolidQueue ::Worker . clear_hooks
0 commit comments