blob: 5d170e55660474814ced5ee85310ffae943564c0 [file] [log] [blame]
Chandan Kumar6f67e372016-05-02 10:19:22 +00001# 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 Kumar6f67e372016-05-02 10:19:22 +000016import os
Alan Bishop89823d92022-09-28 09:06:19 -070017import sys
Chandan Kumar6f67e372016-05-02 10:19:22 +000018
Chandan Kumar6f67e372016-05-02 10:19:22 +000019from tempest import config
20from tempest.test_discover import plugins
21
Sean McGinniscf556b52018-01-24 15:36:06 -060022from cinder_tempest_plugin import config as project_config
23
Chandan Kumar6f67e372016-05-02 10:19:22 +000024
25class CinderTempestPlugin(plugins.TempestPlugin):
26 def load_tests(self):
Sean McGinniscf556b52018-01-24 15:36:06 -060027 """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 Kumar6f67e372016-05-02 10:19:22 +000032 base_path = os.path.split(os.path.dirname(
Sean McGinniscf556b52018-01-24 15:36:06 -060033 os.path.abspath(__file__)))[0]
Chandan Kumar75511e32018-01-22 12:52:00 +053034 test_dir = "cinder_tempest_plugin"
Chandan Kumar6f67e372016-05-02 10:19:22 +000035 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 McGinniscf556b52018-01-24 15:36:06 -060039 """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 Kumar6f67e372016-05-02 10:19:22 +000049
Alan Bishop89823d92022-09-28 09:06:19 -070050 # 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 Bishop40104c72022-08-09 14:00:57 -070056
Chandan Kumar6f67e372016-05-02 10:19:22 +000057 def get_opt_lists(self):
Sean McGinniscf556b52018-01-24 15:36:06 -060058 """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 Bishop89823d92022-09-28 09:06:19 -070063 opt_lists = [
Sean McGinniscf556b52018-01-24 15:36:06 -060064 (config.volume_feature_group.name, project_config.cinder_option),
Patrick East9b434d12016-08-12 17:23:19 -070065 ]
Alan Bishop89823d92022-09-28 09:06:19 -070066
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