summaryrefslogtreecommitdiff
path: root/spec/requests/health_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/health_controller_spec.rb')
-rw-r--r--spec/requests/health_controller_spec.rb22
1 files changed, 18 insertions, 4 deletions
diff --git a/spec/requests/health_controller_spec.rb b/spec/requests/health_controller_spec.rb
index f70faf5bb9c..ae15b63df19 100644
--- a/spec/requests/health_controller_spec.rb
+++ b/spec/requests/health_controller_spec.rb
@@ -127,6 +127,10 @@ RSpec.describe HealthController do
end
it 'responds with readiness checks data' do
+ expect_next_instance_of(Gitlab::GitalyClient::ServerService) do |service|
+ expect(service).to receive(:readiness_check).and_return({ success: true })
+ end
+
subject
expect(json_response['db_check']).to contain_exactly({ 'status' => 'ok' })
@@ -138,19 +142,29 @@ RSpec.describe HealthController do
end
it 'responds with readiness checks data when a failure happens' do
- allow(Gitlab::HealthChecks::Redis::RedisCheck).to receive(:readiness).and_return(
- Gitlab::HealthChecks::Result.new('redis_check', false, "check error"))
+ allow(Gitlab::HealthChecks::Redis::SharedStateCheck).to receive(:readiness).and_return(
+ Gitlab::HealthChecks::Result.new('shared_state_check', false, "check error"))
subject
expect(json_response['cache_check']).to contain_exactly({ 'status' => 'ok' })
- expect(json_response['redis_check']).to contain_exactly(
+ expect(json_response['shared_state_check']).to contain_exactly(
{ 'status' => 'failed', 'message' => 'check error' })
expect(response).to have_gitlab_http_status(:service_unavailable)
expect(response.headers['X-GitLab-Custom-Error']).to eq(1)
end
+ it 'checks all redis instances' do
+ expected_redis_checks = Gitlab::Redis::ALL_CLASSES.map do |redis|
+ { "#{redis.store_name.underscore}_check" => [{ 'status' => 'ok' }] }
+ end
+
+ subject
+
+ expect(json_response).to include(*expected_redis_checks)
+ end
+
context 'when DB is not accessible and connection raises an exception' do
before do
expect(Gitlab::HealthChecks::DbCheck)
@@ -170,7 +184,7 @@ RSpec.describe HealthController do
context 'when any exception happens during the probing' do
before do
- expect(Gitlab::HealthChecks::Redis::RedisCheck)
+ expect(Gitlab::HealthChecks::Redis::CacheCheck)
.to receive(:readiness)
.and_raise(::Redis::CannotConnectError, 'Redis down')
end