2016-05-10 19:19:16 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-11-13 10:52:07 -05:00
|
|
|
feature "Admin Health Check", :feature do
|
2017-01-21 19:11:19 -05:00
|
|
|
include StubENV
|
2016-05-10 19:19:16 -04:00
|
|
|
|
|
|
|
before do
|
2017-01-21 19:11:19 -05:00
|
|
|
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(create(:admin))
|
2016-05-10 19:19:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#show' do
|
|
|
|
before do
|
|
|
|
visit admin_health_check_path
|
|
|
|
end
|
|
|
|
|
2017-01-21 17:55:35 -05:00
|
|
|
it 'has a health check access token' do
|
2017-01-21 19:11:19 -05:00
|
|
|
page.has_text? 'Health Check'
|
|
|
|
page.has_text? 'Health information can be retrieved'
|
|
|
|
|
2018-02-02 13:39:55 -05:00
|
|
|
token = Gitlab::CurrentSettings.health_check_access_token
|
2017-01-21 19:11:19 -05:00
|
|
|
|
2016-05-10 19:19:16 -04:00
|
|
|
expect(page).to have_content("Access token is #{token}")
|
|
|
|
expect(page).to have_selector('#health-check-token', text: token)
|
|
|
|
end
|
|
|
|
|
2017-04-04 14:28:43 -04:00
|
|
|
describe 'reload access token' do
|
2016-05-10 19:19:16 -04:00
|
|
|
it 'changes the access token' do
|
2018-02-02 13:39:55 -05:00
|
|
|
orig_token = Gitlab::CurrentSettings.health_check_access_token
|
2016-05-10 19:19:16 -04:00
|
|
|
click_button 'Reset health check access token'
|
2017-04-04 14:28:43 -04:00
|
|
|
|
|
|
|
expect(page).to have_content('New health check access token has been generated!')
|
2016-05-10 19:19:16 -04:00
|
|
|
expect(find('#health-check-token').text).not_to eq orig_token
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when services are up' do
|
|
|
|
before do
|
2017-11-13 10:52:07 -05:00
|
|
|
stub_storage_settings({}) # Hide the broken storage
|
2016-05-10 19:19:16 -04:00
|
|
|
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-05-17 12:17:15 -04:00
|
|
|
|
2017-11-13 10:52:07 -05:00
|
|
|
context 'with repository storage failures', :broken_storage do
|
2017-05-17 12:17:15 -04:00
|
|
|
before do
|
|
|
|
visit admin_health_check_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows storage failure information' do
|
2017-08-03 06:16:45 -04:00
|
|
|
hostname = Gitlab::Environment.hostname
|
2017-10-12 08:13:59 -04:00
|
|
|
maximum_failures = Gitlab::CurrentSettings.current_application_settings
|
|
|
|
.circuitbreaker_failure_count_threshold
|
2017-11-13 10:52:07 -05:00
|
|
|
number_of_failures = maximum_failures + 1
|
2017-05-17 12:17:15 -04:00
|
|
|
|
2017-11-13 10:52:07 -05:00
|
|
|
expect(page).to have_content("broken: #{number_of_failures} failed storage access attempts:")
|
|
|
|
expect(page).to have_content("#{hostname}: #{number_of_failures} of #{maximum_failures} failures.")
|
2017-05-17 12:17:15 -04:00
|
|
|
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-05-10 19:19:16 -04:00
|
|
|
end
|