Welcome to mirror list, hosted at ThFree Co, Russian Federation.

readiness_spec.rb « probes « health_checks « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d88ffd984c22a44ae0fa217771425c0b75fb0150 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::HealthChecks::Probes::Readiness do
  let(:readiness) { described_class.new }

  describe '#call' do
    subject { readiness.execute }

    it 'responds with readiness checks data' do
      expect(subject.http_status).to eq(200)

      expect(subject.json[:status]).to eq('ok')
      expect(subject.json['db_check']).to contain_exactly(status: 'ok')
      expect(subject.json['cache_check']).to contain_exactly(status: 'ok')
      expect(subject.json['queues_check']).to contain_exactly(status: 'ok')
      expect(subject.json['shared_state_check']).to contain_exactly(status: 'ok')
      expect(subject.json['gitaly_check']).to contain_exactly(
        status: 'ok', labels: { shard: 'default' })
    end

    context 'when Redis fails' do
      before do
        allow(Gitlab::HealthChecks::Redis::RedisCheck).to receive(:readiness).and_return(
          Gitlab::HealthChecks::Result.new('redis_check', false, "check error"))
      end

      it 'responds with failure' do
        expect(subject.http_status).to eq(503)

        expect(subject.json[:status]).to eq('failed')
        expect(subject.json['cache_check']).to contain_exactly(status: 'ok')
        expect(subject.json['redis_check']).to contain_exactly(
          status: 'failed', message: 'check error')
      end
    end
  end
end