health_check 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document CHANGED
@@ -1,5 +1,5 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore CHANGED
@@ -1,21 +1,21 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/MIT-LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright (c) 2010 Ian Heggie
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2010 Ian Heggie
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc CHANGED
@@ -1,79 +1,80 @@
1
- = health_check
2
-
3
- Simple health check of Rails app for use with uptime.openacs.org or wasitup.com
4
-
5
- The basic goal is to check that rails is being launched and that it has access to correctly configured resources (database, email gateway)
6
-
7
- The email gateway is not checked unless the smtp settings have been changed,
8
- specify full or include email in the list of checks or varify the smtp settings
9
- (eg use 127.0.0.1 instead of localhost).
10
-
11
- health_check provides various monitoring URIs
12
-
13
- % curl localhost:3000/health_check
14
- success
15
-
16
- % curl localhost:3000/health_check/standard
17
- success
18
-
19
- % curl localhost:3000/health_check/all
20
- success
21
-
22
- % curl localhost:3000/health_check/site_and_database_and_email_migrations
23
- success
24
-
25
- == Installation
26
-
27
- As a Plugin
28
-
29
- % cd vendor/plugins
30
- % git clone git://github.com/ianheggie/health_check.git
31
-
32
- As a Gem from gemcutter
33
-
34
- % gem install health_check
35
- # Add the following line to config/environment.rb
36
- config.gem "health_check"
37
-
38
- == Uptime Monitoring
39
-
40
- See
41
- * [WasItUp](http://wasitup.com/)
42
- * [Uptime by OpenACS](http://uptime.openacs.org/uptime/)
43
- * [Engine Yard's guide](http://community-support.engineyard.com/faqs/guides/uptime-monitoring-for-your-rails-application) guide based on fitter_happier plugin includes monit and other setup help
44
-
45
- == Checks
46
-
47
- * standard (default) - site, database and migrations checks are run plus email if settings have been changed
48
- * all / full - all checks are run
49
- * database - checks that the database contains the current migration level
50
- * email - basic check of email - :test returns true, :sendmail checks file is present and executable, :smtp sends HELO command to server and checks response
51
- * migration - checks that the database migration level matches that in db/migrations
52
- * site - checks rails is running sufficiently to render text
53
-
54
- == Note on Patches/Pull Requests
55
-
56
- * Fork the project.
57
- * Make your feature addition or bug fix.
58
- * Add tests for it. This is important so I don't break it in a
59
- future version unintentionally.
60
- * Commit, do not mess with rakefile, version, or history.
61
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
62
- * Send me a pull request. Bonus points for topic branches.
63
-
64
- == Copyright
65
-
66
- Copyright (c) 2010 Ian Heggie, released under the MIT license.
67
- See MIT-LICENSE for details.
68
-
69
- == Known Issues
70
-
71
- * Rails 1.x s not currently supported (smtp_settings versus server_settings)
72
- * I wasn't able to get tests to work standalone - the gem has to be installed as a plugin for the tests to work
73
- * No inline documentation for methods
74
-
75
- * Feedback welcome especially with suggested replacement code and corresponding tests
76
-
77
- == Similar projects
78
-
79
- * fitter_happier plugin by atmos - plugin with similar goals, but not compatible with uptime, and does not check email gateway
1
+ = health_check
2
+
3
+ Simple health check of Rails app for use with uptime.openacs.org, wasitup.com or newrelic.com
4
+
5
+ The basic goal is to check that rails is being launched and that it has access to correctly configured resources (database, email gateway)
6
+
7
+ The email gateway is not checked unless the smtp settings have been changed,
8
+ specify full or include email in the list of checks or varify the smtp settings
9
+ (eg use 127.0.0.1 instead of localhost).
10
+
11
+ health_check provides various monitoring URIs
12
+
13
+ % curl localhost:3000/health_check
14
+ success
15
+
16
+ % curl localhost:3000/health_check/standard
17
+ success
18
+
19
+ % curl localhost:3000/health_check/all
20
+ success
21
+
22
+ % curl localhost:3000/health_check/site_and_database_and_email_migrations
23
+ success
24
+
25
+ == Installation
26
+
27
+ As a Plugin
28
+
29
+ % cd vendor/plugins
30
+ % git clone git://github.com/ianheggie/health_check.git
31
+
32
+ As a Gem from gemcutter
33
+
34
+ % gem install health_check
35
+ # Add the following line to config/environment.rb
36
+ config.gem "health_check"
37
+
38
+ == Uptime Monitoring
39
+
40
+ See
41
+ * [WasItUp](http://wasitup.com/)
42
+ * [Uptime by OpenACS](http://uptime.openacs.org/uptime/)
43
+ * [Engine Yard's guide](http://community-support.engineyard.com/faqs/guides/uptime-monitoring-for-your-rails-application) guide based on fitter_happier plugin includes monit and other setup help
44
+ * [NewRelic Availability Monitoring](http://newrelic.com/docs/features/availability-monitoring-faq)
45
+
46
+ == Checks
47
+
48
+ * standard (default) - site, database and migrations checks are run plus email if settings have been changed
49
+ * all / full - all checks are run
50
+ * database - checks that the database contains the current migration level
51
+ * email - basic check of email - :test returns true, :sendmail checks file is present and executable, :smtp sends HELO command to server and checks response
52
+ * migration - checks that the database migration level matches that in db/migrations
53
+ * site - checks rails is running sufficiently to render text
54
+
55
+ == Note on Patches/Pull Requests
56
+
57
+ * Fork the project.
58
+ * Make your feature addition or bug fix.
59
+ * Add tests for it. This is important so I don't break it in a
60
+ future version unintentionally.
61
+ * Commit, do not mess with rakefile, version, or history.
62
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
63
+ * Send me a pull request. Bonus points for topic branches.
64
+
65
+ == Copyright
66
+
67
+ Copyright (c) 2010-2011 Ian Heggie, released under the MIT license.
68
+ See MIT-LICENSE for details.
69
+
70
+ == Known Issues
71
+
72
+ * Rails 1.x s not currently supported (smtp_settings versus server_settings)
73
+ * I wasn't able to get tests to work standalone - the gem has to be installed as a plugin for the tests to work
74
+ * No inline documentation for methods
75
+
76
+ * Feedback welcome especially with suggested replacement code and corresponding tests
77
+
78
+ == Similar projects
79
+
80
+ * fitter_happier plugin by atmos - plugin with similar goals, but not compatible with uptime, and does not check email gateway
data/Rakefile CHANGED
@@ -1,56 +1,56 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "health_check"
8
- gem.summary = %Q{Simple health check of Rails app}
9
- gem.description = %Q{Simple health check of Rails app for use with uptime.openacs.org or wasitup.com}
10
- gem.email = "ian@heggie.biz"
11
- gem.homepage = "http://github.com/ianheggie/health_check"
12
- gem.authors = ["Ian Heggie"]
13
- gem.add_development_dependency "shoulda", ">= 0"
14
- gem.add_development_dependency "sqlite3-ruby", ">= 0"
15
- gem.add_development_dependency 'activerecord', '>= 1.15.4.7794'
16
-
17
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
- end
19
- Jeweler::GemcutterTasks.new
20
- rescue LoadError
21
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
- end
23
-
24
- require 'rake/testtask'
25
- Rake::TestTask.new(:test) do |test|
26
- test.libs << 'lib' << 'test'
27
- test.pattern = 'test/**/test_*.rb'
28
- test.verbose = true
29
- end
30
-
31
- begin
32
- require 'rcov/rcovtask'
33
- Rcov::RcovTask.new do |test|
34
- test.libs << 'test'
35
- test.pattern = 'test/**/test_*.rb'
36
- test.verbose = true
37
- end
38
- rescue LoadError
39
- task :rcov do
40
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
41
- end
42
- end
43
-
44
- task :test => :check_dependencies
45
-
46
- task :default => :test
47
-
48
- require 'rake/rdoctask'
49
- Rake::RDocTask.new do |rdoc|
50
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
-
52
- rdoc.rdoc_dir = 'rdoc'
53
- rdoc.title = "health_check #{version}"
54
- rdoc.rdoc_files.include('README*')
55
- rdoc.rdoc_files.include('lib/**/*.rb')
56
- end
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "health_check"
8
+ gem.summary = %Q{Simple health check of Rails app}
9
+ gem.description = %Q{Simple health check of Rails app for use with uptime.openacs.org or wasitup.com}
10
+ gem.email = "ian@heggie.biz"
11
+ gem.homepage = "http://github.com/ianheggie/health_check"
12
+ gem.authors = ["Ian Heggie"]
13
+ gem.add_development_dependency "shoulda", ">= 0"
14
+ gem.add_development_dependency "sqlite3-ruby", ">= 0"
15
+ gem.add_development_dependency 'activerecord', '>= 1.15.4.7794'
16
+
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ require 'rake/testtask'
25
+ Rake::TestTask.new(:test) do |test|
26
+ test.libs << 'lib' << 'test'
27
+ test.pattern = 'test/**/test_*.rb'
28
+ test.verbose = true
29
+ end
30
+
31
+ begin
32
+ require 'rcov/rcovtask'
33
+ Rcov::RcovTask.new do |test|
34
+ test.libs << 'test'
35
+ test.pattern = 'test/**/test_*.rb'
36
+ test.verbose = true
37
+ end
38
+ rescue LoadError
39
+ task :rcov do
40
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
41
+ end
42
+ end
43
+
44
+ task :test => :check_dependencies
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "health_check #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.0
data/config/routes.rb ADDED
@@ -0,0 +1,13 @@
1
+ if defined?(Rails) and Rails.respond_to?(:version) && Rails.version =~ /^3/
2
+ if defined? Rails31
3
+ Rails31::Application.routes.draw do
4
+ match 'health_check', :to => 'health_check#index'
5
+ match 'health_check/:checks', :to => 'health_check#check'
6
+ end
7
+ else
8
+ Rails.application.routes.draw do |map|
9
+ match 'health_check', :to => 'health_check#index'
10
+ match 'health_check/:checks', :to => 'health_check#check'
11
+ end
12
+ end
13
+ end
data/health_check.gemspec CHANGED
@@ -1,70 +1,71 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{health_check}
8
- s.version = "0.1.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Ian Heggie"]
12
- s.date = %q{2010-01-29}
13
- s.description = %q{Simple health check of Rails app for use with uptime.openacs.org or wasitup.com}
14
- s.email = %q{ian@heggie.biz}
15
- s.extra_rdoc_files = [
16
- "README.rdoc"
17
- ]
18
- s.files = [
19
- ".document",
20
- ".gitignore",
21
- "MIT-LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "health_check.gemspec",
26
- "init.rb",
27
- "lib/health_check.rb",
28
- "lib/health_check/add_routes.rb",
29
- "lib/health_check/health_check_class.rb",
30
- "lib/health_check/health_check_controller.rb",
31
- "test/helper.rb",
32
- "test/migrate/empty/do_not_remove.txt",
33
- "test/migrate/twelve/012_create_users.rb",
34
- "test/migrate/twelve/9_create_countries.rb",
35
- "test/test_health_check_controller.rb",
36
- "test/test_routes.rb"
37
- ]
38
- s.homepage = %q{http://github.com/ianheggie/health_check}
39
- s.rdoc_options = ["--charset=UTF-8"]
40
- s.require_paths = ["lib"]
41
- s.rubygems_version = %q{1.3.5}
42
- s.summary = %q{Simple health check of Rails app}
43
- s.test_files = [
44
- "test/helper.rb",
45
- "test/migrate/twelve/012_create_users.rb",
46
- "test/migrate/twelve/9_create_countries.rb",
47
- "test/test_health_check_controller.rb",
48
- "test/test_routes.rb"
49
- ]
50
-
51
- if s.respond_to? :specification_version then
52
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
53
- s.specification_version = 3
54
-
55
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
56
- s.add_development_dependency(%q<shoulda>, [">= 0"])
57
- s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
58
- s.add_development_dependency(%q<activerecord>, [">= 1.15.4.7794"])
59
- else
60
- s.add_dependency(%q<shoulda>, [">= 0"])
61
- s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
62
- s.add_dependency(%q<activerecord>, [">= 1.15.4.7794"])
63
- end
64
- else
65
- s.add_dependency(%q<shoulda>, [">= 0"])
66
- s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
67
- s.add_dependency(%q<activerecord>, [">= 1.15.4.7794"])
68
- end
69
- end
70
-
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{health_check}
8
+ s.version = "0.2.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ian Heggie"]
12
+ s.date = %q{2011-11-15}
13
+ s.description = %q{Simple health check of Rails app for use with uptime monitoring sites}
14
+ s.email = %q{ian@heggie.biz}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ "MIT-LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "health_check.gemspec",
26
+ "init.rb",
27
+ "config/routes.rb",
28
+ "lib/health_check.rb",
29
+ "lib/health_check/add_routes.rb",
30
+ "lib/health_check/health_check_class.rb",
31
+ "lib/health_check/health_check_controller.rb",
32
+ "test/helper.rb",
33
+ "test/migrate/empty/do_not_remove.txt",
34
+ "test/migrate/twelve/012_create_users.rb",
35
+ "test/migrate/twelve/9_create_countries.rb",
36
+ "test/test_health_check_controller.rb",
37
+ "test/test_routes.rb"
38
+ ]
39
+ s.homepage = %q{http://github.com/ianheggie/health_check}
40
+ s.rdoc_options = ["--charset=UTF-8"]
41
+ s.require_paths = ["lib"]
42
+ s.rubygems_version = %q{1.3.5}
43
+ s.summary = %q{Simple health check of Rails app}
44
+ s.test_files = [
45
+ "test/helper.rb",
46
+ "test/migrate/twelve/012_create_users.rb",
47
+ "test/migrate/twelve/9_create_countries.rb",
48
+ "test/test_health_check_controller.rb",
49
+ "test/test_routes.rb"
50
+ ]
51
+
52
+ if s.respond_to? :specification_version then
53
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
+ s.specification_version = 3
55
+
56
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
58
+ s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
59
+ s.add_development_dependency(%q<activerecord>, [">= 1.15.4.7794"])
60
+ else
61
+ s.add_dependency(%q<shoulda>, [">= 0"])
62
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
63
+ s.add_dependency(%q<activerecord>, [">= 1.15.4.7794"])
64
+ end
65
+ else
66
+ s.add_dependency(%q<shoulda>, [">= 0"])
67
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
68
+ s.add_dependency(%q<activerecord>, [">= 1.15.4.7794"])
69
+ end
70
+ end
71
+
@@ -1,17 +1,20 @@
1
- module ActionController
2
- module Routing #:nodoc:
3
- class RouteSet #:nodoc:
4
- alias_method :draw_without_health_check_routes, :draw
5
- def draw
6
- draw_without_health_check_routes do |map|
7
- map.connect 'health_check',
8
- :controller => 'health_check', :action => 'index'
9
- map.connect 'health_check/:checks',
10
- :controller => 'health_check', :action => 'check'
11
- yield map
12
- end
1
+ # rails 3.x routes defined in config/routes.rb
2
+ unless defined?(Rails) and Rails.respond_to?(:version) && Rails.version =~ /^3/
3
+ # rails prior to 3.0
4
+ module ActionController
5
+ module Routing #:nodoc:
6
+ class RouteSet #:nodoc:
7
+ alias_method :draw_without_health_check_routes, :draw
8
+ def draw
9
+ draw_without_health_check_routes do |map|
10
+ map.connect 'health_check',
11
+ :controller => 'health_check', :action => 'index'
12
+ map.connect 'health_check/:checks',
13
+ :controller => 'health_check', :action => 'check'
14
+ yield map
15
+ end
16
+ end
13
17
  end
14
18
  end
15
19
  end
16
20
  end
17
-
data/lib/health_check.rb CHANGED
@@ -1,3 +1,3 @@
1
- require 'health_check/health_check_class'
2
- require 'health_check/health_check_controller'
3
- require 'health_check/add_routes'
1
+ require 'health_check/health_check_class'
2
+ require 'health_check/health_check_controller'
3
+ require 'health_check/add_routes'
data/test/helper.rb CHANGED
@@ -1,88 +1,88 @@
1
- ENV['RAILS_ENV'] = 'test'
2
-
3
- require 'test/unit'
4
- require 'rubygems'
5
-
6
- # Tests are conducted with health_test as a plugin
7
- environment_file = File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'config', 'environment.rb')
8
- if File.exists?(environment_file)
9
- # test as plugin
10
- require environment_file
11
- else
12
- #tests as gem
13
- fail "TODO: Work out how to test as a gem (test as a plugin instead)"
14
- # TODO: Work out how to do this!
15
- #require 'rails/version'
16
- #RAILS_ROOT = "test" unless defined?(RAILS_ROOT)
17
- #module Rails
18
- # def backtrace_cleaner(args)
19
- # # do nothing
20
- # end
21
- #end
22
-
23
- #require 'active_support'
24
- #require 'action_controller'
25
- #require 'action_controller/base'
26
- ##require 'action_controller/test_case'
27
- #require 'action_view'
28
- #require 'active_record'
29
- ##require 'active_support/backtrace_cleaner'
30
- ##require 'rails/backtrace_cleaner'
31
-
32
- #require 'test_help'
33
- end
34
-
35
-
36
- gem "shoulda"
37
- require 'shoulda'
38
- require 'shoulda/action_controller'
39
-
40
- # rails test help
41
-
42
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
43
- $LOAD_PATH.unshift(File.dirname(__FILE__))
44
-
45
- # gem init
46
- #require 'health_check'
47
-
48
- # plugin init
49
- require File.join(File.dirname(__FILE__), '..', 'init')
50
-
51
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
52
-
53
- EXAMPLE_SMTP_SETTINGS = {
54
- :address => "smtp.gmail.com",
55
- :domain => "test.example.com",
56
- :port => 587
57
- }
58
-
59
- ActionMailer::Base.delivery_method = :test
60
-
61
- # Make sure sendmail settings are set to something that is executrable (we wont actually execute it)
62
- sendmail_path = '/usr/sbin/sendmail'
63
- ['/bin/true', 'c:/windows/explorer.exe', 'c:/winnt/explorer.exe',
64
- File.join(RAILS_ROOT, 'script', 'about')].each do |f|
65
- sendmail_path = f if File.executable? f
66
- end
67
-
68
- EXAMPLE_SENDMAIL_SETTINGS = {
69
- :location => sendmail_path,
70
- :arguments => '--help'
71
- }
72
-
73
- def setup_db(version)
74
- ActiveRecord::Base.connection.initialize_schema_migrations_table
75
- ActiveRecord::Schema.define(:version => version) do
76
- create_table :kitchen do |t|
77
- t.column :owner, :string
78
- t.column :description, :string
79
- end
80
- end if version
81
- end
82
-
83
- def teardown_db
84
- ActiveRecord::Base.connection.tables.each do |table|
85
- ActiveRecord::Base.connection.drop_table(table)
86
- end
87
- end
88
-
1
+ ENV['RAILS_ENV'] = 'test'
2
+
3
+ require 'test/unit'
4
+ require 'rubygems'
5
+
6
+ # Tests are conducted with health_test as a plugin
7
+ environment_file = File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'config', 'environment.rb')
8
+ if File.exists?(environment_file)
9
+ # test as plugin
10
+ require environment_file
11
+ else
12
+ #tests as gem
13
+ fail "TODO: Work out how to test as a gem (test as a plugin instead)"
14
+ # TODO: Work out how to do this!
15
+ #require 'rails/version'
16
+ #RAILS_ROOT = "test" unless defined?(RAILS_ROOT)
17
+ #module Rails
18
+ # def backtrace_cleaner(args)
19
+ # # do nothing
20
+ # end
21
+ #end
22
+
23
+ #require 'active_support'
24
+ #require 'action_controller'
25
+ #require 'action_controller/base'
26
+ ##require 'action_controller/test_case'
27
+ #require 'action_view'
28
+ #require 'active_record'
29
+ ##require 'active_support/backtrace_cleaner'
30
+ ##require 'rails/backtrace_cleaner'
31
+
32
+ #require 'test_help'
33
+ end
34
+
35
+
36
+ gem "shoulda"
37
+ require 'shoulda'
38
+ require 'shoulda/action_controller'
39
+
40
+ # rails test help
41
+
42
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
43
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
44
+
45
+ # gem init
46
+ #require 'health_check'
47
+
48
+ # plugin init
49
+ require File.join(File.dirname(__FILE__), '..', 'init')
50
+
51
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
52
+
53
+ EXAMPLE_SMTP_SETTINGS = {
54
+ :address => "smtp.gmail.com",
55
+ :domain => "test.example.com",
56
+ :port => 587
57
+ }
58
+
59
+ ActionMailer::Base.delivery_method = :test
60
+
61
+ # Make sure sendmail settings are set to something that is executrable (we wont actually execute it)
62
+ sendmail_path = '/usr/sbin/sendmail'
63
+ ['/bin/true', 'c:/windows/explorer.exe', 'c:/winnt/explorer.exe',
64
+ File.join(RAILS_ROOT, 'script', 'about')].each do |f|
65
+ sendmail_path = f if File.executable? f
66
+ end
67
+
68
+ EXAMPLE_SENDMAIL_SETTINGS = {
69
+ :location => sendmail_path,
70
+ :arguments => '--help'
71
+ }
72
+
73
+ def setup_db(version)
74
+ ActiveRecord::Base.connection.initialize_schema_migrations_table
75
+ ActiveRecord::Schema.define(:version => version) do
76
+ create_table :kitchen do |t|
77
+ t.column :owner, :string
78
+ t.column :description, :string
79
+ end
80
+ end if version
81
+ end
82
+
83
+ def teardown_db
84
+ ActiveRecord::Base.connection.tables.each do |table|
85
+ ActiveRecord::Base.connection.drop_table(table)
86
+ end
87
+ end
88
+
@@ -1,175 +1,175 @@
1
- require 'helper'
2
-
3
- class HealthCheckControllerTest < ActionController::TestCase
4
- #context "HealthCheck plugin" do
5
- # should_route :get, "/health_check", :controller => :health_check, :action => :index
6
- # should_route :get, "/health_check/two_checks", :controller => :health_check, :action => :index, :checks => 'two_checks'
7
- #end
8
-
9
- context "GET standard on empty db" do
10
- setup do
11
- HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'empty')
12
- setup_db(nil)
13
- ActionMailer::Base.delivery_method = :test
14
- get :index
15
- end
16
-
17
- teardown do
18
- teardown_db
19
- end
20
-
21
- should_respond_with :success
22
- should_not_set_the_flash
23
- should_respond_with_content_type 'text/plain'
24
- should_render_without_layout
25
- should "return 'success' text" do
26
- assert_equal HealthCheck.success, @response.body
27
- end
28
- end
29
-
30
- context "GET migrations on db with migrations" do
31
- setup do
32
- HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'twelve')
33
- setup_db(12)
34
- ActionMailer::Base.delivery_method = :test
35
- get :check, :checks => 'migrations'
36
- end
37
-
38
- teardown do
39
- teardown_db
40
- end
41
-
42
- should_respond_with :success
43
- should_not_set_the_flash
44
- should_respond_with_content_type 'text/plain'
45
- should_render_without_layout
46
- should "return 'success' text" do
47
- assert_equal HealthCheck.success, @response.body
48
- end
49
- end
50
-
51
- context "GET standard with unactioned migrations" do
52
- setup do
53
- HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'twelve')
54
- setup_db(nil)
55
- ActionMailer::Base.delivery_method = :test
56
- get :index
57
- end
58
-
59
- teardown do
60
- teardown_db
61
- end
62
-
63
- should_respond_with 500
64
- should_not_set_the_flash
65
- should_respond_with_content_type 'text/plain'
66
- should_render_without_layout
67
- should "not return 'success' text" do
68
- assert_not_equal HealthCheck.success, @response.body
69
- end
70
- end
71
-
72
- context "GET email with :test" do
73
- setup do
74
- ActionMailer::Base.delivery_method = :test
75
- get :check, :checks => 'email'
76
- end
77
-
78
- should_respond_with :success
79
- should_not_set_the_flash
80
- should_respond_with_content_type 'text/plain'
81
- should_render_without_layout
82
- should "return 'success' text" do
83
- assert_equal HealthCheck.success, @response.body
84
- end
85
- end
86
-
87
- context "GET standard with bad smtp" do
88
- setup do
89
- HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'twelve')
90
- setup_db(12)
91
- HealthCheck.smtp_timeout = 2.0
92
- ActionMailer::Base.delivery_method = :smtp
93
- ActionMailer::Base.smtp_settings = {
94
- :address => "127.0.0.1",
95
- :domain => "testing.example.com",
96
- :port => 7
97
- }
98
- get :index
99
- end
100
-
101
- teardown do
102
- teardown_db
103
- end
104
-
105
- should_respond_with 500
106
- should_not_set_the_flash
107
- should_respond_with_content_type 'text/plain'
108
- should_render_without_layout
109
- should "not return 'success' text" do
110
- assert_not_equal HealthCheck.success, @response.body
111
- end
112
- end
113
-
114
-
115
- context "GET email with :smtp" do
116
- setup do
117
- # it should not care that the database isnt setup correctly
118
- HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'empty')
119
- setup_db(nil)
120
- ActionMailer::Base.delivery_method = :smtp
121
- HealthCheck.smtp_timeout = 60.0
122
- ActionMailer::Base.smtp_settings = EXAMPLE_SMTP_SETTINGS
123
- get :check, :checks => 'email'
124
- end
125
-
126
- should_respond_with :success
127
- should_respond_with_content_type 'text/plain'
128
- should "return 'success' text" do
129
- assert_equal HealthCheck.success, @response.body
130
- end
131
- end
132
-
133
-
134
- context "GET database_migration_email with missing sendmail" do
135
- setup do
136
- HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'twelve')
137
- setup_db(12)
138
- ActionMailer::Base.delivery_method = :sendmail
139
- ActionMailer::Base.sendmail_settings = { :location => '/no/such/executable', :arguments => '' }
140
- get :check, :checks => 'database_migration_email'
141
- end
142
-
143
- teardown do
144
- teardown_db
145
- end
146
-
147
- should_respond_with 500
148
- should_not_set_the_flash
149
- should_respond_with_content_type 'text/plain'
150
- should_render_without_layout
151
- should "not return 'success' text" do
152
- assert_not_equal HealthCheck.success, @response.body
153
- end
154
- end
155
-
156
- context "GET all with :sendmail" do
157
- setup do
158
- ActionMailer::Base.delivery_method = :sendmail
159
- ActionMailer::Base.sendmail_settings = EXAMPLE_SENDMAIL_SETTINGS
160
- HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'empty')
161
- setup_db(nil)
162
- get :check, :checks => 'all'
163
- end
164
-
165
- teardown do
166
- teardown_db
167
- end
168
-
169
- should_respond_with :success
170
- should_respond_with_content_type 'text/plain'
171
- should "return 'success' text" do
172
- assert_equal HealthCheck.success, @response.body
173
- end
174
- end
175
- end
1
+ require 'helper'
2
+
3
+ class HealthCheckControllerTest < ActionController::TestCase
4
+ #context "HealthCheck plugin" do
5
+ # should_route :get, "/health_check", :controller => :health_check, :action => :index
6
+ # should_route :get, "/health_check/two_checks", :controller => :health_check, :action => :index, :checks => 'two_checks'
7
+ #end
8
+
9
+ context "GET standard on empty db" do
10
+ setup do
11
+ HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'empty')
12
+ setup_db(nil)
13
+ ActionMailer::Base.delivery_method = :test
14
+ get :index
15
+ end
16
+
17
+ teardown do
18
+ teardown_db
19
+ end
20
+
21
+ should_respond_with :success
22
+ should_not_set_the_flash
23
+ should_respond_with_content_type 'text/plain'
24
+ should_render_without_layout
25
+ should "return 'success' text" do
26
+ assert_equal HealthCheck.success, @response.body
27
+ end
28
+ end
29
+
30
+ context "GET migrations on db with migrations" do
31
+ setup do
32
+ HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'twelve')
33
+ setup_db(12)
34
+ ActionMailer::Base.delivery_method = :test
35
+ get :check, :checks => 'migrations'
36
+ end
37
+
38
+ teardown do
39
+ teardown_db
40
+ end
41
+
42
+ should_respond_with :success
43
+ should_not_set_the_flash
44
+ should_respond_with_content_type 'text/plain'
45
+ should_render_without_layout
46
+ should "return 'success' text" do
47
+ assert_equal HealthCheck.success, @response.body
48
+ end
49
+ end
50
+
51
+ context "GET standard with unactioned migrations" do
52
+ setup do
53
+ HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'twelve')
54
+ setup_db(nil)
55
+ ActionMailer::Base.delivery_method = :test
56
+ get :index
57
+ end
58
+
59
+ teardown do
60
+ teardown_db
61
+ end
62
+
63
+ should_respond_with 500
64
+ should_not_set_the_flash
65
+ should_respond_with_content_type 'text/plain'
66
+ should_render_without_layout
67
+ should "not return 'success' text" do
68
+ assert_not_equal HealthCheck.success, @response.body
69
+ end
70
+ end
71
+
72
+ context "GET email with :test" do
73
+ setup do
74
+ ActionMailer::Base.delivery_method = :test
75
+ get :check, :checks => 'email'
76
+ end
77
+
78
+ should_respond_with :success
79
+ should_not_set_the_flash
80
+ should_respond_with_content_type 'text/plain'
81
+ should_render_without_layout
82
+ should "return 'success' text" do
83
+ assert_equal HealthCheck.success, @response.body
84
+ end
85
+ end
86
+
87
+ context "GET standard with bad smtp" do
88
+ setup do
89
+ HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'twelve')
90
+ setup_db(12)
91
+ HealthCheck.smtp_timeout = 2.0
92
+ ActionMailer::Base.delivery_method = :smtp
93
+ ActionMailer::Base.smtp_settings = {
94
+ :address => "127.0.0.1",
95
+ :domain => "testing.example.com",
96
+ :port => 7
97
+ }
98
+ get :index
99
+ end
100
+
101
+ teardown do
102
+ teardown_db
103
+ end
104
+
105
+ should_respond_with 500
106
+ should_not_set_the_flash
107
+ should_respond_with_content_type 'text/plain'
108
+ should_render_without_layout
109
+ should "not return 'success' text" do
110
+ assert_not_equal HealthCheck.success, @response.body
111
+ end
112
+ end
113
+
114
+
115
+ context "GET email with :smtp" do
116
+ setup do
117
+ # it should not care that the database isnt setup correctly
118
+ HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'empty')
119
+ setup_db(nil)
120
+ ActionMailer::Base.delivery_method = :smtp
121
+ HealthCheck.smtp_timeout = 60.0
122
+ ActionMailer::Base.smtp_settings = EXAMPLE_SMTP_SETTINGS
123
+ get :check, :checks => 'email'
124
+ end
125
+
126
+ should_respond_with :success
127
+ should_respond_with_content_type 'text/plain'
128
+ should "return 'success' text" do
129
+ assert_equal HealthCheck.success, @response.body
130
+ end
131
+ end
132
+
133
+
134
+ context "GET database_migration_email with missing sendmail" do
135
+ setup do
136
+ HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'twelve')
137
+ setup_db(12)
138
+ ActionMailer::Base.delivery_method = :sendmail
139
+ ActionMailer::Base.sendmail_settings = { :location => '/no/such/executable', :arguments => '' }
140
+ get :check, :checks => 'database_migration_email'
141
+ end
142
+
143
+ teardown do
144
+ teardown_db
145
+ end
146
+
147
+ should_respond_with 500
148
+ should_not_set_the_flash
149
+ should_respond_with_content_type 'text/plain'
150
+ should_render_without_layout
151
+ should "not return 'success' text" do
152
+ assert_not_equal HealthCheck.success, @response.body
153
+ end
154
+ end
155
+
156
+ context "GET all with :sendmail" do
157
+ setup do
158
+ ActionMailer::Base.delivery_method = :sendmail
159
+ ActionMailer::Base.sendmail_settings = EXAMPLE_SENDMAIL_SETTINGS
160
+ HealthCheck.db_migrate_path = File.join(File.dirname(__FILE__), 'migrate', 'empty')
161
+ setup_db(nil)
162
+ get :check, :checks => 'all'
163
+ end
164
+
165
+ teardown do
166
+ teardown_db
167
+ end
168
+
169
+ should_respond_with :success
170
+ should_respond_with_content_type 'text/plain'
171
+ should "return 'success' text" do
172
+ assert_equal HealthCheck.success, @response.body
173
+ end
174
+ end
175
+ end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: health_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ hash: 21
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 1
10
+ version: 0.2.1
5
11
  platform: ruby
6
12
  authors:
7
13
  - Ian Heggie
@@ -9,40 +15,54 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-01-29 00:00:00 +11:00
13
- default_executable:
18
+ date: 2011-11-15 00:00:00 Z
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: shoulda
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
20
25
  requirements:
21
26
  - - ">="
22
27
  - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
23
31
  version: "0"
24
- version:
32
+ type: :development
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: sqlite3-ruby
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
30
39
  requirements:
31
40
  - - ">="
32
41
  - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
33
45
  version: "0"
34
- version:
46
+ type: :development
47
+ version_requirements: *id002
35
48
  - !ruby/object:Gem::Dependency
36
49
  name: activerecord
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
40
53
  requirements:
41
54
  - - ">="
42
55
  - !ruby/object:Gem::Version
56
+ hash: 15571
57
+ segments:
58
+ - 1
59
+ - 15
60
+ - 4
61
+ - 7794
43
62
  version: 1.15.4.7794
44
- version:
45
- description: Simple health check of Rails app for use with uptime.openacs.org or wasitup.com
63
+ type: :development
64
+ version_requirements: *id003
65
+ description: Simple health check of Rails app for use with uptime monitoring sites
46
66
  email: ian@heggie.biz
47
67
  executables: []
48
68
 
@@ -59,6 +79,7 @@ files:
59
79
  - VERSION
60
80
  - health_check.gemspec
61
81
  - init.rb
82
+ - config/routes.rb
62
83
  - lib/health_check.rb
63
84
  - lib/health_check/add_routes.rb
64
85
  - lib/health_check/health_check_class.rb
@@ -69,7 +90,6 @@ files:
69
90
  - test/migrate/twelve/9_create_countries.rb
70
91
  - test/test_health_check_controller.rb
71
92
  - test/test_routes.rb
72
- has_rdoc: true
73
93
  homepage: http://github.com/ianheggie/health_check
74
94
  licenses: []
75
95
 
@@ -79,21 +99,27 @@ rdoc_options:
79
99
  require_paths:
80
100
  - lib
81
101
  required_ruby_version: !ruby/object:Gem::Requirement
102
+ none: false
82
103
  requirements:
83
104
  - - ">="
84
105
  - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
85
109
  version: "0"
86
- version:
87
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
88
112
  requirements:
89
113
  - - ">="
90
114
  - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
91
118
  version: "0"
92
- version:
93
119
  requirements: []
94
120
 
95
121
  rubyforge_project:
96
- rubygems_version: 1.3.5
122
+ rubygems_version: 1.8.11
97
123
  signing_key:
98
124
  specification_version: 3
99
125
  summary: Simple health check of Rails app