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
This commit is contained in:
parent
c6170a0321
commit
f77e7dcb33
|
@ -144,6 +144,8 @@ def wait_for_volume_status(client, volume_id, status):
|
|||
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) '
|
||||
|
|
|
@ -92,6 +92,10 @@ class VolumeBuildErrorException(TempestException):
|
|||
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"
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import mock
|
|||
|
||||
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 @@ class TestImageWaiters(base.TestCase):
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue