-
Notifications
You must be signed in to change notification settings - Fork 166
/
Copy pathplugin_test.rb
51 lines (38 loc) · 1.22 KB
/
plugin_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true
require "test_helper"
class PumaPluginTest < ActiveSupport::TestCase
self.use_transactional_tests = false
setup do
FileUtils.mkdir_p Rails.root.join("tmp", "pids")
Dir.chdir("test/dummy") do
cmd = %w[
bundle exec puma
-b tcp://127.0.0.1:9222
-C config/puma.rb
-s
config.ru
]
@pid = fork do
exec(*cmd)
end
end
wait_for_registered_processes(4, timeout: 3.second)
end
teardown do
terminate_process(@pid, signal: :INT)
wait_for_registered_processes 0, timeout: 1.second
JobResult.delete_all
end
test "perform jobs inside puma's process" do
StoreResultJob.perform_later(:puma_plugin)
wait_for_jobs_to_finish_for(1.second)
assert_equal 1, JobResult.where(queue_name: :background, status: "completed", value: :puma_plugin).count
end
test "stop the queue on puma's restart" do
signal_process(@pid, :SIGUSR2)
wait_for_registered_processes(4, timeout: 3.second)
StoreResultJob.perform_later(:puma_plugin)
wait_for_jobs_to_finish_for(2.seconds)
assert_equal 1, JobResult.where(queue_name: :background, status: "completed", value: :puma_plugin).count
end
end