gitlab-org--gitlab-foss/spec/lib/gitlab/gitaly_client_spec.rb
Jacob Vosmaer 43f037c903 Don't reuse gRPC channels
It seems that bad things happen when two gRPC stubs share one gRPC
channel so let's stop doing that. The downside of this is that we
create more gRPC connections; one per stub.
2017-05-15 10:52:33 +02:00

35 lines
1.1 KiB
Ruby

require 'spec_helper'
describe Gitlab::GitalyClient, lib: true do
describe '.stub' do
before { described_class.clear_stubs! }
context 'when passed a UNIX socket address' do
it 'passes the address as-is to GRPC' do
address = 'unix:/tmp/gitaly.sock'
allow(Gitlab.config.repositories).to receive(:storages).and_return({
'default' => { 'gitaly_address' => address }
})
expect(Gitaly::Commit::Stub).to receive(:new).with(address, any_args)
described_class.stub(:commit, 'default')
end
end
context 'when passed a TCP address' do
it 'strips tcp:// prefix before passing it to GRPC::Core::Channel initializer' do
address = 'localhost:9876'
prefixed_address = "tcp://#{address}"
allow(Gitlab.config.repositories).to receive(:storages).and_return({
'default' => { 'gitaly_address' => prefixed_address }
})
expect(Gitaly::Commit::Stub).to receive(:new).with(address, any_args)
described_class.stub(:commit, 'default')
end
end
end
end