diff options
author | rpereira2 <rpereira@gitlab.com> | 2019-04-11 17:39:58 +0300 |
---|---|---|
committer | syasonik <syasonik@gitlab.com> | 2019-04-17 15:02:24 +0300 |
commit | 8a51b21918161dda5977a92327175a1728efa1c8 (patch) | |
tree | 90de06942c767b7b350afc7d9c7d98763814a69a /spec/db | |
parent | 38da5d6b23577edcd2a924125e0e4f3f8236f234 (diff) |
Change the schema of the common_metrics.yml
- Change it to the new dashboard syntax described here:
https://gitlab.com/gitlab-org/gitlab-ce/issues/60383.
Diffstat (limited to 'spec/db')
-rw-r--r-- | spec/db/importers/common_metrics_importer_spec.rb | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/spec/db/importers/common_metrics_importer_spec.rb b/spec/db/importers/common_metrics_importer_spec.rb index 6133b17ac61..a717c8cd04d 100644 --- a/spec/db/importers/common_metrics_importer_spec.rb +++ b/spec/db/importers/common_metrics_importer_spec.rb @@ -23,10 +23,10 @@ describe Importers::CommonMetricsImporter do subject { described_class.new } context "does import common_metrics.yml" do - let(:groups) { subject.content } - let(:metrics) { groups.map { |group| group['metrics'] }.flatten } - let(:queries) { metrics.map { |group| group['queries'] }.flatten } - let(:query_ids) { queries.map { |query| query['id'] } } + let(:groups) { subject.content['panel_groups'] } + let(:panels) { groups.map { |group| group['panels'] }.flatten } + let(:metrics) { panels.map { |group| group['metrics'] }.flatten } + let(:metric_ids) { metrics.map { |metric| metric['id'] } } before do subject.execute @@ -36,20 +36,20 @@ describe Importers::CommonMetricsImporter do expect(PrometheusMetric.common.group(:group).count.count).to eq(groups.count) end - it "has the same amount of metrics" do - expect(PrometheusMetric.common.group(:group, :title).count.count).to eq(metrics.count) + it "has the same amount of panels" do + expect(PrometheusMetric.common.group(:group, :title).count.count).to eq(panels.count) end - it "has the same amount of queries" do - expect(PrometheusMetric.common.count).to eq(queries.count) + it "has the same amount of metrics" do + expect(PrometheusMetric.common.count).to eq(metrics.count) end it "does not have duplicate IDs" do - expect(query_ids).to eq(query_ids.uniq) + expect(metric_ids).to eq(metric_ids.uniq) end it "imports all IDs" do - expect(PrometheusMetric.common.pluck(:identifier)).to contain_exactly(*query_ids) + expect(PrometheusMetric.common.pluck(:identifier)).to contain_exactly(*metric_ids) end end @@ -65,24 +65,26 @@ describe Importers::CommonMetricsImporter do context 'does import properly all fields' do let(:query_identifier) { 'response-metric' } - let(:group) do + let(:dashboard) do { - group: 'Response metrics (NGINX Ingress)', - metrics: [{ - title: "Throughput", - y_label: "Requests / Sec", - queries: [{ - id: query_identifier, - query_range: 'my-query', - unit: 'my-unit', - label: 'status code' + panel_groups: [{ + group: 'Response metrics (NGINX Ingress)', + panels: [{ + title: "Throughput", + y_label: "Requests / Sec", + metrics: [{ + id: query_identifier, + query_range: 'my-query', + unit: 'my-unit', + label: 'status code' + }] }] }] } end before do - expect(subject).to receive(:content) { [group.deep_stringify_keys] } + expect(subject).to receive(:content) { dashboard.deep_stringify_keys } end shared_examples 'stores metric' do |