health_check 1.5.0 → 1.5.1
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.
- data/.travis.yml +27 -50
- data/CHANGELOG +267 -0
- data/Gemfile +3 -0
- data/README.rdoc +5 -5
- data/lib/health_check/version.rb +1 -1
- data/test/rails_3.1.gemfile +8 -0
- data/test/rails_3.2.gemfile +7 -0
- data/test/setup_railsapp +52 -14
- data/test/test_with_railsapp +253 -143
- metadata +13 -37
- data/test/rails_4.0.gemfile +0 -19
- data/test/rails_4.1.gemfile +0 -19
- data/test/rails_edge.gemfile +0 -21
data/.travis.yml
CHANGED
@@ -16,87 +16,64 @@ bundler_args: "--binstubs"
|
|
16
16
|
script: ./test/test_with_railsapp
|
17
17
|
|
18
18
|
rvm:
|
19
|
-
-
|
19
|
+
- 1.9.3
|
20
20
|
|
21
21
|
gemfile:
|
22
|
-
- test/
|
22
|
+
- test/rails_3.2.gemfile
|
23
23
|
|
24
24
|
matrix:
|
25
25
|
allow_failures:
|
26
|
-
- rvm: 2.1.0
|
27
|
-
gemfile: test/rails_edge.gemfile
|
28
|
-
|
29
|
-
- rvm: ruby-head
|
30
|
-
gemfile: test/rails_edge.gemfile
|
31
|
-
|
32
|
-
- rvm: jruby-head
|
33
|
-
gemfile: test/rails_edge.gemfile
|
34
26
|
|
35
27
|
include:
|
36
|
-
# rails
|
37
|
-
|
38
|
-
- rvm: 2.1.0
|
39
|
-
gemfile: test/rails_edge.gemfile
|
40
|
-
|
41
|
-
- rvm: ruby-head
|
42
|
-
gemfile: test/rails_edge.gemfile
|
43
|
-
|
44
|
-
- rvm: jruby-head
|
45
|
-
gemfile: test/rails_edge.gemfile
|
46
|
-
|
47
|
-
# rails 4.1 April 8, 2014
|
28
|
+
# rails 3.2 jan 20, 2012 - ruby 1.8.7 or 1.9.2
|
48
29
|
|
49
|
-
- rvm:
|
50
|
-
gemfile: test/
|
51
|
-
env: RAILS_SERVER=puma
|
30
|
+
- rvm: 1.9.3
|
31
|
+
gemfile: test/rails_3.2.gemfile
|
32
|
+
env: RAILS_SERVER=puma RAILS_VERSION=3.2
|
52
33
|
|
53
|
-
- rvm:
|
54
|
-
gemfile: test/
|
55
|
-
env: RAILS_SERVER=passenger
|
34
|
+
- rvm: 1.9.3
|
35
|
+
gemfile: test/rails_3.2.gemfile
|
36
|
+
env: RAILS_SERVER=passenger RAILS_VERSION=3.2
|
56
37
|
|
57
|
-
- rvm:
|
58
|
-
gemfile: test/
|
59
|
-
env: RAILS_SERVER=thin
|
38
|
+
- rvm: 1.9.3
|
39
|
+
gemfile: test/rails_3.2.gemfile
|
40
|
+
env: RAILS_SERVER=thin RAILS_VERSION=3.2
|
60
41
|
|
61
42
|
- rvm: rbx-2.2.6
|
62
|
-
gemfile: test/
|
63
|
-
env: RAILS_ENV2=development
|
64
|
-
|
65
|
-
- rvm: 2.1.2
|
66
|
-
gemfile: test/rails_4.1.gemfile
|
67
|
-
env: RAILS_SERVER=unicorn
|
68
|
-
|
69
|
-
- rvm: jruby-19mode
|
70
|
-
gemfile: test/rails_4.1.gemfile
|
43
|
+
gemfile: test/rails_3.2.gemfile
|
44
|
+
env: RAILS_ENV2=development RAILS_VERSION=3.2
|
71
45
|
|
72
|
-
# rails 4.0 June 25, 2013
|
73
|
-
|
74
46
|
- rvm: 1.9.3
|
75
|
-
gemfile: test/
|
47
|
+
gemfile: test/rails_3.2.gemfile
|
48
|
+
env: RAILS_SERVER=unicorn RAILS_VERSION=3.2
|
76
49
|
|
77
|
-
- rvm:
|
78
|
-
gemfile: test/
|
79
|
-
env:
|
50
|
+
- rvm: jruby-19mode
|
51
|
+
gemfile: test/rails_3.2.gemfile
|
52
|
+
env: RAILS_VERSION=3.2
|
80
53
|
|
81
|
-
- rvm: 2.
|
82
|
-
gemfile: test/
|
54
|
+
- rvm: 2.2.0
|
55
|
+
gemfile: test/rails_3.2.gemfile
|
56
|
+
env: RAILS_VERSION=3.2
|
83
57
|
|
84
|
-
# rails 3.2 jan 20, 2012 - ruby 1.8.7 or 1.9.2
|
85
58
|
- rvm: 1.9.3
|
86
59
|
gemfile: test/rails_3.2.gemfile
|
60
|
+
env: RAILS_VERSION=3.2
|
87
61
|
|
88
62
|
- rvm: jruby-19mode
|
89
63
|
gemfile: test/rails_3.2.gemfile
|
64
|
+
env: RAILS_VERSION=3.2
|
90
65
|
|
91
66
|
# rails 3.1 aug 31, 2011 - ruby 1.8.7 or 1.9.2
|
92
67
|
- rvm: 1.9.2
|
93
68
|
gemfile: test/rails_3.1.gemfile
|
69
|
+
env: RAILS_VERSION=3.1
|
94
70
|
|
95
71
|
- rvm: 1.8.7
|
96
72
|
gemfile: test/rails_3.0.gemfile
|
73
|
+
env: RAILS_VERSION=3.0
|
97
74
|
|
98
75
|
# rails 2.3 march 16 2009 - ruby 1.8.7
|
99
76
|
- rvm: 1.8.7
|
100
77
|
gemfile: test/rails_2.3.gemfile
|
101
|
-
env: RUBYGEMS_VERSION=1.8.25
|
78
|
+
env: RUBYGEMS_VERSION=1.8.25 RAILS_VERSION=2.3
|
102
79
|
|
data/CHANGELOG
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
= Change Log =
|
2
2
|
|
3
|
+
*1.5.1
|
4
|
+
* Created pre_rails4 branch (versions < 2.0) for rails 2.3 and 3.x; with master branch for rails 4.0+
|
5
|
+
*1.5.0
|
6
|
+
* Fixed SMTP test now uses CRNL as per RFC
|
7
|
+
* Check Action
|
3
8
|
* 1.4.1 - Rails 4 and route changes
|
4
9
|
* 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
|
5
10
|
* Uses ActiveRecord::Migration.check_pending! if available and returns the message if an exception is raised (Rails 4.0+)
|
@@ -17,3 +22,265 @@
|
|
17
22
|
* 1.0.2 - Included travis config and gemfiles used in travis tests in gem and changes to test setup so that gem test
|
18
23
|
* 1.x - Includes Rails 3.x suppprt as an Engine
|
19
24
|
* 0.x - Rails 2.3
|
25
|
+
|
26
|
+
+
|
27
|
+
end
|
28
|
+
|
29
|
+
diff --git a/README.rdoc b/README.rdoc
|
30
|
+
index de48110..cf673e8 100644
|
31
|
+
--- a/README.rdoc
|
32
|
+
+++ b/README.rdoc
|
33
|
+
@@ -24,11 +24,11 @@ On failure a 500 http status is returned with a simple explanation of the failur
|
34
|
+
curl localhost:3000/health_check/fail
|
35
|
+
health_check failed: invalid argument to health_test.
|
36
|
+
|
37
|
+
-The health_check controller disables sessions and logging for its actions to minimise the impact of frequent uptime checks on the session store and the log file.
|
38
|
+
+The health_check controller disables sessions for versions that eagerly load sessions. Only failures are logged for rails < '4.1'.
|
39
|
+
|
40
|
+
== Checks
|
41
|
+
|
42
|
+
-* standard (default) - site, database and migrations checks are run plus email if settings have been changed
|
43
|
+
+* standard (default) - site, database and migrations checks are run plus email if ActionMailer is defined and it is not using the default configuration
|
44
|
+
* all / full - all checks are run (can be overriden in config block)
|
45
|
+
* database - checks that the current migration level can be read from the database
|
46
|
+
* email - basic check of email - :test returns true, :sendmail checks file is present and executable, :smtp sends HELO command to server and checks response
|
47
|
+
@@ -100,6 +100,9 @@ To change the configuration of health_check, create a file `config/initializers/
|
48
|
+
|
49
|
+
config.http_status_for_error_object = 500
|
50
|
+
|
51
|
+
+ # You can customize which checks happen on a standard health check
|
52
|
+
+ config.standard_checks = [ 'database', 'migrations', 'custom' ]
|
53
|
+
+
|
54
|
+
# You can set what tests are run with the 'full' or 'all' parameter
|
55
|
+
config.full_checks = ['database', 'migrations', 'custom', 'email', 'cache']
|
56
|
+
|
57
|
+
@@ -189,11 +192,10 @@ See https://github.com/ianheggie/health_check/wiki/Ajax-Example for an Ajax exam
|
58
|
+
|
59
|
+
=== Automated testing and other checks
|
60
|
+
|
61
|
+
-Travis CI runs the tests: {<img src="https://travis-ci.org/ianheggie/health_check.png">}[https://travis-ci.org/ianheggie/health_check]
|
62
|
+
-
|
63
|
+
-Code Climate monitors code quality: {<img src="https://codeclimate.com/github/ianheggie/health_check.png" />}[https://codeclimate.com/github/ianheggie/health_check]
|
64
|
+
-
|
65
|
+
-Gemnasium monitors gem dependencies {<img src="https://gemnasium.com/ianheggie/health_check.png">}[https://gemnasium.com/ianheggie/health_check]
|
66
|
+
+* {<img src="https://badge.fury.io/rb/health_check.png" alt="Gem Version" />}[http://badge.fury.io/rb/health_check] - Latest Gem
|
67
|
+
+* {<img src="https://travis-ci.org/ianheggie/health_check.png">}[https://travis-ci.org/ianheggie/health_check] - Travis CI
|
68
|
+
+* {<img src="https://codeclimate.com/github/ianheggie/health_check.png" />}[https://codeclimate.com/github/ianheggie/health_check] - Code quality
|
69
|
+
+* {<img src="https://gemnasium.com/ianheggie/health_check.png">}[https://gemnasium.com/ianheggie/health_check] - Gem dependencies
|
70
|
+
|
71
|
+
=== Manual testing
|
72
|
+
|
73
|
+
@@ -230,10 +232,18 @@ The command `rake test` will also launch these tests, except it cannot install t
|
74
|
+
|
75
|
+
== Copyright
|
76
|
+
|
77
|
+
-Copyright (c) 2010-2013 Ian Heggie, released under the MIT license.
|
78
|
+
+Copyright (c) 2010-2014 Ian Heggie, released under the MIT license.
|
79
|
+
See MIT-LICENSE for details.
|
80
|
+
|
81
|
+
== Contributors
|
82
|
+
|
83
|
+
-Thanks go to the various people who have given feedback and suggestions via the issues list and pull requests
|
84
|
+
+Thanks go to the various people who have given feedback and suggestions via the issues list and pull requests.
|
85
|
+
+
|
86
|
+
+=== Contributing
|
87
|
+
+
|
88
|
+
+1. Fork it
|
89
|
+
+2. Create your feature branch (`git checkout -b my-new-feature`)
|
90
|
+
+3. Commit your changes (`git commit -am 'Add some feature'`)
|
91
|
+
+4. Push to the branch (`git push origin my-new-feature`)
|
92
|
+
+5. Create new Pull Request (Code with BDD tests are favoured)
|
93
|
+
|
94
|
+
diff --git a/health_check.gemspec b/health_check.gemspec
|
95
|
+
index 1b7f8fc..e6b70f5 100644
|
96
|
+
--- a/health_check.gemspec
|
97
|
+
+++ b/health_check.gemspec
|
98
|
+
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
|
99
|
+
gem.description = <<-EOF
|
100
|
+
Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
|
101
|
+
EOF
|
102
|
+
- gem.homepage = "http://ianheggie.github.io/health_check/"
|
103
|
+
+ gem.homepage = "https://github.com/ianheggie/health_check"
|
104
|
+
|
105
|
+
gem.files = `git ls-files`.split($/)
|
106
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
107
|
+
@@ -23,6 +23,5 @@ Gem::Specification.new do |gem|
|
108
|
+
gem.add_dependency(%q<rails>, [">= 2.3.0"])
|
109
|
+
gem.add_development_dependency(%q<rake>, [">= 0.8.3"])
|
110
|
+
gem.add_development_dependency(%q<shoulda>, ["~> 2.11.0"])
|
111
|
+
- gem.add_development_dependency(%q<sqlite3>, ["~> 1.3.7"])
|
112
|
+
gem.add_development_dependency(%q<bundler>, ["~> 1.2"])
|
113
|
+
end
|
114
|
+
diff --git a/lib/health_check.rb b/lib/health_check.rb
|
115
|
+
index 04d6aec..45f8fd2 100644
|
116
|
+
--- a/lib/health_check.rb
|
117
|
+
+++ b/lib/health_check.rb
|
118
|
+
@@ -28,8 +28,10 @@ module HealthCheck
|
119
|
+
# Array of custom check blocks
|
120
|
+
mattr_accessor :custom_checks
|
121
|
+
mattr_accessor :full_checks
|
122
|
+
+ mattr_accessor :standard_checks
|
123
|
+
self.custom_checks = [ ]
|
124
|
+
self.full_checks = ['database', 'migrations', 'custom', 'email', 'cache']
|
125
|
+
+ self.standard_checks = [ 'database', 'migrations', 'custom' ]
|
126
|
+
|
127
|
+
def self.add_custom_check(&block)
|
128
|
+
custom_checks << block
|
129
|
+
diff --git a/lib/health_check/health_check_controller.rb b/lib/health_check/health_check_controller.rb
|
130
|
+
index 4b5fa7a..7d544f7 100644
|
131
|
+
--- a/lib/health_check/health_check_controller.rb
|
132
|
+
+++ b/lib/health_check/health_check_controller.rb
|
133
|
+
@@ -4,8 +4,6 @@
|
134
|
+
module HealthCheck
|
135
|
+
class HealthCheckController < ActionController::Base
|
136
|
+
|
137
|
+
- session(:off) if Rails.version < '3.0'
|
138
|
+
-
|
139
|
+
layout false if self.respond_to? :layout
|
140
|
+
|
141
|
+
def index
|
142
|
+
@@ -34,9 +32,9 @@ module HealthCheck
|
143
|
+
end
|
144
|
+
# Log a single line as some uptime checkers only record that it failed, not the text returned
|
145
|
+
if logger
|
146
|
+
- silence_level, logger.level = logger.level, @old_logger_level
|
147
|
+
+ silence_level, logger.level = logger.level, @old_logger_level if @old_logger_level
|
148
|
+
logger.info msg
|
149
|
+
- logger.level = silence_level
|
150
|
+
+ logger.level = silence_level if @old_logger_level
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
diff --git a/lib/health_check/utils.rb b/lib/health_check/utils.rb
|
155
|
+
index b6da3f8..e7a10f6 100644
|
156
|
+
--- a/lib/health_check/utils.rb
|
157
|
+
+++ b/lib/health_check/utils.rb
|
158
|
+
@@ -46,8 +46,8 @@ module HealthCheck
|
159
|
+
when 'cache'
|
160
|
+
errors << HealthCheck::Utils.check_cache
|
161
|
+
when "standard"
|
162
|
+
- errors << HealthCheck::Utils.process_checks("database_migrations_custom")
|
163
|
+
- errors << HealthCheck::Utils.process_checks("email") unless HealthCheck::Utils.default_action_mailer_configuration?
|
164
|
+
+ errors << HealthCheck::Utils.process_checks(HealthCheck.standard_checks.join('_'))
|
165
|
+
+ errors << HealthCheck::Utils.process_checks("email") if HealthCheck::Utils.mailer_configured?
|
166
|
+
when "custom"
|
167
|
+
HealthCheck.custom_checks.each do |custom_check|
|
168
|
+
errors << custom_check.call(self)
|
169
|
+
@@ -71,8 +71,8 @@ module HealthCheck
|
170
|
+
@@db_migrate_path = value
|
171
|
+
end
|
172
|
+
|
173
|
+
- def self.default_action_mailer_configuration?
|
174
|
+
- ActionMailer::Base.delivery_method == :smtp && HealthCheck::Utils.default_smtp_settings == ActionMailer::Base.smtp_settings
|
175
|
+
+ def self.mailer_configured?
|
176
|
+
+ defined?(ActionMailer::Base) && (ActionMailer::Base.delivery_method != :smtp || HealthCheck::Utils.default_smtp_settings != ActionMailer::Base.smtp_settings)
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.get_database_version
|
180
|
+
@@ -117,11 +117,11 @@ module HealthCheck
|
181
|
+
while status != nil && status !~ /^2/
|
182
|
+
status = t.gets
|
183
|
+
end
|
184
|
+
- t.puts "HELO #{settings[:domain]}"
|
185
|
+
+ t.puts "HELO #{settings[:domain]}\r"
|
186
|
+
while status != nil && status !~ /^250/
|
187
|
+
status = t.gets
|
188
|
+
end
|
189
|
+
- t.puts "QUIT"
|
190
|
+
+ t.puts "QUIT\r"
|
191
|
+
status = t.gets
|
192
|
+
ensure
|
193
|
+
t.close
|
194
|
+
diff --git a/lib/health_check/version.rb b/lib/health_check/version.rb
|
195
|
+
index 8264365..0cf2f60 100644
|
196
|
+
--- a/lib/health_check/version.rb
|
197
|
+
+++ b/lib/health_check/version.rb
|
198
|
+
@@ -1,4 +1,4 @@
|
199
|
+
module HealthCheck
|
200
|
+
- VERSION = "1.4.1"
|
201
|
+
+ VERSION = "1.5.0"
|
202
|
+
end
|
203
|
+
|
204
|
+
diff --git a/test/fake_smtp_server b/test/fake_smtp_server
|
205
|
+
index e55ee3a..7f1e645 100755
|
206
|
+
--- a/test/fake_smtp_server
|
207
|
+
+++ b/test/fake_smtp_server
|
208
|
+
@@ -23,8 +23,8 @@ client = server.accept # Wait for a client to connect
|
209
|
+
send(client, "220 dummy-smtp.example.com SMTP")
|
210
|
+
cmd = receive(client)
|
211
|
+
|
212
|
+
-while cmd !~ /^QUIT/
|
213
|
+
- if cmd =~ /^HELO/
|
214
|
+
+while cmd !~ /^QUIT\r/
|
215
|
+
+ if cmd =~ /^HELO(.*)\r/
|
216
|
+
send(client, "250 Welcome to a dummy smtp server")
|
217
|
+
else
|
218
|
+
send(client, "502 I am so dumb I only understand HELO and QUIT")
|
219
|
+
diff --git a/test/rails_2.3.gemfile b/test/rails_2.3.gemfile
|
220
|
+
index 80aa9fc..e30fa69 100644
|
221
|
+
--- a/test/rails_2.3.gemfile
|
222
|
+
+++ b/test/rails_2.3.gemfile
|
223
|
+
@@ -13,6 +13,9 @@ gem 'rails', "~> 2.3.15"
|
224
|
+
gem 'rdoc'
|
225
|
+
gem 'rdoc-data'
|
226
|
+
|
227
|
+
+# mime-types 2.0 requires Ruby version >= 1.9.2
|
228
|
+
+gem "mime-types", "< 2.0"
|
229
|
+
+
|
230
|
+
group :development, :test do
|
231
|
+
if defined?(JRUBY_VERSION)
|
232
|
+
gem 'jruby-openssl'
|
233
|
+
diff --git a/test/rails_4.1.gemfile b/test/rails_4.1.gemfile
|
234
|
+
new file mode 100644
|
235
|
+
index 0000000..b199010
|
236
|
+
--- /dev/null
|
237
|
+
+++ b/test/rails_4.1.gemfile
|
238
|
+
@@ -0,0 +1,19 @@
|
239
|
+
+# Gemfile for health_test testing
|
240
|
+
+
|
241
|
+
+source 'https://rubygems.org'
|
242
|
+
+
|
243
|
+
+ruby '1.9.3' if RUBY_VERSION < '1.9.3'
|
244
|
+
+
|
245
|
+
+gem 'rails', "~> 4.1.0"
|
246
|
+
+gem 'rake', '>= 0.8.3'
|
247
|
+
+gem "rack", '~> 1.5.2'
|
248
|
+
+
|
249
|
+
+group :development, :test do
|
250
|
+
+ if defined?(JRUBY_VERSION)
|
251
|
+
+ gem 'jruby-openssl'
|
252
|
+
+ gem 'activerecord-jdbcsqlite3-adapter'
|
253
|
+
+ else
|
254
|
+
+ gem 'sqlite3', "~> 1.3.7"
|
255
|
+
+ end
|
256
|
+
+ gem 'shoulda'
|
257
|
+
+end
|
258
|
+
diff --git a/test/setup_railsapp b/test/setup_railsapp
|
259
|
+
index 5f414f9..80f6116 100755
|
260
|
+
--- a/test/setup_railsapp
|
261
|
+
+++ b/test/setup_railsapp
|
262
|
+
@@ -164,6 +164,9 @@ then
|
263
|
+
echo ================= Gemfile ===================
|
264
|
+
cat Gemfile
|
265
|
+
echo
|
266
|
+
+ echo ================= Gemfile.lock ===================
|
267
|
+
+ cat Gemfile.lock
|
268
|
+
+ echo
|
269
|
+
else
|
270
|
+
dest=$railsapp/vendor/plugins/health_check
|
271
|
+
echo Installing health_check as plugin in $dest ...
|
272
|
+
diff --git a/test/test_with_railsapp b/test/test_with_railsapp
|
273
|
+
index 2ba4bc4..c866c68 100755
|
274
|
+
--- a/test/test_with_railsapp
|
275
|
+
+++ b/test/test_with_railsapp
|
276
|
+
@@ -306,6 +306,10 @@ common_tests()
|
277
|
+
date > $custom_file
|
278
|
+
}
|
279
|
+
|
280
|
+
+
|
281
|
+
+# required for rails 4.1+ in production mode
|
282
|
+
+export SECRET_KEY_BASE=cf2f49c38a3fe67416ddf680f4f3187c0fce7dd1b9b117b34d195df75b274e08a04877e23803b2fdf1aa9a655269d94bc4888aa325cf7e721cc47368cfe56a80
|
283
|
+
+
|
284
|
+
echo ========================================================
|
285
|
+
echo TESTING WITHOUT CATCHALL in test env
|
286
|
+
echo ========================================================
|
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
= health_check gem
|
1
|
+
= health_check gem (pre_rails4 branch)
|
2
2
|
|
3
3
|
Simple health check of Rails app for use with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
|
4
4
|
|
5
|
+
Use {master}[https://github.com/ianheggie/health_check/tree/master] branch or gem versions >= 2.0 for Rails 4.0+
|
6
|
+
|
5
7
|
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)
|
6
8
|
|
7
9
|
health_check provides various monitoring URIs, for example:
|
@@ -24,7 +26,7 @@ On failure a 500 http status is returned with a simple explanation of the failur
|
|
24
26
|
curl localhost:3000/health_check/fail
|
25
27
|
health_check failed: invalid argument to health_test.
|
26
28
|
|
27
|
-
The health_check controller disables sessions for versions that eagerly load sessions. Only failures are logged
|
29
|
+
The health_check controller disables sessions for versions that eagerly load sessions. Only failures are logged.
|
28
30
|
|
29
31
|
== Checks
|
30
32
|
|
@@ -41,8 +43,6 @@ The email gateway is not checked unless the smtp settings have been changed.
|
|
41
43
|
Specify full or include email in the list of checks to verify the smtp settings
|
42
44
|
(eg use 127.0.0.1 instead of localhost).
|
43
45
|
|
44
|
-
Note: rails 4.0 also checks migrations by default in development mode and throws an ActiveRecord::PendingMigrationError exception (http error 500) if there is an error
|
45
|
-
|
46
46
|
== Installation
|
47
47
|
|
48
48
|
=== As a Gem from rubygems (Rails 3.0 and above)
|
@@ -232,7 +232,7 @@ The command `rake test` will also launch these tests, except it cannot install t
|
|
232
232
|
|
233
233
|
== Copyright
|
234
234
|
|
235
|
-
Copyright (c) 2010-
|
235
|
+
Copyright (c) 2010-2015 Ian Heggie, released under the MIT license.
|
236
236
|
See MIT-LICENSE for details.
|
237
237
|
|
238
238
|
== Contributors
|
data/lib/health_check/version.rb
CHANGED
data/test/rails_3.1.gemfile
CHANGED
@@ -5,6 +5,7 @@ source 'https://rubygems.org'
|
|
5
5
|
gem 'rails', "~> 3.1.0"
|
6
6
|
gem 'rake', '>= 0.8.3'
|
7
7
|
|
8
|
+
|
8
9
|
group :development, :test do
|
9
10
|
if defined?(JRUBY_VERSION)
|
10
11
|
gem 'jruby-openssl'
|
@@ -14,3 +15,10 @@ group :development, :test do
|
|
14
15
|
end
|
15
16
|
gem 'shoulda', "~> 2.11.0"
|
16
17
|
end
|
18
|
+
|
19
|
+
# next version requires ruby 1.9.3
|
20
|
+
gem 'i18n', '~> 0.6.11' if RUBY_VERSION < '1.9.3' # REQUIRED
|
21
|
+
|
22
|
+
# Initial Gemfile has therubyracer commented out
|
23
|
+
gem 'therubyrhino', :platform => :jruby # REQUIRED
|
24
|
+
gem 'therubyracer', :platform => :ruby # REQUIRED
|
data/test/rails_3.2.gemfile
CHANGED
@@ -14,3 +14,10 @@ group :development, :test do
|
|
14
14
|
end
|
15
15
|
gem 'shoulda', "~> 2.11.0"
|
16
16
|
end
|
17
|
+
|
18
|
+
# next version requires ruby 1.9.3
|
19
|
+
gem 'i18n', '~> 0.6.11' if RUBY_VERSION < '1.9.3' # REQUIRED
|
20
|
+
|
21
|
+
# Initial Gemfile has therubyracer commented out
|
22
|
+
gem 'therubyrhino', :platform => :jruby # REQUIRED
|
23
|
+
gem 'therubyracer', :platform => :ruby # REQUIRED
|
data/test/setup_railsapp
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
# Any failure causes exit
|
4
4
|
set -e
|
5
5
|
|
6
|
+
case "$1" in
|
7
|
+
[0-9]*)
|
8
|
+
export BUNDLE_GEMFILE=$PWD/test/rails_$1.gemfile
|
9
|
+
;;
|
10
|
+
esac
|
6
11
|
while :
|
7
12
|
do
|
8
13
|
case "$BUNDLE_GEMFILE" in
|
@@ -39,16 +44,32 @@ else
|
|
39
44
|
$rehash
|
40
45
|
fi
|
41
46
|
|
42
|
-
echo "Running bundle
|
43
|
-
if ! bundle
|
47
|
+
echo "Running bundle with BUNDLE_GEMFILE=$BUNDLE_GEMFILE ..."
|
48
|
+
if ! bundle ; then
|
44
49
|
echo "Test aborted (missing required gems)"
|
45
50
|
exit 2
|
46
51
|
fi
|
47
52
|
$rehash
|
48
53
|
|
49
54
|
rails="$base_dir/test/bin/rails"
|
55
|
+
|
56
|
+
echo Checking $rails is present ...
|
57
|
+
[ -f $rails ] || bundle binstub railties || echo '(ignored bundle exit status)'
|
58
|
+
[ -f $rails ] || bundle binstub rails || echo '(ignored bundle exit status)'
|
59
|
+
if [ ! -f $rails ]; then
|
60
|
+
echo "Test aborted (unable to create $rails)"
|
61
|
+
exit 2
|
62
|
+
fi
|
63
|
+
|
50
64
|
rake="$base_dir/test/bin/rake"
|
51
65
|
|
66
|
+
echo Checking $rake is present ...
|
67
|
+
[ -f $rake ] || bundle binstub rake || echo '(ignored bundle exit status)'
|
68
|
+
if [ ! -f $rake ]; then
|
69
|
+
echo "Test aborted (unable to create $rake)"
|
70
|
+
exit 2
|
71
|
+
fi
|
72
|
+
|
52
73
|
actual_rails_version=`$rails -v`
|
53
74
|
|
54
75
|
[ -d lib/health_check ] || exec echo setup_railsapp MUST be executed in the base of the health_check gem/clone of git repository
|
@@ -130,6 +151,7 @@ end
|
|
130
151
|
!
|
131
152
|
|
132
153
|
echo Unsetting BUNDLE_GEMFILE '(so Gemfile for rails application will be used)'
|
154
|
+
INITIAL_BUNDLE_GEMFILE=$BUNDLE_GEMFILE
|
133
155
|
unset BUNDLE_GEMFILE
|
134
156
|
|
135
157
|
if [ -s Gemfile ]
|
@@ -146,24 +168,38 @@ then
|
|
146
168
|
echo "gem '$RAILS_SERVER'" >> Gemfile
|
147
169
|
;;
|
148
170
|
esac
|
171
|
+
echo Adding required Gemfile lines ...
|
172
|
+
egrep REQUIRED $INITIAL_BUNDLE_GEMFILE | tee -a Gemfile
|
149
173
|
echo
|
150
|
-
echo
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
echo a | rake rails:update:bin
|
156
|
-
;;
|
157
|
-
esac
|
174
|
+
echo ================= Gemfile ===================
|
175
|
+
cat Gemfile
|
176
|
+
echo
|
177
|
+
echo running bundle install
|
178
|
+
bundle install
|
158
179
|
$rehash
|
159
180
|
echo "Using binstubs in $railsapp/bin for rails and rake commands"
|
160
181
|
rails="$railsapp/bin/rails"
|
182
|
+
|
183
|
+
echo Checking $rails is present ...
|
184
|
+
[ -f $rails ] || bundle binstub railties || echo '(ignored bundle exit status)'
|
185
|
+
[ -f $rails ] || bundle binstub rails || echo '(ignored bundle exit status)'
|
186
|
+
if [ ! -f $rails ]; then
|
187
|
+
echo "Test aborted (unable to create $rails)"
|
188
|
+
exit 2
|
189
|
+
fi
|
190
|
+
|
161
191
|
rake="$railsapp/bin/rake"
|
192
|
+
|
193
|
+
echo Checking $rake is present ...
|
194
|
+
[ -f $rake ] || bundle binstub rake || echo '(ignored bundle exit status)'
|
195
|
+
if [ ! -f $rake ]; then
|
196
|
+
echo "Test aborted (unable to create $rake)"
|
197
|
+
exit 2
|
198
|
+
fi
|
199
|
+
|
200
|
+
$rehash
|
162
201
|
# Fix for rvm, otherwise bundle run from rails create fails
|
163
202
|
export PATH="`pwd`/bin:$PATH"
|
164
|
-
echo ================= Gemfile ===================
|
165
|
-
cat Gemfile
|
166
|
-
echo
|
167
203
|
echo ================= Gemfile.lock ===================
|
168
204
|
cat Gemfile.lock
|
169
205
|
echo
|
@@ -313,18 +349,20 @@ if [ -s config/routes.rb ]; then
|
|
313
349
|
|
314
350
|
case "$var" in
|
315
351
|
'')
|
352
|
+
# rails 3.0+
|
316
353
|
echo " # -----------------------------------------"
|
317
354
|
echo " # START OF SECTION FOR TESTING HEALTH_CHECK"
|
318
355
|
echo " get 'example(/:action(/:id))(.:format)' => 'example'"
|
319
356
|
echo " if File.exists?('$catchall_file')"
|
320
357
|
echo " health_check_routes"
|
321
358
|
echo " # CATCH ALL ROUTE"
|
322
|
-
echo " get '*path' => 'example#catchall'"
|
359
|
+
echo " get '*path', :to => 'example#catchall'"
|
323
360
|
echo " end"
|
324
361
|
echo " # END OF SECTION FOR TESTING HEALTH_CHECK"
|
325
362
|
echo " # ---------------------------------------"
|
326
363
|
;;
|
327
364
|
*)
|
365
|
+
# rails 2.3
|
328
366
|
echo " # -----------------------------------------"
|
329
367
|
echo " # START OF SECTION FOR TESTING HEALTH_CHECK"
|
330
368
|
echo " # example controller"
|
data/test/test_with_railsapp
CHANGED
@@ -3,27 +3,34 @@
|
|
3
3
|
# Any failure causes exit
|
4
4
|
set -e
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
. test/init_variables
|
9
|
-
cd $railsapp
|
6
|
+
cleanup_db()
|
7
|
+
{
|
10
8
|
echo Dropping database ...
|
11
|
-
$rake db:drop
|
9
|
+
$rake db:drop
|
12
10
|
echo Removing migrations ...
|
13
11
|
rm -f db/migrate/* db/schema.rb
|
14
12
|
case `ruby -e 'puts JRUBY_VERSION' 2> /dev/null` in
|
15
13
|
[0-9]*)
|
16
14
|
echo 'Jruby requires the database to be created before the server is started: running rake db:migrate'
|
17
|
-
$rake db:migrate
|
15
|
+
$rake db:migrate
|
18
16
|
;;
|
19
17
|
esac
|
18
|
+
}
|
19
|
+
|
20
|
+
case "$1" in
|
21
|
+
redo)
|
22
|
+
. test/init_variables
|
23
|
+
cd $railsapp
|
24
|
+
cleanup_db
|
20
25
|
actual_rails_version=`$rails -v`
|
21
26
|
;;
|
22
27
|
*)
|
23
|
-
. test/setup_railsapp
|
28
|
+
. test/setup_railsapp $1
|
24
29
|
;;
|
25
30
|
esac
|
26
31
|
|
32
|
+
run_test=$2
|
33
|
+
|
27
34
|
cd $railsapp
|
28
35
|
date > $custom_file
|
29
36
|
rm -f $catchall_file
|
@@ -113,6 +120,7 @@ stop_server()
|
|
113
120
|
echo ========================================================
|
114
121
|
echo "Killing rails server [pid: $server_pid]"
|
115
122
|
kill -1 $server_pid || true
|
123
|
+
[ ! -x bin/spring ] || bin/spring stop || true
|
116
124
|
sleep 2
|
117
125
|
kill -9 $server_pid || true
|
118
126
|
;;
|
@@ -161,187 +169,289 @@ trap "finish FAILED 1" 0
|
|
161
169
|
common_tests()
|
162
170
|
{
|
163
171
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
172
|
+
test_no=$1
|
173
|
+
|
174
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
175
|
+
echo "${test_no}: CHECKING routes exist..."
|
176
|
+
$rake routes | tee /tmp/t$$
|
177
|
+
echo
|
178
|
+
case `egrep health_check /tmp/t$$ || true` in
|
179
|
+
'')
|
180
|
+
echo WARNING - routes for health_check not listed!
|
181
|
+
;;
|
182
|
+
esac
|
183
|
+
echo
|
184
|
+
fi
|
177
185
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
186
|
+
test_no=`expr 1 + $test_no`
|
187
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
188
|
+
echo "${test_no}: TESTING can get a static file ..."
|
189
|
+
case "$RAILS_ENV=`egrep serve_static_files config/environments/production.rb`" in
|
190
|
+
production*static*)
|
191
|
+
echo " SKIPPED (disabled in production)"
|
192
|
+
;;
|
193
|
+
*)
|
194
|
+
$testurl ${host}/static.txt 200 text/plain STATIC-FILE
|
195
|
+
;;
|
196
|
+
esac
|
197
|
+
echo
|
198
|
+
fi
|
182
199
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
200
|
+
test_no=`expr 1 + $test_no`
|
201
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
202
|
+
echo "${test_no}: TESTING can get an example controller ..."
|
203
|
+
$testurl ${host}/example 200 text/html 'example page'
|
204
|
+
echo
|
205
|
+
fi
|
187
206
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
207
|
+
test_no=`expr 1 + $test_no`
|
208
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
209
|
+
echo "${test_no}: TESTING direct call to catchall method on example controller ..."
|
210
|
+
$testurl ${host}/example/catchall 200 text/html 'catch all route'
|
211
|
+
echo
|
212
|
+
fi
|
192
213
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
214
|
+
test_no=`expr 1 + $test_no`
|
215
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
216
|
+
echo "${test_no}: TESTING health_check/migration should pass with no database migrations ..."
|
217
|
+
ls db/migrate
|
218
|
+
$testurl ${host}/health_check/migration 200 text/plain $success
|
219
|
+
echo
|
220
|
+
fi
|
198
221
|
|
199
|
-
|
200
|
-
$
|
201
|
-
|
222
|
+
test_no=`expr 1 + $test_no`
|
223
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
224
|
+
echo "${test_no}: TESTING health_check/migration should fail without initial database migration ..."
|
225
|
+
cp $base_dir/test/migrate/nine/* db/migrate
|
226
|
+
ls db/migrate
|
227
|
+
$testurl ${host}/health_check/migration 550 text/plain failed
|
228
|
+
echo
|
229
|
+
fi
|
202
230
|
|
203
|
-
|
204
|
-
$
|
205
|
-
|
231
|
+
test_no=`expr 1 + $test_no`
|
232
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
233
|
+
echo "${test_no}: TESTING health_check/database should pass without initial database migration (since it ignores the difference) ..."
|
234
|
+
$testurl ${host}/health_check/database 200 text/plain $success
|
235
|
+
echo
|
236
|
+
fi
|
206
237
|
|
207
|
-
|
208
|
-
$
|
209
|
-
|
210
|
-
|
238
|
+
test_no=`expr 1 + $test_no`
|
239
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
240
|
+
echo "${test_no}: TESTING health_check/site should pass ..."
|
241
|
+
$testurl ${host}/health_check/site 200 text/plain $success
|
242
|
+
echo
|
243
|
+
fi
|
211
244
|
|
212
|
-
|
213
|
-
|
245
|
+
test_no=`expr 1 + $test_no`
|
246
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
247
|
+
echo "${test_no}: TESTING health_check/migration should pass after initial database migration ..."
|
248
|
+
$rake db:migrate
|
249
|
+
$testurl ${host}/health_check/migration 200 text/plain $success
|
250
|
+
echo
|
251
|
+
fi
|
214
252
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
253
|
+
test_no=`expr 1 + $test_no`
|
254
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
255
|
+
echo "${test_no}: TESTING health_check/migration should fail without all migrations ..."
|
256
|
+
cp $base_dir/test/migrate/twelve/* db/migrate
|
257
|
+
|
258
|
+
case "$actual_rails_version" in
|
259
|
+
*' '[12].*|*' '3.[01]*)
|
260
|
+
echo removing db/migrate/*.*.rb "($actual_rails_version does not support extra dots in migration names)"
|
261
|
+
rm -f db/migrate/*.*.rb
|
262
|
+
;;
|
263
|
+
esac
|
264
|
+
ls db/migrate
|
265
|
+
$testurl ${host}/health_check/migration 550 text/plain failed
|
266
|
+
echo
|
267
|
+
fi
|
224
268
|
|
225
|
-
|
226
|
-
$
|
227
|
-
|
228
|
-
|
269
|
+
test_no=`expr 1 + $test_no`
|
270
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
271
|
+
echo "${test_no}: TESTING health_check/migration should pass after both database migrations ..."
|
272
|
+
$rake db:migrate
|
273
|
+
$testurl ${host}/health_check/migration 200 text/plain $success
|
274
|
+
echo
|
275
|
+
fi
|
229
276
|
|
230
|
-
|
231
|
-
$
|
232
|
-
|
233
|
-
|
277
|
+
test_no=`expr 1 + $test_no`
|
278
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
279
|
+
echo "${test_no}: TESTING health_check/migration should pass after both database migrations ..."
|
280
|
+
$rake db:migrate
|
281
|
+
$testurl ${host}/health_check/migration 200 text/plain $success
|
282
|
+
echo
|
283
|
+
fi
|
234
284
|
|
235
|
-
|
236
|
-
$
|
237
|
-
|
285
|
+
test_no=`expr 1 + $test_no`
|
286
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
287
|
+
echo "${test_no}: TESTING health_check/email should fail without smtp available ..."
|
288
|
+
$testurl ${host}/health_check/email 550 text/plain failed
|
289
|
+
echo
|
290
|
+
fi
|
238
291
|
|
239
|
-
|
240
|
-
$
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
292
|
+
test_no=`expr 1 + $test_no`
|
293
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
294
|
+
echo "${test_no}: TESTING health_check/email should pass with smtp available ..."
|
295
|
+
$fake_smtp_server &
|
296
|
+
fake_smtp_pid=$!
|
297
|
+
sleep 5
|
298
|
+
$testurl ${host}/health_check/email 200 text/plain $success
|
299
|
+
echo
|
300
|
+
fi
|
245
301
|
|
246
|
-
|
247
|
-
$
|
248
|
-
|
302
|
+
test_no=`expr 1 + $test_no`
|
303
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
304
|
+
echo "${test_no}: TESTING health_check (all) should fail without smtp available ..."
|
305
|
+
$testurl ${host}/health_check 550 text/plain failed
|
306
|
+
echo
|
307
|
+
fi
|
249
308
|
|
250
|
-
|
251
|
-
$
|
252
|
-
|
309
|
+
test_no=`expr 1 + $test_no`
|
310
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
311
|
+
echo "${test_no}: TESTING health_check/all should fail without smtp available ..."
|
312
|
+
$testurl ${host}/health_check 550 text/plain failed
|
313
|
+
echo
|
314
|
+
fi
|
253
315
|
|
254
316
|
kill -9 $fake_smtp_pid || echo fake_smtp_server had finished as expected
|
255
|
-
|
256
|
-
$
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
317
|
+
test_no=`expr 1 + $test_no`
|
318
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
319
|
+
echo "${test_no}: TESTING health_check (all) should pass with smtp available ..."
|
320
|
+
$fake_smtp_server &
|
321
|
+
fake_smtp_pid=$!
|
322
|
+
sleep 5
|
323
|
+
$testurl ${host}/health_check 200 text/plain $success
|
324
|
+
echo
|
325
|
+
fi
|
261
326
|
|
262
327
|
kill -9 $fake_smtp_pid || echo fake_smtp_server had finished as expected
|
263
|
-
|
264
|
-
$
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
328
|
+
test_no=`expr 1 + $test_no`
|
329
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
330
|
+
echo "${test_no}: TESTING health_check/all should pass with smtp available ..."
|
331
|
+
$fake_smtp_server &
|
332
|
+
fake_smtp_pid=$!
|
333
|
+
sleep 5
|
334
|
+
$testurl ${host}/health_check/all 200 text/plain $success
|
335
|
+
echo
|
336
|
+
fi
|
269
337
|
|
270
|
-
|
271
|
-
$
|
272
|
-
|
338
|
+
test_no=`expr 1 + $test_no`
|
339
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
340
|
+
echo "${test_no}: TESTING health_check/custom should pass ..."
|
341
|
+
$testurl ${host}/health_check/custom 200 text/plain $success
|
342
|
+
echo
|
343
|
+
fi
|
273
344
|
|
274
|
-
|
275
|
-
$
|
276
|
-
|
345
|
+
test_no=`expr 1 + $test_no`
|
346
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
347
|
+
echo "${test_no}: TESTING health_check/custom.html should pass (returning plain text) ..."
|
348
|
+
$testurl ${host}/health_check/custom.html 200 text/plain $success
|
349
|
+
echo
|
350
|
+
fi
|
277
351
|
|
278
|
-
|
279
|
-
$
|
280
|
-
|
281
|
-
|
352
|
+
test_no=`expr 1 + $test_no`
|
353
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
354
|
+
echo "${test_no}: TESTING health_check/custom.json should pass ..."
|
355
|
+
$testurl ${host}/health_check/custom.json 200 application/json '"healthy":true'
|
356
|
+
$testurl ${host}/health_check/custom.json 200 application/json "\"message\":\"$success\""
|
357
|
+
echo
|
358
|
+
fi
|
282
359
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
360
|
+
test_no=`expr 1 + $test_no`
|
361
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
362
|
+
echo "${test_no}: TESTING health_check/custom.xml should pass ..."
|
363
|
+
$testurl ${host}/health_check/custom.xml 200 application/xml '<healthy type="boolean">true</healthy>'
|
364
|
+
$testurl ${host}/health_check/custom.xml 200 application/xml "<message>$success</message>"
|
365
|
+
echo
|
366
|
+
fi
|
287
367
|
|
288
|
-
|
368
|
+
test_no=`expr 1 + $test_no`
|
289
369
|
rm -f $custom_file
|
290
|
-
$
|
291
|
-
|
370
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
371
|
+
echo "${test_no}: TESTING health_check/custom should fail when custom returns string ..."
|
372
|
+
$testurl ${host}/health_check/custom 550 text/plain failed
|
373
|
+
echo
|
374
|
+
fi
|
292
375
|
|
293
|
-
|
294
|
-
$
|
295
|
-
|
376
|
+
test_no=`expr 1 + $test_no`
|
377
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
378
|
+
echo "${test_no}: TESTING health_check (all) should fail when custom check fails ..."
|
379
|
+
$testurl ${host}/health_check 550 text/plain "$custom_file is missing!"
|
380
|
+
echo
|
381
|
+
fi
|
296
382
|
|
297
|
-
|
298
|
-
$
|
299
|
-
|
300
|
-
|
383
|
+
test_no=`expr 1 + $test_no`
|
384
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
385
|
+
echo "${test_no}: TESTING health_check.json (all) should fail when custom check fails ..."
|
386
|
+
$testurl ${host}/health_check.json 555 application/json '"healthy":false'
|
387
|
+
$testurl ${host}/health_check.json 555 application/json "$custom_file is missing!"
|
388
|
+
echo
|
389
|
+
fi
|
301
390
|
|
302
|
-
|
303
|
-
|
304
|
-
|
391
|
+
test_no=`expr 1 + $test_no`
|
392
|
+
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
393
|
+
echo "${test_no}: TESTING health_check.xml (all) should fail when custom check fails ..."
|
394
|
+
$testurl ${host}/health_check.xml 555 application/xml '<healthy type="boolean">false</healthy>'
|
395
|
+
echo
|
396
|
+
fi
|
305
397
|
|
306
398
|
date > $custom_file
|
399
|
+
|
307
400
|
}
|
308
401
|
|
309
402
|
|
310
403
|
# required for rails 4.1+ in production mode
|
311
404
|
export SECRET_KEY_BASE=cf2f49c38a3fe67416ddf680f4f3187c0fce7dd1b9b117b34d195df75b274e08a04877e23803b2fdf1aa9a655269d94bc4888aa325cf7e721cc47368cfe56a80
|
312
405
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
406
|
+
case "$run_test" in
|
407
|
+
???)
|
408
|
+
;;
|
409
|
+
*)
|
410
|
+
echo ========================================================
|
411
|
+
echo TESTING WITHOUT CATCHALL in test env
|
412
|
+
echo ========================================================
|
413
|
+
export RAILS_ENV=test RACK_ENV=test
|
414
|
+
|
415
|
+
start_server
|
416
|
+
|
417
|
+
# get a static file
|
317
418
|
|
318
|
-
|
419
|
+
echo
|
420
|
+
echo 'TESTING no catchall route active ...'
|
421
|
+
expected_status=404,500,502
|
422
|
+
$testurl ${host}/another/url $expected_status
|
319
423
|
|
320
|
-
|
424
|
+
common_tests 1
|
425
|
+
;;
|
426
|
+
esac
|
321
427
|
|
322
|
-
echo
|
323
|
-
echo 'TESTING no catchall route active ...'
|
324
|
-
expected_status=404,500,502
|
325
|
-
$testurl ${host}/another/url $expected_status
|
326
428
|
|
327
|
-
|
429
|
+
case "$run_test" in
|
430
|
+
''|???)
|
431
|
+
echo ========================================================
|
432
|
+
echo TESTING WITH CATCHALL in ${RAILS_ENV2:-production} env
|
433
|
+
echo ========================================================
|
434
|
+
export RAILS_ENV=${RAILS_ENV2:-production} RACK_ENV=${RAILS_ENV2:-production}
|
328
435
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
436
|
+
case "$run_trest" in
|
437
|
+
'')
|
438
|
+
stop_server
|
439
|
+
cleanup_db
|
440
|
+
;;
|
441
|
+
esac
|
333
442
|
|
334
|
-
date > $catchall_file
|
443
|
+
date > $catchall_file
|
335
444
|
|
336
|
-
|
337
|
-
start_server
|
445
|
+
start_server
|
338
446
|
|
339
|
-
echo
|
340
|
-
echo 'TESTING catchall route active ...'
|
341
|
-
$testurl ${host}/another/url 200 text/html 'catch all route'
|
342
|
-
echo
|
447
|
+
echo
|
448
|
+
echo 'TESTING catchall route active ...'
|
449
|
+
$testurl ${host}/another/url 200 text/html 'catch all route'
|
450
|
+
echo
|
343
451
|
|
344
|
-
common_tests
|
452
|
+
common_tests 101
|
453
|
+
;;
|
454
|
+
esac
|
345
455
|
|
346
456
|
rm -f $catchall_file
|
347
457
|
|
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: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-03-19 00:00:00.000000000 +11:00
|
13
|
+
default_executable:
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: rails
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirement: &17685240 !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
@@ -21,15 +22,10 @@ dependencies:
|
|
21
22
|
version: 2.3.0
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 2.3.0
|
25
|
+
version_requirements: *17685240
|
30
26
|
- !ruby/object:Gem::Dependency
|
31
27
|
name: rake
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
28
|
+
requirement: &17502900 !ruby/object:Gem::Requirement
|
33
29
|
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
@@ -37,15 +33,10 @@ dependencies:
|
|
37
33
|
version: 0.8.3
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 0.8.3
|
36
|
+
version_requirements: *17502900
|
46
37
|
- !ruby/object:Gem::Dependency
|
47
38
|
name: shoulda
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirement: &17497480 !ruby/object:Gem::Requirement
|
49
40
|
none: false
|
50
41
|
requirements:
|
51
42
|
- - ~>
|
@@ -53,15 +44,10 @@ dependencies:
|
|
53
44
|
version: 2.11.0
|
54
45
|
type: :development
|
55
46
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2.11.0
|
47
|
+
version_requirements: *17497480
|
62
48
|
- !ruby/object:Gem::Dependency
|
63
49
|
name: bundler
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirement: &17496680 !ruby/object:Gem::Requirement
|
65
51
|
none: false
|
66
52
|
requirements:
|
67
53
|
- - ~>
|
@@ -69,12 +55,7 @@ dependencies:
|
|
69
55
|
version: '1.2'
|
70
56
|
type: :development
|
71
57
|
prerelease: false
|
72
|
-
version_requirements:
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '1.2'
|
58
|
+
version_requirements: *17496680
|
78
59
|
description: ! " \tSimple health check of Rails app for uptime monitoring with Pingdom,
|
79
60
|
NewRelic, EngineYard or uptime.openacs.org etc.\n"
|
80
61
|
email:
|
@@ -113,15 +94,13 @@ files:
|
|
113
94
|
- test/rails_3.0.gemfile
|
114
95
|
- test/rails_3.1.gemfile
|
115
96
|
- test/rails_3.2.gemfile
|
116
|
-
- test/rails_4.0.gemfile
|
117
|
-
- test/rails_4.1.gemfile
|
118
|
-
- test/rails_edge.gemfile
|
119
97
|
- test/setup_railsapp
|
120
98
|
- test/test_helper.rb
|
121
99
|
- test/test_with_railsapp
|
122
100
|
- test/testurl
|
123
101
|
- test/unit/health_check_controller_test.rb
|
124
102
|
- test/unit/routes_test.rb
|
103
|
+
has_rdoc: true
|
125
104
|
homepage: https://github.com/ianheggie/health_check
|
126
105
|
licenses: []
|
127
106
|
post_install_message:
|
@@ -142,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
121
|
version: '0'
|
143
122
|
requirements: []
|
144
123
|
rubyforge_project:
|
145
|
-
rubygems_version: 1.
|
124
|
+
rubygems_version: 1.3.9.5
|
146
125
|
signing_key:
|
147
126
|
specification_version: 3
|
148
127
|
summary: Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic,
|
@@ -159,9 +138,6 @@ test_files:
|
|
159
138
|
- test/rails_3.0.gemfile
|
160
139
|
- test/rails_3.1.gemfile
|
161
140
|
- test/rails_3.2.gemfile
|
162
|
-
- test/rails_4.0.gemfile
|
163
|
-
- test/rails_4.1.gemfile
|
164
|
-
- test/rails_edge.gemfile
|
165
141
|
- test/setup_railsapp
|
166
142
|
- test/test_helper.rb
|
167
143
|
- test/test_with_railsapp
|
data/test/rails_4.0.gemfile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# Gemfile for health_test testing
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
ruby '1.9.3' if RUBY_VERSION < '1.9.3'
|
6
|
-
|
7
|
-
gem 'rails', "~> 4.0.0"
|
8
|
-
gem 'rake', '>= 0.8.3'
|
9
|
-
gem "rack", '~> 1.5.2'
|
10
|
-
|
11
|
-
group :development, :test do
|
12
|
-
if defined?(JRUBY_VERSION)
|
13
|
-
gem 'jruby-openssl'
|
14
|
-
gem 'activerecord-jdbcsqlite3-adapter'
|
15
|
-
else
|
16
|
-
gem 'sqlite3', "~> 1.3.7"
|
17
|
-
end
|
18
|
-
gem 'shoulda'
|
19
|
-
end
|
data/test/rails_4.1.gemfile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# Gemfile for health_test testing
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
ruby '1.9.3' if RUBY_VERSION < '1.9.3'
|
6
|
-
|
7
|
-
gem 'rails', "~> 4.1.0"
|
8
|
-
gem 'rake', '>= 0.8.3'
|
9
|
-
gem "rack", '~> 1.5.2'
|
10
|
-
|
11
|
-
group :development, :test do
|
12
|
-
if defined?(JRUBY_VERSION)
|
13
|
-
gem 'jruby-openssl'
|
14
|
-
gem 'activerecord-jdbcsqlite3-adapter'
|
15
|
-
else
|
16
|
-
gem 'sqlite3', "~> 1.3.7"
|
17
|
-
end
|
18
|
-
gem 'shoulda'
|
19
|
-
end
|
data/test/rails_edge.gemfile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# Gemfile for health_test testing
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
# Bundle edge Rails instead:
|
6
|
-
|
7
|
-
ruby '1.9.3' if RUBY_VERSION < '1.9.3'
|
8
|
-
|
9
|
-
gem 'rails'
|
10
|
-
gem 'rake'
|
11
|
-
gem 'rack'
|
12
|
-
|
13
|
-
group :development, :test do
|
14
|
-
if defined?(JRUBY_VERSION)
|
15
|
-
gem 'jruby-openssl'
|
16
|
-
gem 'activerecord-jdbcsqlite3-adapter'
|
17
|
-
else
|
18
|
-
gem 'sqlite3'
|
19
|
-
end
|
20
|
-
gem 'shoulda'
|
21
|
-
end
|