gitlab-org--gitlab-foss/spec/lib/gitaly/server_spec.rb
Zeger-Jan van de Weg 65840591cd
Gitaly metrics check for read/writeability
Prior to this change, health checks checked for writeability of the NFS
shards. Given we're moving away from that, this patch extends the checks
for Gitaly to check for read and writeability.

Potentially some dashboards will break, as over time these metrics will
no longer appear as Prometheus doesn't get the data anymore.
Observability in the circuit breaker will be reduced, but its not
expected to be turned on and the circuit breaker is being removed soon
too.

Closes https://gitlab.com/gitlab-org/gitaly/issues/1218
2018-06-27 08:56:19 +02:00

64 lines
1.6 KiB
Ruby

require 'spec_helper'
describe Gitaly::Server do
let(:server) { described_class.new('default') }
describe '.all' do
let(:storages) { Gitlab.config.repositories.storages }
it 'includes all storages' do
expect(storages.count).to eq(described_class.all.count)
expect(storages.keys).to eq(described_class.all.map(&:storage))
end
end
subject { described_class.all.first }
it { is_expected.to respond_to(:server_version) }
it { is_expected.to respond_to(:git_binary_version) }
it { is_expected.to respond_to(:up_to_date?) }
it { is_expected.to respond_to(:address) }
describe 'readable?' do
context 'when the storage is readable' do
it 'returns true' do
expect(server).to be_readable
end
end
context 'when the storage is not readable' do
let(:server) { described_class.new('broken') }
it 'returns false' do
expect(server).not_to be_readable
end
end
end
describe 'writeable?' do
context 'when the storage is writeable' do
it 'returns true' do
expect(server).to be_writeable
end
end
context 'when the storage is not writeable' do
let(:server) { described_class.new('broken') }
it 'returns false' do
expect(server).not_to be_writeable
end
end
end
describe 'request memoization' do
context 'when requesting multiple properties', :request_store do
it 'uses memoization for the info request' do
expect do
subject.server_version
subject.up_to_date?
end.to change { Gitlab::GitalyClient.get_request_count }.by(1)
end
end
end
end