Codebase list cinder-tempest-plugin / 545a887
Port to the tempest stable plugin interface (clients) This is one of the last tempest plugins which was still not using the proper interface to define its clients. (Hopefully) no behavioral changes, just refactoring. Change-Id: Ia57c771186cd1bf283f30b58007395d33aefa4a9 Luigi Toscano 1 year, 8 months ago
6 changed file(s) with 98 addition(s) and 66 deletion(s). Raw diff Collapse all Expand all
1919 from tempest.lib import decorators
2020
2121 from cinder_tempest_plugin.api.volume import base
22 from cinder_tempest_plugin import cinder_clients
2322
2423 CONF = config.CONF
2524
2625
2726 class ConsistencyGroupsV2Test(base.BaseVolumeAdminTest):
28 @classmethod
29 def setup_clients(cls):
30 super(ConsistencyGroupsV2Test, cls).setup_clients()
31
32 manager = cinder_clients.Manager(cls.os_admin)
33 cls.consistencygroups_adm_client = manager.consistencygroups_adm_client
3427
3528 @classmethod
3629 def skip_checks(cls):
4033 "feature disabled")
4134
4235 def _delete_consistencygroup(self, cg_id):
43 self.consistencygroups_adm_client.delete_consistencygroup(cg_id)
36 self.admin_consistencygroups_client.delete_consistencygroup(cg_id)
4437 vols = self.admin_volume_client.list_volumes(detail=True)['volumes']
4538 for vol in vols:
4639 if vol['consistencygroup_id'] == cg_id:
4740 self.admin_volume_client.wait_for_resource_deletion(vol['id'])
48 self.consistencygroups_adm_client.wait_for_consistencygroup_deletion(
41 self.admin_consistencygroups_client.wait_for_consistencygroup_deletion(
4942 cg_id)
5043
5144 def _delete_cgsnapshot(self, cgsnapshot_id, cg_id):
52 self.consistencygroups_adm_client.delete_cgsnapshot(cgsnapshot_id)
45 self.admin_consistencygroups_client.delete_cgsnapshot(cgsnapshot_id)
5346 vols = self.admin_volume_client.list_volumes(detail=True)['volumes']
5447 snapshots = self.os_admin.snapshots_v2_client.list_snapshots(
5548 detail=True)['snapshots']
5952 vol['id'] == snap['volume_id']):
6053 (self.snapshots_client.
6154 wait_for_resource_deletion(snap['id']))
62 self.consistencygroups_adm_client.wait_for_cgsnapshot_deletion(
55 self.admin_consistencygroups_client.wait_for_cgsnapshot_deletion(
6356 cgsnapshot_id)
6457
6558 @decorators.idempotent_id('3fe776ba-ec1f-4e6c-8d78-4b14c3a7fc44')
7265 # Create CG
7366 cg_name = data_utils.rand_name('CG')
7467 create_consistencygroup = (
75 self.consistencygroups_adm_client.create_consistencygroup)
76 cg = create_consistencygroup(volume_type['id'],
77 name=cg_name)['consistencygroup']
78 self.consistencygroups_adm_client.wait_for_consistencygroup_status(
68 self.admin_consistencygroups_client.create_consistencygroup)
69 cg = create_consistencygroup(volume_type['id'],
70 name=cg_name)['consistencygroup']
71 self.admin_consistencygroups_client.wait_for_consistencygroup_status(
7972 cg['id'], 'available')
8073 self.assertEqual(cg_name, cg['name'])
8174
9184 volume['id'], 'available')
9285
9386 # Get a given CG
94 cg = self.consistencygroups_adm_client.show_consistencygroup(
87 cg = self.admin_consistencygroups_client.show_consistencygroup(
9588 cg['id'])['consistencygroup']
9689 self.assertEqual(cg_name, cg['name'])
9790
9891 # Get all CGs with detail
99 cgs = self.consistencygroups_adm_client.list_consistencygroups(
92 cgs = self.admin_consistencygroups_client.list_consistencygroups(
10093 detail=True)['consistencygroups']
10194 self.assertIn((cg['name'], cg['id']),
10295 [(m['name'], m['id']) for m in cgs])
116109 # Create CG
117110 cg_name = data_utils.rand_name('CG')
118111 create_consistencygroup = (
119 self.consistencygroups_adm_client.create_consistencygroup)
120 cg = create_consistencygroup(volume_type['id'],
121 name=cg_name)['consistencygroup']
122 self.consistencygroups_adm_client.wait_for_consistencygroup_status(
112 self.admin_consistencygroups_client.create_consistencygroup)
113 cg = create_consistencygroup(volume_type['id'],
114 name=cg_name)['consistencygroup']
115 self.admin_consistencygroups_client.wait_for_consistencygroup_status(
123116 cg['id'], 'available')
124117 self.assertEqual(cg_name, cg['name'])
125118
136129 # Create cgsnapshot
137130 cgsnapshot_name = data_utils.rand_name('cgsnapshot')
138131 create_cgsnapshot = (
139 self.consistencygroups_adm_client.create_cgsnapshot)
132 self.admin_consistencygroups_client.create_cgsnapshot)
140133 cgsnapshot = create_cgsnapshot(cg['id'],
141134 name=cgsnapshot_name)['cgsnapshot']
142 self.consistencygroups_adm_client.wait_for_cgsnapshot_status(
135 self.admin_consistencygroups_client.wait_for_cgsnapshot_status(
143136 cgsnapshot['id'], 'available')
144137 self.assertEqual(cgsnapshot_name, cgsnapshot['name'])
145138 snapshots = self.os_admin.snapshots_v2_client.list_snapshots(
151144 snap['id'], 'available')
152145
153146 # Get a given CG snapshot
154 cgsnapshot = self.consistencygroups_adm_client.show_cgsnapshot(
147 cgsnapshot = self.admin_consistencygroups_client.show_cgsnapshot(
155148 cgsnapshot['id'])['cgsnapshot']
156149 self.assertEqual(cgsnapshot_name, cgsnapshot['name'])
157150
158151 # Get all CG snapshots with detail
159 cgsnapshots = self.consistencygroups_adm_client.list_cgsnapshots(
152 cgsnapshots = self.admin_consistencygroups_client.list_cgsnapshots(
160153 detail=True)['cgsnapshots']
161154 self.assertIn((cgsnapshot['name'], cgsnapshot['id']),
162155 [(m['name'], m['id']) for m in cgsnapshots])
176169 # Create CG
177170 cg_name = data_utils.rand_name('CG')
178171 create_consistencygroup = (
179 self.consistencygroups_adm_client.create_consistencygroup)
180 cg = create_consistencygroup(volume_type['id'],
181 name=cg_name)['consistencygroup']
182 self.consistencygroups_adm_client.wait_for_consistencygroup_status(
172 self.admin_consistencygroups_client.create_consistencygroup)
173 cg = create_consistencygroup(volume_type['id'],
174 name=cg_name)['consistencygroup']
175 self.admin_consistencygroups_client.wait_for_consistencygroup_status(
183176 cg['id'], 'available')
184177 self.assertEqual(cg_name, cg['name'])
185178
196189 # Create cgsnapshot
197190 cgsnapshot_name = data_utils.rand_name('cgsnapshot')
198191 create_cgsnapshot = (
199 self.consistencygroups_adm_client.create_cgsnapshot)
192 self.admin_consistencygroups_client.create_cgsnapshot)
200193 cgsnapshot = create_cgsnapshot(cg['id'],
201194 name=cgsnapshot_name)['cgsnapshot']
202 self.consistencygroups_adm_client.wait_for_cgsnapshot_status(
195 self.admin_consistencygroups_client.wait_for_cgsnapshot_status(
203196 cgsnapshot['id'], 'available')
204197 self.assertEqual(cgsnapshot_name, cgsnapshot['name'])
205198 snapshots = self.snapshots_client.list_snapshots(
212205 # Create CG from CG snapshot
213206 cg_name2 = data_utils.rand_name('CG_from_snap')
214207 create_consistencygroup2 = (
215 self.consistencygroups_adm_client.create_consistencygroup_from_src)
208 self.admin_consistencygroups_client.
209 create_consistencygroup_from_src
210 )
216211 cg2 = create_consistencygroup2(cgsnapshot_id=cgsnapshot['id'],
217212 name=cg_name2)['consistencygroup']
218 self.consistencygroups_adm_client.wait_for_consistencygroup_status(
213 self.admin_consistencygroups_client.wait_for_consistencygroup_status(
219214 cg2['id'], 'available')
220215 self.assertEqual(cg_name2, cg2['name'])
221216 vols = self.admin_volume_client.list_volumes(
241236 # Create CG
242237 cg_name = data_utils.rand_name('CG')
243238 create_consistencygroup = (
244 self.consistencygroups_adm_client.create_consistencygroup)
245 cg = create_consistencygroup(volume_type['id'],
246 name=cg_name)['consistencygroup']
247 self.consistencygroups_adm_client.wait_for_consistencygroup_status(
239 self.admin_consistencygroups_client.create_consistencygroup)
240 cg = create_consistencygroup(volume_type['id'],
241 name=cg_name)['consistencygroup']
242 self.admin_consistencygroups_client.wait_for_consistencygroup_status(
248243 cg['id'], 'available')
249244 self.assertEqual(cg_name, cg['name'])
250245
261256 # Create CG from CG
262257 cg_name2 = data_utils.rand_name('CG_from_cg')
263258 create_consistencygroup2 = (
264 self.consistencygroups_adm_client.create_consistencygroup_from_src)
259 self.admin_consistencygroups_client.
260 create_consistencygroup_from_src
261 )
265262 cg2 = create_consistencygroup2(source_cgid=cg['id'],
266263 name=cg_name2)['consistencygroup']
267 self.consistencygroups_adm_client.wait_for_consistencygroup_status(
264 self.admin_consistencygroups_client.wait_for_consistencygroup_status(
268265 cg2['id'], 'available')
269266 self.assertEqual(cg_name2, cg2['name'])
270267 vols = self.admin_volume_client.list_volumes(
4949 cls.backups_client = cls.os_primary.backups_client_latest
5050 cls.volumes_client = cls.os_primary.volumes_client_latest
5151 cls.snapshots_client = cls.os_primary.snapshots_client_latest
52 cls.volume_revert_client = (
53 cls.os_primary.volume_revert_v3.VolumeRevertClient()
54 )
5255
5356 @classmethod
5457 def setup_credentials(cls):
195198 cls.admin_volume_types_client = cls.os_admin.volume_types_client_latest
196199 cls.admin_backups_client = cls.os_admin.backups_client_latest
197200 cls.admin_volume_client = cls.os_admin.volumes_client_latest
201 cls.admin_consistencygroups_client = (
202 cls.os_admin.consistencygroups_v3.ConsistencyGroupsClient()
203 )
198204
199205 @classmethod
200206 def create_volume_type(cls, name=None, **kwargs):
1818 from tempest.lib import exceptions
1919
2020 from cinder_tempest_plugin.api.volume import base
21 from cinder_tempest_plugin import cinder_clients
2221
2322 CONF = config.CONF
2423
3130 super(VolumeRevertTests, cls).skip_checks()
3231 if not CONF.volume_feature_enabled.volume_revert:
3332 raise cls.skipException("Cinder volume revert feature disabled")
34
35 @classmethod
36 def setup_clients(cls):
37 super(VolumeRevertTests, cls).setup_clients()
38
39 manager = cinder_clients.Manager(cls.os_primary)
40 cls.volume_revert_client = manager.volume_revert_client
4133
4234 def setUp(self):
4335 super(VolumeRevertTests, self).setUp()
1313 # under the License.
1414
1515 from tempest import config
16
17 from cinder_tempest_plugin.services import consistencygroups_client
18 from cinder_tempest_plugin.services import volume_revert_client
16 from tempest.lib.services import clients
1917
2018 CONF = config.CONF
2119
2220
23 class Manager(object):
24 def __init__(self, base_manager):
25 params = {
26 'service': CONF.volume.catalog_type,
27 'region': CONF.volume.region or CONF.identity.region,
28 'endpoint_type': CONF.volume.endpoint_type,
29 'build_interval': CONF.volume.build_interval,
30 'build_timeout': CONF.volume.build_timeout
31 }
32 params.update(base_manager.default_params)
33 auth_provider = base_manager.auth_provider
21 class Clients(clients.ServiceClients):
22 """Tempest stable service clients and loaded plugins service clients"""
3423
35 self.consistencygroups_adm_client = (
36 consistencygroups_client.ConsistencyGroupsClient(auth_provider,
37 **params))
38 self.volume_revert_client = (
39 volume_revert_client.VolumeRevertClient(auth_provider, **params))
24 def __init__(self, credentials, service=None):
25 """Emulate the interface of Tempest's clients.Manager"""
26 # Identity settings
27 if CONF.identity.auth_version == 'v2':
28 identity_uri = CONF.identity.uri
29 else:
30 identity_uri = CONF.identity.uri_v3
31 super(Clients, self).__init__(credentials, identity_uri)
6868 project_config.barbican_service_option))
6969
7070 return opt_lists
71
72 def get_service_clients(self):
73 volumes_config = config.service_client_config('volume')
74
75 consistencygroups_params = {
76 'name': 'consistencygroups_v3',
77 'service_version': 'consistencygroups.v3',
78 'module_path': 'cinder_tempest_plugin.services.'
79 'consistencygroups_client',
80 'client_names': ['ConsistencyGroupsClient'],
81 }
82 consistencygroups_params.update(volumes_config)
83
84 volumerevert_params = {
85 'name': 'volume_revert_v3',
86 'service_version': 'volume_revert.v3',
87 'module_path': 'cinder_tempest_plugin.services.'
88 'volume_revert_client',
89 'client_names': ['VolumeRevertClient'],
90 }
91 volumerevert_params.update(volumes_config)
92
93 return [consistencygroups_params, volumerevert_params]
0 #
1 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
2 # use this file except in compliance with the License. You may obtain a copy of
3 # the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations under
11 # the License.
12
13 from cinder_tempest_plugin.services.consistencygroups_client import \
14 ConsistencyGroupsClient
15 from cinder_tempest_plugin.services.volume_revert_client import \
16 VolumeRevertClient
17
18 __all__ = [
19 'ConsistencyGroupsClient',
20 'VolumeRevertClient'
21 ]