Handle 'error_restoring' status in wait_for_volume_status
If cinder hits an error when restoring a volume from a backup the volume
is set to 'error_restoring' status. If tempest doesn't handle this and
fail fast, tests keep waiting for the volume to go to 'available' status
or timeout - and the timeout is what happens.
Related-Bug: #1483434
Change-Id: I8f6d0828a84ec5d4a5fa6332e55152bd67eaa605
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)