Merge pull request from okriuchykhin/ok_SCI_2604

Improve health check endpoint [SCI-2604]
This commit is contained in:
Alex Kriuchykhin 2018-08-24 16:55:47 +02:00 committed by GitHub
commit 18dfeb537b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 4 deletions
app/controllers/api
config/initializers
docker-compose.yml
spec/controllers/api

View file

@ -34,6 +34,8 @@ module Api
end
def health
User.new && Team.new && Project.new
User.first if params[:db]
render plain: 'RUNNING'
end

View file

@ -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]

View file

@ -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

View file

@ -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

View file

@ -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