summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-05-11 23:24:26 +0200
committerPawel Chojnacki <pawel@chojnacki.ws>2017-05-11 23:24:26 +0200
commit436e90780b88955c946f9a1839342669eb43f525 (patch)
tree84d17f36830103b960f0be5d6e52e529193ea084 /spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
parent693602d957b2bb48a5270d249a2e2708c03bd803 (diff)
downloadgitlab-ce-436e90780b88955c946f9a1839342669eb43f525.tar.gz
match query times with appropriate delta
Diffstat (limited to 'spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb')
-rw-r--r--spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
index e739005ba83..cc7d7e57f06 100644
--- a/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
+++ b/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
@@ -12,22 +12,23 @@ describe Gitlab::Prometheus::Queries::DeploymentQuery, lib: true do
end
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',
- 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]))',
- 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]))',
- 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',
- 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',
- 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',
- time: stop_time)
+ time: stop_time_matcher)
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)