summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/git
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-08-03 15:24:43 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2017-08-04 15:38:50 +0200
commit0dd4c306ca953e6d09a862f9641469340f8e822f (patch)
tree4a106f676e8a2fcc395c80db12f87ae783a33bc0 /spec/lib/gitlab/git
parent022c38e63e202e9da2608d020face6c108e47313 (diff)
downloadgitlab-ce-0dd4c306ca953e6d09a862f9641469340f8e822f.tar.gz
Only track accessibility once
Diffstat (limited to 'spec/lib/gitlab/git')
-rw-r--r--spec/lib/gitlab/git/storage/circuit_breaker_spec.rb35
1 files changed, 32 insertions, 3 deletions
diff --git a/spec/lib/gitlab/git/storage/circuit_breaker_spec.rb b/spec/lib/gitlab/git/storage/circuit_breaker_spec.rb
index 6fab224ad0d..b2886628601 100644
--- a/spec/lib/gitlab/git/storage/circuit_breaker_spec.rb
+++ b/spec/lib/gitlab/git/storage/circuit_breaker_spec.rb
@@ -120,19 +120,48 @@ describe Gitlab::Git::Storage::CircuitBreaker, clean_gitlab_redis_shared_state:
end
end
- describe '#check_storage_accessible!' do
+ describe "storage_available?" do
context 'when the storage is available' do
it 'tracks that the storage was accessible an raises the error' do
expect(circuit_breaker).to receive(:track_storage_accessible)
- circuit_breaker.check_storage_accessible!
+ circuit_breaker.storage_available?
+ end
+
+ it 'only performs the check once' do
+ expect(Gitlab::Git::Storage::ForkedStorageCheck)
+ .to receive(:storage_available?).once.and_call_original
+
+ 2.times { circuit_breaker.storage_available? }
+ end
+ end
+
+ context 'when storage is not available' do
+ let(:circuit_breaker) { described_class.new('broken') }
+
+ it 'tracks that the storage was inaccessible' do
+ expect(circuit_breaker).to receive(:track_storage_inaccessible)
+
+ circuit_breaker.storage_available?
+ end
+ end
+ end
+
+ describe '#check_storage_accessible!' do
+ it 'raises an exception with retry time when the circuit is open' do
+ allow(circuit_breaker).to receive(:circuit_broken?).and_return(true)
+
+ expect { circuit_breaker.check_storage_accessible! }
+ .to raise_error do |exception|
+ expect(exception).to be_kind_of(Gitlab::Git::Storage::CircuitOpen)
+ expect(exception.retry_after).to eq(30)
end
end
context 'when the storage is not available' do
let(:circuit_breaker) { described_class.new('broken') }
- it 'tracks that the storage was unavailable and raises an error with retry time' do
+ it 'raises an error' do
expect(circuit_breaker).to receive(:track_storage_inaccessible)
expect { circuit_breaker.check_storage_accessible! }