Add ceilometer tests for more glance and cinder notifications
Added ceilometer tests for cinder notifications: snapshot, snapshot.size Added ceilometer tests for glance notifications: image.download, image.serve, image.delete Partially implements: blueprint ceilometer-ostf-notification-tests Change-Id: I526dc98c4790828a0a7b4b91d5bb97c65bd1c2d0
This commit is contained in:
parent
d8d650ed76
commit
3160f5bf5c
|
@ -46,12 +46,11 @@ class CeilometerBaseTest(fuel_health.nmanager.PlatformServicesBaseClass):
|
|||
'router.update']
|
||||
cls.neutron_floatingip_notifications = ['ip.floating.create',
|
||||
'ip.floating.update']
|
||||
cls.glance_notifications = ['image.update', 'image.upload',
|
||||
'image.delete', 'image.download',
|
||||
'image.serve']
|
||||
cls.volume_notifications = ['volume', 'volume.size']
|
||||
cls.snapshot_notifications = ['snapshot', 'snapshot.size']
|
||||
cls.glance_notifications = ['image', 'image.size', 'image.update',
|
||||
'image.upload']
|
||||
'image.upload', 'image.download',
|
||||
'image.serve', 'image.delete']
|
||||
cls.swift_notifications = ['storage.objects.incoming.bytes',
|
||||
'storage.objects.outgoing.bytes',
|
||||
'storage.api.request']
|
||||
|
@ -338,6 +337,19 @@ class CeilometerBaseTest(fuel_health.nmanager.PlatformServicesBaseClass):
|
|||
self.sahara_client.clusters.delete(cluster.id)
|
||||
return cluster
|
||||
|
||||
def glance_helper(self):
|
||||
image = self.glance_client.images.create(
|
||||
name=rand_name('ostf-ceilo-image'))
|
||||
self.objects_for_delete.append((self.glance_client.images.delete,
|
||||
image.id))
|
||||
self.glance_client.images.update(image.id, data='data',
|
||||
disk_format='qcow2',
|
||||
container_format='bare')
|
||||
self.glance_client.images.upload(image.id, 'upload_data')
|
||||
self.glance_client.images.data(image.id)
|
||||
self.glance_client.images.delete(image.id)
|
||||
return image
|
||||
|
||||
@staticmethod
|
||||
def cleanup_resources(object_list):
|
||||
for method, resource in object_list:
|
||||
|
|
|
@ -49,6 +49,7 @@ except:
|
|||
import cinderclient.client
|
||||
import keystoneclient
|
||||
import novaclient.client
|
||||
import glanceclient.client
|
||||
|
||||
from fuel_health.common.ssh import Client as SSHClient
|
||||
from fuel_health.common.utils.data_utils import rand_name
|
||||
|
@ -92,6 +93,7 @@ class OfficialClientManager(fuel_health.manager.Manager):
|
|||
self.traceback = traceback.format_exc()
|
||||
|
||||
if self.clients_initialized:
|
||||
self.glance_client = self._get_glance_client()
|
||||
self.volume_client = self._get_volume_client()
|
||||
self.heat_client = self._get_heat_client()
|
||||
self.murano_client = self._get_murano_client()
|
||||
|
@ -102,6 +104,7 @@ class OfficialClientManager(fuel_health.manager.Manager):
|
|||
'compute_client',
|
||||
'identity_client',
|
||||
'identity_v3_client',
|
||||
'glance_client',
|
||||
'volume_client',
|
||||
'heat_client',
|
||||
'murano_client',
|
||||
|
@ -138,6 +141,26 @@ class OfficialClientManager(fuel_health.manager.Manager):
|
|||
no_cache=True,
|
||||
insecure=dscv)
|
||||
|
||||
def _get_glance_client(self, version=2, username=None, password=None,
|
||||
tenant_name=None):
|
||||
if not username:
|
||||
username = self.config.identity.admin_username
|
||||
if not password:
|
||||
password = self.config.identity.admin_password
|
||||
if not tenant_name:
|
||||
tenant_name = self.config.identity.admin_tenant_name
|
||||
|
||||
keystone = self._get_identity_client(username, password, tenant_name)
|
||||
try:
|
||||
endpoint = keystone.service_catalog.url_for(
|
||||
service_type='image',
|
||||
endpoint_type='publicURL')
|
||||
except keystoneclient.exceptions.EndpointNotFound:
|
||||
LOG.warning('Can not initialize glance client')
|
||||
return None
|
||||
return glanceclient.client.Client(version, endpoint=endpoint,
|
||||
token=keystone.auth_token)
|
||||
|
||||
def _get_volume_client(self, username=None, password=None,
|
||||
tenant_name=None):
|
||||
if not username:
|
||||
|
@ -311,6 +334,20 @@ class OfficialClientTest(fuel_health.test.TestCase):
|
|||
|
||||
return volume
|
||||
|
||||
def _create_snapshot(self, client, volume_id, expected_state=None,
|
||||
**kwargs):
|
||||
kwargs.setdefault('display_name', rand_name('ostf-test-volume'))
|
||||
snapshot = client.volume_snapshots.create(volume_id, **kwargs)
|
||||
self.set_resource(kwargs['display_name'], snapshot)
|
||||
if expected_state:
|
||||
def await_state():
|
||||
if client.volume_snapshots.get(
|
||||
snapshot.id).status == expected_state:
|
||||
return True
|
||||
fuel_health.test.call_until_true(await_state, 50, 1)
|
||||
|
||||
return snapshot
|
||||
|
||||
def get_image_from_name(self):
|
||||
image_name = self.manager.config.compute.image_name
|
||||
images = [i for i in self.compute_client.images.list()
|
||||
|
|
|
@ -159,13 +159,16 @@ class CeilometerApiPlatformTests(ceilometermanager.CeilometerBaseTest):
|
|||
Scenario:
|
||||
1. Create volume.
|
||||
2. Check volume notifications.
|
||||
3. Create volume snapshot.
|
||||
4. Check volume snapshot notifications.
|
||||
Duration: 10 s.
|
||||
Deployment tags: Ceilometer
|
||||
"""
|
||||
|
||||
if (not self.config.volume.cinder_node_exist
|
||||
and not self.config.volume.ceph_exist):
|
||||
self.fail('There are no cinder nodes or ceph storage for volume')
|
||||
self.skipTest("There are no cinder nodes or "
|
||||
"ceph storage for volume")
|
||||
|
||||
fail_msg = "Creation volume failed"
|
||||
msg = "Volume was created"
|
||||
|
@ -183,6 +186,22 @@ class CeilometerApiPlatformTests(ceilometermanager.CeilometerBaseTest):
|
|||
fail_msg, msg,
|
||||
self.volume_notifications, query)
|
||||
|
||||
fail_msg = "Creation volume snapshot failed"
|
||||
msg = "Volume snapshot was created"
|
||||
|
||||
snapshot = self.verify(60, self._create_snapshot, 3,
|
||||
fail_msg, msg,
|
||||
self.volume_client,
|
||||
volume.id, 'available')
|
||||
|
||||
query = [{'field': 'resource', 'op': 'eq', 'value': snapshot.id}]
|
||||
fail_msg = "Volume snapshot notifications are not received."
|
||||
msg = "Volume snapshot notifications are received."
|
||||
|
||||
self.verify(600, self.wait_notifications, 4,
|
||||
fail_msg, msg,
|
||||
self.snapshot_notifications, query)
|
||||
|
||||
def test_check_glance_notifications(self):
|
||||
"""Ceilometer test to check get Glance notifications.
|
||||
Target component: Ceilometer
|
||||
|
@ -192,8 +211,8 @@ class CeilometerApiPlatformTests(ceilometermanager.CeilometerBaseTest):
|
|||
Duration: 5 s.
|
||||
Deployment tags: Ceilometer
|
||||
"""
|
||||
query = [{'field': 'resource', 'op': 'eq',
|
||||
'value': self.get_image_from_name()}]
|
||||
image = self.glance_helper()
|
||||
query = [{'field': 'resource', 'op': 'eq', 'value': image.id}]
|
||||
|
||||
fail_msg = "Glance notifications are not received."
|
||||
msg = "Glance notifications are received."
|
||||
|
|
|
@ -6,6 +6,7 @@ python-novaclient>=2.17.0
|
|||
python-neutronclient>=2.3.6,<3
|
||||
python-heatclient>=0.2.9
|
||||
python-saharaclient>=0.6.0
|
||||
python-glanceclient>=0.14.0
|
||||
paramiko>=1.10.1
|
||||
requests>=1.2.3
|
||||
unittest2>=0.5.1
|
||||
|
|
Loading…
Reference in New Issue