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:
Diffstat (limited to 'spec/requests/projects/ci/promeheus_metrics/histograms_controller_spec.rb')
-rw-r--r--spec/requests/projects/ci/promeheus_metrics/histograms_controller_spec.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/requests/projects/ci/promeheus_metrics/histograms_controller_spec.rb b/spec/requests/projects/ci/promeheus_metrics/histograms_controller_spec.rb
new file mode 100644
index 00000000000..5d2f3e98bb4
--- /dev/null
+++ b/spec/requests/projects/ci/promeheus_metrics/histograms_controller_spec.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'Projects::Ci::PrometheusMetrics::HistogramsController' do
+ let_it_be(:project) { create(:project, :public) }
+
+ describe 'POST /*namespace_id/:project_id/-/ci/prometheus_metrics/histograms' do
+ context 'with known histograms' do
+ it 'returns 201 Created' do
+ post histograms_route(histograms: [
+ { name: :pipeline_graph_link_calculation_duration_seconds, value: 1 },
+ { name: :pipeline_graph_links_total, value: 10 }
+ ])
+
+ expect(response).to have_gitlab_http_status(:created)
+ end
+ end
+
+ context 'with unknown histograms' do
+ it 'returns 404 Not Found' do
+ post histograms_route(histograms: [{ name: :chunky_bacon, value: 5 }])
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
+ context 'with the feature flag disabled' do
+ before do
+ stub_feature_flags(ci_accept_frontend_prometheus_metrics: false)
+ end
+
+ it 'returns 202 Accepted' do
+ post histograms_route(histograms: [
+ { name: :pipeline_graph_link_calculation_duration_seconds, value: 1 }
+ ])
+
+ expect(response).to have_gitlab_http_status(:accepted)
+ end
+ end
+ end
+
+ def histograms_route(params = {})
+ namespace_project_ci_prometheus_metrics_histograms_path(namespace_id: project.namespace, project_id: project, **params)
+ end
+end