Kiall Mac Innes | 25fb29e | 2016-04-07 08:07:04 +0100 | [diff] [blame] | 1 | # Copyright 2016 Hewlett Packard Enterprise Development Company, L.P. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
sonu.kumar | d8471de | 2016-04-14 19:20:17 +0900 | [diff] [blame] | 14 | import six |
Kiall Mac Innes | 25fb29e | 2016-04-07 08:07:04 +0100 | [diff] [blame] | 15 | from tempest import test |
Kiall Mac Innes | 8ae796c | 2016-04-21 13:47:25 +0100 | [diff] [blame] | 16 | from tempest import config |
Kiall Mac Innes | 25fb29e | 2016-04-07 08:07:04 +0100 | [diff] [blame] | 17 | |
| 18 | from designate_tempest_plugin import clients |
| 19 | |
| 20 | |
Kiall Mac Innes | 8ae796c | 2016-04-21 13:47:25 +0100 | [diff] [blame] | 21 | CONF = config.CONF |
| 22 | |
| 23 | |
Kiall Mac Innes | 25fb29e | 2016-04-07 08:07:04 +0100 | [diff] [blame] | 24 | class BaseDnsTest(test.BaseTestCase): |
Kiall Mac Innes | 560c89b | 2016-04-13 11:21:56 +0100 | [diff] [blame] | 25 | """Base class for DNS tests.""" |
Kiall Mac Innes | 25fb29e | 2016-04-07 08:07:04 +0100 | [diff] [blame] | 26 | |
Kiall Mac Innes | 25fb29e | 2016-04-07 08:07:04 +0100 | [diff] [blame] | 27 | # NOTE(andreaf) credentials holds a list of the credentials to be allocated |
| 28 | # at class setup time. Credential types can be 'primary', 'alt', 'admin' or |
| 29 | # a list of roles - the first element of the list being a label, and the |
| 30 | # rest the actual roles. |
| 31 | # NOTE(kiall) primary will result in a manager @ cls.os, alt will have |
| 32 | # cls.os_alt, and admin will have cls.os_adm. |
Kiall Mac Innes | 560c89b | 2016-04-13 11:21:56 +0100 | [diff] [blame] | 33 | # NOTE(kiall) We should default to only primary, and request additional |
| 34 | # credentials in the tests that require them. |
| 35 | credentials = ['primary'] |
sonu.kumar | d8471de | 2016-04-14 19:20:17 +0900 | [diff] [blame] | 36 | |
Kiall Mac Innes | 8ae796c | 2016-04-21 13:47:25 +0100 | [diff] [blame] | 37 | @classmethod |
| 38 | def skip_checks(cls): |
| 39 | super(BaseDnsTest, cls).skip_checks() |
| 40 | |
| 41 | if not CONF.service_available.designate: |
| 42 | skip_msg = ("%s skipped as designate is not available" |
| 43 | % cls.__name__) |
| 44 | raise cls.skipException(skip_msg) |
| 45 | |
sonu.kumar | d8471de | 2016-04-14 19:20:17 +0900 | [diff] [blame] | 46 | def assertExpected(self, expected, actual, excluded_keys): |
| 47 | for key, value in six.iteritems(expected): |
| 48 | if key not in excluded_keys: |
| 49 | self.assertIn(key, actual) |
| 50 | self.assertEqual(value, actual[key], key) |
Kiall Mac Innes | 8ae796c | 2016-04-21 13:47:25 +0100 | [diff] [blame] | 51 | |
| 52 | |
| 53 | class BaseDnsV1Test(BaseDnsTest): |
| 54 | """Base class for DNS V1 API tests.""" |
| 55 | |
| 56 | # Use the Designate V1 Client Manager |
| 57 | client_manager = clients.ManagerV1 |
| 58 | |
| 59 | @classmethod |
| 60 | def skip_checks(cls): |
| 61 | super(BaseDnsV1Test, cls).skip_checks() |
| 62 | |
| 63 | if not CONF.dns_feature_enabled.api_v1: |
| 64 | skip_msg = ("%s skipped as designate v1 API is not available" |
| 65 | % cls.__name__) |
| 66 | raise cls.skipException(skip_msg) |
| 67 | |
| 68 | |
| 69 | class BaseDnsV2Test(BaseDnsTest): |
| 70 | """Base class for DNS V2 API tests.""" |
| 71 | |
| 72 | # Use the Designate V2 Client Manager |
| 73 | client_manager = clients.ManagerV2 |
| 74 | |
| 75 | @classmethod |
| 76 | def skip_checks(cls): |
| 77 | super(BaseDnsV2Test, cls).skip_checks() |
| 78 | |
| 79 | if not CONF.dns_feature_enabled.api_v2: |
| 80 | skip_msg = ("%s skipped as designate v2 API is not available" |
| 81 | % cls.__name__) |
| 82 | raise cls.skipException(skip_msg) |
| 83 | |
| 84 | |
| 85 | class BaseDnsAdminTest(BaseDnsTest): |
| 86 | """Base class for DNS Admin API tests.""" |
| 87 | |
Graham Hayes | c811498 | 2016-07-04 17:46:08 +0100 | [diff] [blame^] | 88 | # Use the Designate Admin Client Manager |
| 89 | client_manager = clients.ManagerAdmin |
Kiall Mac Innes | 8ae796c | 2016-04-21 13:47:25 +0100 | [diff] [blame] | 90 | |
| 91 | @classmethod |
| 92 | def skip_checks(cls): |
| 93 | super(BaseDnsAdminTest, cls).skip_checks() |
| 94 | if not CONF.dns_feature_enabled.api_admin: |
| 95 | skip_msg = ("%s skipped as designate admin API is not available" |
| 96 | % cls.__name__) |
| 97 | raise cls.skipException(skip_msg) |