inst-jobs 2.3.3 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/db/migrate/20101216224513_create_delayed_jobs.rb +9 -7
  3. data/db/migrate/20110531144916_cleanup_delayed_jobs_indexes.rb +8 -13
  4. data/db/migrate/20110610213249_optimize_delayed_jobs.rb +8 -8
  5. data/db/migrate/20110831210257_add_delayed_jobs_next_in_strand.rb +25 -25
  6. data/db/migrate/20120510004759_delayed_jobs_delete_trigger_lock_for_update.rb +4 -8
  7. data/db/migrate/20120531150712_drop_psql_jobs_pop_fn.rb +1 -3
  8. data/db/migrate/20120607164022_delayed_jobs_use_advisory_locks.rb +11 -15
  9. data/db/migrate/20120607181141_index_jobs_on_locked_by.rb +1 -1
  10. data/db/migrate/20120608191051_add_jobs_run_at_index.rb +2 -2
  11. data/db/migrate/20120927184213_change_delayed_jobs_handler_to_text.rb +1 -1
  12. data/db/migrate/20140505215510_copy_failed_jobs_original_id.rb +2 -3
  13. data/db/migrate/20150807133223_add_max_concurrent_to_jobs.rb +9 -13
  14. data/db/migrate/20151210162949_improve_max_concurrent.rb +4 -8
  15. data/db/migrate/20161206323555_add_back_default_string_limits_jobs.rb +3 -2
  16. data/db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb +13 -17
  17. data/db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb +8 -8
  18. data/db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb +72 -77
  19. data/db/migrate/20200825011002_add_strand_order_override.rb +93 -97
  20. data/db/migrate/20210809145804_add_n_strand_index.rb +3 -3
  21. data/db/migrate/20210812210128_add_singleton_column.rb +203 -0
  22. data/exe/inst_jobs +3 -2
  23. data/lib/delayed/backend/active_record.rb +182 -148
  24. data/lib/delayed/backend/base.rb +79 -74
  25. data/lib/delayed/batch.rb +11 -9
  26. data/lib/delayed/cli.rb +98 -84
  27. data/lib/delayed/core_ext/kernel.rb +4 -2
  28. data/lib/delayed/daemon.rb +70 -74
  29. data/lib/delayed/job_tracking.rb +26 -25
  30. data/lib/delayed/lifecycle.rb +27 -24
  31. data/lib/delayed/log_tailer.rb +17 -17
  32. data/lib/delayed/logging.rb +13 -16
  33. data/lib/delayed/message_sending.rb +42 -51
  34. data/lib/delayed/performable_method.rb +5 -7
  35. data/lib/delayed/periodic.rb +66 -65
  36. data/lib/delayed/plugin.rb +2 -4
  37. data/lib/delayed/pool.rb +198 -193
  38. data/lib/delayed/server/helpers.rb +6 -6
  39. data/lib/delayed/server.rb +51 -54
  40. data/lib/delayed/settings.rb +93 -81
  41. data/lib/delayed/testing.rb +21 -22
  42. data/lib/delayed/version.rb +1 -1
  43. data/lib/delayed/work_queue/in_process.rb +21 -18
  44. data/lib/delayed/work_queue/parent_process/client.rb +54 -55
  45. data/lib/delayed/work_queue/parent_process/server.rb +215 -209
  46. data/lib/delayed/work_queue/parent_process.rb +52 -53
  47. data/lib/delayed/worker/consul_health_check.rb +21 -19
  48. data/lib/delayed/worker/health_check.rb +21 -12
  49. data/lib/delayed/worker/null_health_check.rb +3 -1
  50. data/lib/delayed/worker/process_helper.rb +8 -9
  51. data/lib/delayed/worker.rb +271 -265
  52. data/lib/delayed/yaml_extensions.rb +12 -10
  53. data/lib/delayed_job.rb +37 -38
  54. data/lib/inst-jobs.rb +1 -1
  55. data/spec/active_record_job_spec.rb +128 -135
  56. data/spec/delayed/cli_spec.rb +7 -7
  57. data/spec/delayed/daemon_spec.rb +8 -8
  58. data/spec/delayed/message_sending_spec.rb +8 -9
  59. data/spec/delayed/periodic_spec.rb +13 -12
  60. data/spec/delayed/server_spec.rb +38 -38
  61. data/spec/delayed/settings_spec.rb +26 -25
  62. data/spec/delayed/work_queue/in_process_spec.rb +7 -7
  63. data/spec/delayed/work_queue/parent_process/client_spec.rb +15 -11
  64. data/spec/delayed/work_queue/parent_process/server_spec.rb +43 -40
  65. data/spec/delayed/work_queue/parent_process_spec.rb +21 -21
  66. data/spec/delayed/worker/consul_health_check_spec.rb +22 -22
  67. data/spec/delayed/worker/health_check_spec.rb +51 -49
  68. data/spec/delayed/worker_spec.rb +28 -25
  69. data/spec/gemfiles/52.gemfile +5 -3
  70. data/spec/gemfiles/52.gemfile.lock +240 -0
  71. data/spec/gemfiles/60.gemfile +5 -3
  72. data/spec/gemfiles/60.gemfile.lock +1 -1
  73. data/spec/gemfiles/61.gemfile +5 -3
  74. data/spec/sample_jobs.rb +45 -15
  75. data/spec/shared/delayed_batch.rb +74 -67
  76. data/spec/shared/delayed_method.rb +143 -102
  77. data/spec/shared/performable_method.rb +39 -38
  78. data/spec/shared/shared_backend.rb +517 -441
  79. data/spec/shared/testing.rb +14 -14
  80. data/spec/shared/worker.rb +155 -147
  81. data/spec/shared_jobs_specs.rb +13 -13
  82. data/spec/spec_helper.rb +43 -40
  83. metadata +74 -56
  84. data/lib/delayed/backend/redis/bulk_update.lua +0 -50
  85. data/lib/delayed/backend/redis/destroy_job.lua +0 -2
  86. data/lib/delayed/backend/redis/enqueue.lua +0 -29
  87. data/lib/delayed/backend/redis/fail_job.lua +0 -5
  88. data/lib/delayed/backend/redis/find_available.lua +0 -3
  89. data/lib/delayed/backend/redis/functions.rb +0 -59
  90. data/lib/delayed/backend/redis/get_and_lock_next_available.lua +0 -17
  91. data/lib/delayed/backend/redis/includes/jobs_common.lua +0 -203
  92. data/lib/delayed/backend/redis/job.rb +0 -528
  93. data/lib/delayed/backend/redis/set_running.lua +0 -5
  94. data/lib/delayed/backend/redis/tickle_strand.lua +0 -2
  95. data/spec/redis_job_spec.rb +0 -148
@@ -1,22 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe Delayed::CLI do
6
- describe '#parse_cli_options!' do
7
- it 'correctly parses the --config option' do
8
- cli = described_class.new(%w{run --config /path/to/some/file.yml})
6
+ describe "#parse_cli_options!" do
7
+ it "correctly parses the --config option" do
8
+ cli = described_class.new(%w[run --config /path/to/some/file.yml])
9
9
  options = cli.parse_cli_options!
10
- expect(options).to include config_file: '/path/to/some/file.yml'
10
+ expect(options).to include config_file: "/path/to/some/file.yml"
11
11
  end
12
12
  end
13
13
 
14
- describe '#run' do
14
+ describe "#run" do
15
15
  before do
16
16
  expect(Delayed::Settings).to receive(:worker_config).and_return({})
17
17
  end
18
18
 
19
- it 'prints help when no command is given' do
19
+ it "prints help when no command is given" do
20
20
  cli = described_class.new([])
21
21
  expect(cli).to receive(:puts).with(/Usage/)
22
22
  cli.run
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe Delayed::Daemon do
6
6
  let(:pid_folder) { "/test/pid/folder" }
@@ -11,25 +11,25 @@ RSpec.describe Delayed::Daemon do
11
11
  allow(subject).to receive(:pid).and_return(pid)
12
12
  end
13
13
 
14
- describe '#stop' do
15
- it 'prints status if not running' do
14
+ describe "#stop" do
15
+ it "prints status if not running" do
16
16
  expect(subject).to receive(:status).with(print: false, pid: pid).and_return(false)
17
17
  expect(subject).to receive(:status).with(no_args)
18
- expect(Process).to receive(:kill).never
18
+ expect(Process).not_to receive(:kill)
19
19
  subject.stop
20
20
  end
21
21
 
22
- it 'prints status if draining' do
22
+ it "prints status if draining" do
23
23
  expect(subject).to receive(:status).with(print: false, pid: pid).and_return(:draining)
24
24
  expect(subject).to receive(:status).with(no_args)
25
- expect(Process).to receive(:kill).never
25
+ expect(Process).not_to receive(:kill)
26
26
  subject.stop
27
27
  end
28
28
 
29
- it 'sends QUIT by default' do
29
+ it "sends QUIT by default" do
30
30
  expect(subject).to receive(:status).with(print: false, pid: pid).and_return(:running)
31
31
  expect(subject).to receive(:puts).with(/Stopping pool/)
32
- expect(Process).to receive(:kill).with('QUIT', pid)
32
+ expect(Process).to receive(:kill).with("QUIT", pid)
33
33
  expect(subject).to receive(:wait).with(false)
34
34
  subject.stop
35
35
  end
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
4
- require 'debug_inspector'
3
+ require "spec_helper"
4
+ require "debug_inspector"
5
5
 
6
6
  RSpec.describe Delayed::MessageSending do
7
7
  before do
8
8
  allow(::Rails.env).to receive(:test?).and_return(true)
9
9
  end
10
10
 
11
- before (:all) do
12
- class SpecClass
11
+ before(:all) do
12
+ # this has to be a "real" constant
13
+ class SpecClass # rubocop:disable RSpec/LeakyConstantDeclaration, Lint/ConstantDefinitionInBlock
13
14
  def call_private(**enqueue_args)
14
15
  delay(**enqueue_args).private_method
15
16
  end
@@ -21,13 +22,11 @@ RSpec.describe Delayed::MessageSending do
21
22
 
22
23
  private
23
24
 
24
- def private_method
25
- end
25
+ def private_method; end
26
26
 
27
27
  protected
28
28
 
29
- def protected_method
30
- end
29
+ def protected_method; end
31
30
  end
32
31
  end
33
32
 
@@ -89,7 +88,7 @@ RSpec.describe Delayed::MessageSending do
89
88
  Kernel.delay.sleep(1)
90
89
  end
91
90
 
92
- def encode_with(encoder)
91
+ def encode_with(_encoder)
93
92
  raise "yaml encoding failed"
94
93
  end
95
94
  end
@@ -1,30 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe Delayed::Periodic do
6
- around(:each) do |block|
6
+ around do |block|
7
7
  # make sure we can use ".cron" and
8
8
  # such safely without leaking global state
9
- prev_sched = Delayed::Periodic.scheduled
10
- prev_ovr = Delayed::Periodic.overrides
11
- Delayed::Periodic.scheduled = {}
12
- Delayed::Periodic.overrides = {}
9
+ prev_sched = described_class.scheduled
10
+ prev_ovr = described_class.overrides
11
+ described_class.scheduled = {}
12
+ described_class.overrides = {}
13
13
  block.call
14
14
  ensure
15
- Delayed::Periodic.scheduled = prev_sched
16
- Delayed::Periodic.overrides = prev_ovr
15
+ described_class.scheduled = prev_sched
16
+ described_class.overrides = prev_ovr
17
17
  Delayed::Job.delete_all
18
18
  end
19
19
 
20
20
  describe ".cron" do
21
- let(:job_name){ 'just a test'}
21
+ let(:job_name) { "just a test" }
22
+
22
23
  it "provides a tag by default for periodic jobs" do
23
- Delayed::Periodic.cron job_name, '*/10 * * * *' do
24
+ described_class.cron job_name, "*/10 * * * *" do
24
25
  # no-op
25
26
  end
26
- instance = Delayed::Periodic.scheduled[job_name]
27
- expect(instance).to_not be_nil
27
+ instance = described_class.scheduled[job_name]
28
+ expect(instance).not_to be_nil
28
29
  expect(instance.enqueue_args[:singleton]).to eq("periodic: just a test")
29
30
  end
30
31
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
4
- require 'delayed/server'
3
+ require "spec_helper"
4
+ require "delayed/server"
5
5
 
6
6
  RSpec.describe Delayed::Server, sinatra: true do
7
7
  include Rack::Test::Methods
@@ -24,78 +24,78 @@ RSpec.describe Delayed::Server, sinatra: true do
24
24
  before do
25
25
  3.times do |i|
26
26
  Delayed::Job.create!({
27
- run_at: Time.now,
28
- locked_at: Time.now,
29
- locked_by: "dummy-runner-#{i}:${$$}",
30
- })
27
+ run_at: Time.zone.now,
28
+ locked_at: Time.zone.now,
29
+ locked_by: "dummy-runner-#{i}:${$$}"
30
+ })
31
31
  end
32
- get '/running'
32
+ get "/running"
33
33
  end
34
34
 
35
- it 'must return a json object with the running job data in an array', aggregate_failures: true do
35
+ it "must return a json object with the running job data in an array", aggregate_failures: true do
36
36
  expect(last_response).to be_ok
37
- expect(parsed_body['data']).to be_an Array
38
- expect(parsed_body['data'].size).to eq 3
37
+ expect(parsed_body["data"]).to be_an Array
38
+ expect(parsed_body["data"].size).to eq 3
39
39
  end
40
40
  end
41
41
 
42
42
  describe "get '/jobs'" do
43
- let!(:job_1) { Delayed::Job.enqueue(SimpleJob.new, strand: 'strand-1') }
44
- let!(:job_2) { Delayed::Job.enqueue(SimpleJob.new, strand: 'strand-2') }
45
- let!(:job_3) { Delayed::Job.enqueue(SimpleJob.new, strand: 'strand-3') }
43
+ let!(:job1) { Delayed::Job.enqueue(SimpleJob.new, strand: "strand-1") }
44
+ let!(:job2) { Delayed::Job.enqueue(SimpleJob.new, strand: "strand-2") }
45
+ let!(:job3) { Delayed::Job.enqueue(SimpleJob.new, strand: "strand-3") }
46
46
 
47
- context 'with the flavor param set to id' do
47
+ context "with the flavor param set to id" do
48
48
  before do
49
- get "/jobs?flavor=id&search_term=#{job_2.id}"
49
+ get "/jobs?flavor=id&search_term=#{job2.id}"
50
50
  end
51
51
 
52
- it 'must only return the job with the id specified in the search_term param' do
53
- jobs = parsed_body['data']
54
- job_ids = jobs.map{ |j| j['id'] }
55
- expect(job_ids).to eq [job_2.id]
52
+ it "must only return the job with the id specified in the search_term param" do
53
+ jobs = parsed_body["data"]
54
+ job_ids = jobs.map { |j| j["id"] }
55
+ expect(job_ids).to eq [job2.id]
56
56
  end
57
57
 
58
- it 'must set recordsFiltered in the response to 1' do
59
- expect(parsed_body['recordsFiltered']).to eq 1
58
+ it "must set recordsFiltered in the response to 1" do
59
+ expect(parsed_body["recordsFiltered"]).to eq 1
60
60
  end
61
61
  end
62
62
  end
63
63
 
64
64
  describe "post '/bulk_update'" do
65
- let!(:job_1) { Delayed::Job.enqueue(SimpleJob.new, strand: 'strand-1') }
66
- let!(:job_2) { Delayed::Job.enqueue(SimpleJob.new, strand: 'strand-2') }
67
- let!(:job_3) { Delayed::Job.enqueue(SimpleJob.new, strand: 'strand-3') }
65
+ let!(:job1) { Delayed::Job.enqueue(SimpleJob.new, strand: "strand-1") }
66
+ let!(:job2) { Delayed::Job.enqueue(SimpleJob.new, strand: "strand-2") }
67
+ let!(:job3) { Delayed::Job.enqueue(SimpleJob.new, strand: "strand-3") }
68
68
 
69
- context 'with update enabled' do
69
+ context "with update enabled" do
70
70
  before do
71
71
  @update = true
72
- post "/bulk_update", params=JSON.generate(action: 'destroy', ids: [job_1.id])
72
+ post "/bulk_update", JSON.generate(action: "destroy", ids: [job1.id])
73
73
  end
74
74
 
75
- it 'must remove job_1' do
76
- expect{ Delayed::Job.find(job_1.id) }.to raise_error(ActiveRecord::RecordNotFound)
77
- expect(Delayed::Job.find(job_2.id)).to_not be_nil
78
- expect(Delayed::Job.find(job_3.id)).to_not be_nil
75
+ it "must remove job1" do
76
+ expect { Delayed::Job.find(job1.id) }.to raise_error(ActiveRecord::RecordNotFound)
77
+ expect(Delayed::Job.find(job2.id)).not_to be_nil
78
+ expect(Delayed::Job.find(job3.id)).not_to be_nil
79
79
  end
80
80
 
81
- it 'must return ok' do
81
+ it "must return ok" do
82
82
  expect(last_response.ok?).to be true
83
83
  end
84
84
  end
85
85
 
86
- context 'with update disabled' do
86
+ context "with update disabled" do
87
87
  before do
88
88
  @update = false
89
- post "/bulk_update", params=JSON.generate(action: 'destroy', ids: [job_1.id])
89
+ post "/bulk_update", JSON.generate(action: "destroy", ids: [job1.id])
90
90
  end
91
91
 
92
- it 'must not remove job_1' do
93
- expect(Delayed::Job.find(job_1.id)).to_not be_nil
94
- expect(Delayed::Job.find(job_2.id)).to_not be_nil
95
- expect(Delayed::Job.find(job_3.id)).to_not be_nil
92
+ it "must not remove job1" do
93
+ expect(Delayed::Job.find(job1.id)).not_to be_nil
94
+ expect(Delayed::Job.find(job2.id)).not_to be_nil
95
+ expect(Delayed::Job.find(job3.id)).not_to be_nil
96
96
  end
97
97
 
98
- it 'must return forbidden' do
98
+ it "must return forbidden" do
99
99
  expect(last_response.forbidden?).to be true
100
100
  end
101
101
  end
@@ -1,47 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe Delayed::Settings do
6
- let(:configfile) {<<-YAML
7
- default:
8
- workers:
9
- - queue: myqueue
10
- workers: 2
11
- - queue: secondqueue
12
- max_priority: 7
13
- max_attempts: 1
6
+ let(:configfile) do
7
+ <<~YAML
8
+ default:
9
+ workers:
10
+ - queue: myqueue
11
+ workers: 2
12
+ - queue: secondqueue
13
+ max_priority: 7
14
+ max_attempts: 1
14
15
  YAML
15
- }
16
+ end
16
17
 
17
- describe '.worker_config' do
18
- it 'merges each worker config with the top-level config' do
18
+ describe ".worker_config" do
19
+ it "merges each worker config with the top-level config" do
19
20
  expect(File).to receive(:read).with("fname").and_return(configfile)
20
21
  config = described_class.worker_config("fname")
21
22
  expect(config[:workers]).to eq([
22
- {'queue' => 'myqueue', 'workers' => 2, 'max_attempts' => 1},
23
- {'queue' => 'secondqueue', 'max_priority' => 7, 'max_attempts' => 1},
24
- ])
23
+ { "queue" => "myqueue", "workers" => 2, "max_attempts" => 1 },
24
+ { "queue" => "secondqueue", "max_priority" => 7, "max_attempts" => 1 }
25
+ ])
25
26
  end
26
27
  end
27
28
 
28
- describe '.apply_worker_config!' do
29
- it 'applies global settings from the given config' do
29
+ describe ".apply_worker_config!" do
30
+ it "applies global settings from the given config" do
30
31
  expect(described_class).to receive(:last_ditch_logfile=).with(true)
31
- described_class.apply_worker_config!('last_ditch_logfile' => true)
32
+ described_class.apply_worker_config!("last_ditch_logfile" => true)
32
33
  end
33
34
 
34
- it 'merges in parent_process overrides to default config' do
35
- described_class.apply_worker_config!('parent_process' => { 'foo' => 'bar' })
35
+ it "merges in parent_process overrides to default config" do
36
+ described_class.apply_worker_config!("parent_process" => { "foo" => "bar" })
36
37
 
37
- expect(Delayed::Settings.parent_process).to include('foo' => 'bar')
38
+ expect(described_class.parent_process).to include("foo" => "bar")
38
39
  end
39
40
  end
40
41
 
41
- describe '.parent_process_client_timeout=' do
42
- it 'must update the value in the parent_process settings hash' do
43
- Delayed::Settings.parent_process_client_timeout = 42
44
- expect(Delayed::Settings.parent_process['server_socket_timeout']).to eq 42
42
+ describe ".parent_process_client_timeout=" do
43
+ it "must update the value in the parent_process settings hash" do
44
+ described_class.parent_process_client_timeout = 42
45
+ expect(described_class.parent_process["server_socket_timeout"]).to eq 42
45
46
  end
46
47
  end
47
48
  end
@@ -1,27 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe Delayed::WorkQueue::InProcess do
6
6
  before :all do
7
7
  Delayed.select_backend(Delayed::Backend::ActiveRecord::Job)
8
8
  end
9
9
 
10
- after :each do
10
+ after do
11
11
  Delayed::Worker.lifecycle.reset!
12
12
  end
13
13
 
14
14
  let(:subject) { described_class.new }
15
- let(:worker_config) { {queue: "test", min_priority: 1, max_priority: 2} }
15
+ let(:worker_config) { { queue: "test", min_priority: 1, max_priority: 2 } }
16
16
  let(:args) { ["worker_name", worker_config] }
17
17
 
18
- it 'triggers the lifecycle event around the pop' do
18
+ it "triggers the lifecycle event around the pop" do
19
19
  called = false
20
20
  Delayed::Worker.lifecycle.around(:work_queue_pop) do |queue, &cb|
21
21
  expect(queue).to eq(subject)
22
- expect(Delayed::Job).to receive(:get_and_lock_next_available).
23
- with("worker_name", "test", 1, 2).
24
- and_return(:job)
22
+ expect(Delayed::Job).to receive(:get_and_lock_next_available)
23
+ .with("worker_name", "test", 1, 2)
24
+ .and_return(:job)
25
25
  called = true
26
26
  cb.call(queue)
27
27
  end
@@ -1,22 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe Delayed::WorkQueue::ParentProcess::Client do
6
6
  let(:subject) { described_class.new(addrinfo).tap(&:init) }
7
- let(:addrinfo) { double('Addrinfo') }
8
- let(:connection) { double('Socket') }
7
+ let(:addrinfo) { double("Addrinfo") }
8
+ let(:connection) { double("Socket") }
9
9
  let(:job) { Delayed::Job.new(locked_by: "worker_name") }
10
10
  let(:worker_config) { { queue: "queue_name", min_priority: 1, max_priority: 2 } }
11
11
  let(:args) { ["worker_name", worker_config] }
12
12
  let(:job_args) { [["worker_name"], "queue_name", 1, 2] }
13
13
 
14
14
  before :all do
15
- FileUtils.mkdir_p(Delayed::Settings.expand_rails_path('tmp'))
15
+ FileUtils.mkdir_p(Delayed::Settings.expand_rails_path("tmp"))
16
16
  Delayed.select_backend(Delayed::Backend::ActiveRecord::Job)
17
17
  end
18
18
 
19
- it 'marshals the given arguments to the server and returns the response' do
19
+ it "marshals the given arguments to the server and returns the response" do
20
20
  expect(addrinfo).to receive(:connect).once.and_return(connection)
21
21
  expect(connection).to receive(:eof?).and_return(false)
22
22
  expect(IO).to receive(:select).and_return([[connection], nil, nil])
@@ -26,7 +26,7 @@ RSpec.describe Delayed::WorkQueue::ParentProcess::Client do
26
26
  expect(response).to eq(job)
27
27
  end
28
28
 
29
- it 'returns nil and then reconnects on socket write error' do
29
+ it "returns nil and then reconnects on socket write error" do
30
30
  expect(addrinfo).to receive(:connect).once.and_return(connection)
31
31
  expect(Marshal).to receive(:dump).and_raise(SystemCallError.new("failure"))
32
32
  expect(IO).to receive(:select).and_return([[connection], nil, nil])
@@ -42,7 +42,7 @@ RSpec.describe Delayed::WorkQueue::ParentProcess::Client do
42
42
  expect(response).to eq(job)
43
43
  end
44
44
 
45
- it 'returns nil and then reconnects when the socket indicates eof' do
45
+ it "returns nil and then reconnects when the socket indicates eof" do
46
46
  expect(addrinfo).to receive(:connect).once.and_return(connection)
47
47
  expect(connection).to receive(:eof?).and_return(true)
48
48
  expect(Marshal).to receive(:dump).with(args, connection).ordered
@@ -59,17 +59,19 @@ RSpec.describe Delayed::WorkQueue::ParentProcess::Client do
59
59
  expect(response).to eq(job)
60
60
  end
61
61
 
62
- it 'errors if the response is not a locked job' do
62
+ it "errors if the response is not a locked job" do
63
63
  expect(addrinfo).to receive(:connect).once.and_return(connection)
64
64
  expect(Marshal).to receive(:dump).with(args, connection)
65
65
  expect(IO).to receive(:select).and_return([[connection], nil, nil])
66
66
  expect(Marshal).to receive(:load).with(connection).and_return(:not_a_job)
67
67
  expect(connection).to receive(:eof?).and_return(false)
68
68
 
69
- expect { subject.get_and_lock_next_available(*args) }.to raise_error(Delayed::WorkQueue::ParentProcess::ProtocolError)
69
+ expect do
70
+ subject.get_and_lock_next_available(*args)
71
+ end.to raise_error(Delayed::WorkQueue::ParentProcess::ProtocolError)
70
72
  end
71
73
 
72
- it 'errors if the response is a job not locked by this worker' do
74
+ it "errors if the response is a job not locked by this worker" do
73
75
  expect(addrinfo).to receive(:connect).once.and_return(connection)
74
76
  expect(Marshal).to receive(:dump).with(args, connection)
75
77
  job.locked_by = "somebody_else"
@@ -77,6 +79,8 @@ RSpec.describe Delayed::WorkQueue::ParentProcess::Client do
77
79
  expect(Marshal).to receive(:load).with(connection).and_return(job)
78
80
  expect(connection).to receive(:eof?).and_return(false)
79
81
 
80
- expect { subject.get_and_lock_next_available(*args) }.to raise_error(Delayed::WorkQueue::ParentProcess::ProtocolError)
82
+ expect do
83
+ subject.get_and_lock_next_available(*args)
84
+ end.to raise_error(Delayed::WorkQueue::ParentProcess::ProtocolError)
81
85
  end
82
86
  end