Kiall Mac Innes | 25fb29e | 2016-04-07 08:07:04 +0100 | [diff] [blame] | 1 | # Copyright 2016 NEC Corporation. All rights reserved. |
| 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. |
| 14 | |
| 15 | import os |
| 16 | |
| 17 | from tempest import config |
| 18 | from tempest.test_discover import plugins |
| 19 | |
| 20 | from designate_tempest_plugin import config as project_config |
Michael Johnson | df9fda1 | 2021-07-09 16:39:08 +0000 | [diff] [blame] | 21 | from designate_tempest_plugin.services.dns import v2 as dns_v2_services |
Kiall Mac Innes | 25fb29e | 2016-04-07 08:07:04 +0100 | [diff] [blame] | 22 | |
| 23 | |
| 24 | class DesignateTempestPlugin(plugins.TempestPlugin): |
| 25 | """ |
| 26 | A DesignateTempestPlugin class provides the basic hooks for an external |
| 27 | plugin to provide tempest the necessary information to run the plugin. |
| 28 | """ |
| 29 | def load_tests(self): |
| 30 | """ |
| 31 | Method to return the information necessary to load the tests in the |
| 32 | plugin. |
| 33 | |
| 34 | :return: a tuple with the first value being the test_dir and the second |
| 35 | being the top_level |
| 36 | :return type: tuple |
| 37 | """ |
| 38 | base_path = os.path.split(os.path.dirname( |
| 39 | os.path.abspath(__file__)))[0] |
| 40 | test_dir = "designate_tempest_plugin/tests" |
| 41 | full_test_dir = os.path.join(base_path, test_dir) |
| 42 | return full_test_dir, base_path |
| 43 | |
| 44 | def register_opts(self, conf): |
| 45 | """ |
| 46 | Add additional configuration options to tempest. |
| 47 | |
| 48 | This method will be run for the plugin during the register_opts() |
| 49 | function in tempest.config |
| 50 | |
| 51 | Parameters: |
| 52 | conf (ConfigOpts): The conf object that can be used to register |
| 53 | additional options on. |
| 54 | """ |
Kiall Mac Innes | 8ae796c | 2016-04-21 13:47:25 +0100 | [diff] [blame] | 55 | config.register_opt_group(conf, project_config.service_available_group, |
| 56 | project_config.ServiceAvailableGroup) |
Kiall Mac Innes | 25fb29e | 2016-04-07 08:07:04 +0100 | [diff] [blame] | 57 | config.register_opt_group(conf, project_config.dns_group, |
| 58 | project_config.DnsGroup) |
Kiall Mac Innes | 8ae796c | 2016-04-21 13:47:25 +0100 | [diff] [blame] | 59 | config.register_opt_group(conf, project_config.dns_feature_group, |
| 60 | project_config.DnsFeatureGroup) |
Michael Johnson | a3a2363 | 2021-07-21 21:55:32 +0000 | [diff] [blame] | 61 | config.register_opt_group(conf, project_config.enforce_scope_group, |
| 62 | project_config.EnforceScopeGroup) |
Kiall Mac Innes | 25fb29e | 2016-04-07 08:07:04 +0100 | [diff] [blame] | 63 | |
| 64 | def get_opt_lists(self): |
| 65 | """ |
| 66 | Get a list of options for sample config generation |
| 67 | |
| 68 | Return option_list: A list of tuples with the group name |
| 69 | and options in that group. |
| 70 | Return type: list |
| 71 | """ |
Kiall Mac Innes | 8ae796c | 2016-04-21 13:47:25 +0100 | [diff] [blame] | 72 | return [ |
| 73 | (project_config.service_available_group.name, |
| 74 | project_config.ServiceAvailableGroup), |
| 75 | (project_config.dns_group.name, |
| 76 | project_config.DnsGroup), |
| 77 | (project_config.dns_feature_group.name, |
| 78 | project_config.DnsFeatureGroup), |
| 79 | ] |
Andrea Frittoli | 0eeb290 | 2017-10-26 15:39:27 +0200 | [diff] [blame] | 80 | |
| 81 | def get_service_clients(self): |
| 82 | dns_config = config.service_client_config('dns') |
| 83 | admin_params = { |
| 84 | 'name': 'dns_admin', |
| 85 | 'service_version': 'dns.admin', |
| 86 | 'module_path': 'designate_tempest_plugin.services.dns.admin', |
| 87 | 'client_names': ['QuotasClient'] |
| 88 | } |
| 89 | v2_params = { |
| 90 | 'name': 'dns_v2', |
| 91 | 'service_version': 'dns.v2', |
| 92 | 'module_path': 'designate_tempest_plugin.services.dns.v2', |
Michael Johnson | df9fda1 | 2021-07-09 16:39:08 +0000 | [diff] [blame] | 93 | 'client_names': dns_v2_services.__all__ |
Andrea Frittoli | 0eeb290 | 2017-10-26 15:39:27 +0200 | [diff] [blame] | 94 | } |
| 95 | admin_params.update(dns_config) |
| 96 | v2_params.update(dns_config) |
| 97 | return [admin_params, v2_params] |