Extract EE specific files/lines for some prometheus files
We have the following files containing EE specific code. We should move them to ee/
spec/support/prometheus/additional_metrics_shared_examples.rb (Just move EE tests to an EE file)
diff --git a/spec/support/prometheus/additional_metrics_shared_examples.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/support/prometheus/additional_metrics_shared_examples.rb
index 0fd67531c3b..a830c83c23a 100644
--- a/spec/support/prometheus/additional_metrics_shared_examples.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/support/prometheus/additional_metrics_shared_examples.rb
@@ -116,6 +116,50 @@ RSpec.shared_examples 'additional metrics query' do
end
end
+ context 'with custom metrics' do
+ let!(:metric) { create(:prometheus_metric, project: project) }
+ before do
+ allow(client).to receive(:query_range).with('avg(metric)', any_args).and_return(query_range_result)
+ end
+
+ context 'without common metrics' do
+ before do
+ allow(metric_group_class).to receive(:common_metrics).and_return([])
+ end
+
+ it 'return group data for custom metric' do
+ queries_with_result = { queries: [{ query_range: 'avg(metric)', unit: 'm/s', label: 'legend', result: query_range_result }] }
+ expect(query_result).to match_schema('prometheus/additional_metrics_query_result')
+
+ expect(query_result.count).to eq(1)
+ expect(query_result.first[:metrics].count).to eq(1)
+
+ expect(query_result.first[:metrics].first).to include(queries_with_result)
+ end
+ end
+
+ context 'with common metrics' do
+ before do
+ allow(client).to receive(:query_range).with('query_range_a', any_args).and_return(query_range_result)
+
+ allow(metric_group_class).to receive(:common_metrics).and_return([simple_metric_group(metrics: [simple_metric])])
+ end
+
+ it 'return group data for custom metric' do
+ custom_queries_with_result = { queries: [{ query_range: 'avg(metric)', unit: 'm/s', label: 'legend', result: query_range_result }] }
+ common_queries_with_result = { queries: [{ query_range: 'query_range_a', result: query_range_result }] }
+
+ expect(query_result).to match_schema('prometheus/additional_metrics_query_result')
+
+ expect(query_result.count).to eq(2)
+ expect(query_result).to all(satisfy { |r| r[:metrics].count == 1 })
+
+ expect(query_result[0][:metrics].first).to include(common_queries_with_result)
+ expect(query_result[1][:metrics].first).to include(custom_queries_with_result)
+ end
+ end
+ end
+
context 'with two groups with one metric each' do
let(:metrics) { [simple_metric(queries: [simple_query])] }
Edited by Yorick Peterse