roqua-support 0.1.31 → 0.1.32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed3f4fd495ac70793c3205d0ef1d26c30660c7e8
4
- data.tar.gz: 673b3bee6a8251f9cb0f2c8700f9e42c0444a5c9
3
+ metadata.gz: a9d0ec0470625062a0df4edb555e4147b66ad68d
4
+ data.tar.gz: 7a6a0a0a4724b6c669d33f270c287440c0aa854f
5
5
  SHA512:
6
- metadata.gz: cc14ae28e46cc910743f30789d8aa133a662353272b1a2650dabb905cf69b39fd1feb5a3b8b71db03655d0bdc5246b806ac5c616f1154815dc2702b1e55b6a91
7
- data.tar.gz: e4bdbcae705a0c8b1879602ed920c1798106b0c9458ea6a55b3e4f4cb52602466ba7a5db78faccbd823cbdeb96daaf7673ce117cb580fdd091d4a01bb30edd0c
6
+ metadata.gz: cbd3b91615e9541dbef76167809a7fe2e50134a810605d9aa46aafa75d3f16bfc192f037dbebc34b4919b09950060b5014d925022ed9d15fa1ace34acf259317
7
+ data.tar.gz: 96ffc851835f35ff9a866fff1c9d7152a85d14ae93599759d554bace1e8352f364099233cb6549d5e7c619cc25d6bda1211efd9412e0ccd689ac562a0339dbde
data/.gitlab-ci.yml CHANGED
@@ -1,26 +1,52 @@
1
- image: "registry.roqua.nl/roqua/roqua-build-images:ruby-2.3-rails-base-test"
2
-
3
1
  variables:
4
2
  RAILS_ENV: "test"
5
3
 
6
- cache:
7
- paths:
8
- - .gems
9
-
10
4
  before_script:
11
5
  - export BUNDLE_PATH=$CI_PROJECT_DIR/.gems
12
6
  - bundle --jobs 2 --retry 3
13
7
  - bundle exec appraisal
14
8
  - bundle --jobs 2 --retry 3
15
9
 
16
- rails_41:
10
+ .ruby_23: &ruby_23
11
+ image: registry.roqua.nl/roqua/roqua-build-images:ruby-2.3-rails-base-test
12
+ cache:
13
+ key: ruby_23
14
+ paths:
15
+ - .gems
16
+
17
+ .ruby_24: &ruby_24
18
+ image: registry.roqua.nl/roqua/roqua-build-images:ruby-2.4-rails-base-test
19
+ cache:
20
+ key: ruby_24
21
+ paths:
22
+ - .gems
23
+
24
+ rails_41_ruby_23:
25
+ <<: *ruby_23
17
26
  script:
18
27
  - bundle exec appraisal rails41 bundle exec rspec
19
28
 
20
- rails_42:
29
+ rails_42_ruby_23:
30
+ <<: *ruby_23
21
31
  script:
22
32
  - bundle exec appraisal rails42 bundle exec rspec
23
33
 
24
- rails_50:
34
+ rails_50_ruby_23:
35
+ <<: *ruby_23
25
36
  script:
26
37
  - bundle exec appraisal rails50 bundle exec rspec
38
+
39
+ rails_50_ruby_24:
40
+ <<: *ruby_24
41
+ script:
42
+ - bundle exec appraisal rails50 bundle exec rspec
43
+
44
+ rails_51_ruby_23:
45
+ <<: *ruby_23
46
+ script:
47
+ - bundle exec appraisal rails51 bundle exec rspec
48
+
49
+ rails_51_ruby_24:
50
+ <<: *ruby_24
51
+ script:
52
+ - bundle exec appraisal rails51 bundle exec rspec
data/Appraisals CHANGED
@@ -9,3 +9,7 @@ end
9
9
  appraise "rails50" do
10
10
  gem "activesupport", "5.0"
11
11
  end
12
+
13
+ appraise "rails51" do
14
+ gem "activesupport", "5.1"
15
+ end
data/Gemfile CHANGED
@@ -11,6 +11,7 @@ group :test do
11
11
  gem 'active_interaction', '~> 3.0'
12
12
  gem 'appsignal'
13
13
  gem 'combustion', '~> 0.5.2'
14
+ gem 'fakefs', require: 'fakefs/safe'
14
15
  gem 'guard-rspec', '~> 4.2.6'
15
16
  gem 'responders'
16
17
  gem 'rspec-instrumentation-matcher'
data/Gemfile.lock CHANGED
@@ -65,6 +65,7 @@ GEM
65
65
  delayed_job (>= 3.0, < 5)
66
66
  diff-lcs (1.3)
67
67
  erubis (2.7.0)
68
+ fakefs (0.15.0)
68
69
  ffi (1.9.17)
69
70
  formatador (0.2.5)
70
71
  guard (2.14.0)
@@ -183,6 +184,7 @@ DEPENDENCIES
183
184
  bundler (~> 1.0)
184
185
  combustion (~> 0.5.2)
185
186
  delayed_job_active_record
187
+ fakefs
186
188
  guard-rspec (~> 4.2.6)
187
189
  rake
188
190
  responders
@@ -195,4 +197,4 @@ DEPENDENCIES
195
197
  timecop
196
198
 
197
199
  BUNDLED WITH
198
- 1.16.1
200
+ 1.16.2
data/README.md CHANGED
@@ -100,6 +100,14 @@ class ApiAreaController < ApplicationController
100
100
  ...
101
101
  ```
102
102
 
103
+ # Delayed Job activity monitoring
104
+
105
+ To add monitoring of whether Delayed Job keeps picking up jobs or checking for new jobs, add the following line to an initializer:
106
+
107
+ ```ruby
108
+ require 'roqua/core_ext/delayed_job/activity_monitoring'
109
+ ```
110
+
103
111
  # AppSignal Probes
104
112
 
105
113
  roqua-support contains one generic probe to monitor the current delayed job backlog count: `Roqua::Probes::DelayedJobProbe`
@@ -3,11 +3,13 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
+ gem "roqua_styleguide", :git => "https://gitlab.roqua.nl/roqua/styleguide.git"
6
7
  gem "activesupport", "4.1"
7
8
 
8
9
  group :test do
9
10
  gem "actionpack", ">= 4.0"
10
11
  gem "active_interaction", "~> 3.0"
12
+ gem "appsignal"
11
13
  gem "combustion", "~> 0.5.2"
12
14
  gem "guard-rspec", "~> 4.2.6"
13
15
  gem "responders"
@@ -3,11 +3,13 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
+ gem "roqua_styleguide", :git => "https://gitlab.roqua.nl/roqua/styleguide.git"
6
7
  gem "activesupport", "4.2"
7
8
 
8
9
  group :test do
9
10
  gem "actionpack", ">= 4.0"
10
11
  gem "active_interaction", "~> 3.0"
12
+ gem "appsignal"
11
13
  gem "combustion", "~> 0.5.2"
12
14
  gem "guard-rspec", "~> 4.2.6"
13
15
  gem "responders"
@@ -3,11 +3,13 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
+ gem "roqua_styleguide", :git => "https://gitlab.roqua.nl/roqua/styleguide.git"
6
7
  gem "activesupport", "5.0"
7
8
 
8
9
  group :test do
9
10
  gem "actionpack", ">= 4.0"
10
11
  gem "active_interaction", "~> 3.0"
12
+ gem "appsignal"
11
13
  gem "combustion", "~> 0.5.2"
12
14
  gem "guard-rspec", "~> 4.2.6"
13
15
  gem "responders"
@@ -0,0 +1,20 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "roqua_styleguide", :git => "https://gitlab.roqua.nl/roqua/styleguide.git"
7
+ gem "activesupport", "5.1"
8
+
9
+ group :test do
10
+ gem "actionpack", ">= 4.0"
11
+ gem "active_interaction", "~> 3.0"
12
+ gem "appsignal"
13
+ gem "combustion", "~> 0.5.2"
14
+ gem "guard-rspec", "~> 4.2.6"
15
+ gem "responders"
16
+ gem "rspec-instrumentation-matcher"
17
+ gem "rspec-rails"
18
+ end
19
+
20
+ gemspec :path => "../"
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module Support
3
- VERSION = '0.1.31'.freeze
3
+ VERSION = '0.1.32'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,32 @@
1
+ require 'delayed_job'
2
+
3
+ #
4
+ # Updates the modification time of the file $RAILS_ROOT/tmp/delayed_job_activity when
5
+ # relevant worker activity occurs. To be used for monitoring whether a DelayedJob
6
+ # worker is still picking up new work in a timely fashion.
7
+ #
8
+ # A file based approach is used so it is easy to add a health check to a Docker container
9
+ # with the following command:
10
+ # `find /app/tmp -mmin -$MAXIMUM_AGE_OF_FILE_IN_MINUTES -type f -print | grep delayed_job_activity`
11
+ #
12
+ module DelayedJobActivityMonitoring
13
+ def work_off(num = 100)
14
+ FileUtils.touch(Rails.root.join('tmp', 'delayed_job_activity'))
15
+ super(num)
16
+ end
17
+
18
+ protected
19
+
20
+ def reserve_job
21
+ super.tap do |job|
22
+ if job
23
+ FileUtils.touch(
24
+ Rails.root.join('tmp', 'delayed_job_activity'),
25
+ mtime: job.max_run_time.from_now
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ Delayed::Worker.send(:prepend, DelayedJobActivityMonitoring) if defined?(Delayed) && defined?(Delayed::Worker)
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+ require 'pathname'
3
+ require 'timecop'
4
+ require 'fakefs/safe'
5
+
6
+ require 'roqua/core_ext/delayed_job/activity_monitoring'
7
+
8
+ describe DelayedJobActivityMonitoring do
9
+ after do
10
+ Timecop.return
11
+ end
12
+
13
+ def initialize_fake_rails_root
14
+ FileUtils.mkdir_p(File.join('/app', 'tmp'))
15
+ allow(Rails).to receive(:root).and_return(Pathname.new('/app'))
16
+ end
17
+
18
+ let(:monitoring_filename) { Rails.root.join('tmp', 'delayed_job_activity').to_s }
19
+
20
+ it 'creates a file' do
21
+ FakeFS.with_fresh do
22
+ initialize_fake_rails_root
23
+ expect { Delayed::Worker.new.work_off }
24
+ .to change { File.exist?(monitoring_filename) }
25
+
26
+ expect(File.mtime(monitoring_filename))
27
+ .to be_within(1.second).of(Time.now)
28
+ end
29
+ end
30
+
31
+ it 'updates the file modification time' do
32
+ FakeFS.with_fresh do
33
+ initialize_fake_rails_root
34
+
35
+ Delayed::Worker.new.work_off
36
+
37
+ Timecop.travel(1.minute)
38
+
39
+ expect { Delayed::Worker.new.work_off }
40
+ .to change { File.mtime(monitoring_filename) }
41
+
42
+ expect(File.mtime(monitoring_filename))
43
+ .to be_within(1.second).of(Time.now)
44
+ end
45
+ end
46
+
47
+ describe 'when a job is reserved' do
48
+ let(:max_run_time) { 2.hours }
49
+ let(:job) do
50
+ double(
51
+ name: 'name',
52
+ id: 123,
53
+ queue: 'queue',
54
+ max_run_time: max_run_time,
55
+ invoke_job: nil,
56
+ destroy: nil
57
+ )
58
+ end
59
+
60
+ it 'creates a file with a modification time in the future' do
61
+ FakeFS.with_fresh do
62
+ initialize_fake_rails_root
63
+
64
+ worker = Delayed::Worker.new
65
+ expect(Delayed::Job).to receive(:reserve).and_return(job)
66
+
67
+ expect { worker.send(:reserve_and_run_one_job) }
68
+ .to change { File.exist?(monitoring_filename) }
69
+
70
+ expect(File.mtime(monitoring_filename))
71
+ .to be_within(1.second).of(max_run_time.from_now)
72
+ end
73
+ end
74
+ end
75
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roqua-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.31
4
+ version: 0.1.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-19 00:00:00.000000000 Z
11
+ date: 2018-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_interaction
@@ -199,6 +199,7 @@ files:
199
199
  - gemfiles/rails41.gemfile
200
200
  - gemfiles/rails42.gemfile
201
201
  - gemfiles/rails50.gemfile
202
+ - gemfiles/rails51.gemfile
202
203
  - lib/roqua-support.rb
203
204
  - lib/roqua-support/railtie.rb
204
205
  - lib/roqua-support/version.rb
@@ -207,6 +208,7 @@ files:
207
208
  - lib/roqua/core_ext/active_interaction/rails_instrumentation.rb
208
209
  - lib/roqua/core_ext/activerecord/uniq_find_or_create.rb
209
210
  - lib/roqua/core_ext/array/stable_sort_by.rb
211
+ - lib/roqua/core_ext/delayed_job/activity_monitoring.rb
210
212
  - lib/roqua/core_ext/enumerable/sort_by_alphanum.rb
211
213
  - lib/roqua/core_ext/fabrication/singleton.rb
212
214
  - lib/roqua/core_ext/fixnum/clamp.rb
@@ -241,6 +243,7 @@ files:
241
243
  - spec/roqua/core_ext/active_interaction/rails_intrumentation_spec.rb
242
244
  - spec/roqua/core_ext/activerecord/uniq_find_or_create_spec.rb
243
245
  - spec/roqua/core_ext/array/stable_sort_by_spec.rb
246
+ - spec/roqua/core_ext/delayed_job/activity_monitoring_spec.rb
244
247
  - spec/roqua/core_ext/enumerable/sort_by_alphanum_spec.rb
245
248
  - spec/roqua/core_ext/fabrication/singleton_spec.rb
246
249
  - spec/roqua/core_ext/fixnum/clamp_spec.rb
@@ -293,6 +296,7 @@ test_files:
293
296
  - spec/roqua/core_ext/active_interaction/rails_intrumentation_spec.rb
294
297
  - spec/roqua/core_ext/activerecord/uniq_find_or_create_spec.rb
295
298
  - spec/roqua/core_ext/array/stable_sort_by_spec.rb
299
+ - spec/roqua/core_ext/delayed_job/activity_monitoring_spec.rb
296
300
  - spec/roqua/core_ext/enumerable/sort_by_alphanum_spec.rb
297
301
  - spec/roqua/core_ext/fabrication/singleton_spec.rb
298
302
  - spec/roqua/core_ext/fixnum/clamp_spec.rb