Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7a70566a
Commit
7a70566a
authored
Apr 20, 2021
by
Luis Mejia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tier and distribution based on ee option
parent
b584d36d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
16 deletions
+62
-16
generator_templates/usage_metric_definition/metric_definition.yml
...r_templates/usage_metric_definition/metric_definition.yml
+2
-4
lib/generators/gitlab/usage_metric_definition_generator.rb
lib/generators/gitlab/usage_metric_definition_generator.rb
+13
-2
spec/fixtures/lib/generators/gitlab/usage_metric_definition_generator/sample_metric_with_ee.yml
...age_metric_definition_generator/sample_metric_with_ee.yml
+20
-0
spec/fixtures/lib/generators/gitlab/usage_metric_definition_generator/sample_metric_with_name_suggestions.yml
...inition_generator/sample_metric_with_name_suggestions.yml
+5
-5
spec/lib/generators/gitlab/usage_metric_definition_generator_spec.rb
...nerators/gitlab/usage_metric_definition_generator_spec.rb
+22
-5
No files found.
generator_templates/usage_metric_definition/metric_definition.yml
View file @
7a70566a
...
...
@@ -13,7 +13,5 @@ time_frame: <%= time_frame %>
data_source
:
distribution
:
<%= distribution %>
# tier:
# - free
# - premium
# - ultimate
tier
:
<%= tier %>
lib/generators/gitlab/usage_metric_definition_generator.rb
View file @
7a70566a
...
...
@@ -53,8 +53,19 @@ module Gitlab
end
def
distribution
value
=
[
'- ce'
]
value
<<
'- ee'
if
ee?
value
=
[]
value
<<
'- ce'
unless
ee?
value
<<
'- ee'
value
.
join
(
"
\n
"
)
end
def
tier
value
=
if
ee?
[
'#- premium'
]
else
[
'- free'
,
'- premium'
]
end
value
<<
'- ultimate'
value
.
join
(
"
\n
"
)
end
...
...
spec/fixtures/lib/generators/gitlab/usage_metric_definition_generator/sample_metric_with_ee.yml
0 → 100644
View file @
7a70566a
---
# See Usage Ping metrics dictionary docs https://docs.gitlab.com/ee/development/usage_ping/metrics_dictionary.html
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
spec/fixtures/lib/generators/gitlab/usage_metric_definition_generator/sample_metric_with_name_suggestions.yml
View file @
7a70566a
...
...
@@ -15,8 +15,8 @@ time_frame: 7d
data_source
:
distribution
:
-
ce
# Add here corresponding tiers
#
tier:
#
- free
#
- premium
#
- ultimate
-
ee
tier
:
-
free
-
premium
-
ultimate
spec/lib/generators/gitlab/usage_metric_definition_generator_spec.rb
View file @
7a70566a
...
...
@@ -20,20 +20,37 @@ RSpec.describe Gitlab::UsageMetricDefinitionGenerator do
end
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.
before
do
stub_const
(
'Gitlab::VERSION'
,
'13.9.0'
)
allow
(
::
Gitlab
::
Usage
::
Metrics
::
NamesSuggestions
::
Generator
).
to
receive
(
:generate
).
and_return
(
'test metric name'
)
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
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
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 is true'
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
}
expect
(
YAML
.
safe_load
(
File
.
read
(
metric_definition_path
))).
to
eq
(
sample_metric
)
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
)
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment