Skip to content

Commit

Permalink
Add postgres and redis healthchecks for continuous deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
callumknights committed Jan 5, 2021
1 parent 4ae231f commit 3078972
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
5 changes: 4 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
Rails.application.routes.draw do
root to: "links#index"

get "/healthcheck", to: proc { [200, {}, %w[OK]] }
get "/healthcheck", to: GovukHealthcheck.rack_response(
GovukHealthcheck::ActiveRecord,
GovukHealthcheck::SidekiqRedis,
)

resources "local_authorities", only: %i[index show], param: :local_authority_slug do
member do
Expand Down
19 changes: 16 additions & 3 deletions spec/requests/healthcheck_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
RSpec.describe "healthcheck path", type: :request do
it "should respond with 'OK'" do
before do
get "/healthcheck"
end

it "returns a 200 HTTP status" do
expect(response).to have_http_status(:ok)
end

it "returns postgres connection status" do
json = JSON.parse(response.body)

expect(json["checks"]).to include("database_connectivity")
end

expect(response.status).to eq(200)
expect(response.body).to eq("OK")
it "returns redis connections status" do
expect(data.fetch(:checks)).to include(
redis_connectivity: { status: "ok" },
)
end
end

0 comments on commit 3078972

Please sign in to comment.