Add setUp to ensure volume availability in snapshot tests
Add setUp method to check volume state before each test runs.
The method verifies the volume is available and creates it if
it doesn't exist, preventing race conditions during test execution.
Change-Id: I6513078e053cae13035de26d382ecd8eecfcb51e
Signed-off-by: lkuchlan <lkuchlan@redhat.com>
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 35afffd..4d24372 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -40,6 +40,21 @@
super(VolumesSnapshotTestJSON, cls).resource_setup()
cls.volume_origin = cls.create_volume()
+ def setUp(self):
+ super(VolumesSnapshotTestJSON, self).setUp()
+ # Check volume and make sure it is in available state before the next
+ # test uses it.
+ try:
+ vol = self.volumes_client.show_volume(
+ self.volume_origin['id'])['volume']
+ if vol['status'] != 'available':
+ waiters.wait_for_volume_resource_status(
+ self.volumes_client,
+ self.volume_origin['id'],
+ 'available')
+ except (lib_exc.NotFound, lib_exc.TimeoutException):
+ self.volume_origin = self.create_volume()
+
@decorators.idempotent_id('8567b54c-4455-446d-a1cf-651ddeaa3ff2')
@utils.services('compute')
def test_snapshot_create_delete_with_volume_in_use(self):