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
Boxiang Sun
gitlab-ce
Commits
436e9078
Commit
436e9078
authored
May 11, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
match query times with appropriate delta
parent
693602d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
+9
-8
No files found.
spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
View file @
436e9078
...
@@ -12,22 +12,23 @@ describe Gitlab::Prometheus::Queries::DeploymentQuery, lib: true do
...
@@ -12,22 +12,23 @@ describe Gitlab::Prometheus::Queries::DeploymentQuery, lib: true do
end
end
it
'sends appropriate queries to prometheus'
do
it
'sends appropriate queries to prometheus'
do
start_time
=
(
deployment
.
created_at
-
30
.
minutes
).
to_f
start_time_matcher
=
be_within
(
0.5
).
of
((
deployment
.
created_at
-
30
.
minutes
).
to_f
)
stop_time_matcher
=
be_within
(
0.5
).
of
((
deployment
.
created_at
+
30
.
minutes
).
to_f
)
created_at_matcher
=
be_within
(
0.5
).
of
(
deployment
.
created_at
.
to_f
)
stop_time
=
(
deployment
.
created_at
+
30
.
minutes
).
to_f
expect
(
client
).
to
receive
(
:query_range
).
with
(
'avg(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}) / 2^20'
,
expect
(
client
).
to
receive
(
:query_range
).
with
(
'avg(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}) / 2^20'
,
start:
start_time
,
stop:
stop_time
)
start:
start_time
_matcher
,
stop:
stop_time_matcher
)
expect
(
client
).
to
receive
(
:query
).
with
(
'avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))'
,
expect
(
client
).
to
receive
(
:query
).
with
(
'avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))'
,
time:
deployment
.
created_at
.
to_f
)
time:
created_at_matcher
)
expect
(
client
).
to
receive
(
:query
).
with
(
'avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))'
,
expect
(
client
).
to
receive
(
:query
).
with
(
'avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))'
,
time:
stop_time
)
time:
stop_time
_matcher
)
expect
(
client
).
to
receive
(
:query_range
).
with
(
'avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[2m])) * 100'
,
expect
(
client
).
to
receive
(
:query_range
).
with
(
'avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[2m])) * 100'
,
start:
start_time
,
stop:
stop_time
)
start:
start_time
_matcher
,
stop:
stop_time_matcher
)
expect
(
client
).
to
receive
(
:query
).
with
(
'avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100'
,
expect
(
client
).
to
receive
(
:query
).
with
(
'avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100'
,
time:
deployment
.
created_at
.
to_f
)
time:
created_at_matcher
)
expect
(
client
).
to
receive
(
:query
).
with
(
'avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100'
,
expect
(
client
).
to
receive
(
:query
).
with
(
'avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100'
,
time:
stop_time
)
time:
stop_time
_matcher
)
expect
(
subject
.
query
(
deployment
.
id
)).
to
eq
(
memory_values:
nil
,
memory_before:
nil
,
memory_after:
nil
,
expect
(
subject
.
query
(
deployment
.
id
)).
to
eq
(
memory_values:
nil
,
memory_before:
nil
,
memory_after:
nil
,
cpu_values:
nil
,
cpu_before:
nil
,
cpu_after:
nil
)
cpu_values:
nil
,
cpu_before:
nil
,
cpu_after:
nil
)
...
...
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