Skip to content

Commit

Permalink
Merge pull request #1265 from jrafanie/fix_sporadic_test_failures_due…
Browse files Browse the repository at this point in the history
…_to_date_wrapping

Query metric rollups using start_date derived from the first rollup
  • Loading branch information
Fryguy authored Aug 16, 2024
2 parents e318288 + cef1b13 commit c46f881
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spec/requests/providers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1457,18 +1457,18 @@ def gen_import_request
let(:provider) { FactoryBot.create(:ems_redhat) }
let(:provider1) { FactoryBot.create(:ems_redhat) }
let(:url) { api_provider_metric_rollups_url(nil, provider) }
let(:first_ts) { 1.hour.ago }

before do
FactoryBot.create_list(:metric_rollup_cm_hr, 3, :resource => provider, :timestamp => 1.hour.ago)
FactoryBot.create_list(:metric_rollup_cm_hr, 3, :resource => provider, :timestamp => first_ts)
FactoryBot.create_list(:metric_rollup_cm_daily, 1, :resource => provider)
FactoryBot.create_list(:metric_rollup_cm_hr, 1, :resource => provider1)
end

it 'returns the metric rollups for the provider' do
api_basic_authorize subcollection_action_identifier(:providers, :metric_rollups, :read, :get)

provider.metric_rollups.where(:capture_interval_name => 'hourly').name
get(url, :params => { :capture_interval => 'hourly', :start_date => Time.zone.today.to_s })
get(url, :params => { :capture_interval => 'hourly', :start_date => first_ts.to_date.to_s })

expected = {
'count' => 5,
Expand All @@ -1483,7 +1483,7 @@ def gen_import_request
it 'will not return metric rollups without an appropriate role' do
api_basic_authorize

get(url, :params => { :capture_interval => 'hourly', :start_date => Time.zone.today.to_s })
get(url, :params => { :capture_interval => 'hourly', :start_date => first_ts.to_date.to_s })

expect(response).to have_http_status(:forbidden)
end
Expand Down

0 comments on commit c46f881

Please sign in to comment.