Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move health probes to Grape API v2 (closes #2066) #2071

Merged
merged 1 commit into from Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/api/v2/public/tools.rb
Expand Up @@ -21,6 +21,18 @@ class Tools < Grape::API
present OpenStruct.new(v), with: Entities::Version
end
end

resource :health do
desc 'Get application liveness status'
head "/alive" do
status Services::HealthChecker.alive? ? 200 : 503
end

desc 'Get application readiness status'
head "/ready" do
status Services::HealthChecker.ready? ? 200 : 503
end
end
end
end
end
Expand Down
20 changes: 0 additions & 20 deletions app/controllers/public/health_controller.rb

This file was deleted.

3 changes: 0 additions & 3 deletions config/routes.rb
Expand Up @@ -55,9 +55,6 @@ def draw(routes_name)
end
end

get 'health/alive', to: 'public/health#alive'
get 'health/ready', to: 'public/health#ready'

get 'trading/:market_id', to: BlackHoleRouter.new, as: :trading

draw :admin
Expand Down
26 changes: 26 additions & 0 deletions spec/api/v2/public/tools_spec.rb
Expand Up @@ -10,4 +10,30 @@
expect(JSON.parse(response.body)).to be_between(now.iso8601, (now + 1).iso8601)
end
end

describe '/health' do
it 'returns successful liveness probe' do
head '/api/v2/public/health/alive'
expect(response).to be_success
end

it 'returns failed liveness probe' do
Market.stubs(:connected?).returns(false)

head '/api/v2/public/health/alive'
expect(response).to have_http_status(503)
end

it 'returns successful readiness probe' do
head '/api/v2/public/health/ready'
expect(response).to be_success
end

it 'returns failed readiness probe' do
Bunny.stubs(:run).returns(false)

head '/api/v2/public/health/alive'
expect(response).to have_http_status(503)
end
end
end