health_check 2.2.1 → 2.3.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.
@@ -1,4 +1,9 @@
1
1
  sudo: false
2
+ addons:
3
+ apt:
4
+ packages:
5
+ - net-tools
6
+
2
7
  cache: bundler
3
8
  language: ruby
4
9
  notifications:
@@ -9,7 +14,7 @@ notifications:
9
14
  before_install:
10
15
  - gem update --system $RUBYGEMS_VERSION
11
16
  - gem --version
12
- - gem install bundler
17
+ - gem install bundler ${BUNDLER_VERSION:+-v} ${BUNDLER_VERSION}
13
18
  - bundle --version
14
19
  - mkdir -p tmp/bundle
15
20
 
@@ -76,9 +81,12 @@ matrix:
76
81
  gemfile: test/rails_4.2.gemfile
77
82
  env: RAILS_SERVER=unicorn RAILS_VERSION=4.2
78
83
 
79
- - rvm: jruby-19mode
80
- gemfile: test/rails_4.2.gemfile
81
- env: RAILS_VERSION=4.2
84
+ # Disabled because it takes way too long (40+ mins)
85
+ # Temporary version lock until Bundler >= 1.13.2
86
+ # https://github.com/bundler/bundler/issues/4975
87
+ #- rvm: jruby-19mode
88
+ # gemfile: test/rails_4.2.gemfile
89
+ # env: BUNDLER_VERSION=1.12.5 RAILS_VERSION=4.2
82
90
 
83
91
  # rails 4.1 April 8, 2014
84
92
 
data/CHANGELOG CHANGED
@@ -1,5 +1,29 @@
1
1
  = Change Log =
2
2
 
3
+ * 2.3.0
4
+ * Fix route reload issue
5
+ * Various fixes to get tests working with bundle/jruby and other gem issues
6
+ * Document additional branches
7
+ * Fix route reload issue (auto routing previosuly conflicted with devise)
8
+ * Removed ref to rails 2.3, 3.*
9
+
10
+ * 2.2.1
11
+ * Adjust private/public cache-control based on max_age set
12
+ * 2.2.0
13
+ * Add max_age so we can control the caching of responses, don't run tests if Last-modified still matches
14
+ * Added basic auth - Thanks omadahealth
15
+ * A few macinations due to gem changes and avoidning triggering deprecation notices
16
+ * Add single quote to README to make the configuration file valid - Thanks Ryan Selk <ryanselk@gmail.com>
17
+ * Fixed README formatting
18
+ * 2.1.0
19
+ * Updated contributed tests so there is both the forced check and a *-if-present check which tests if the gem's class is loaded
20
+ * Added resque-redis check - Thanks filiphaftek <filip.haftek@airhelp.com>
21
+ * In addition to adding a test file to S3, we will also try to delete it to confirm that delete operations are possible - Thanks Anton Dimitrov <dimitrov.anton@gmail.com>
22
+ * Added redis, sidekiq-redis and s3 health-checks - Thanks Filip <filip.haftek@airhelp.com>
23
+ * Fix render options - Thanks Yuji Hanamura <yuji.developer@gmail.com>
24
+ * Fix to always return a 200 status code on success rather than 304 (adds Last-Modified) - Thanks macgregordennis <macgregordennis@gmail.com>
25
+ * Added Rails 5.0 tests
26
+
3
27
  * 2.0.0 - Removed silence - recommend to use a log filtering gem instead
4
28
  * 1.4.1 - Rails 4 and route changes
5
29
  * Now handles routes being generated multiple times by some gem / rails / ruby combinations - Previously multiple calls to health_check_routes where ignored, now explicit calls to health_check_route always adds the route but flags that it doesn't have to be added again on the end of the list
data/Gemfile CHANGED
@@ -15,6 +15,6 @@ group :development, :test do
15
15
  gem 'travis-lint'
16
16
  # mime-types 2.0 requires Ruby version >= 1.9.2
17
17
  # mime-types 3.0 requires Ruby version >= 2.0
18
- gem 'mime-types', RUBY_VERSION < '1.9.2' ? '< 2.0' : (defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3' : '>= 3.0')
18
+ gem 'mime-types', defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3' : '>= 3.0'
19
19
 
20
20
  end
@@ -2,8 +2,10 @@
2
2
 
3
3
  Simple health check of Rails 4.x+ apps for use with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
4
4
 
5
- Use {pre_rails4}[https://github.com/ianheggie/health_check/tree/pre_rails4] branch or gem versions < 2.0 for Rails 2.3 and 3.x;
6
- Use {master}[https://github.com/ianheggie/health_check/tree/master] branch or gem versions ~> 2.0 for Rails 4.x and 5.x;
5
+ Use
6
+ * {master}[https://github.com/ianheggie/health_check/tree/master] branch or gem versions ~> 2.0 for Rails 4.x and 5.x;
7
+ * {pre_rails4}[https://github.com/ianheggie/health_check/tree/pre_rails4] branch or gem versions ~> 1.7 for Rails 3.x;
8
+ * {rails2.3}[https://github.com/ianheggie/health_check/tree/rails2.3] branch or gem versions ~> 1.6.1 for Rails 2.3;
7
9
 
8
10
  The basic goal is to quickly check that rails is up and running and that it has access to correctly configured resources (database, email gateway)
9
11
 
@@ -127,6 +129,12 @@ If you have a catchall route then add the following line above the catch all rou
127
129
  To change the url prefix (eg to /ping), add the following line in `config/routes.rb`:
128
130
  health_check_routes('ping')
129
131
 
132
+ === Installing As Middleware
133
+
134
+ To use health_check as middleware add the following line to the config/application.rb:
135
+ `config.middleware.insert_after "Rails::Rack::Logger", HealthCheck::MiddlewareHealthcheck`
136
+ In config/initializers/health_check.rb config.uri can be changed to other than default 'health_check'
137
+
130
138
  == Uptime Monitoring
131
139
 
132
140
  Use a website monitoring service to check the url regularly for the word "success" (without the quotes) rather than just a 200 http status so
@@ -1,8 +1,5 @@
1
- if defined?(HealthCheck::Engine)
2
- unless HealthCheck::Engine.routes_already_defined
3
- # Ifmountable use: HealthCheck::Engine.routes.draw do
4
- Rails.application.routes.draw do
5
- health_check_routes()
6
- end
1
+ unless HealthCheck::Engine.routes_explicitly_defined
2
+ Rails.application.routes.draw do
3
+ add_health_check_routes()
7
4
  end
8
5
  end
@@ -4,7 +4,7 @@
4
4
  module HealthCheck
5
5
 
6
6
  class Engine < Rails::Engine
7
- cattr_accessor :routes_already_defined
7
+ cattr_accessor :routes_explicitly_defined
8
8
  end
9
9
 
10
10
  # Text output upon success
@@ -24,7 +24,7 @@ module HealthCheck
24
24
  self.http_status_for_error_object = 500
25
25
 
26
26
  # max-age of response in seconds
27
- # cache-control is public when max_age > 1 and basic authentication is used
27
+ # cache-control is public when max_age > 1 and basic authentication is used
28
28
  mattr_accessor :max_age
29
29
  self.max_age = 1
30
30
 
@@ -32,6 +32,10 @@ module HealthCheck
32
32
  mattr_accessor :buckets
33
33
  self.buckets = {}
34
34
 
35
+ # health check uri path for middleware check
36
+ mattr_accessor :uri
37
+ self.uri = 'health_check'
38
+
35
39
  # Basic Authentication
36
40
  mattr_accessor :basic_auth_username, :basic_auth_password
37
41
  self.basic_auth_username = nil
@@ -64,5 +68,6 @@ require 'health_check/sidekiq_health_check'
64
68
  require 'health_check/utils'
65
69
  require 'health_check/health_check_controller'
66
70
  require 'health_check/health_check_routes'
71
+ require 'health_check/middleware_health_check'
67
72
 
68
73
  # vi: sw=2 sm ai:
@@ -5,7 +5,7 @@ module HealthCheck
5
5
  class HealthCheckController < ActionController::Base
6
6
 
7
7
  layout false if self.respond_to? :layout
8
- before_filter :authenticate
8
+ before_action :authenticate
9
9
 
10
10
  def index
11
11
  last_modified = Time.now.utc
@@ -1,12 +1,14 @@
1
- if defined?(HealthCheck::Engine)
1
+ module ActionDispatch::Routing
2
+ class Mapper
2
3
 
3
- module ActionDispatch::Routing
4
- class Mapper
5
- def health_check_routes(prefix = nil)
6
- HealthCheck::Engine.routes_already_defined ||= true
7
- get "#{prefix || 'health_check'}(/:checks)(.:format)", :to => 'health_check/health_check#index'
8
- end
4
+ def health_check_routes(prefix = nil)
5
+ HealthCheck::Engine.routes_explicitly_defined = true
6
+ add_health_check_routes(prefix)
7
+ end
8
+
9
+ def add_health_check_routes(prefix = nil)
10
+ get "#{prefix || 'health_check'}(/:checks)(.:format)", :to => 'health_check/health_check#index'
9
11
  end
10
- end
11
12
 
13
+ end
12
14
  end
@@ -0,0 +1,44 @@
1
+ module HealthCheck
2
+ class MiddlewareHealthcheck
3
+
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ uri = env['PATH_INFO']
10
+ if uri.include? HealthCheck.uri
11
+ response_type = uri[/\.(json|xml)/,1] || 'plain'
12
+ response_method = 'response_' + response_type
13
+ checks = env['QUERY_STRING'][/checks=([a-z0-9\-_]*)/,1] || 'standard'
14
+ begin
15
+ errors = HealthCheck::Utils.process_checks(checks)
16
+ rescue => e
17
+ errors = e.message.blank? ? e.class.to_s : e.message.to_s
18
+ end
19
+ if errors.blank?
20
+ send(response_method, 200, HealthCheck.success, true)
21
+ else
22
+ msg = "health_check failed: #{errors}"
23
+ send(response_method, 500, msg, false)
24
+ end
25
+ else
26
+ @app.call(env)
27
+ end
28
+ end
29
+
30
+ def response_json code, msg, healthy
31
+ obj = { healthy: healthy, message: msg }
32
+ [ code, { 'Content-Type' => 'application/json' }, [obj.to_json] ]
33
+ end
34
+
35
+ def response_xml code, msg, healthy
36
+ obj = { healthy: healthy, message: msg }
37
+ [ code, { 'Content-Type' => 'text/xml' }, [obj.to_xml] ]
38
+ end
39
+
40
+ def response_plain code, msg, healthy
41
+ [ code, { 'Content-Type' => 'text/plain' }, [msg] ]
42
+ end
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module HealthCheck
2
- VERSION = "2.2.1"
2
+ VERSION = "2.3.0"
3
3
  end
@@ -30,4 +30,4 @@ gem 'therubyrhino', :platform => :jruby # REQUIRED
30
30
  gem 'therubyracer', :platform => :ruby # REQUIRED
31
31
  # mime-types 2.0 requires Ruby version >= 1.9.2
32
32
  # mime-types 3.0 requires Ruby version >= 2.0
33
- gem 'mime-types', RUBY_VERSION < '1.9.2' ? '< 2.0' : (defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3' : '>= 3.0') # REQUIRED
33
+ gem 'mime-types', defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3' : '>= 3.0' # REQUIRED
@@ -30,4 +30,4 @@ gem 'therubyrhino', :platform => :jruby # REQUIRED
30
30
  gem 'therubyracer', :platform => :ruby # REQUIRED
31
31
  # mime-types 2.0 requires Ruby version >= 1.9.2
32
32
  # mime-types 3.0 requires Ruby version >= 2.0
33
- gem 'mime-types', RUBY_VERSION < '1.9.2' ? '< 2.0' : (defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3' : '>= 3.0') # REQUIRED
33
+ gem 'mime-types', defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3' : '>= 3.0' # REQUIRED
@@ -27,4 +27,4 @@ end
27
27
 
28
28
  # mime-types 2.0 requires Ruby version >= 1.9.2
29
29
  # mime-types 3.0 requires Ruby version >= 2.0
30
- gem 'mime-types', RUBY_VERSION < '1.9.2' ? '< 2.0' : (defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3' : '>= 3.0') # REQUIRED
30
+ gem 'mime-types', defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3' : '>= 3.0' # REQUIRED
@@ -52,7 +52,7 @@ else
52
52
  fi
53
53
 
54
54
  echo "Running bundle with BUNDLE_GEMFILE=$BUNDLE_GEMFILE ..."
55
- if ! bundle ; then
55
+ if ! bundle install ; then
56
56
  echo "Test aborted (missing required gems)"
57
57
  exit 2
58
58
  fi
@@ -82,12 +82,21 @@ actual_rails_version=`$rails -v`
82
82
 
83
83
  [ -d lib/health_check ] || exec echo setup_railsapp MUST be executed in the base of the health_check gem/clone of git repository
84
84
 
85
- echo Installing health_check as a gem into tmp/gems
86
- env GEM_HOME=$tmp_dir/gems rake install
87
-
88
85
  export GEM_PATH="$tmp_dir/gems:`gem environment gempath`"
89
86
  echo Set GEM_PATH=$GEM_PATH
90
87
 
88
+ echo Installing health_check as a gem into $tmp_dir/gems
89
+ rm -f pkg/health_check-*.gem
90
+ if env GEM_HOME=$tmp_dir/gems $rake install
91
+ then
92
+ echo rake install passed
93
+ else
94
+ echo rake install failed! running gem install pkg/health_check-*.gem manually to see error message:
95
+ env GEM_HOME=$tmp_dir/gems gem install pkg/health_check-*.gem
96
+ echo gem install worked, but flagging it as a FAIL anyway since rake install failed!
97
+ exit 2
98
+ fi
99
+
91
100
  echo Gems in tmp/gems:
92
101
  ls tmp/gems
93
102
 
@@ -192,9 +192,9 @@ common_tests()
192
192
  echo "${test_no}: CHECKING routes exist..."
193
193
  $rake routes | tee /tmp/t$$
194
194
  echo
195
- case `egrep health_check /tmp/t$$ || true` in
195
+ case `egrep ${route_prefix} /tmp/t$$ || true` in
196
196
  '')
197
- echo WARNING - routes for health_check not listed!
197
+ echo WARNING - routes for ${route_prefix} not listed!
198
198
  ;;
199
199
  esac
200
200
  echo
@@ -231,185 +231,179 @@ common_tests()
231
231
 
232
232
  test_no=`expr 1 + $test_no`
233
233
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
234
- echo "${test_no}: TESTING health_check/migration should pass with no database migrations ..."
234
+ echo "${test_no}: TESTING ${route_prefix}/migration should pass with no database migrations ..."
235
235
  ls db/migrate
236
- $testurl ${host}/health_check/migration 200 text/plain $success
236
+ $testurl ${host}/${route_prefix}/migration 200 text/plain $success
237
237
  echo
238
238
  fi
239
239
 
240
240
  test_no=`expr 1 + $test_no`
241
241
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
242
- echo "${test_no}: TESTING health_check/migration should fail without initial database migration ..."
242
+ echo "${test_no}: TESTING ${route_prefix}/migration should fail without initial database migration ..."
243
243
  cp $base_dir/test/migrate/nine/* db/migrate
244
244
  ls db/migrate
245
- $testurl ${host}/health_check/migration 550 text/plain failed
245
+ $testurl ${host}/${route_prefix}/migration 550 text/plain failed
246
246
  echo
247
247
  fi
248
248
 
249
249
  test_no=`expr 1 + $test_no`
250
250
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
251
- echo "${test_no}: TESTING health_check/database should pass without initial database migration (since it ignores the difference) ..."
252
- $testurl ${host}/health_check/database 200 text/plain $success
251
+ echo "${test_no}: TESTING ${route_prefix}/database should pass without initial database migration (since it ignores the difference) ..."
252
+ $testurl ${host}/${route_prefix}/database 200 text/plain $success
253
253
  echo
254
254
  fi
255
255
 
256
256
  test_no=`expr 1 + $test_no`
257
257
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
258
- echo "${test_no}: TESTING health_check/site should pass ..."
259
- $testurl ${host}/health_check/site 200 text/plain $success
258
+ echo "${test_no}: TESTING ${route_prefix}/site should pass ..."
259
+ $testurl ${host}/${route_prefix}/site 200 text/plain $success
260
260
  echo
261
261
  fi
262
262
 
263
263
  test_no=`expr 1 + $test_no`
264
264
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
265
- echo "${test_no}: TESTING health_check/migration should pass after initial database migration ..."
265
+ echo "${test_no}: TESTING ${route_prefix}/migration should pass after initial database migration ..."
266
266
  $rake db:migrate
267
- $testurl ${host}/health_check/migration 200 text/plain $success
267
+ $testurl ${host}/${route_prefix}/migration 200 text/plain $success
268
268
  echo
269
269
  fi
270
270
 
271
271
  test_no=`expr 1 + $test_no`
272
272
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
273
- echo "${test_no}: TESTING health_check/migration should fail without all migrations ..."
273
+ echo "${test_no}: TESTING ${route_prefix}/migration should fail without all migrations ..."
274
274
  cp $base_dir/test/migrate/twelve/* db/migrate
275
275
 
276
- case "$actual_rails_version" in
277
- *' '[12].*|*' '3.[01]*)
278
- echo removing db/migrate/*.*.rb "($actual_rails_version does not support extra dots in migration names)"
279
- rm -f db/migrate/*.*.rb
280
- ;;
281
- esac
282
276
  ls db/migrate
283
- $testurl ${host}/health_check/migration 550 text/plain failed
277
+ $testurl ${host}/${route_prefix}/migration 550 text/plain failed
284
278
  echo
285
279
  fi
286
280
 
287
281
  test_no=`expr 1 + $test_no`
288
282
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
289
- echo "${test_no}: TESTING health_check/migration should pass after both database migrations ..."
283
+ echo "${test_no}: TESTING ${route_prefix}/migration should pass after both database migrations ..."
290
284
  $rake db:migrate
291
- $testurl ${host}/health_check/migration 200 text/plain $success
285
+ $testurl ${host}/${route_prefix}/migration 200 text/plain $success
292
286
  echo
293
287
  fi
294
288
 
295
289
  test_no=`expr 1 + $test_no`
296
290
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
297
- echo "${test_no}: TESTING health_check/migration should pass after both database migrations ..."
291
+ echo "${test_no}: TESTING ${route_prefix}/migration should pass after both database migrations ..."
298
292
  $rake db:migrate
299
- $testurl ${host}/health_check/migration 200 text/plain $success
293
+ $testurl ${host}/${route_prefix}/migration 200 text/plain $success
300
294
  echo
301
295
  fi
302
296
 
303
297
  test_no=`expr 1 + $test_no`
304
298
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
305
- echo "${test_no}: TESTING health_check/email should fail without smtp available ..."
306
- $testurl ${host}/health_check/email 550 text/plain failed
299
+ echo "${test_no}: TESTING ${route_prefix}/email should fail without smtp available ..."
300
+ $testurl ${host}/${route_prefix}/email 550 text/plain failed
307
301
  echo
308
302
  fi
309
303
 
310
304
  test_no=`expr 1 + $test_no`
311
305
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
312
- echo "${test_no}: TESTING health_check/email should pass with smtp available ..."
306
+ echo "${test_no}: TESTING ${route_prefix}/email should pass with smtp available ..."
313
307
  $fake_smtp_server &
314
308
  fake_smtp_pid=$!
315
309
  sleep 5
316
- $testurl ${host}/health_check/email 200 text/plain $success
310
+ $testurl ${host}/${route_prefix}/email 200 text/plain $success
317
311
  echo
318
312
  fi
319
313
 
320
314
  test_no=`expr 1 + $test_no`
321
315
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
322
- echo "${test_no}: TESTING health_check (all) should fail without smtp available ..."
323
- $testurl ${host}/health_check 550 text/plain failed
316
+ echo "${test_no}: TESTING ${route_prefix} (all) should fail without smtp available ..."
317
+ $testurl ${host}/${route_prefix} 550 text/plain failed
324
318
  echo
325
319
  fi
326
320
 
327
321
  test_no=`expr 1 + $test_no`
328
322
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
329
- echo "${test_no}: TESTING health_check/all should fail without smtp available ..."
330
- $testurl ${host}/health_check 550 text/plain failed
323
+ echo "${test_no}: TESTING ${route_prefix}/all should fail without smtp available ..."
324
+ $testurl ${host}/${route_prefix} 550 text/plain failed
331
325
  echo
332
326
  fi
333
327
 
334
328
  kill -9 $fake_smtp_pid || echo fake_smtp_server had finished as expected
335
329
  test_no=`expr 1 + $test_no`
336
330
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
337
- echo "${test_no}: TESTING health_check (all) should pass with smtp available ..."
331
+ echo "${test_no}: TESTING ${route_prefix} (all) should pass with smtp available ..."
338
332
  $fake_smtp_server &
339
333
  fake_smtp_pid=$!
340
334
  sleep 5
341
- $testurl ${host}/health_check 200 text/plain $success
335
+ $testurl ${host}/${route_prefix} 200 text/plain $success
342
336
  echo
343
337
  fi
344
338
 
345
339
  kill -9 $fake_smtp_pid || echo fake_smtp_server had finished as expected
346
340
  test_no=`expr 1 + $test_no`
347
341
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
348
- echo "${test_no}: TESTING health_check/all should pass with smtp available ..."
342
+ echo "${test_no}: TESTING ${route_prefix}/all should pass with smtp available ..."
349
343
  $fake_smtp_server &
350
344
  fake_smtp_pid=$!
351
345
  sleep 5
352
- $testurl ${host}/health_check/all 200 text/plain $success
346
+ $testurl ${host}/${route_prefix}/all 200 text/plain $success
353
347
  echo
354
348
  fi
355
349
 
356
350
  test_no=`expr 1 + $test_no`
357
351
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
358
- echo "${test_no}: TESTING health_check/custom should pass ..."
359
- $testurl ${host}/health_check/custom 200 text/plain $success
352
+ echo "${test_no}: TESTING ${route_prefix}/custom should pass ..."
353
+ $testurl ${host}/${route_prefix}/custom 200 text/plain $success
360
354
  echo
361
355
  fi
362
356
 
363
357
  test_no=`expr 1 + $test_no`
364
358
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
365
- echo "${test_no}: TESTING health_check/custom.html should pass (returning plain text) ..."
366
- $testurl ${host}/health_check/custom.html 200 text/plain $success
359
+ echo "${test_no}: TESTING ${route_prefix}/custom.html should pass (returning plain text) ..."
360
+ $testurl ${host}/${route_prefix}/custom.html 200 text/plain $success
367
361
  echo
368
362
  fi
369
363
 
370
364
  test_no=`expr 1 + $test_no`
371
365
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
372
- echo "${test_no}: TESTING health_check/custom.json should pass ..."
373
- $testurl ${host}/health_check/custom.json 200 application/json '"healthy":true'
374
- $testurl ${host}/health_check/custom.json 200 application/json "\"message\":\"$success\""
366
+ echo "${test_no}: TESTING ${route_prefix}/custom.json should pass ..."
367
+ $testurl ${host}/${route_prefix}/custom.json 200 application/json '"healthy":true'
368
+ $testurl ${host}/${route_prefix}/custom.json 200 application/json "\"message\":\"$success\""
375
369
  echo
376
370
  fi
377
371
 
378
372
  test_no=`expr 1 + $test_no`
379
373
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
380
- echo "${test_no}: TESTING health_check/custom.xml should pass ..."
381
- $testurl ${host}/health_check/custom.xml 200 application/xml '<healthy type="boolean">true</healthy>'
382
- $testurl ${host}/health_check/custom.xml 200 application/xml "<message>$success</message>"
374
+ echo "${test_no}: TESTING ${route_prefix}/custom.xml should pass ..."
375
+ $testurl ${host}/${route_prefix}/custom.xml 200 application/xml '<healthy type="boolean">true</healthy>'
376
+ $testurl ${host}/${route_prefix}/custom.xml 200 application/xml "<message>$success</message>"
383
377
  echo
384
378
  fi
385
379
 
386
380
  test_no=`expr 1 + $test_no`
387
381
  rm -f $custom_file
388
382
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
389
- echo "${test_no}: TESTING health_check/custom should fail when custom returns string ..."
390
- $testurl ${host}/health_check/custom 550 text/plain failed
383
+ echo "${test_no}: TESTING ${route_prefix}/custom should fail when custom returns string ..."
384
+ $testurl ${host}/${route_prefix}/custom 550 text/plain failed
391
385
  echo
392
386
  fi
393
387
 
394
388
  test_no=`expr 1 + $test_no`
395
389
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
396
- echo "${test_no}: TESTING health_check (all) should fail when custom check fails ..."
397
- $testurl ${host}/health_check 550 text/plain "$custom_file is missing!"
390
+ echo "${test_no}: TESTING ${route_prefix} (all) should fail when custom check fails ..."
391
+ $testurl ${host}/${route_prefix} 550 text/plain "$custom_file is missing!"
398
392
  echo
399
393
  fi
400
394
 
401
395
  test_no=`expr 1 + $test_no`
402
396
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
403
- echo "${test_no}: TESTING health_check.json (all) should fail when custom check fails ..."
404
- $testurl ${host}/health_check.json 555 application/json '"healthy":false'
405
- $testurl ${host}/health_check.json 555 application/json "$custom_file is missing!"
397
+ echo "${test_no}: TESTING ${route_prefix}.json (all) should fail when custom check fails ..."
398
+ $testurl ${host}/${route_prefix}.json 555 application/json '"healthy":false'
399
+ $testurl ${host}/${route_prefix}.json 555 application/json "$custom_file is missing!"
406
400
  echo
407
401
  fi
408
402
 
409
403
  test_no=`expr 1 + $test_no`
410
404
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
411
- echo "${test_no}: TESTING health_check.xml (all) should fail when custom check fails ..."
412
- $testurl ${host}/health_check.xml 555 application/xml '<healthy type="boolean">false</healthy>'
405
+ echo "${test_no}: TESTING ${route_prefix}.xml (all) should fail when custom check fails ..."
406
+ $testurl ${host}/${route_prefix}.xml 555 application/xml '<healthy type="boolean">false</healthy>'
413
407
  echo
414
408
  fi
415
409
 
@@ -446,6 +440,8 @@ case "$run_test" in
446
440
 
447
441
  # get a static file
448
442
 
443
+ route_prefix=health_check
444
+
449
445
  echo
450
446
  echo 'TESTING no catchall route active ...'
451
447
  expected_status=404,500,502
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: health_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-18 00:00:00.000000000 Z
12
+ date: 2016-10-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -99,6 +99,7 @@ files:
99
99
  - lib/health_check/base_health_check.rb
100
100
  - lib/health_check/health_check_controller.rb
101
101
  - lib/health_check/health_check_routes.rb
102
+ - lib/health_check/middleware_health_check.rb
102
103
  - lib/health_check/redis_health_check.rb
103
104
  - lib/health_check/resque_health_check.rb
104
105
  - lib/health_check/s3_health_check.rb