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>2023-07-19 17:16:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 17:16:28 +0300
commite4384360a16dd9a19d4d2d25d0ef1f2b862ed2a6 (patch)
tree2fcdfa7dcdb9db8f5208b2562f4b4e803d671243 /spec/lib/gitlab/metrics
parentffda4e7bcac36987f936b4ba515995a6698698f0 (diff)
Add latest changes from gitlab-org/gitlab@16-2-stable-eev16.2.0-rc42
Diffstat (limited to 'spec/lib/gitlab/metrics')
-rw-r--r--spec/lib/gitlab/metrics/dashboard/url_spec.rb107
-rw-r--r--spec/lib/gitlab/metrics/environment_spec.rb3
-rw-r--r--spec/lib/gitlab/metrics/sidekiq_slis_spec.rb58
3 files changed, 46 insertions, 122 deletions
diff --git a/spec/lib/gitlab/metrics/dashboard/url_spec.rb b/spec/lib/gitlab/metrics/dashboard/url_spec.rb
index d49200f87cc..a035cf02da4 100644
--- a/spec/lib/gitlab/metrics/dashboard/url_spec.rb
+++ b/spec/lib/gitlab/metrics/dashboard/url_spec.rb
@@ -5,78 +5,6 @@ require 'spec_helper'
RSpec.describe Gitlab::Metrics::Dashboard::Url do
include Gitlab::Routing.url_helpers
- describe '#metrics_regex' do
- let(:environment_id) { 1 }
- let(:url_params) do
- [
- 'foo',
- 'bar',
- environment_id,
- {
- start: '2019-08-02T05:43:09.000Z',
- dashboard: 'config/prometheus/common_metrics.yml',
- group: 'awesome group',
- anchor: 'title'
- }
- ]
- end
-
- let(:expected_params) do
- {
- 'url' => url,
- 'namespace' => 'foo',
- 'project' => 'bar',
- 'environment' => '1',
- 'query' => '?dashboard=config%2Fprometheus%2Fcommon_metrics.yml&group=awesome+group&start=2019-08-02T05%3A43%3A09.000Z',
- 'anchor' => '#title'
- }
- end
-
- subject { described_class.metrics_regex }
-
- context 'for /-/environments/:environment_id/metrics route' do
- let(:url) { metrics_namespace_project_environment_url(*url_params) }
-
- it_behaves_like 'regex which matches url when expected'
- end
-
- context 'for /-/metrics?environment=:environment_id route' do
- let(:url) { namespace_project_metrics_dashboard_url(*url_params) }
- let(:url_params) do
- [
- 'namespace1',
- 'project1',
- {
- environment: environment_id,
- start: '2019-08-02T05:43:09.000Z',
- dashboard: 'config/prometheus/common_metrics.yml',
- group: 'awesome group',
- anchor: 'title'
- }
- ]
- end
-
- let(:expected_params) do
- {
- 'url' => url,
- 'namespace' => 'namespace1',
- 'project' => 'project1',
- 'environment' => environment_id.to_s,
- 'query' => "?dashboard=config%2Fprometheus%2Fcommon_metrics.yml&environment=#{environment_id}&group=awesome+group&start=2019-08-02T05%3A43%3A09.000Z",
- 'anchor' => '#title'
- }
- end
-
- it_behaves_like 'regex which matches url when expected'
- end
-
- context 'for metrics_dashboard route' do
- let(:url) { metrics_dashboard_namespace_project_environment_url(*url_params) }
-
- it_behaves_like 'regex which matches url when expected'
- end
- end
-
describe '#clusters_regex' do
let(:url) { Gitlab::Routing.url_helpers.namespace_project_cluster_url(*url_params) }
let(:url_params) do
@@ -130,33 +58,6 @@ RSpec.describe Gitlab::Metrics::Dashboard::Url do
end
end
- describe '#grafana_regex' do
- let(:url) do
- namespace_project_grafana_api_metrics_dashboard_url(
- 'foo',
- 'bar',
- start: '2019-08-02T05:43:09.000Z',
- dashboard: 'config/prometheus/common_metrics.yml',
- group: 'awesome group',
- anchor: 'title'
- )
- end
-
- let(:expected_params) do
- {
- 'url' => url,
- 'namespace' => 'foo',
- 'project' => 'bar',
- 'query' => '?dashboard=config%2Fprometheus%2Fcommon_metrics.yml&group=awesome+group&start=2019-08-02T05%3A43%3A09.000Z',
- 'anchor' => '#title'
- }
- end
-
- subject { described_class.grafana_regex }
-
- it_behaves_like 'regex which matches url when expected'
- end
-
describe '#alert_regex' do
let(:url) { Gitlab::Routing.url_helpers.metrics_dashboard_namespace_project_prometheus_alert_url(*url_params) }
let(:url_params) do
@@ -202,12 +103,4 @@ RSpec.describe Gitlab::Metrics::Dashboard::Url do
end
end
end
-
- describe '#build_dashboard_url' do
- it 'builds the url for the dashboard endpoint' do
- url = described_class.build_dashboard_url('foo', 'bar', 1)
-
- expect(url).to match described_class.metrics_regex
- end
- end
end
diff --git a/spec/lib/gitlab/metrics/environment_spec.rb b/spec/lib/gitlab/metrics/environment_spec.rb
index e94162e625e..4e3b1b5273e 100644
--- a/spec/lib/gitlab/metrics/environment_spec.rb
+++ b/spec/lib/gitlab/metrics/environment_spec.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rspec-parameterized'
-
-require_relative '../../../support/helpers/stub_env'
+require 'gitlab/rspec/all'
RSpec.describe Gitlab::Metrics::Environment, feature_category: :error_budgets do
include StubENV
diff --git a/spec/lib/gitlab/metrics/sidekiq_slis_spec.rb b/spec/lib/gitlab/metrics/sidekiq_slis_spec.rb
index eef9a9c79e6..9536b42cd92 100644
--- a/spec/lib/gitlab/metrics/sidekiq_slis_spec.rb
+++ b/spec/lib/gitlab/metrics/sidekiq_slis_spec.rb
@@ -4,23 +4,30 @@ require 'spec_helper'
RSpec.describe Gitlab::Metrics::SidekiqSlis, feature_category: :error_budgets do
using RSpec::Parameterized::TableSyntax
+ let(:labels) do
+ [
+ {
+ worker: "Projects::RecordTargetPlatformsWorker",
+ feature_category: "projects",
+ urgency: "low"
+ }
+ ]
+ end
+
+ describe ".initialize_execution_slis!" do
+ it "initializes the apdex and error rate SLIs" do
+ expect(Gitlab::Metrics::Sli::Apdex).to receive(:initialize_sli).with(:sidekiq_execution, labels)
+ expect(Gitlab::Metrics::Sli::ErrorRate).to receive(:initialize_sli).with(:sidekiq_execution, labels)
- describe ".initialize_slis!" do
- let(:possible_labels) do
- [
- {
- worker: "Projects::RecordTargetPlatformsWorker",
- feature_category: "projects",
- urgency: "low"
- }
- ]
+ described_class.initialize_execution_slis!(labels)
end
+ end
- it "initializes the apdex and error rate SLIs" do
- expect(Gitlab::Metrics::Sli::Apdex).to receive(:initialize_sli).with(:sidekiq_execution, possible_labels)
- expect(Gitlab::Metrics::Sli::ErrorRate).to receive(:initialize_sli).with(:sidekiq_execution, possible_labels)
+ describe ".initialize_queueing_slis!" do
+ it "initializes the apdex SLIs" do
+ expect(Gitlab::Metrics::Sli::Apdex).to receive(:initialize_sli).with(:sidekiq_queueing, labels)
- described_class.initialize_slis!(possible_labels)
+ described_class.initialize_queueing_slis!(labels)
end
end
@@ -62,4 +69,29 @@ RSpec.describe Gitlab::Metrics::SidekiqSlis, feature_category: :error_budgets do
described_class.record_execution_error(labels, error)
end
end
+
+ describe ".record_queueing_apdex" do
+ where(:urgency, :duration, :success) do
+ "high" | 5 | true
+ "high" | 11 | false
+ "low" | 50 | true
+ "low" | 70 | false
+ "throttled" | 100 | true
+ "throttled" | 1_000_000 | true
+ "not_found" | 50 | true
+ "not_found" | 70 | false
+ end
+
+ with_them do
+ it "increments the apdex SLI with success based on urgency requirement" do
+ labels = { urgency: urgency }
+ expect(Gitlab::Metrics::Sli::Apdex[:sidekiq_queueing]).to receive(:increment).with(
+ labels: labels,
+ success: success
+ )
+
+ described_class.record_queueing_apdex(labels, duration)
+ end
+ end
+ end
end