mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 01:35:34 +08:00
Improve health check endpoint [SCI-2604]
This commit is contained in:
parent
422baaf64a
commit
1a57289009
5 changed files with 21 additions and 4 deletions
|
@ -34,6 +34,8 @@ module Api
|
|||
end
|
||||
|
||||
def health
|
||||
User.new && Team.new && Project.new
|
||||
User.first if params[:db]
|
||||
render plain: 'RUNNING'
|
||||
end
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class Extends
|
|||
repository_asset_value: :asset]
|
||||
|
||||
# List of implemented core API versions
|
||||
API_VERSIONS = ['20170715']
|
||||
API_VERSIONS = %w(20170715 v1)
|
||||
|
||||
# Array used for injecting names of additional authentication methods for API
|
||||
API_PLUGABLE_AUTH_METHODS = [:azure_jwt_auth]
|
||||
|
|
|
@ -7,7 +7,8 @@ Rails.application.configure do
|
|||
config.log_tags,
|
||||
silence: [
|
||||
# Silence WickedPDF rendering in logs
|
||||
%r{/projects/[0-9]*/reports/generate.pdf}
|
||||
%r{/projects/[0-9]*/reports/generate.pdf},
|
||||
'/api/health'
|
||||
]
|
||||
)
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ version: '2'
|
|||
services:
|
||||
db:
|
||||
container_name: scinote_db_development
|
||||
image: postgres:9.4
|
||||
image: postgres:9.6
|
||||
volumes:
|
||||
- scinote_development_postgres:/var/lib/postgresql/data
|
||||
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Api::ApiController, type: :controller do
|
||||
describe 'GET #health' do
|
||||
before do
|
||||
get :health
|
||||
end
|
||||
|
||||
it 'Returns HTTP success and with correct text' do
|
||||
expect(response).to be_success
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body).to match('RUNNING')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #status' do
|
||||
before do
|
||||
get :status
|
||||
|
@ -17,7 +29,9 @@ describe Api::ApiController, type: :controller do
|
|||
expect(hash_body).to match(
|
||||
'message' => I18n.t('api.core.status_ok'),
|
||||
'versions' => [{ 'version' => '20170715',
|
||||
'baseUrl' => '/api/20170715/' }]
|
||||
'baseUrl' => '/api/20170715/' },
|
||||
{ 'version' => 'v1',
|
||||
'baseUrl' => '/api/v1/' }]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue