backburner 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -4
- data/README.md +70 -14
- data/lib/active_job/queue_adapters/backburner_adapter.rb +9 -2
- data/lib/backburner/cli.rb +1 -1
- data/lib/backburner/enqueue_pool.rb +2 -0
- data/lib/backburner/performable.rb +28 -3
- data/lib/backburner/version.rb +1 -1
- data/lib/backburner/worker.rb +38 -4
- data/lib/backburner/workers/threading.rb +16 -0
- data/lib/backburner/workers/threads_on_fork.rb +1 -0
- metadata +8 -82
- data/.github/workflows/ci.yml +0 -45
- data/.github/workflows/github-release.yml +0 -58
- data/.github/workflows/release.yml +0 -221
- data/.gitignore +0 -17
- data/CONTRIBUTING.md +0 -37
- data/Gemfile +0 -7
- data/Rakefile +0 -17
- data/TODO +0 -4
- data/backburner.gemspec +0 -31
- data/examples/custom.rb +0 -25
- data/examples/demo.rb +0 -60
- data/examples/god.rb +0 -46
- data/examples/hooked.rb +0 -87
- data/examples/retried.rb +0 -31
- data/examples/simple.rb +0 -43
- data/examples/stress.rb +0 -31
- data/test/active_job_adapter_test.rb +0 -24
- data/test/async_proxy_test.rb +0 -36
- data/test/back_burner_test.rb +0 -101
- data/test/connection_test.rb +0 -201
- data/test/fixtures/active_job_app.rb +0 -53
- data/test/fixtures/active_jobs.rb +0 -11
- data/test/fixtures/autoload/test_broken_name_job.rb +0 -4
- data/test/fixtures/autoload/test_broken_no_method_job.rb +0 -4
- data/test/fixtures/autoload/test_broken_require_job.rb +0 -4
- data/test/fixtures/autoload/test_broken_runtime_job.rb +0 -4
- data/test/fixtures/autoload/test_broken_syntax_job.rb +0 -4
- data/test/fixtures/autoload/test_broken_timeout_job.rb +0 -4
- data/test/fixtures/autoload/test_same_name_job.rb +0 -5
- data/test/fixtures/hooked.rb +0 -122
- data/test/fixtures/test_fork_jobs.rb +0 -77
- data/test/fixtures/test_forking_jobs.rb +0 -56
- data/test/fixtures/test_jobs.rb +0 -140
- data/test/fixtures/test_queue_settings.rb +0 -54
- data/test/helpers/templogger.rb +0 -22
- data/test/helpers_test.rb +0 -462
- data/test/hooks_test.rb +0 -112
- data/test/job_test.rb +0 -207
- data/test/logger_test.rb +0 -71
- data/test/performable_test.rb +0 -138
- data/test/queue_test.rb +0 -132
- data/test/test_helper.rb +0 -182
- data/test/worker_test.rb +0 -502
- data/test/workers/forking_worker_test.rb +0 -199
- data/test/workers/simple_worker_test.rb +0 -622
- data/test/workers/threading_worker_test.rb +0 -125
- data/test/workers/threads_on_fork_worker_test.rb +0 -751
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
|
2
|
-
require File.expand_path('../../fixtures/test_jobs', __FILE__)
|
|
3
|
-
require File.expand_path('../../fixtures/hooked', __FILE__)
|
|
4
|
-
require File.expand_path('../../fixtures/test_queue_settings', __FILE__)
|
|
5
|
-
|
|
6
|
-
describe "Backburner::Workers::Threading worker" do
|
|
7
|
-
before do
|
|
8
|
-
Backburner.default_queues.clear
|
|
9
|
-
@worker_class = Backburner::Workers::Threading
|
|
10
|
-
@worker_class.shutdown_timeout = 2
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe "for prepare method" do
|
|
14
|
-
it "should make tube names array always unique to avoid duplication" do
|
|
15
|
-
worker = @worker_class.new(["foo", "demo.test.foo"])
|
|
16
|
-
capture_stdout { worker.prepare }
|
|
17
|
-
assert_equal ["demo.test.foo"], worker.tube_names
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'creates a thread pool per queue' do
|
|
21
|
-
worker = @worker_class.new(%w(foo bar))
|
|
22
|
-
capture_stdout { worker.prepare }
|
|
23
|
-
assert_equal 2, worker.instance_variable_get("@thread_pools").keys.size
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'uses Concurrent.processor_count if no custom thread count is provided' do
|
|
27
|
-
worker = @worker_class.new("foo")
|
|
28
|
-
capture_stdout { worker.prepare }
|
|
29
|
-
assert_equal ::Concurrent.processor_count, worker.instance_variable_get("@thread_pools")["demo.test.foo"].max_length
|
|
30
|
-
end
|
|
31
|
-
end # prepare
|
|
32
|
-
|
|
33
|
-
describe "for process_tube_names method" do
|
|
34
|
-
it "should interpret the job_name:threads_limit format" do
|
|
35
|
-
worker = @worker_class.new(["foo:4"])
|
|
36
|
-
assert_equal ["foo"], worker.tube_names
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "should interpret correctly even if missing values" do
|
|
40
|
-
tubes = %W(foo1:2 foo2)
|
|
41
|
-
worker = @worker_class.new(tubes)
|
|
42
|
-
assert_equal %W(foo1 foo2), worker.tube_names
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "should store interpreted values correctly" do
|
|
46
|
-
tubes = %W(foo1 foo2:2)
|
|
47
|
-
worker = @worker_class.new(tubes)
|
|
48
|
-
assert_equal({
|
|
49
|
-
"demo.test.foo1" => { :threads => nil },
|
|
50
|
-
"demo.test.foo2" => { :threads => 2 }
|
|
51
|
-
}, worker.instance_variable_get("@tubes_data"))
|
|
52
|
-
end
|
|
53
|
-
end # process_tube_names
|
|
54
|
-
|
|
55
|
-
describe "for process_tube_options method" do
|
|
56
|
-
it "should take a shared tube's limit from the class that owns the tube, not from subclasses" do
|
|
57
|
-
worker = @worker_class.new(%w(tube-limits tube-limits-testtubelimitslambdachildjob))
|
|
58
|
-
assert_equal({
|
|
59
|
-
"demo.test.tube-limits" => { :threads => 5 },
|
|
60
|
-
"demo.test.tube-limits-testtubelimitslambdachildjob" => { :threads => 4 }
|
|
61
|
-
}, worker.instance_variable_get("@tubes_data"))
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it "should fill in a shared tube's limit from a subclass when the tube's class sets none" do
|
|
65
|
-
worker = @worker_class.new(%w(tube-few-limits))
|
|
66
|
-
assert_equal({ "demo.test.tube-few-limits" => { :threads => 3 } }, worker.instance_variable_get("@tubes_data"))
|
|
67
|
-
end
|
|
68
|
-
end # process_tube_options
|
|
69
|
-
|
|
70
|
-
describe 'working a queue' do
|
|
71
|
-
before do
|
|
72
|
-
@worker = @worker_class.new(["foo:3"])
|
|
73
|
-
capture_stdout { @worker.prepare }
|
|
74
|
-
$worker_test_count = 0
|
|
75
|
-
$worker_success = false
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it 'runs work_on_job per thread' do
|
|
79
|
-
clear_jobs!("foo")
|
|
80
|
-
job_count=10
|
|
81
|
-
# TestJob adds the given arguments together and then to $worker_test_count
|
|
82
|
-
job_count.times { @worker_class.enqueue TestJob, [1, 0], :queue => "foo" }
|
|
83
|
-
capture_stdout do
|
|
84
|
-
@worker.start(false) # don't wait for shutdown
|
|
85
|
-
sleep 0.5 # Wait for threads to do their work
|
|
86
|
-
end
|
|
87
|
-
assert_equal job_count, $worker_test_count
|
|
88
|
-
end
|
|
89
|
-
end # working a queue
|
|
90
|
-
|
|
91
|
-
describe 'shutting down' do
|
|
92
|
-
before do
|
|
93
|
-
@thread_count = 3
|
|
94
|
-
@worker = @worker_class.new(["threaded-shutdown:#{@thread_count}"])
|
|
95
|
-
@worker.exit_on_shutdown = false
|
|
96
|
-
$worker_test_count = 0
|
|
97
|
-
clear_jobs!("threaded-shutdown")
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it 'gracefully exits and completes all in-flight jobs' do
|
|
101
|
-
6.times { @worker_class.enqueue TestSlowJob, [1, 0], :queue => "threaded-shutdown" }
|
|
102
|
-
Thread.new { sleep 0.1; @worker.self_write.puts("TERM") }
|
|
103
|
-
capture_stdout do
|
|
104
|
-
@worker.start
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
assert_equal @thread_count, $worker_test_count
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# Its own tube and worker: the jobs it leaves reserved go back to ready when their connections are
|
|
111
|
-
# finalized, and must not reach another test's workers
|
|
112
|
-
it 'forces an exit when a job is stuck' do
|
|
113
|
-
clear_jobs!("threaded-stuck")
|
|
114
|
-
@worker = @worker_class.new(["threaded-stuck:#{@thread_count}"])
|
|
115
|
-
@worker.exit_on_shutdown = false
|
|
116
|
-
6.times { @worker_class.enqueue TestStuckJob, [1, 0], :queue => "threaded-stuck" }
|
|
117
|
-
Thread.new { sleep 0.1; @worker.self_write.puts("TERM") }
|
|
118
|
-
capture_stdout do
|
|
119
|
-
@worker.start
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
assert_equal 0, $worker_test_count
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|