@@ -8,29 +8,41 @@ class LifecycleHooksTest < ActiveSupport::TestCase
8
8
test "run lifecycle hooks" do
9
9
SolidQueue . on_start { JobResult . create! ( status : :hook_called , value : :start ) }
10
10
SolidQueue . on_stop { JobResult . create! ( status : :hook_called , value : :stop ) }
11
+ SolidQueue . on_exit { JobResult . create! ( status : :hook_called , value : :exit ) }
11
12
12
13
SolidQueue . on_worker_start { JobResult . create! ( status : :hook_called , value : :worker_start ) }
13
14
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 ) }
14
16
15
17
SolidQueue . on_dispatcher_start { JobResult . create! ( status : :hook_called , value : :dispatcher_start ) }
16
18
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 ) }
17
20
18
21
SolidQueue . on_scheduler_start { JobResult . create! ( status : :hook_called , value : :scheduler_start ) }
19
22
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 ) }
20
24
21
25
pid = run_supervisor_as_fork ( workers : [ { queues : "*" } ] , dispatchers : [ { batch_size : 100 } ] , skip_recurring : false )
22
26
wait_for_registered_processes ( 4 )
23
27
24
28
terminate_process ( pid )
25
29
wait_for_registered_processes ( 0 )
26
30
31
+
27
32
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
+ binding . b
35
+ assert_equal 12 , job_results . count
36
+ job_results
30
37
end
31
38
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
39
+ assert_equal ( { "hook_called" => 12 } , results . map ( &:status ) . tally )
40
+ assert_equal %w[
41
+ start stop exit
42
+ worker_start worker_stop worker_exit
43
+ dispatcher_start dispatcher_stop dispatcher_exit
44
+ scheduler_start scheduler_stop scheduler_exit
45
+ ] . sort , results . map ( &:value ) . sort
34
46
ensure
35
47
SolidQueue ::Supervisor . clear_hooks
36
48
SolidQueue ::Worker . clear_hooks
0 commit comments