diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-09 15:39:53 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-09 15:39:53 +0000 |
commit | ff0dfda44e6b0896c31ef7822227877c4c95e12c (patch) | |
tree | 049db614074bd3343fd1e370113873ffb6ee4fed /spec/lib | |
parent | dbff55cb6962eb6209b1c4ced1cd79fb53607ebd (diff) | |
download | gitlab-ce-ff0dfda44e6b0896c31ef7822227877c4c95e12c.tar.gz |
Add latest changes from gitlab-org/gitlab@15-8-stable-ee
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/gitaly_client/server_service_spec.rb | 42 | ||||
-rw-r--r-- | spec/lib/gitlab/health_checks/gitaly_check_spec.rb | 22 | ||||
-rw-r--r-- | spec/lib/gitlab/health_checks/probes/collection_spec.rb | 4 |
3 files changed, 3 insertions, 65 deletions
diff --git a/spec/lib/gitlab/gitaly_client/server_service_spec.rb b/spec/lib/gitlab/gitaly_client/server_service_spec.rb deleted file mode 100644 index 615f2ce0c21..00000000000 --- a/spec/lib/gitlab/gitaly_client/server_service_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Gitlab::GitalyClient::ServerService do - let(:storage) { 'default' } - - describe '#readiness_check' do - before do - ::Gitlab::GitalyClient.clear_stubs! - end - - let(:request) do - Gitaly::ReadinessCheckRequest.new(timeout: 30) - end - - subject(:readiness_check) { described_class.new(storage).readiness_check } - - it 'returns a positive success if no failures happened' do - expect_next_instance_of(Gitaly::ServerService::Stub) do |service| - response = Gitaly::ReadinessCheckResponse.new(ok_response: Gitaly::ReadinessCheckResponse::Ok.new) - expect(service).to receive(:readiness_check).with(request, kind_of(Hash)).and_return(response) - end - - expect(readiness_check[:success]).to eq(true) - end - - it 'returns a negative success and a compiled message if at least one failure happened' do - failure1 = Gitaly::ReadinessCheckResponse::Failure::Response.new(name: '1', error_message: 'msg 1') - failure2 = Gitaly::ReadinessCheckResponse::Failure::Response.new(name: '2', error_message: 'msg 2') - failures = Gitaly::ReadinessCheckResponse::Failure.new(failed_checks: [failure1, failure2]) - response = Gitaly::ReadinessCheckResponse.new(failure_response: failures) - - expect_next_instance_of(Gitaly::ServerService::Stub) do |service| - expect(service).to receive(:readiness_check).with(request, kind_of(Hash)).and_return(response) - end - - expect(readiness_check[:success]).to eq(false) - expect(readiness_check[:message]).to eq("1: msg 1\n2: msg 2") - end - end -end diff --git a/spec/lib/gitlab/health_checks/gitaly_check_spec.rb b/spec/lib/gitlab/health_checks/gitaly_check_spec.rb index 948452c0b58..64c4e92f80b 100644 --- a/spec/lib/gitlab/health_checks/gitaly_check_spec.rb +++ b/spec/lib/gitlab/health_checks/gitaly_check_spec.rb @@ -14,36 +14,20 @@ RSpec.describe Gitlab::HealthChecks::GitalyCheck do subject { described_class.readiness } before do - expect(Gitlab::GitalyClient::HealthCheckService).to receive(:new).and_return(healthy_check) + expect(Gitlab::GitalyClient::HealthCheckService).to receive(:new).and_return(gitaly_check) end context 'Gitaly server is up' do - before do - expect(Gitlab::GitalyClient::ServerService).to receive(:new).and_return(ready_check) - end - - let(:healthy_check) { double(check: { success: true }) } - let(:ready_check) { double(readiness_check: { success: true }) } + let(:gitaly_check) { double(check: { success: true }) } it { is_expected.to eq([result_class.new('gitaly_check', true, nil, shard: 'default')]) } end context 'Gitaly server is down' do - let(:healthy_check) { double(check: { success: false, message: 'Connection refused' }) } + let(:gitaly_check) { double(check: { success: false, message: 'Connection refused' }) } it { is_expected.to eq([result_class.new('gitaly_check', false, 'Connection refused', shard: 'default')]) } end - - context 'Gitaly server is not ready' do - before do - expect(Gitlab::GitalyClient::ServerService).to receive(:new).and_return(ready_check) - end - - let(:healthy_check) { double(check: { success: true }) } - let(:ready_check) { double(readiness_check: { success: false, message: 'A readiness check has failed' }) } - - it { is_expected.to match_array([result_class.new('gitaly_check', false, 'A readiness check has failed', shard: 'default')]) } - end end describe '#metrics' do diff --git a/spec/lib/gitlab/health_checks/probes/collection_spec.rb b/spec/lib/gitlab/health_checks/probes/collection_spec.rb index f1791375cea..09e1a828aeb 100644 --- a/spec/lib/gitlab/health_checks/probes/collection_spec.rb +++ b/spec/lib/gitlab/health_checks/probes/collection_spec.rb @@ -18,10 +18,6 @@ RSpec.describe Gitlab::HealthChecks::Probes::Collection 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 - expect(subject.http_status).to eq(200) expect(subject.json[:status]).to eq('ok') |