blob: e1a69261939a1f922f501d09d1f09f9a7f19efd8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
require 'spec_helper'
describe Gitlab::ShardHealthCache, :clean_gitlab_redis_cache do
let(:shards) { %w(foo bar) }
before do
described_class.update(shards)
end
describe '.clear' do
it 'leaves no shards around' do
described_class.clear
expect(described_class.healthy_shard_count).to eq(0)
end
end
describe '.update' do
it 'returns the healthy shards' do
expect(described_class.cached_healthy_shards).to match_array(shards)
end
it 'replaces the existing set' do
new_set = %w(test me more)
described_class.update(new_set)
expect(described_class.cached_healthy_shards).to match_array(new_set)
end
end
describe '.healthy_shard_count' do
it 'returns the healthy shard count' do
expect(described_class.healthy_shard_count).to eq(2)
end
it 'returns 0 if no shards are available' do
described_class.update([])
expect(described_class.healthy_shard_count).to eq(0)
end
end
describe '.healthy_shard?' do
it 'returns true for a healthy shard' do
expect(described_class.healthy_shard?('foo')).to be_truthy
end
it 'returns false for an unknown shard' do
expect(described_class.healthy_shard?('unknown')).to be_falsey
end
end
end
|