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
diff --git a/cinder_tempest_plugin/api/volume/admin/test_consistencygroups.py b/cinder_tempest_plugin/api/volume/admin/test_consistencygroups.py
index 42c78f1..191ecb2 100644
--- a/cinder_tempest_plugin/api/volume/admin/test_consistencygroups.py
+++ b/cinder_tempest_plugin/api/volume/admin/test_consistencygroups.py
@@ -20,18 +20,11 @@
from tempest.lib import decorators
from cinder_tempest_plugin.api.volume import base
-from cinder_tempest_plugin import cinder_clients
CONF = config.CONF
class ConsistencyGroupsV2Test(base.BaseVolumeAdminTest):
- @classmethod
- def setup_clients(cls):
- super(ConsistencyGroupsV2Test, cls).setup_clients()
-
- manager = cinder_clients.Manager(cls.os_admin)
- cls.consistencygroups_adm_client = manager.consistencygroups_adm_client
@classmethod
def skip_checks(cls):
@@ -41,16 +34,16 @@
"feature disabled")
def _delete_consistencygroup(self, cg_id):
- self.consistencygroups_adm_client.delete_consistencygroup(cg_id)
+ self.admin_consistencygroups_client.delete_consistencygroup(cg_id)
vols = self.admin_volume_client.list_volumes(detail=True)['volumes']
for vol in vols:
if vol['consistencygroup_id'] == cg_id:
self.admin_volume_client.wait_for_resource_deletion(vol['id'])
- self.consistencygroups_adm_client.wait_for_consistencygroup_deletion(
+ self.admin_consistencygroups_client.wait_for_consistencygroup_deletion(
cg_id)
def _delete_cgsnapshot(self, cgsnapshot_id, cg_id):
- self.consistencygroups_adm_client.delete_cgsnapshot(cgsnapshot_id)
+ self.admin_consistencygroups_client.delete_cgsnapshot(cgsnapshot_id)
vols = self.admin_volume_client.list_volumes(detail=True)['volumes']
snapshots = self.os_admin.snapshots_v2_client.list_snapshots(
detail=True)['snapshots']
@@ -60,7 +53,7 @@
vol['id'] == snap['volume_id']):
(self.snapshots_client.
wait_for_resource_deletion(snap['id']))
- self.consistencygroups_adm_client.wait_for_cgsnapshot_deletion(
+ self.admin_consistencygroups_client.wait_for_cgsnapshot_deletion(
cgsnapshot_id)
@decorators.idempotent_id('3fe776ba-ec1f-4e6c-8d78-4b14c3a7fc44')
@@ -73,10 +66,10 @@
# Create CG
cg_name = data_utils.rand_name('CG')
create_consistencygroup = (
- self.consistencygroups_adm_client.create_consistencygroup)
+ self.admin_consistencygroups_client.create_consistencygroup)
cg = create_consistencygroup(volume_type['id'],
name=cg_name)['consistencygroup']
- self.consistencygroups_adm_client.wait_for_consistencygroup_status(
+ self.admin_consistencygroups_client.wait_for_consistencygroup_status(
cg['id'], 'available')
self.assertEqual(cg_name, cg['name'])
@@ -92,12 +85,12 @@
volume['id'], 'available')
# Get a given CG
- cg = self.consistencygroups_adm_client.show_consistencygroup(
+ cg = self.admin_consistencygroups_client.show_consistencygroup(
cg['id'])['consistencygroup']
self.assertEqual(cg_name, cg['name'])
# Get all CGs with detail
- cgs = self.consistencygroups_adm_client.list_consistencygroups(
+ cgs = self.admin_consistencygroups_client.list_consistencygroups(
detail=True)['consistencygroups']
self.assertIn((cg['name'], cg['id']),
[(m['name'], m['id']) for m in cgs])
@@ -117,10 +110,10 @@
# Create CG
cg_name = data_utils.rand_name('CG')
create_consistencygroup = (
- self.consistencygroups_adm_client.create_consistencygroup)
+ self.admin_consistencygroups_client.create_consistencygroup)
cg = create_consistencygroup(volume_type['id'],
name=cg_name)['consistencygroup']
- self.consistencygroups_adm_client.wait_for_consistencygroup_status(
+ self.admin_consistencygroups_client.wait_for_consistencygroup_status(
cg['id'], 'available')
self.assertEqual(cg_name, cg['name'])
@@ -137,10 +130,10 @@
# Create cgsnapshot
cgsnapshot_name = data_utils.rand_name('cgsnapshot')
create_cgsnapshot = (
- self.consistencygroups_adm_client.create_cgsnapshot)
+ self.admin_consistencygroups_client.create_cgsnapshot)
cgsnapshot = create_cgsnapshot(cg['id'],
name=cgsnapshot_name)['cgsnapshot']
- self.consistencygroups_adm_client.wait_for_cgsnapshot_status(
+ self.admin_consistencygroups_client.wait_for_cgsnapshot_status(
cgsnapshot['id'], 'available')
self.assertEqual(cgsnapshot_name, cgsnapshot['name'])
snapshots = self.os_admin.snapshots_v2_client.list_snapshots(
@@ -152,12 +145,12 @@
snap['id'], 'available')
# Get a given CG snapshot
- cgsnapshot = self.consistencygroups_adm_client.show_cgsnapshot(
+ cgsnapshot = self.admin_consistencygroups_client.show_cgsnapshot(
cgsnapshot['id'])['cgsnapshot']
self.assertEqual(cgsnapshot_name, cgsnapshot['name'])
# Get all CG snapshots with detail
- cgsnapshots = self.consistencygroups_adm_client.list_cgsnapshots(
+ cgsnapshots = self.admin_consistencygroups_client.list_cgsnapshots(
detail=True)['cgsnapshots']
self.assertIn((cgsnapshot['name'], cgsnapshot['id']),
[(m['name'], m['id']) for m in cgsnapshots])
@@ -177,10 +170,10 @@
# Create CG
cg_name = data_utils.rand_name('CG')
create_consistencygroup = (
- self.consistencygroups_adm_client.create_consistencygroup)
+ self.admin_consistencygroups_client.create_consistencygroup)
cg = create_consistencygroup(volume_type['id'],
name=cg_name)['consistencygroup']
- self.consistencygroups_adm_client.wait_for_consistencygroup_status(
+ self.admin_consistencygroups_client.wait_for_consistencygroup_status(
cg['id'], 'available')
self.assertEqual(cg_name, cg['name'])
@@ -197,10 +190,10 @@
# Create cgsnapshot
cgsnapshot_name = data_utils.rand_name('cgsnapshot')
create_cgsnapshot = (
- self.consistencygroups_adm_client.create_cgsnapshot)
+ self.admin_consistencygroups_client.create_cgsnapshot)
cgsnapshot = create_cgsnapshot(cg['id'],
name=cgsnapshot_name)['cgsnapshot']
- self.consistencygroups_adm_client.wait_for_cgsnapshot_status(
+ self.admin_consistencygroups_client.wait_for_cgsnapshot_status(
cgsnapshot['id'], 'available')
self.assertEqual(cgsnapshot_name, cgsnapshot['name'])
snapshots = self.snapshots_client.list_snapshots(
@@ -213,10 +206,12 @@
# Create CG from CG snapshot
cg_name2 = data_utils.rand_name('CG_from_snap')
create_consistencygroup2 = (
- self.consistencygroups_adm_client.create_consistencygroup_from_src)
+ self.admin_consistencygroups_client.
+ create_consistencygroup_from_src
+ )
cg2 = create_consistencygroup2(cgsnapshot_id=cgsnapshot['id'],
name=cg_name2)['consistencygroup']
- self.consistencygroups_adm_client.wait_for_consistencygroup_status(
+ self.admin_consistencygroups_client.wait_for_consistencygroup_status(
cg2['id'], 'available')
self.assertEqual(cg_name2, cg2['name'])
vols = self.admin_volume_client.list_volumes(
@@ -242,10 +237,10 @@
# Create CG
cg_name = data_utils.rand_name('CG')
create_consistencygroup = (
- self.consistencygroups_adm_client.create_consistencygroup)
+ self.admin_consistencygroups_client.create_consistencygroup)
cg = create_consistencygroup(volume_type['id'],
name=cg_name)['consistencygroup']
- self.consistencygroups_adm_client.wait_for_consistencygroup_status(
+ self.admin_consistencygroups_client.wait_for_consistencygroup_status(
cg['id'], 'available')
self.assertEqual(cg_name, cg['name'])
@@ -262,10 +257,12 @@
# Create CG from CG
cg_name2 = data_utils.rand_name('CG_from_cg')
create_consistencygroup2 = (
- self.consistencygroups_adm_client.create_consistencygroup_from_src)
+ self.admin_consistencygroups_client.
+ create_consistencygroup_from_src
+ )
cg2 = create_consistencygroup2(source_cgid=cg['id'],
name=cg_name2)['consistencygroup']
- self.consistencygroups_adm_client.wait_for_consistencygroup_status(
+ self.admin_consistencygroups_client.wait_for_consistencygroup_status(
cg2['id'], 'available')
self.assertEqual(cg_name2, cg2['name'])
vols = self.admin_volume_client.list_volumes(
diff --git a/cinder_tempest_plugin/api/volume/base.py b/cinder_tempest_plugin/api/volume/base.py
index c0f53bd..1c64973 100644
--- a/cinder_tempest_plugin/api/volume/base.py
+++ b/cinder_tempest_plugin/api/volume/base.py
@@ -50,6 +50,9 @@
cls.backups_client = cls.os_primary.backups_client_latest
cls.volumes_client = cls.os_primary.volumes_client_latest
cls.snapshots_client = cls.os_primary.snapshots_client_latest
+ cls.volume_revert_client = (
+ cls.os_primary.volume_revert_v3.VolumeRevertClient()
+ )
@classmethod
def setup_credentials(cls):
@@ -196,6 +199,9 @@
cls.admin_volume_types_client = cls.os_admin.volume_types_client_latest
cls.admin_backups_client = cls.os_admin.backups_client_latest
cls.admin_volume_client = cls.os_admin.volumes_client_latest
+ cls.admin_consistencygroups_client = (
+ cls.os_admin.consistencygroups_v3.ConsistencyGroupsClient()
+ )
@classmethod
def create_volume_type(cls, name=None, **kwargs):
diff --git a/cinder_tempest_plugin/api/volume/test_volume_revert.py b/cinder_tempest_plugin/api/volume/test_volume_revert.py
index 2c4d6bd..c585c3c 100644
--- a/cinder_tempest_plugin/api/volume/test_volume_revert.py
+++ b/cinder_tempest_plugin/api/volume/test_volume_revert.py
@@ -19,7 +19,6 @@
from tempest.lib import exceptions
from cinder_tempest_plugin.api.volume import base
-from cinder_tempest_plugin import cinder_clients
CONF = config.CONF
@@ -33,13 +32,6 @@
if not CONF.volume_feature_enabled.volume_revert:
raise cls.skipException("Cinder volume revert feature disabled")
- @classmethod
- def setup_clients(cls):
- super(VolumeRevertTests, cls).setup_clients()
-
- manager = cinder_clients.Manager(cls.os_primary)
- cls.volume_revert_client = manager.volume_revert_client
-
def setUp(self):
super(VolumeRevertTests, self).setUp()
# Create volume
diff --git a/cinder_tempest_plugin/cinder_clients.py b/cinder_tempest_plugin/cinder_clients.py
index f4c7c0e..b27d22c 100644
--- a/cinder_tempest_plugin/cinder_clients.py
+++ b/cinder_tempest_plugin/cinder_clients.py
@@ -14,27 +14,19 @@
# under the License.
from tempest import config
-
-from cinder_tempest_plugin.services import consistencygroups_client
-from cinder_tempest_plugin.services import volume_revert_client
+from tempest.lib.services import clients
CONF = config.CONF
-class Manager(object):
- def __init__(self, base_manager):
- params = {
- 'service': CONF.volume.catalog_type,
- 'region': CONF.volume.region or CONF.identity.region,
- 'endpoint_type': CONF.volume.endpoint_type,
- 'build_interval': CONF.volume.build_interval,
- 'build_timeout': CONF.volume.build_timeout
- }
- params.update(base_manager.default_params)
- auth_provider = base_manager.auth_provider
+class Clients(clients.ServiceClients):
+ """Tempest stable service clients and loaded plugins service clients"""
- self.consistencygroups_adm_client = (
- consistencygroups_client.ConsistencyGroupsClient(auth_provider,
- **params))
- self.volume_revert_client = (
- volume_revert_client.VolumeRevertClient(auth_provider, **params))
+ def __init__(self, credentials, service=None):
+ """Emulate the interface of Tempest's clients.Manager"""
+ # Identity settings
+ if CONF.identity.auth_version == 'v2':
+ identity_uri = CONF.identity.uri
+ else:
+ identity_uri = CONF.identity.uri_v3
+ super(Clients, self).__init__(credentials, identity_uri)
diff --git a/cinder_tempest_plugin/plugin.py b/cinder_tempest_plugin/plugin.py
index 5d170e5..79c835c 100644
--- a/cinder_tempest_plugin/plugin.py
+++ b/cinder_tempest_plugin/plugin.py
@@ -69,3 +69,26 @@
project_config.barbican_service_option))
return opt_lists
+
+ def get_service_clients(self):
+ volumes_config = config.service_client_config('volume')
+
+ consistencygroups_params = {
+ 'name': 'consistencygroups_v3',
+ 'service_version': 'consistencygroups.v3',
+ 'module_path': 'cinder_tempest_plugin.services.'
+ 'consistencygroups_client',
+ 'client_names': ['ConsistencyGroupsClient'],
+ }
+ consistencygroups_params.update(volumes_config)
+
+ volumerevert_params = {
+ 'name': 'volume_revert_v3',
+ 'service_version': 'volume_revert.v3',
+ 'module_path': 'cinder_tempest_plugin.services.'
+ 'volume_revert_client',
+ 'client_names': ['VolumeRevertClient'],
+ }
+ volumerevert_params.update(volumes_config)
+
+ return [consistencygroups_params, volumerevert_params]
diff --git a/cinder_tempest_plugin/services/__init__.py b/cinder_tempest_plugin/services/__init__.py
index e69de29..8be06b7 100644
--- a/cinder_tempest_plugin/services/__init__.py
+++ b/cinder_tempest_plugin/services/__init__.py
@@ -0,0 +1,22 @@
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+from cinder_tempest_plugin.services.consistencygroups_client import \
+ ConsistencyGroupsClient
+from cinder_tempest_plugin.services.volume_revert_client import \
+ VolumeRevertClient
+
+__all__ = [
+ 'ConsistencyGroupsClient',
+ 'VolumeRevertClient'
+]