BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
ffedc52e
Commit
ffedc52e
authored
Jun 05, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup Additional Metrics tests
parent
a3eb8264
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
68 deletions
+20
-68
additional_metrics_deployment_query_spec.rb
...theus/queries/additional_metrics_deployment_query_spec.rb
+0
-8
additional_metrics_query_spec.rb
...itlab/prometheus/queries/additional_metrics_query_spec.rb
+0
-1
matched_metrics_query_spec.rb
...b/gitlab/prometheus/queries/matched_metrics_query_spec.rb
+11
-1
additional_metrics_query_helper.rb
spec/support/prometheus/additional_metrics_query_helper.rb
+0
-31
additional_metrics_shared_examples.rb
.../support/prometheus/additional_metrics_shared_examples.rb
+9
-3
matched_metrics_query_helper.rb
spec/support/prometheus/matched_metrics_query_helper.rb
+0
-24
No files found.
spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb
View file @
ffedc52e
require
'spec_helper'
describe
Gitlab
::
Prometheus
::
Queries
::
AdditionalMetricsDeploymentQuery
,
lib:
true
do
include
Prometheus
::
AdditionalMetricsQueryHelper
include
Prometheus
::
MetricBuilders
let
(
:metric_group_class
)
{
Gitlab
::
Prometheus
::
MetricGroup
}
let
(
:metric_class
)
{
Gitlab
::
Prometheus
::
Metric
}
let
(
:client
)
{
double
(
'prometheus_client'
)
}
let
(
:environment
)
{
create
(
:environment
,
slug:
'environment-slug'
)
}
let
(
:deployment
)
{
create
(
:deployment
,
environment:
environment
)
}
subject
(
:query_result
)
{
described_class
.
new
(
client
).
query
(
deployment
.
id
)
}
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
include_examples
'additional metrics query'
do
it
'queries using specific time'
do
expect
(
client
).
to
receive
(
:query_range
).
with
(
anything
,
...
...
spec/lib/gitlab/prometheus/queries/additional_metrics_query_spec.rb
View file @
ffedc52e
require
'spec_helper'
describe
Gitlab
::
Prometheus
::
Queries
::
AdditionalMetricsQuery
,
lib:
true
do
include
Prometheus
::
AdditionalMetricsQueryHelper
include
Prometheus
::
MetricBuilders
let
(
:client
)
{
double
(
'prometheus_client'
)
}
...
...
spec/lib/gitlab/prometheus/queries/matched_metrics_query_spec.rb
View file @
ffedc52e
require
'spec_helper'
describe
Gitlab
::
Prometheus
::
Queries
::
MatchedMetricsQuery
,
lib:
true
do
include
Prometheus
::
MatchedMetricsQueryHelper
include
Prometheus
::
MetricBuilders
let
(
:metric_group_class
)
{
Gitlab
::
Prometheus
::
MetricGroup
}
let
(
:metric_class
)
{
Gitlab
::
Prometheus
::
Metric
}
def
series_info_with_environment
(
*
more_metrics
)
%w{metric_a metric_b}
.
concat
(
more_metrics
).
map
{
|
metric_name
|
{
'__name__'
=>
metric_name
,
'environment'
=>
''
}
}
end
let
(
:metric_names
)
{
%w{metric_a metric_b}
}
let
(
:series_info_without_environment
)
do
[{
'__name__'
=>
'metric_a'
},
{
'__name__'
=>
'metric_b'
}]
end
let
(
:partialy_empty_series_info
)
{
[{
'__name__'
=>
'metric_a'
,
'environment'
=>
''
}]
}
let
(
:empty_series_info
)
{
[]
}
let
(
:client
)
{
double
(
'prometheus_client'
)
}
subject
{
described_class
.
new
(
client
)
}
...
...
spec/support/prometheus/additional_metrics_query_helper.rb
deleted
100644 → 0
View file @
a3eb8264
module
Prometheus
module
AdditionalMetricsQueryHelper
def
metric_names
%w{metric_a metric_b}
end
def
query_result
[
{
'metric'
:
{},
'value'
:
[
1488772511.004
,
'0.000041021495238095323'
]
}
]
end
def
query_range_result
[
{
'metric'
:
{},
'values'
:
[
[
1488758662.506
,
'0.00002996364761904785'
],
[
1488758722.506
,
'0.00003090239047619091'
]
]
}
]
end
end
end
spec/support/prometheus/additional_metrics_shared_examples.rb
View file @
ffedc52e
RSpec
.
shared_examples
'additional metrics query'
do
include
Prometheus
::
MetricBuilders
let
(
:metric_group_class
)
{
Gitlab
::
Prometheus
::
MetricGroup
}
let
(
:metric_class
)
{
Gitlab
::
Prometheus
::
Metric
}
let
(
:metric_names
)
{
%w{metric_a metric_b}
}
let
(
:query_range_result
)
do
[{
'metric'
:
{},
'values'
:
[[
1488758662.506
,
'0.00002996364761904785'
],
[
1488758722.506
,
'0.00003090239047619091'
]]
}]
end
before
do
allow
(
client
).
to
receive
(
:label_values
).
and_return
(
metric_names
)
allow
(
metric_group_class
).
to
receive
(
:all
).
and_return
([
simple_metric_group
(
metrics:
[
simple_metric
])])
end
let
(
:metric_group_class
)
{
Gitlab
::
Prometheus
::
MetricGroup
}
let
(
:metric_class
)
{
Gitlab
::
Prometheus
::
Metric
}
context
'with one group where two metrics is found'
do
before
do
allow
(
metric_group_class
).
to
receive
(
:all
).
and_return
([
simple_metric_group
])
...
...
spec/support/prometheus/matched_metrics_query_helper.rb
deleted
100644 → 0
View file @
a3eb8264
module
Prometheus
module
MatchedMetricsQueryHelper
def
metric_names
%w{metric_a metric_b}
end
def
series_info_with_environment
(
*
more_metrics
)
%w{metric_a metric_b}
.
concat
(
more_metrics
).
map
{
|
metric_name
|
{
'__name__'
=>
metric_name
,
'environment'
=>
''
}
}
end
def
series_info_without_environment
[{
'__name__'
=>
'metric_a'
},
{
'__name__'
=>
'metric_b'
}]
end
def
partialy_empty_series_info
[{
'__name__'
=>
'metric_a'
,
'environment'
=>
''
}]
end
def
empty_series_info
[]
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