blob: c4614c6934d85d357c4e121a985089aa0704dcd9 [file] [log] [blame]
Yassine Lamgarchal05638762013-12-27 20:10:32 +01001# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
vrovachev95a16cc2014-02-04 15:29:48 +040013from tempest.common.utils import data_utils
Yassine Lamgarchal05638762013-12-27 20:10:32 +010014from tempest import config
vrovachev95a16cc2014-02-04 15:29:48 +040015from tempest import exceptions
Yassine Lamgarchal05638762013-12-27 20:10:32 +010016import tempest.test
17
18CONF = config.CONF
19
20
21class BaseTelemetryTest(tempest.test.BaseTestCase):
22
23 """Base test case class for all Telemetry API tests."""
24
25 @classmethod
26 def setUpClass(cls):
Yassine Lamgarchal05638762013-12-27 20:10:32 +010027 if not CONF.service_available.ceilometer:
28 raise cls.skipException("Ceilometer support is required")
vrovachev95a16cc2014-02-04 15:29:48 +040029 super(BaseTelemetryTest, cls).setUpClass()
30 os = cls.get_client_manager()
31 cls.telemetry_client = os.telemetry_client
32 cls.alarm_ids = []
33
34 @classmethod
35 def create_alarm(cls, **kwargs):
36 resp, body = cls.telemetry_client.create_alarm(
37 name=data_utils.rand_name('telemetry_alarm'),
38 type='threshold', **kwargs)
39 if resp['status'] == '201':
40 cls.alarm_ids.append(body['alarm_id'])
41 return resp, body
42
43 @classmethod
44 def tearDownClass(cls):
45 for alarm_id in cls.alarm_ids:
46 try:
47 cls.telemetry_client.delete_alarm(alarm_id)
48 except exceptions.NotFound:
49 pass
50 cls.clear_isolated_creds()
51 super(BaseTelemetryTest, cls).tearDownClass()