Add basic Ceilometer alarm test
This sends a manual ceilometer sample to trigger the alarm,
then confirms that the autoscale policy/group reacts correctly.
Note: this doesn't used ScenarioBaseTest as it skips the test
unnecessarily on unused images and networks.
Change-Id: I5c842779d90497ba88df66bbfd8f447679645192
Depends-On: Ib3795bcca9d5ec3d68c6443a9854dbc56118ca40
diff --git a/common/clients.py b/common/clients.py
index 1ba3a21..6042456 100644
--- a/common/clients.py
+++ b/common/clients.py
@@ -12,6 +12,7 @@
import os
+import ceilometerclient.client
import cinderclient.client
import heatclient.client
import keystoneclient.exceptions
@@ -30,6 +31,7 @@
CINDERCLIENT_VERSION = '1'
HEATCLIENT_VERSION = '1'
NOVACLIENT_VERSION = '2'
+ CEILOMETER_VERSION = '2'
def __init__(self, conf):
self.conf = conf
@@ -39,6 +41,7 @@
self.network_client = self._get_network_client()
self.volume_client = self._get_volume_client()
self.object_client = self._get_object_client()
+ self.metering_client = self._get_metering_client()
def _get_orchestration_client(self):
region = self.conf.region
@@ -136,3 +139,27 @@
'insecure': dscv,
}
return swiftclient.client.Connection(**args)
+
+ def _get_metering_client(self):
+ dscv = self.conf.disable_ssl_certificate_validation
+
+ keystone = self._get_identity_client()
+ endpoint = keystone.service_catalog.url_for(
+ attr='region',
+ filter_value=self.conf.region,
+ service_type='metering',
+ endpoint_type='publicURL')
+
+ args = {
+ 'username': self.conf.username,
+ 'password': self.conf.password,
+ 'tenant_name': self.conf.tenant_name,
+ 'auth_url': self.conf.auth_url,
+ 'insecure': dscv,
+ 'region_name': self.conf.region,
+ 'endpoint_type': 'publicURL',
+ 'service_type': 'metering',
+ }
+
+ return ceilometerclient.client.Client(self.CEILOMETER_VERSION,
+ endpoint, **args)