blob: e9583cdde10f81275e2ca534786b0e3609deae53 [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
lkuchlanec9aee22025-05-15 15:52:41 +030050 config.register_opt_group(conf, config.volume_group,
51 project_config.concurrency_option)
52
Alan Bishop89823d92022-09-28 09:06:19 -070053 # Define the 'barbican' service_available option, but only if the
54 # barbican_tempest_plugin isn't present. It also defines the option,
55 # and we need to avoid a duplicate option registration.
56 if 'barbican_tempest_plugin' not in sys.modules:
57 config.register_opt_group(conf, config.service_available_group,
58 project_config.barbican_service_option)
Alan Bishop40104c72022-08-09 14:00:57 -070059
Chandan Kumar6f67e372016-05-02 10:19:22 +000060 def get_opt_lists(self):
Sean McGinniscf556b52018-01-24 15:36:06 -060061 """Get a list of options for sample config generation.
62
63 :return: A list of tuples with the group name and options in that
64 group.
65 """
Alan Bishop89823d92022-09-28 09:06:19 -070066 opt_lists = [
Sean McGinniscf556b52018-01-24 15:36:06 -060067 (config.volume_feature_group.name, project_config.cinder_option),
lkuchlanec9aee22025-05-15 15:52:41 +030068 (config.volume_group.name, project_config.concurrency_option),
Patrick East9b434d12016-08-12 17:23:19 -070069 ]
Alan Bishop89823d92022-09-28 09:06:19 -070070
71 if 'barbican_tempest_plugin' not in sys.modules:
72 opt_lists.append((config.service_available_group.name,
73 project_config.barbican_service_option))
74
75 return opt_lists
Luigi Toscano545a8872024-09-20 15:24:47 +020076
77 def get_service_clients(self):
78 volumes_config = config.service_client_config('volume')
79
80 consistencygroups_params = {
81 'name': 'consistencygroups_v3',
82 'service_version': 'consistencygroups.v3',
83 'module_path': 'cinder_tempest_plugin.services.'
84 'consistencygroups_client',
85 'client_names': ['ConsistencyGroupsClient'],
86 }
87 consistencygroups_params.update(volumes_config)
88
89 volumerevert_params = {
90 'name': 'volume_revert_v3',
91 'service_version': 'volume_revert.v3',
92 'module_path': 'cinder_tempest_plugin.services.'
93 'volume_revert_client',
94 'client_names': ['VolumeRevertClient'],
95 }
96 volumerevert_params.update(volumes_config)
97
98 return [consistencygroups_params, volumerevert_params]