Commit 33671cac authored by Alper Akgun's avatar Alper Akgun

Merge branch...

Merge branch 'mwaw/323460-feature-flag-product_intelligence_metrics_names_suggestions-default_on' into 'master'

Rollout  [Feature flag] `product_intelligence_metrics_names_suggestions` [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!58995
parents 8820f698 3874901c
---
title: Rollout product_intelligence_metrics_names_suggestions feature flag
merge_request: 58995
author:
type: added
---
name: product_intelligence_metrics_names_suggestions
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55733
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/323460
milestone: '13.10'
type: development
group: group::product intelligence
default_enabled: false
......@@ -65,8 +65,6 @@ module Gitlab
private
def metric_name_suggestion
return unless Feature.enabled?(:product_intelligence_metrics_names_suggestions, default_enabled: :yaml)
"\nname: \"#{Usage::Metrics::NamesSuggestions::Generator.generate(key_path)}\""
end
......
......@@ -32,38 +32,20 @@ RSpec.describe Gitlab::UsageMetricDefinitionGenerator do
end
describe 'Creating metric definition file' do
let(:sample_metric) { load_sample_metric_definition }
# Stub version so that `milestone` key remains constant between releases to prevent flakiness.
before do
stub_const('Gitlab::VERSION', '13.9.0')
allow(::Gitlab::Usage::Metrics::NamesSuggestions::Generator).to receive(:generate).and_return('test metric name')
end
context 'with product_intelligence_metrics_names_suggestions feature ON' do
let(:sample_metric) { load_sample_metric_definition(filename: 'sample_metric_with_name_suggestions.yml') }
it 'creates a metric definition file using the template' do
stub_feature_flags(product_intelligence_metrics_names_suggestions: true)
described_class.new([key_path], { 'dir' => dir }).invoke_all
metric_definition_path = Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_test_metric.yml')).first
expect(YAML.safe_load(File.read(metric_definition_path))).to eq(sample_metric)
end
end
context 'with product_intelligence_metrics_names_suggestions feature OFF' do
it 'creates a metric definition file using the template' do
stub_feature_flags(product_intelligence_metrics_names_suggestions: false)
let(:sample_metric) { load_sample_metric_definition(filename: 'sample_metric_with_name_suggestions.yml') }
described_class.new([key_path], { 'dir' => dir }).invoke_all
it 'creates a metric definition file using the template' do
described_class.new([key_path], { 'dir' => dir }).invoke_all
metric_definition_path = Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_test_metric.yml')).first
metric_definition_path = Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_test_metric.yml')).first
expect(YAML.safe_load(File.read(metric_definition_path))).to eq(sample_metric)
end
expect(YAML.safe_load(File.read(metric_definition_path))).to eq(sample_metric)
end
end
......@@ -104,28 +86,12 @@ RSpec.describe Gitlab::UsageMetricDefinitionGenerator do
end
describe 'Name suggestions' do
context 'with product_intelligence_metrics_names_suggestions feature ON' do
it 'adds name key to metric definition' do
stub_feature_flags(product_intelligence_metrics_names_suggestions: true)
expect(::Gitlab::Usage::Metrics::NamesSuggestions::Generator).to receive(:generate).and_return('some name')
described_class.new([key_path], { 'dir' => dir }).invoke_all
metric_definition_path = Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_test_metric.yml')).first
expect(YAML.safe_load(File.read(metric_definition_path))).to include("name" => "some name")
end
end
context 'with product_intelligence_metrics_names_suggestions feature OFF' do
it 'adds name key to metric definition' do
stub_feature_flags(product_intelligence_metrics_names_suggestions: false)
it 'adds name key to metric definition' do
expect(::Gitlab::Usage::Metrics::NamesSuggestions::Generator).to receive(:generate).and_return('some name')
described_class.new([key_path], { 'dir' => dir }).invoke_all
metric_definition_path = Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_test_metric.yml')).first
expect(::Gitlab::Usage::Metrics::NamesSuggestions::Generator).not_to receive(:generate)
described_class.new([key_path], { 'dir' => dir }).invoke_all
metric_definition_path = Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_test_metric.yml')).first
expect(YAML.safe_load(File.read(metric_definition_path)).keys).not_to include(:name)
end
expect(YAML.safe_load(File.read(metric_definition_path))).to include("name" => "some name")
end
end
end
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