Merge "image: handle glance delete notifications"

This commit is contained in:
Jenkins 2012-10-09 20:35:44 +00:00 committed by Gerrit Code Review
commit fe3be9bacd
3 changed files with 35 additions and 0 deletions

View File

@ -78,6 +78,7 @@ class ImageCRUDBase(ImageBase):
return [ return [
'image.update', 'image.update',
'image.upload', 'image.upload',
'image.delete',
] ]

View File

@ -85,6 +85,7 @@ image Gauge 1 image ID Image polling -> it (st
image.size Gauge bytes image ID Uploaded image size image.size Gauge bytes image ID Uploaded image size
image.update Delta reqs image ID Number of update on the image image.update Delta reqs image ID Number of update on the image
image.upload Delta reqs image ID Number of upload of the image image.upload Delta reqs image ID Number of upload of the image
image.delete Delta reqs image ID Number of delete on the image
image.download Delta bytes image ID Image is downloaded image.download Delta bytes image ID Image is downloaded
image.serve Delta bytes image ID Image is served out image.serve Delta bytes image ID Image is served out
======================== ========== ======= ======== ======================================================= ======================== ========== ======= ======== =======================================================

View File

@ -77,6 +77,14 @@ NOTIFICATION_UPLOAD = {"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"timestamp": NOW} "timestamp": NOW}
NOTIFICATION_DELETE = {"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "images.example.com",
"event_type": "image.delete",
"priority": "info",
"payload": IMAGE_META,
"timestamp": NOW}
class TestNotification(unittest.TestCase): class TestNotification(unittest.TestCase):
def _verify_common_counter(self, c, name, volume): def _verify_common_counter(self, c, name, volume):
@ -160,3 +168,28 @@ class TestNotification(unittest.TestCase):
self._verify_common_counter(upload, 'image.size', self._verify_common_counter(upload, 'image.size',
IMAGE_META['size']) IMAGE_META['size'])
self.assertEqual(upload.type, counter.TYPE_GAUGE) self.assertEqual(upload.type, counter.TYPE_GAUGE)
def test_image_crud_on_delete(self):
handler = notifications.ImageCRUD()
counters = handler.process_notification(NOTIFICATION_DELETE)
self.assertEqual(len(counters), 1)
delete = counters[0]
self._verify_common_counter(delete, 'image.delete', 1)
self.assertEqual(delete.type, counter.TYPE_DELTA)
def test_image_on_delete(self):
handler = notifications.Image()
counters = handler.process_notification(NOTIFICATION_DELETE)
self.assertEqual(len(counters), 1)
delete = counters[0]
self._verify_common_counter(delete, 'image', 1)
self.assertEqual(delete.type, counter.TYPE_GAUGE)
def test_image_size_on_delete(self):
handler = notifications.ImageSize()
counters = handler.process_notification(NOTIFICATION_DELETE)
self.assertEqual(len(counters), 1)
delete = counters[0]
self._verify_common_counter(delete, 'image.size',
IMAGE_META['size'])
self.assertEqual(delete.type, counter.TYPE_GAUGE)