Merge "Handle 'error_restoring' status in wait_for_volume_status"
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index 85a03cf..8112e9e 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -144,6 +144,8 @@
volume_status = body['status']
if volume_status == 'error':
raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
+ if volume_status == 'error_restoring':
+ raise exceptions.VolumeRestoreErrorException(volume_id=volume_id)
if int(time.time()) - start >= client.build_timeout:
message = ('Volume %s failed to reach %s status (current %s) '
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index 15617c6..15482ab 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -92,6 +92,10 @@
message = "Volume %(volume_id)s failed to build and is in ERROR status"
+class VolumeRestoreErrorException(TempestException):
+ message = "Volume %(volume_id)s failed to restore and is in ERROR status"
+
+
class SnapshotBuildErrorException(TempestException):
message = "Snapshot %(snapshot_id)s failed to build and is in ERROR status"
diff --git a/tempest/tests/test_waiters.py b/tempest/tests/test_waiters.py
index 329d610..7aa6595 100644
--- a/tempest/tests/test_waiters.py
+++ b/tempest/tests/test_waiters.py
@@ -18,6 +18,7 @@
from tempest.common import waiters
from tempest import exceptions
+from tempest.services.volume.json import volumes_client
from tempest.tests import base
@@ -47,3 +48,21 @@
self.assertRaises(exceptions.AddImageException,
waiters.wait_for_image_status,
self.client, 'fake_image_id', 'active')
+
+ @mock.patch.object(time, 'sleep')
+ def test_wait_for_volume_status_error_restoring(self, mock_sleep):
+ # Tests that the wait method raises VolumeRestoreErrorException if
+ # the volume status is 'error_restoring'.
+ client = mock.Mock(spec=volumes_client.BaseVolumesClient,
+ build_interval=1)
+ volume1 = {'status': 'restoring-backup'}
+ volume2 = {'status': 'error_restoring'}
+ mock_show = mock.Mock(side_effect=(volume1, volume2))
+ client.show_volume = mock_show
+ volume_id = '7532b91e-aa0a-4e06-b3e5-20c0c5ee1caa'
+ self.assertRaises(exceptions.VolumeRestoreErrorException,
+ waiters.wait_for_volume_status,
+ client, volume_id, 'available')
+ mock_show.assert_has_calls([mock.call(volume_id),
+ mock.call(volume_id)])
+ mock_sleep.assert_called_once_with(1)