summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-03-13 22:24:37 +0000
committerGerrit Code Review <review@openstack.org>2023-03-13 22:24:37 +0000
commit35b4b58d01e0e92a3e5d3dcadba9c874482bcc20 (patch)
tree413fb8b36c03a2c838abf9a93896b84496a5690e
parentbaa3cc712cbf37a077291f69d8b621bd6f759132 (diff)
parente9a58a1cc79feb7d96b7d6db7587e6c39f2450a5 (diff)
downloadtempest-35b4b58d01e0e92a3e5d3dcadba9c874482bcc20.tar.gz
Merge "Introduce a change that will allow more clients to make volumes"
-rw-r--r--tempest/scenario/manager.py42
1 files changed, 28 insertions, 14 deletions
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index bf3f62fa7..db0aa5a40 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -325,13 +325,15 @@ class ScenarioTest(tempest.test.BaseTestCase):
def create_volume(self, size=None, name=None, snapshot_id=None,
imageRef=None, volume_type=None, wait_until='available',
- **kwargs):
+ client=None, **kwargs):
"""Creates volume
This wrapper utility creates volume and waits for volume to be
in 'available' state by default. If wait_until is None, means no wait.
This method returns the volume's full representation by GET request.
"""
+ if client is None:
+ client = self.volumes_client
if size is None:
size = CONF.volume.volume_size
@@ -355,19 +357,20 @@ class ScenarioTest(tempest.test.BaseTestCase):
kwargs.setdefault('availability_zone',
CONF.compute.compute_volume_common_az)
- volume = self.volumes_client.create_volume(**kwargs)['volume']
+ volume = client.create_volume(**kwargs)['volume']
- self.addCleanup(self.volumes_client.wait_for_resource_deletion,
+ self.addCleanup(client.wait_for_resource_deletion,
volume['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
- self.volumes_client.delete_volume, volume['id'])
+ client.delete_volume, volume['id'])
self.assertEqual(name, volume['name'])
if wait_until:
- waiters.wait_for_volume_resource_status(self.volumes_client,
+ waiters.wait_for_volume_resource_status(client,
volume['id'], wait_until)
# The volume retrieved on creation has a non-up-to-date status.
# Retrieval after it becomes active ensures correct details.
- volume = self.volumes_client.show_volume(volume['id'])['volume']
+ volume = client.show_volume(volume['id'])['volume']
+
return volume
def create_backup(self, volume_id, name=None, description=None,
@@ -858,32 +861,43 @@ class ScenarioTest(tempest.test.BaseTestCase):
image_name, server['name'])
return snapshot_image
- def nova_volume_attach(self, server, volume_to_attach, **kwargs):
+ def nova_volume_attach(self, server, volume_to_attach,
+ volumes_client=None, servers_client=None,
+ **kwargs):
"""Compute volume attach
This utility attaches volume from compute and waits for the
volume status to be 'in-use' state.
"""
- volume = self.servers_client.attach_volume(
+ if volumes_client is None:
+ volumes_client = self.volumes_client
+ if servers_client is None:
+ servers_client = self.servers_client
+
+ volume = servers_client.attach_volume(
server['id'], volumeId=volume_to_attach['id'],
**kwargs)['volumeAttachment']
self.assertEqual(volume_to_attach['id'], volume['id'])
- waiters.wait_for_volume_resource_status(self.volumes_client,
+ waiters.wait_for_volume_resource_status(volumes_client,
volume['id'], 'in-use')
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
- self.nova_volume_detach, server, volume)
+ self.nova_volume_detach, server, volume,
+ servers_client)
# Return the updated volume after the attachment
- return self.volumes_client.show_volume(volume['id'])['volume']
+ return volumes_client.show_volume(volume['id'])['volume']
- def nova_volume_detach(self, server, volume):
+ def nova_volume_detach(self, server, volume, servers_client=None):
"""Compute volume detach
This utility detaches the volume from the server and checks whether the
volume attachment has been removed from Nova.
"""
- self.servers_client.detach_volume(server['id'], volume['id'])
+ if servers_client is None:
+ servers_client = self.servers_client
+
+ servers_client.detach_volume(server['id'], volume['id'])
waiters.wait_for_volume_attachment_remove_from_server(
- self.servers_client, server['id'], volume['id'])
+ servers_client, server['id'], volume['id'])
def ping_ip_address(self, ip_address, should_succeed=True,
ping_timeout=None, mtu=None, server=None):