Yassine Lamgarchal | 0563876 | 2013-12-27 20:10:32 +0100 | [diff] [blame] | 1 | # 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 | |
vrovachev | 95a16cc | 2014-02-04 15:29:48 +0400 | [diff] [blame] | 13 | from tempest.common.utils import data_utils |
Yassine Lamgarchal | 0563876 | 2013-12-27 20:10:32 +0100 | [diff] [blame] | 14 | from tempest import config |
vrovachev | 95a16cc | 2014-02-04 15:29:48 +0400 | [diff] [blame] | 15 | from tempest import exceptions |
Yassine Lamgarchal | 0563876 | 2013-12-27 20:10:32 +0100 | [diff] [blame] | 16 | import tempest.test |
| 17 | |
| 18 | CONF = config.CONF |
| 19 | |
| 20 | |
| 21 | class BaseTelemetryTest(tempest.test.BaseTestCase): |
| 22 | |
| 23 | """Base test case class for all Telemetry API tests.""" |
| 24 | |
| 25 | @classmethod |
| 26 | def setUpClass(cls): |
Yassine Lamgarchal | 0563876 | 2013-12-27 20:10:32 +0100 | [diff] [blame] | 27 | if not CONF.service_available.ceilometer: |
| 28 | raise cls.skipException("Ceilometer support is required") |
vrovachev | 95a16cc | 2014-02-04 15:29:48 +0400 | [diff] [blame] | 29 | 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() |