-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- So far we monitor the database (automatically included), the cache, and Solr This branch uses a fork of the health-monitor-rails gem which includes the Solr monitor.
- Loading branch information
Showing
5 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
Rails.application.config.after_initialize do | ||
HealthMonitor.configure do |config| | ||
config.cache | ||
|
||
config.solr.configure do |c| | ||
c.url = Blacklight.default_index.connection.uri.to_s | ||
end | ||
|
||
# Make this health check available at /health | ||
config.path = :health | ||
|
||
config.error_callback = proc do |e| | ||
Rails.logger.error "Health check failed with: #{e.message}" | ||
Honeybadger.notify(e) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
require "rails_helper" | ||
|
||
RSpec.describe "Health Check", type: :request do | ||
describe "GET /health" do | ||
it "has a health check" do | ||
get "/health.json" | ||
expect(response).to be_successful | ||
end | ||
|
||
context 'when solr is down' do | ||
let(:solr_url) { /\/solr\/admin\/cores\?action=STATUS/ } | ||
let(:solr_stub) do | ||
stub_request(:get, solr_url) | ||
.to_return( | ||
body: { responseHeader: { status: 500 } }.to_json, headers: { "Content-Type" => "text/json" } | ||
) | ||
end | ||
|
||
before { solr_stub } | ||
|
||
it "errors when a service is down" do | ||
get "/health.json" | ||
expect(solr_stub).to have_been_requested | ||
expect(response).not_to be_successful | ||
expect(response.status).to eq 503 | ||
solr_response = JSON.parse(response.body)["results"].find { |x| x["name"] == "Solr" } | ||
expect(solr_response["message"]).to start_with "The solr has an invalid status" | ||
end | ||
end | ||
end | ||
end |