mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-04 04:04:36 +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
|
end
|
||||||
|
|
||||||
def health
|
def health
|
||||||
|
User.new && Team.new && Project.new
|
||||||
|
User.first if params[:db]
|
||||||
render plain: 'RUNNING'
|
render plain: 'RUNNING'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class Extends
|
||||||
repository_asset_value: :asset]
|
repository_asset_value: :asset]
|
||||||
|
|
||||||
# List of implemented core API versions
|
# 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
|
# Array used for injecting names of additional authentication methods for API
|
||||||
API_PLUGABLE_AUTH_METHODS = [:azure_jwt_auth]
|
API_PLUGABLE_AUTH_METHODS = [:azure_jwt_auth]
|
||||||
|
|
|
@ -7,7 +7,8 @@ Rails.application.configure do
|
||||||
config.log_tags,
|
config.log_tags,
|
||||||
silence: [
|
silence: [
|
||||||
# Silence WickedPDF rendering in logs
|
# Silence WickedPDF rendering in logs
|
||||||
%r{/projects/[0-9]*/reports/generate.pdf}
|
%r{/projects/[0-9]*/reports/generate.pdf},
|
||||||
|
'/api/health'
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ version: '2'
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
container_name: scinote_db_development
|
container_name: scinote_db_development
|
||||||
image: postgres:9.4
|
image: postgres:9.6
|
||||||
volumes:
|
volumes:
|
||||||
- scinote_development_postgres:/var/lib/postgresql/data
|
- scinote_development_postgres:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,18 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Api::ApiController, type: :controller do
|
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
|
describe 'GET #status' do
|
||||||
before do
|
before do
|
||||||
get :status
|
get :status
|
||||||
|
@ -17,7 +29,9 @@ describe Api::ApiController, type: :controller do
|
||||||
expect(hash_body).to match(
|
expect(hash_body).to match(
|
||||||
'message' => I18n.t('api.core.status_ok'),
|
'message' => I18n.t('api.core.status_ok'),
|
||||||
'versions' => [{ 'version' => '20170715',
|
'versions' => [{ 'version' => '20170715',
|
||||||
'baseUrl' => '/api/20170715/' }]
|
'baseUrl' => '/api/20170715/' },
|
||||||
|
{ 'version' => 'v1',
|
||||||
|
'baseUrl' => '/api/v1/' }]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue