Commit 66af8321 authored by nmilojevic1's avatar nmilojevic1

Add specs for the counters for multi_store

parent 6441e975
...@@ -114,6 +114,12 @@ RSpec.describe Gitlab::Redis::MultiStore do ...@@ -114,6 +114,12 @@ RSpec.describe Gitlab::Redis::MultiStore do
end end
RSpec.shared_examples_for 'fallback read from the secondary store' do RSpec.shared_examples_for 'fallback read from the secondary store' do
let(:counter) { Gitlab::Metrics::NullMetric.instance }
before do
allow(Gitlab::Metrics).to receive(:counter).and_return(counter)
end
it 'fallback and execute on secondary instance' do it 'fallback and execute on secondary instance' do
expect(secondary_store).to receive(name).with(*args).and_call_original expect(secondary_store).to receive(name).with(*args).and_call_original
...@@ -128,7 +134,7 @@ RSpec.describe Gitlab::Redis::MultiStore do ...@@ -128,7 +134,7 @@ RSpec.describe Gitlab::Redis::MultiStore do
end end
it 'increment read fallback count metrics' do it 'increment read fallback count metrics' do
expect(multi_store).to receive(:increment_read_fallback_count).with(name) expect(counter).to receive(:increment).with(command: name, instance_name: instance_name)
subject subject
end end
...@@ -401,9 +407,12 @@ RSpec.describe Gitlab::Redis::MultiStore do ...@@ -401,9 +407,12 @@ RSpec.describe Gitlab::Redis::MultiStore do
end end
context 'with unsupported command' do context 'with unsupported command' do
let(:counter) { Gitlab::Metrics::NullMetric.instance }
before do before do
primary_store.flushdb primary_store.flushdb
secondary_store.flushdb secondary_store.flushdb
allow(Gitlab::Metrics).to receive(:counter).and_return(counter)
end end
let_it_be(:key) { "redis:counter" } let_it_be(:key) { "redis:counter" }
...@@ -426,7 +435,7 @@ RSpec.describe Gitlab::Redis::MultiStore do ...@@ -426,7 +435,7 @@ RSpec.describe Gitlab::Redis::MultiStore do
end end
it 'increments method missing counter' do it 'increments method missing counter' do
expect(multi_store).to receive(:increment_method_missing_count).with(:incr) expect(counter).to receive(:increment).with(command: :incr, instance_name: instance_name)
subject subject
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment