Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-20 14:10:13 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-20 14:10:13 +0300
commit0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch)
tree7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/lib/gitlab/metrics/sli_spec.rb
parent72123183a20411a36d607d70b12d57c484394c8e (diff)
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/lib/gitlab/metrics/sli_spec.rb')
-rw-r--r--spec/lib/gitlab/metrics/sli_spec.rb58
1 files changed, 31 insertions, 27 deletions
diff --git a/spec/lib/gitlab/metrics/sli_spec.rb b/spec/lib/gitlab/metrics/sli_spec.rb
index 9b776d6738d..102ea442b3a 100644
--- a/spec/lib/gitlab/metrics/sli_spec.rb
+++ b/spec/lib/gitlab/metrics/sli_spec.rb
@@ -17,13 +17,13 @@ RSpec.describe Gitlab::Metrics::Sli do
it 'allows different SLIs to be defined on each subclass' do
apdex_counters = [
- fake_total_counter('foo', 'apdex'),
- fake_numerator_counter('foo', 'apdex', 'success')
+ fake_total_counter('foo_apdex'),
+ fake_numerator_counter('foo_apdex', 'success')
]
error_rate_counters = [
- fake_total_counter('foo', 'error_rate'),
- fake_numerator_counter('foo', 'error_rate', 'error')
+ fake_total_counter('foo'),
+ fake_numerator_counter('foo', 'error')
]
apdex = described_class::Apdex.initialize_sli(:foo, [{ hello: :world }])
@@ -40,13 +40,17 @@ RSpec.describe Gitlab::Metrics::Sli do
end
subclasses = {
- Gitlab::Metrics::Sli::Apdex => :success,
- Gitlab::Metrics::Sli::ErrorRate => :error
+ Gitlab::Metrics::Sli::Apdex => {
+ suffix: '_apdex',
+ numerator: :success
+ },
+ Gitlab::Metrics::Sli::ErrorRate => {
+ suffix: '',
+ numerator: :error
+ }
}
- subclasses.each do |subclass, numerator_type|
- subclass_type = subclass.to_s.demodulize.underscore
-
+ subclasses.each do |subclass, subclass_info|
describe subclass do
describe 'Class methods' do
before do
@@ -73,8 +77,8 @@ RSpec.describe Gitlab::Metrics::Sli do
describe '.initialize_sli' do
it 'returns and stores a new initialized SLI' do
counters = [
- fake_total_counter(:bar, subclass_type),
- fake_numerator_counter(:bar, subclass_type, numerator_type)
+ fake_total_counter("bar#{subclass_info[:suffix]}"),
+ fake_numerator_counter("bar#{subclass_info[:suffix]}", subclass_info[:numerator])
]
sli = described_class.initialize_sli(:bar, [{ hello: :world }])
@@ -86,8 +90,8 @@ RSpec.describe Gitlab::Metrics::Sli do
it 'does not change labels for an already-initialized SLI' do
counters = [
- fake_total_counter(:bar, subclass_type),
- fake_numerator_counter(:bar, subclass_type, numerator_type)
+ fake_total_counter("bar#{subclass_info[:suffix]}"),
+ fake_numerator_counter("bar#{subclass_info[:suffix]}", subclass_info[:numerator])
]
sli = described_class.initialize_sli(:bar, [{ hello: :world }])
@@ -106,8 +110,8 @@ RSpec.describe Gitlab::Metrics::Sli do
describe '.initialized?' do
before do
- fake_total_counter(:boom, subclass_type)
- fake_numerator_counter(:boom, subclass_type, numerator_type)
+ fake_total_counter("boom#{subclass_info[:suffix]}")
+ fake_numerator_counter("boom#{subclass_info[:suffix]}", subclass_info[:numerator])
end
it 'is true when an SLI was initialized with labels' do
@@ -125,8 +129,8 @@ RSpec.describe Gitlab::Metrics::Sli do
describe '#initialize_counters' do
it 'initializes counters for the passed label combinations' do
counters = [
- fake_total_counter(:hey, subclass_type),
- fake_numerator_counter(:hey, subclass_type, numerator_type)
+ fake_total_counter("hey#{subclass_info[:suffix]}"),
+ fake_numerator_counter("hey#{subclass_info[:suffix]}", subclass_info[:numerator])
]
described_class.new(:hey).initialize_counters([{ foo: 'bar' }, { foo: 'baz' }])
@@ -138,18 +142,18 @@ RSpec.describe Gitlab::Metrics::Sli do
describe "#increment" do
let!(:sli) { described_class.new(:heyo) }
- let!(:total_counter) { fake_total_counter(:heyo, subclass_type) }
- let!(:numerator_counter) { fake_numerator_counter(:heyo, subclass_type, numerator_type) }
+ let!(:total_counter) { fake_total_counter("heyo#{subclass_info[:suffix]}") }
+ let!(:numerator_counter) { fake_numerator_counter("heyo#{subclass_info[:suffix]}", subclass_info[:numerator]) }
- it "increments both counters for labels when #{numerator_type} is true" do
- sli.increment(labels: { hello: "world" }, numerator_type => true)
+ it "increments both counters for labels when #{subclass_info[:numerator]} is true" do
+ sli.increment(labels: { hello: "world" }, subclass_info[:numerator] => true)
expect(total_counter).to have_received(:increment).with({ hello: 'world' })
expect(numerator_counter).to have_received(:increment).with({ hello: 'world' })
end
- it "only increments the total counters for labels when #{numerator_type} is false" do
- sli.increment(labels: { hello: "world" }, numerator_type => false)
+ it "only increments the total counters for labels when #{subclass_info[:numerator]} is false" do
+ sli.increment(labels: { hello: "world" }, subclass_info[:numerator] => false)
expect(total_counter).to have_received(:increment).with({ hello: 'world' })
expect(numerator_counter).not_to have_received(:increment).with({ hello: 'world' })
@@ -168,11 +172,11 @@ RSpec.describe Gitlab::Metrics::Sli do
fake_counter
end
- def fake_total_counter(name, type)
- fake_prometheus_counter("gitlab_sli:#{name}_#{type}:total")
+ def fake_total_counter(name)
+ fake_prometheus_counter("gitlab_sli:#{name}:total")
end
- def fake_numerator_counter(name, type, numerator_name)
- fake_prometheus_counter("gitlab_sli:#{name}_#{type}:#{numerator_name}_total")
+ def fake_numerator_counter(name, numerator_name)
+ fake_prometheus_counter("gitlab_sli:#{name}:#{numerator_name}_total")
end
end