diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample index 9de749282e..e9e5b2eb36 100644 --- a/etc/tempest.conf.sample +++ b/etc/tempest.conf.sample @@ -1092,6 +1092,16 @@ #too_slow_to_test = true +[telemetry-feature-enabled] + +# +# From tempest.config +# + +# Runs Ceilometer event-related tests (boolean value) +#events = false + + [validation] # diff --git a/tempest/api/telemetry/base.py b/tempest/api/telemetry/base.py index cce8e2ab04..e8f8abec97 100644 --- a/tempest/api/telemetry/base.py +++ b/tempest/api/telemetry/base.py @@ -121,3 +121,27 @@ class BaseTelemetryTest(tempest.test.BaseTestCase): 'Sample for metric:%s with query:%s has not been added to the ' 'database within %d seconds' % (metric, query, CONF.compute.build_timeout)) + + +class BaseTelemetryAdminTest(BaseTelemetryTest): + """Base test case class for admin Telemetry API tests.""" + + credentials = ['primary', 'admin'] + + @classmethod + def setup_clients(cls): + super(BaseTelemetryAdminTest, cls).setup_clients() + cls.telemetry_admin_client = cls.os_adm.telemetry_client + + def await_events(self, query): + timeout = CONF.compute.build_timeout + start = timeutils.utcnow() + while timeutils.delta_seconds(start, timeutils.utcnow()) < timeout: + body = self.telemetry_admin_client.list_events(query) + if body: + return body + time.sleep(CONF.compute.build_interval) + + raise exceptions.TimeoutException( + 'Event with query:%s has not been added to the ' + 'database within %d seconds' % (query, CONF.compute.build_timeout)) diff --git a/tempest/api/telemetry/test_telemetry_notification_api.py b/tempest/api/telemetry/test_telemetry_notification_api.py index 52793c8b92..705791014e 100644 --- a/tempest/api/telemetry/test_telemetry_notification_api.py +++ b/tempest/api/telemetry/test_telemetry_notification_api.py @@ -71,3 +71,27 @@ class TelemetryNotificationAPITestJSON(base.BaseTelemetryTest): for metric in self.glance_v2_notifications: self.await_samples(metric, query) + + +class TelemetryNotificationAdminAPITestJSON(base.BaseTelemetryAdminTest): + + @classmethod + def skip_checks(cls): + super(TelemetryNotificationAdminAPITestJSON, cls).skip_checks() + if CONF.telemetry.too_slow_to_test: + raise cls.skipException("Ceilometer feature for fast work mysql " + "is disabled") + + @test.idempotent_id('29604198-8b45-4fc0-8af8-1cae4f94ebe9') + @test.services('compute') + def test_check_nova_notification_event_and_meter(self): + + body = self.create_server() + + if CONF.telemetry_feature_enabled.events: + query = ('instance_id', 'eq', body['id']) + self.await_events(query) + + query = ('resource', 'eq', body['id']) + for metric in self.nova_notifications: + self.await_samples(metric, query) diff --git a/tempest/config.py b/tempest/config.py index 5628ec9c38..3a2906c8bf 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -826,6 +826,16 @@ TelemetryGroup = [ ] +telemetry_feature_group = cfg.OptGroup(name='telemetry-feature-enabled', + title='Enabled Ceilometer Features') + +TelemetryFeaturesGroup = [ + cfg.BoolOpt('events', + default=False, + help="Runs Ceilometer event-related tests"), +] + + dashboard_group = cfg.OptGroup(name="dashboard", title="Dashboard options") @@ -1157,6 +1167,7 @@ _opts = [ (database_group, DatabaseGroup), (orchestration_group, OrchestrationGroup), (telemetry_group, TelemetryGroup), + (telemetry_feature_group, TelemetryFeaturesGroup), (dashboard_group, DashboardGroup), (data_processing_group, DataProcessingGroup), (data_processing_feature_group, DataProcessingFeaturesGroup), @@ -1219,6 +1230,7 @@ class TempestConfigPrivate(object): self.orchestration = _CONF.orchestration self.messaging = _CONF.messaging self.telemetry = _CONF.telemetry + self.telemetry_feature_enabled = _CONF['telemetry-feature-enabled'] self.dashboard = _CONF.dashboard self.data_processing = _CONF.data_processing self.data_processing_feature_enabled = _CONF[ diff --git a/tempest/services/telemetry/json/telemetry_client.py b/tempest/services/telemetry/json/telemetry_client.py index 554f574681..b89b9e3e15 100644 --- a/tempest/services/telemetry/json/telemetry_client.py +++ b/tempest/services/telemetry/json/telemetry_client.py @@ -84,6 +84,10 @@ class TelemetryClientJSON(service_client.ServiceClient): uri = '%s/meters/%s' % (self.uri_prefix, meter_id) return self._helper_list(uri, query) + def list_events(self, query=None): + uri = '%s/events' % self.uri_prefix + return self._helper_list(uri, query) + def show_resource(self, resource_id): uri = '%s/resources/%s' % (self.uri_prefix, resource_id) resp, body = self.get(uri)