Commit 0aa08e7b authored by Arturo Herrero's avatar Arturo Herrero

Merge branch...

Merge branch '327870-improve-metric-yaml-defintion-generator-to-fill-correct-tier-and-distribution' into 'master'

Resolve "Improve Metric YAML defintion generator to fill correct tier and distribution"

See merge request gitlab-org/gitlab!59669
parents 9005c44b ce13e42b
...@@ -13,7 +13,5 @@ time_frame: <%= time_frame %> ...@@ -13,7 +13,5 @@ time_frame: <%= time_frame %>
data_source: data_source:
distribution: distribution:
<%= distribution %> <%= distribution %>
# tier: tier:
# - free <%= tier %>
# - premium
# - ultimate
...@@ -53,9 +53,11 @@ module Gitlab ...@@ -53,9 +53,11 @@ module Gitlab
end end
def distribution def distribution
value = ['- ce'] (ee? ? ['- ee'] : ['- ce', '- ee']).join("\n")
value << '- ee' if ee? end
value.join("\n")
def tier
(ee? ? ['#- premium', '- ultimate'] : ['- free', '- premium', '- ultimate']).join("\n")
end end
def milestone def milestone
......
---
key_path: counts_weekly.test_metric
name: test metric name
description:
product_section:
product_stage:
product_group:
product_category:
value_type: number
status: implemented
milestone: "13.9"
introduced_by_url:
time_frame: 7d
data_source:
distribution:
- ee
tier:
#- premium
- ultimate
...@@ -15,8 +15,8 @@ time_frame: 7d ...@@ -15,8 +15,8 @@ time_frame: 7d
data_source: data_source:
distribution: distribution:
- ce - ce
# Add here corresponding tiers - ee
# tier: tier:
# - free - free
# - premium - premium
# - ultimate - ultimate
...@@ -20,22 +20,39 @@ RSpec.describe Gitlab::UsageMetricDefinitionGenerator do ...@@ -20,22 +20,39 @@ RSpec.describe Gitlab::UsageMetricDefinitionGenerator do
end end
describe 'Creating metric definition file' do describe 'Creating metric definition file' do
let(:sample_metric) { load_sample_metric_definition(filename: sample_filename) }
# Stub version so that `milestone` key remains constant between releases to prevent flakiness. # Stub version so that `milestone` key remains constant between releases to prevent flakiness.
before do before do
stub_const('Gitlab::VERSION', '13.9.0') stub_const('Gitlab::VERSION', '13.9.0')
allow(::Gitlab::Usage::Metrics::NamesSuggestions::Generator).to receive(:generate).and_return('test metric name') allow(::Gitlab::Usage::Metrics::NamesSuggestions::Generator).to receive(:generate).and_return('test metric name')
end end
let(:sample_metric) { load_sample_metric_definition(filename: 'sample_metric_with_name_suggestions.yml') } context 'without ee option' do
let(:sample_filename) { 'sample_metric_with_name_suggestions.yml' }
let(:metric_definition_path) { Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_test_metric.yml')).first }
it 'creates a metric definition file using the template' do it 'creates a metric definition file using the template' do
described_class.new([key_path], { 'dir' => dir }).invoke_all described_class.new([key_path], { 'dir' => dir }).invoke_all
expect(YAML.safe_load(File.read(metric_definition_path))).to eq(sample_metric)
end
end
metric_definition_path = Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_test_metric.yml')).first context 'with ee option' do
let(:sample_filename) { 'sample_metric_with_ee.yml' }
let(:metric_definition_path) { Dir.glob(File.join(temp_dir, 'ee/config/metrics/counts_7d/*_test_metric.yml')).first }
before do
stub_const("#{described_class}::TOP_LEVEL_DIR", 'config')
stub_const("#{described_class}::TOP_LEVEL_DIR_EE", File.join(temp_dir, 'ee'))
end
it 'creates a metric definition file using the template' do
described_class.new([key_path], { 'dir' => dir, 'ee': true }).invoke_all
expect(YAML.safe_load(File.read(metric_definition_path))).to eq(sample_metric) expect(YAML.safe_load(File.read(metric_definition_path))).to eq(sample_metric)
end end
end end
end
describe 'Validation' do describe 'Validation' do
let(:options) { [key_path, '--dir', dir] } let(:options) { [key_path, '--dir', dir] }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment