Merge "Add notification sample test for aggregate.cache_images.start|end"
This commit is contained in:
commit
9742a64403
|
@ -61,6 +61,10 @@ jQuery(document).ready(function(){
|
||||||
pkgutil.iter_modules(nova.notifications.objects.__path__))))
|
pkgutil.iter_modules(nova.notifications.objects.__path__))))
|
||||||
|
|
||||||
def _collect_notifications(self):
|
def _collect_notifications(self):
|
||||||
|
# If you do not see your notification sample showing up in the docs
|
||||||
|
# be sure that the sample filename matches what is registered on the
|
||||||
|
# versioned notification object class using the
|
||||||
|
# @base.notification_sample decorator.
|
||||||
self._import_all_notification_packages()
|
self._import_all_notification_packages()
|
||||||
base.NovaObjectRegistry.register_notification_objects()
|
base.NovaObjectRegistry.register_notification_objects()
|
||||||
notifications = {}
|
notifications = {}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"priority": "INFO",
|
||||||
|
"payload": {
|
||||||
|
"$ref": "common_payloads/AggregatePayload.json#",
|
||||||
|
"nova_object.data": {
|
||||||
|
"hosts": ["compute"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"event_type": "aggregate.cache_images.end",
|
||||||
|
"publisher_id": "nova-api:fake-mini"
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"priority": "INFO",
|
||||||
|
"payload": {
|
||||||
|
"$ref": "common_payloads/AggregatePayload.json#",
|
||||||
|
"nova_object.data": {
|
||||||
|
"hosts": ["compute"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"event_type": "aggregate.cache_images.start",
|
||||||
|
"publisher_id": "nova-api:fake-mini"
|
||||||
|
}
|
|
@ -1640,7 +1640,8 @@ class ComputeTaskManager(base.Base):
|
||||||
:param image_id: The IDs of the image to cache
|
:param image_id: The IDs of the image to cache
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO(danms): Fix notification sample for IMAGE_CACHE action
|
# TODO(mriedem): Consider including the list of images in the
|
||||||
|
# notification payload.
|
||||||
compute_utils.notify_about_aggregate_action(
|
compute_utils.notify_about_aggregate_action(
|
||||||
context, aggregate,
|
context, aggregate,
|
||||||
fields.NotificationAction.IMAGE_CACHE,
|
fields.NotificationAction.IMAGE_CACHE,
|
||||||
|
|
|
@ -54,6 +54,8 @@ class AggregatePayload(base.NotificationPayloadBase):
|
||||||
@base.notification_sample('aggregate-update_metadata-end.json')
|
@base.notification_sample('aggregate-update_metadata-end.json')
|
||||||
@base.notification_sample('aggregate-update_prop-start.json')
|
@base.notification_sample('aggregate-update_prop-start.json')
|
||||||
@base.notification_sample('aggregate-update_prop-end.json')
|
@base.notification_sample('aggregate-update_prop-end.json')
|
||||||
|
@base.notification_sample('aggregate-cache_images-start.json')
|
||||||
|
@base.notification_sample('aggregate-cache_images-end.json')
|
||||||
@nova_base.NovaObjectRegistry.register_notification
|
@nova_base.NovaObjectRegistry.register_notification
|
||||||
class AggregateNotification(base.NotificationBase):
|
class AggregateNotification(base.NotificationBase):
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
|
|
|
@ -166,3 +166,45 @@ class TestAggregateNotificationSample(
|
||||||
'uuid': aggregate['uuid'],
|
'uuid': aggregate['uuid'],
|
||||||
'id': aggregate['id']},
|
'id': aggregate['id']},
|
||||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
|
actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
|
||||||
|
|
||||||
|
def test_aggregate_cache_images(self):
|
||||||
|
aggregate_req = {
|
||||||
|
"aggregate": {
|
||||||
|
"name": "my-aggregate",
|
||||||
|
"availability_zone": "nova"}}
|
||||||
|
aggregate = self.admin_api.post_aggregate(aggregate_req)
|
||||||
|
add_host_req = {
|
||||||
|
"add_host": {
|
||||||
|
"host": "compute"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.admin_api.post_aggregate_action(aggregate['id'], add_host_req)
|
||||||
|
|
||||||
|
fake_notifier.reset()
|
||||||
|
|
||||||
|
cache_images_req = {
|
||||||
|
'cache': [
|
||||||
|
{'id': '155d900f-4e14-4e4c-a73d-069cbf4541e6'}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
self.admin_api.api_post('/os-aggregates/%s/images' % aggregate['id'],
|
||||||
|
cache_images_req)
|
||||||
|
# Since the operation is asynchronous we have to wait for the end
|
||||||
|
# notification.
|
||||||
|
fake_notifier.wait_for_versioned_notifications(
|
||||||
|
'aggregate.cache_images.end')
|
||||||
|
|
||||||
|
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
|
||||||
|
fake_notifier.VERSIONED_NOTIFICATIONS)
|
||||||
|
self._verify_notification(
|
||||||
|
'aggregate-cache_images-start',
|
||||||
|
replacements={
|
||||||
|
'uuid': aggregate['uuid'],
|
||||||
|
'id': aggregate['id']},
|
||||||
|
actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
|
||||||
|
self._verify_notification(
|
||||||
|
'aggregate-cache_images-end',
|
||||||
|
replacements={
|
||||||
|
'uuid': aggregate['uuid'],
|
||||||
|
'id': aggregate['id']},
|
||||||
|
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
|
||||||
|
|
Loading…
Reference in New Issue