Skip to content

Commit

Permalink
Merge pull request #503 from aufi/event_history_catchup
Browse files Browse the repository at this point in the history
Allow skip historical Events from OpenStack

(cherry picked from commit 1a8bc1a)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1751900
  • Loading branch information
Ladas authored and simaishi committed Sep 19, 2019
1 parent aac5897 commit 300e357
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/settings.yml
Expand Up @@ -21,7 +21,8 @@
:read_timeout: 60
:blacklisted_event_names: []
:event_handling:
:event_backread_seconds: 15
:event_backread_seconds: 5
:event_skip_history: false
:event_groups:
:addition:
:critical:
Expand Down
Expand Up @@ -140,7 +140,13 @@ def list_events(query_options)
end
end

def skip_history?
Settings.fetch_path(:ems, :ems_openstack, :event_handling, :event_skip_history) || false
end

def latest_event_timestamp
@since ||= @ems.ems_events.maximum(:timestamp)
return @since if @since.present?

@since = @ems.ems_events.maximum(:timestamp) || skip_history? ? @ems.created_on.iso8601 : nil
end
end
40 changes: 40 additions & 0 deletions spec/legacy/events/openstack_ceilometer_event_monitor_spec.rb
Expand Up @@ -77,5 +77,45 @@
subject.stop
end
end

it 'sets query options for Panko with events history' do
ems_double = double(:created_on => Time.now.utc, :ems_events => [])
allow(subject.class).to receive(:connect_service_from_settings).and_return nil
allow(ems_double).to receive(:connect).with(:service => 'Event')
allow(ems_double).to receive(:ems_events).and_return double(:maximum => nil)
subject.instance_variable_set(:@ems, ems_double)

allow(subject).to receive(:skip_history?).and_return false

subject.provider_connection
expect(subject.send(:query_options)).to eq([{
'field' => 'start_timestamp',
'op' => 'ge',
'value' => ''
}, {
'field' => 'all_tenants',
'value' => 'True'
}])
end

it 'sets query options for Panko without events history' do
ems_double = double(:created_on => Time.now.utc, :ems_events => [])
allow(subject.class).to receive(:connect_service_from_settings).and_return nil
allow(ems_double).to receive(:connect).with(:service => 'Event')
allow(ems_double).to receive(:ems_events).and_return double(:maximum => nil)
subject.instance_variable_set(:@ems, ems_double)

allow(subject).to receive(:skip_history?).and_return true

subject.provider_connection
expect(subject.send(:query_options)).to eq([{
'field' => 'start_timestamp',
'op' => 'ge',
'value' => ems_double.created_on.iso8601
}, {
'field' => 'all_tenants',
'value' => 'True'
}])
end
end
end

0 comments on commit 300e357

Please sign in to comment.