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
0
Merge Requests
0
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
Jérome Perrin
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
9 deletions
+45
-9
spec/lib/gitlab/prometheus/queries/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
context
'some queries return results'
do
before
do
expect
(
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
)
expect
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_empty'
,
any_args
).
and_return
([])
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
(
query_range_result
)
allow
(
client
).
to
receive
(
:query_range
).
with
(
'query_range_empty'
,
any_args
).
and_return
([])
end
it
'return
results
only for queries with results'
do
it
'return
group data
only for queries with results'
do
expected
=
[
{
group:
'name'
,
...
...
@@ -61,14 +61,13 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsQuery, lib: true do
allow
(
client
).
to
receive
(
:label_values
).
and_return
(
metric_names
)
end
context
'
some
queries return results'
do
context
'
both
queries return results'
do
before
do
expect
(
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_a'
,
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
it
'return results only for queries with results'
do
puts
query_result
it
'return group data both queries'
do
expected
=
[
{
group:
'group_a'
,
...
...
@@ -117,5 +116,42 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsQuery, lib: true do
expect
(
query_result
).
to
eq
(
expected
)
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
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