Merge "Add glance notifications tests for ceilometer"
diff --git a/tempest/api/telemetry/base.py b/tempest/api/telemetry/base.py
index 2b422fd..b5b2bb1 100644
--- a/tempest/api/telemetry/base.py
+++ b/tempest/api/telemetry/base.py
@@ -34,19 +34,27 @@
         cls.telemetry_client = os.telemetry_client
         cls.servers_client = os.servers_client
         cls.flavors_client = os.flavors_client
+        cls.image_client = os.image_client
+        cls.image_client_v2 = os.image_client_v2
 
         cls.nova_notifications = ['memory', 'vcpus', 'disk.root.size',
                                   'disk.ephemeral.size']
+
+        cls.glance_notifications = ['image.update', 'image.upload',
+                                    'image.delete']
+
+        cls.glance_v2_notifications = ['image.download', 'image.serve']
+
         cls.server_ids = []
         cls.alarm_ids = []
+        cls.image_ids = []
 
     @classmethod
     def create_alarm(cls, **kwargs):
         resp, body = cls.telemetry_client.create_alarm(
             name=data_utils.rand_name('telemetry_alarm'),
             type='threshold', **kwargs)
-        if resp['status'] == '201':
-            cls.alarm_ids.append(body['alarm_id'])
+        cls.alarm_ids.append(body['alarm_id'])
         return resp, body
 
     @classmethod
@@ -55,8 +63,15 @@
             data_utils.rand_name('ceilometer-instance'),
             CONF.compute.image_ref, CONF.compute.flavor_ref,
             wait_until='ACTIVE')
-        if resp['status'] == '202':
-            cls.server_ids.append(body['id'])
+        cls.server_ids.append(body['id'])
+        return resp, body
+
+    @classmethod
+    def create_image(cls, client):
+        resp, body = client.create_image(
+            data_utils.rand_name('image'), container_format='bare',
+            disk_format='raw', visibility='private')
+        cls.image_ids.append(body['id'])
         return resp, body
 
     @staticmethod
@@ -71,6 +86,7 @@
     def tearDownClass(cls):
         cls.cleanup_resources(cls.telemetry_client.delete_alarm, cls.alarm_ids)
         cls.cleanup_resources(cls.servers_client.delete_server, cls.server_ids)
+        cls.cleanup_resources(cls.image_client.delete_image, cls.image_ids)
         cls.clear_isolated_creds()
         super(BaseTelemetryTest, cls).tearDownClass()
 
diff --git a/tempest/api/telemetry/test_telemetry_notification_api.py b/tempest/api/telemetry/test_telemetry_notification_api.py
index f401b9b..2a170c7 100644
--- a/tempest/api/telemetry/test_telemetry_notification_api.py
+++ b/tempest/api/telemetry/test_telemetry_notification_api.py
@@ -43,6 +43,36 @@
         for metric in self.nova_notifications:
             self.await_samples(metric, query)
 
+    @test.attr(type="smoke")
+    @test.services("image")
+    @testtools.skipIf(not CONF.image_feature_enabled.api_v1,
+                      "Glance api v1 is disabled")
+    def test_check_glance_v1_notifications(self):
+        _, body = self.create_image(self.image_client)
+        self.image_client.update_image(body['id'], data='data')
+
+        query = 'resource', 'eq', body['id']
+
+        self.image_client.delete_image(body['id'])
+
+        for metric in self.glance_notifications:
+            self.await_samples(metric, query)
+
+    @test.attr(type="smoke")
+    @test.services("image")
+    @testtools.skipIf(not CONF.image_feature_enabled.api_v2,
+                      "Glance api v2 is disabled")
+    def test_check_glance_v2_notifications(self):
+        _, body = self.create_image(self.image_client_v2)
+
+        self.image_client_v2.store_image(body['id'], "file")
+        self.image_client_v2.get_image_file(body['id'])
+
+        query = 'resource', 'eq', body['id']
+
+        for metric in self.glance_v2_notifications:
+            self.await_samples(metric, query)
+
 
 class TelemetryNotificationAPITestXML(TelemetryNotificationAPITestJSON):
     _interface = 'xml'