Merge "Fix notification for NotImplemented record_events"

This commit is contained in:
Jenkins 2014-06-09 17:09:15 +00:00 committed by Gerrit Code Review
commit 06009baa08
2 changed files with 15 additions and 1 deletions

View File

@ -64,7 +64,12 @@ class EventsNotificationEndpoint(object):
LOG.debug(_('Saving event "%s"'), event.event_type)
problem_events = []
for dispatcher_ext in self.dispatcher_manager:
problem_events.extend(dispatcher_ext.obj.record_events(event))
try:
problem_events.extend(
dispatcher_ext.obj.record_events(event))
except NotImplementedError:
LOG.warn(_('Event is not implemented with the storage'
' backend'))
if models.Event.UNKNOWN_PROBLEM in [x[0] for x in problem_events]:
if not cfg.CONF.notification.ack_on_event_error:
return oslo.messaging.NotificationResult.REQUEUE

View File

@ -101,6 +101,15 @@ class TestEventEndpoint(tests_base.BaseTestCase):
self.endpoint.event_converter.to_event.return_value = mock.MagicMock(
event_type='test.test')
@mock.patch('ceilometer.event.endpoint.LOG')
def test_event_not_implemented(self, log):
self.mock_dispatcher.record_events.side_effect = NotImplementedError
message = {'event_type': "foo", 'message_id': "abc"}
ret = self.endpoint.process_notification(message)
log.warn.assert_called_once_with(
'Event is not implemented with the storage backend')
self.assertEqual(oslo.messaging.NotificationResult.HANDLED, ret)
def test_message_to_event(self):
self.endpoint.info(TEST_NOTICE_CTXT, 'compute.vagrant-precise',
'compute.instance.create.end',