diff options
author | Stan Hu <stanhu@gmail.com> | 2018-01-21 15:34:09 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-01-24 15:47:27 -0800 |
commit | 867126130946a9d3c3da7ff8e64b59b14da13599 (patch) | |
tree | b67bf98dce78a0b953e63e84ff95a24c60b8af15 /spec/lib/gitlab/gitaly_client_spec.rb | |
parent | 44728e0527bc7c5cf982be2fbbd26e24a79e5d8f (diff) | |
download | gitlab-ce-867126130946a9d3c3da7ff8e64b59b14da13599.tar.gz |
Add a gRPC health check to ensure Gitaly is upsh-add-gitaly-health-check
This will enable Geo to skip shards that not operational.
Relates to gitlab-org/gitlab-ee#4329
Diffstat (limited to 'spec/lib/gitlab/gitaly_client_spec.rb')
-rw-r--r-- | spec/lib/gitlab/gitaly_client_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb index 309b7338ef0..81bcd8c28ed 100644 --- a/spec/lib/gitlab/gitaly_client_spec.rb +++ b/spec/lib/gitlab/gitaly_client_spec.rb @@ -3,6 +3,31 @@ require 'spec_helper' # We stub Gitaly in `spec/support/gitaly.rb` for other tests. We don't want # those stubs while testing the GitalyClient itself. describe Gitlab::GitalyClient, skip_gitaly_mock: true do + describe '.stub_class' do + it 'returns the gRPC health check stub' do + expect(described_class.stub_class(:health_check)).to eq(::Grpc::Health::V1::Health::Stub) + end + + it 'returns a Gitaly stub' do + expect(described_class.stub_class(:ref_service)).to eq(::Gitaly::RefService::Stub) + end + end + + describe '.stub_address' do + it 'returns the same result after being called multiple times' do + address = 'localhost:9876' + prefixed_address = "tcp://#{address}" + + allow(Gitlab.config.repositories).to receive(:storages).and_return({ + 'default' => { 'gitaly_address' => prefixed_address } + }) + + 2.times do + expect(described_class.stub_address('default')).to eq('localhost:9876') + end + end + end + describe '.stub' do # Notice that this is referring to gRPC "stubs", not rspec stubs before do |