Allows to skip wait for volume create
Current code does not support skipping wait for
volume, tempest plugins require test without waiting
and still use all existing flow code.
Examples:
Create multiple volume in a batch without waiting
Create multiple volumes and expecting for error state
Instead of duplicating code its better to set a flag,
wait_until default value is available, when its None we
skip waiting inside create volume
Change-Id: I7fe90e26f773b3a128e3d1bff1b89a3ef665eebb
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index b90b5bb..172b6ed 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -98,7 +98,7 @@
def create_volume(cls, wait_until='available', **kwargs):
"""Wrapper utility that returns a test volume.
- :param wait_until: wait till volume status.
+ :param wait_until: wait till volume status, None means no wait.
"""
if 'size' not in kwargs:
kwargs['size'] = CONF.volume.volume_size
@@ -127,8 +127,9 @@
cls.addClassResourceCleanup(test_utils.call_and_ignore_notfound_exc,
cls.delete_volume, cls.volumes_client,
volume['id'])
- waiters.wait_for_volume_resource_status(cls.volumes_client,
- volume['id'], wait_until)
+ if wait_until:
+ waiters.wait_for_volume_resource_status(cls.volumes_client,
+ volume['id'], wait_until)
return volume
@classmethod
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 1d24bc1..db28487 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -321,11 +321,12 @@
return server
def create_volume(self, size=None, name=None, snapshot_id=None,
- imageRef=None, volume_type=None, **kwargs):
+ imageRef=None, volume_type=None, wait_until='available',
+ **kwargs):
"""Creates volume
This wrapper utility creates volume and waits for volume to be
- in 'available' state.
+ in 'available' state by default. If wait_until is None, means no wait.
This method returns the volume's full representation by GET request.
"""
@@ -358,11 +359,12 @@
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.volumes_client.delete_volume, volume['id'])
self.assertEqual(name, volume['name'])
- waiters.wait_for_volume_resource_status(self.volumes_client,
- volume['id'], 'available')
- # 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']
+ if wait_until:
+ waiters.wait_for_volume_resource_status(self.volumes_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']
return volume
def create_backup(self, volume_id, name=None, description=None,