debian-mirror-gitlab/spec/features/admin/admin_health_check_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.9 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2016-06-02 11:05:42 +05:30
require 'spec_helper'
2023-06-20 00:43:36 +05:30
RSpec.describe "Admin Health Check", :js, feature_category: :error_budgets do
2017-08-17 22:00:37 +05:30
include StubENV
2023-05-27 22:25:52 +05:30
include Spec::Support::Helpers::ModalHelpers
2020-04-08 14:13:33 +05:30
let_it_be(:admin) { create(:admin) }
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')
2018-12-13 13:39:08 +05:30
sign_in(admin)
2021-02-22 17:27:13 +05:30
gitlab_enable_admin_mode_sign_in(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'
2018-03-17 18:26:18 +05:30
token = Gitlab::CurrentSettings.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
2018-03-17 18:26:18 +05:30
orig_token = Gitlab::CurrentSettings.health_check_access_token
2023-05-27 22:25:52 +05:30
click_link 'Reset health check access token'
accept_gl_confirm('Are you sure you want to reset the health check 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
2018-03-17 18:26:18 +05:30
stub_storage_settings({}) # Hide the broken storage
2016-06-02 11:05:42 +05:30
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
end