summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-05-16 08:59:52 +0000
committerRobert Speicher <robert@gitlab.com>2017-05-16 08:59:52 +0000
commit21c96a657c4bb9f64cdf9e548280e10266bc6ee9 (patch)
tree01d070455dd80bf461122996fc3099a520bc1772
parent17806d7619e3bcf9c006788d65ea85d56c34bc14 (diff)
parent0ddd1d52fdf64301caa391795cee91700b85fd81 (diff)
downloadgitlab-ce-21c96a657c4bb9f64cdf9e548280e10266bc6ee9.tar.gz
Merge branch '32231-fix-transient-failure-of-deployment-query-spec' into 'master'
Fix transient failure of deployment query spec Closes #32231 See merge request !11371
-rw-r--r--spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb21
1 files changed, 11 insertions, 10 deletions
diff --git a/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
index cc7d7e57f06..d957dd932c4 100644
--- a/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
+++ b/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
@@ -8,27 +8,28 @@ describe Gitlab::Prometheus::Queries::DeploymentQuery, lib: true do
subject { described_class.new(client) }
around do |example|
- Timecop.freeze { example.run }
+ time_without_subsecond_values = Time.local(2008, 9, 1, 12, 0, 0)
+ Timecop.freeze(time_without_subsecond_values) { example.run }
end
it 'sends appropriate queries to prometheus' do
- 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)
+ start_time = (deployment.created_at - 30.minutes).to_f
+ stop_time = (deployment.created_at + 30.minutes).to_f
+ created_at = deployment.created_at.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_matcher, stop: stop_time_matcher)
+ start: start_time, stop: stop_time)
expect(client).to receive(:query).with('avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))',
- time: created_at_matcher)
+ time: created_at)
expect(client).to receive(:query).with('avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))',
- time: stop_time_matcher)
+ time: stop_time)
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_matcher, stop: stop_time_matcher)
+ start: start_time, stop: stop_time)
expect(client).to receive(:query).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100',
- time: created_at_matcher)
+ time: created_at)
expect(client).to receive(:query).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100',
- time: stop_time_matcher)
+ time: stop_time)
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)