Skip to content
Snippets Groups Projects
Commit 436e9078 authored by Pawel Chojnacki's avatar Pawel Chojnacki
Browse files

match query times with appropriate delta

parent 693602d9
No related branches found
No related tags found
2 merge requests!12073Add RC2 changes to 9-3-stable,!10981Expose memory deltas between app deployments and refactor prometheus queries to support more custom queries
Loading
Loading
@@ -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)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment