Chandan Kumar | 6f67e37 | 2016-05-02 10:19:22 +0000 | [diff] [blame] | 1 | # Copyright 2015 |
| 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
Chandan Kumar | 6f67e37 | 2016-05-02 10:19:22 +0000 | [diff] [blame] | 16 | import os |
Alan Bishop | 89823d9 | 2022-09-28 09:06:19 -0700 | [diff] [blame] | 17 | import sys |
Chandan Kumar | 6f67e37 | 2016-05-02 10:19:22 +0000 | [diff] [blame] | 18 | |
Chandan Kumar | 6f67e37 | 2016-05-02 10:19:22 +0000 | [diff] [blame] | 19 | from tempest import config |
| 20 | from tempest.test_discover import plugins |
| 21 | |
Sean McGinnis | cf556b5 | 2018-01-24 15:36:06 -0600 | [diff] [blame] | 22 | from cinder_tempest_plugin import config as project_config |
| 23 | |
Chandan Kumar | 6f67e37 | 2016-05-02 10:19:22 +0000 | [diff] [blame] | 24 | |
| 25 | class CinderTempestPlugin(plugins.TempestPlugin): |
| 26 | def load_tests(self): |
Sean McGinnis | cf556b5 | 2018-01-24 15:36:06 -0600 | [diff] [blame] | 27 | """Provides information to load the plugin tests. |
| 28 | |
| 29 | :return: A tuple with the first value being the test dir and the |
| 30 | second being the top level dir. |
| 31 | """ |
Chandan Kumar | 6f67e37 | 2016-05-02 10:19:22 +0000 | [diff] [blame] | 32 | base_path = os.path.split(os.path.dirname( |
Sean McGinnis | cf556b5 | 2018-01-24 15:36:06 -0600 | [diff] [blame] | 33 | os.path.abspath(__file__)))[0] |
Chandan Kumar | 75511e3 | 2018-01-22 12:52:00 +0530 | [diff] [blame] | 34 | test_dir = "cinder_tempest_plugin" |
Chandan Kumar | 6f67e37 | 2016-05-02 10:19:22 +0000 | [diff] [blame] | 35 | full_test_dir = os.path.join(base_path, test_dir) |
| 36 | return full_test_dir, base_path |
| 37 | |
| 38 | def register_opts(self, conf): |
Sean McGinnis | cf556b5 | 2018-01-24 15:36:06 -0600 | [diff] [blame] | 39 | """Adds additional configuration options to tempest. |
| 40 | |
| 41 | This method will be run for the plugin during the register_opts() |
| 42 | function in tempest.config |
| 43 | |
| 44 | :param conf: The conf object that can be used to register additional |
| 45 | options. |
| 46 | """ |
| 47 | config.register_opt_group(conf, config.volume_feature_group, |
| 48 | project_config.cinder_option) |
Chandan Kumar | 6f67e37 | 2016-05-02 10:19:22 +0000 | [diff] [blame] | 49 | |
Alan Bishop | 89823d9 | 2022-09-28 09:06:19 -0700 | [diff] [blame] | 50 | # Define the 'barbican' service_available option, but only if the |
| 51 | # barbican_tempest_plugin isn't present. It also defines the option, |
| 52 | # and we need to avoid a duplicate option registration. |
| 53 | if 'barbican_tempest_plugin' not in sys.modules: |
| 54 | config.register_opt_group(conf, config.service_available_group, |
| 55 | project_config.barbican_service_option) |
Alan Bishop | 40104c7 | 2022-08-09 14:00:57 -0700 | [diff] [blame] | 56 | |
Chandan Kumar | 6f67e37 | 2016-05-02 10:19:22 +0000 | [diff] [blame] | 57 | def get_opt_lists(self): |
Sean McGinnis | cf556b5 | 2018-01-24 15:36:06 -0600 | [diff] [blame] | 58 | """Get a list of options for sample config generation. |
| 59 | |
| 60 | :return: A list of tuples with the group name and options in that |
| 61 | group. |
| 62 | """ |
Alan Bishop | 89823d9 | 2022-09-28 09:06:19 -0700 | [diff] [blame] | 63 | opt_lists = [ |
Sean McGinnis | cf556b5 | 2018-01-24 15:36:06 -0600 | [diff] [blame] | 64 | (config.volume_feature_group.name, project_config.cinder_option), |
Patrick East | 9b434d1 | 2016-08-12 17:23:19 -0700 | [diff] [blame] | 65 | ] |
Alan Bishop | 89823d9 | 2022-09-28 09:06:19 -0700 | [diff] [blame] | 66 | |
| 67 | if 'barbican_tempest_plugin' not in sys.modules: |
| 68 | opt_lists.append((config.service_available_group.name, |
| 69 | project_config.barbican_service_option)) |
| 70 | |
| 71 | return opt_lists |