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
cf4aeafa
Commit
cf4aeafa
authored
Jun 05, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test Partial additional query response
parent
eaaad702
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
9 deletions
+45
-9
additional_metrics_query_spec.rb
...itlab/prometheus/queries/additional_metrics_query_spec.rb
+45
-9
No files found.
spec/lib/gitlab/prometheus/queries/additional_metrics_query_spec.rb
View file @
cf4aeafa
...
@@ -24,12 +24,12 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsQuery, lib: true do
...
@@ -24,12 +24,12 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsQuery, lib: true do
context
'some queries return results'
do
context
'some queries return results'
do
before
do
before
do
expect
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_a'
,
any_args
).
and_return
(
query_range_result
)
allow
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_a'
,
any_args
).
and_return
(
query_range_result
)
expect
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_b'
,
any_args
).
and_return
(
query_range_result
)
allow
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_b'
,
any_args
).
and_return
(
query_range_result
)
expect
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_empty'
,
any_args
).
and_return
([])
allow
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_empty'
,
any_args
).
and_return
([])
end
end
it
'return
results
only for queries with results'
do
it
'return
group data
only for queries with results'
do
expected
=
[
expected
=
[
{
{
group:
'name'
,
group:
'name'
,
...
@@ -61,14 +61,13 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsQuery, lib: true do
...
@@ -61,14 +61,13 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsQuery, lib: true do
allow
(
client
).
to
receive
(
:label_values
).
and_return
(
metric_names
)
allow
(
client
).
to
receive
(
:label_values
).
and_return
(
metric_names
)
end
end
context
'
some
queries return results'
do
context
'
both
queries return results'
do
before
do
before
do
expect
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_a'
,
any_args
).
and_return
(
query_range_result
)
allow
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_a'
,
any_args
).
and_return
(
query_range_result
)
expect
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_b'
,
any_args
).
and_return
(
query_range_result
)
allow
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_b'
,
any_args
).
and_return
(
query_range_result
)
end
end
it
'return results only for queries with results'
do
it
'return group data both queries'
do
puts
query_result
expected
=
[
expected
=
[
{
{
group:
'group_a'
,
group:
'group_a'
,
...
@@ -117,5 +116,42 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsQuery, lib: true do
...
@@ -117,5 +116,42 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsQuery, lib: true do
expect
(
query_result
).
to
eq
(
expected
)
expect
(
query_result
).
to
eq
(
expected
)
end
end
end
end
context
'one query returns result'
do
before
do
allow
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_a'
,
any_args
).
and_return
(
query_range_result
)
allow
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_b'
,
any_args
).
and_return
([])
end
it
'queries using specific time'
do
expect
(
client
).
to
receive
(
:query_range
).
with
(
anything
,
start:
8
.
hours
.
ago
.
to_f
,
stop:
Time
.
now
.
to_f
)
expect
(
query_result
).
not_to
be_nil
end
it
'return group data only for query with results'
do
expected
=
[
{
group:
'group_a'
,
priority:
1
,
metrics:
[
{
title:
'title'
,
weight:
nil
,
y_label:
'Values'
,
queries:
[
{
query_range:
'query_range_a'
,
result:
query_range_result
}
]
}
]
}
]
expect
(
query_result
).
to
eq
(
expected
)
end
end
end
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