2016-06-02 11:05:42 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
feature "Admin Health Check", feature: true, broken_storage: true do
|
2017-08-17 22:00:37 +05:30
|
|
|
include StubENV
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
before do
|
2017-08-17 22:00:37 +05:30
|
|
|
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(create(:admin))
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
describe '#show' do
|
|
|
|
before do
|
|
|
|
visit admin_health_check_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a health check access token' do
|
2017-08-17 22:00:37 +05:30
|
|
|
page.has_text? 'Health Check'
|
|
|
|
page.has_text? 'Health information can be retrieved'
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
token = current_application_settings.health_check_access_token
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
expect(page).to have_content("Access token is #{token}")
|
|
|
|
expect(page).to have_selector('#health-check-token', text: token)
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
describe 'reload access token' do
|
2016-06-02 11:05:42 +05:30
|
|
|
it 'changes the access token' do
|
|
|
|
orig_token = current_application_settings.health_check_access_token
|
|
|
|
click_button 'Reset health check access token'
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(page).to have_content('New health check access token has been generated!')
|
2016-06-02 11:05:42 +05:30
|
|
|
expect(find('#health-check-token').text).not_to eq orig_token
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when services are up' do
|
|
|
|
before do
|
|
|
|
visit admin_health_check_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows healthy status' do
|
|
|
|
expect(page).to have_content('Current Status: Healthy')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a service is down' do
|
|
|
|
before do
|
|
|
|
allow(HealthCheck::Utils).to receive(:process_checks).and_return('The server is on fire')
|
|
|
|
visit admin_health_check_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows unhealthy status' do
|
|
|
|
expect(page).to have_content('Current Status: Unhealthy')
|
|
|
|
expect(page).to have_content('The server is on fire')
|
|
|
|
end
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
context 'with repository storage failures' do
|
|
|
|
before do
|
|
|
|
# Track a failure
|
|
|
|
Gitlab::Git::Storage::CircuitBreaker.for_storage('broken').perform { nil } rescue nil
|
|
|
|
visit admin_health_check_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows storage failure information' do
|
|
|
|
hostname = Gitlab::Environment.hostname
|
|
|
|
|
|
|
|
expect(page).to have_content('broken: failed storage access attempt on host:')
|
|
|
|
expect(page).to have_content("#{hostname}: 1 of 10 failures.")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows resetting storage failures' do
|
|
|
|
click_button 'Reset git storage health information'
|
|
|
|
|
|
|
|
expect(page).to have_content('Git storage health information has been reset')
|
|
|
|
expect(page).not_to have_content('failed storage access attempt')
|
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|