Break wait_for_volume_resource_status when error_extending

When extending volume reaches status error_extending, we should
return from wait_for_volume_resource_status immediately instead
of waiting for the TimeoutException.

Change-Id: I3db0325c23ebb8d42fe77f4c28552fe9cf5ed807
changes/96/662696/1
zhufl 3 years ago
parent 558eb2c8fd
commit 0ea2c01d75
  1. 2
      tempest/common/waiters.py
  2. 5
      tempest/exceptions.py
  3. 19
      tempest/tests/common/test_waiters.py

@ -202,6 +202,8 @@ def wait_for_volume_resource_status(client, resource_id, status):
resource_name=resource_name, resource_id=resource_id)
if resource_name == 'volume' and resource_status == 'error_restoring':
raise exceptions.VolumeRestoreErrorException(volume_id=resource_id)
if resource_status == 'error_extending' and resource_status != status:
raise exceptions.VolumeExtendErrorException(volume_id=resource_id)
if int(time.time()) - start >= client.build_timeout:
message = ('%s %s failed to reach %s status (current %s) '

@ -42,6 +42,11 @@ class VolumeRestoreErrorException(exceptions.TempestException):
message = "Volume %(volume_id)s failed to restore and is in ERROR status"
class VolumeExtendErrorException(exceptions.TempestException):
message = ("Volume %(volume_id)s failed to extend and "
"is in error_extending status")
class StackBuildErrorException(exceptions.TempestException):
message = ("Stack %(stack_identifier)s is in %(stack_status)s status "
"due to '%(stack_status_reason)s'")

@ -73,6 +73,25 @@ class TestImageWaiters(base.TestCase):
mock.call(volume_id)])
mock_sleep.assert_called_once_with(1)
@mock.patch.object(time, 'sleep')
def test_wait_for_volume_status_error_extending(self, mock_sleep):
# Tests that the wait method raises VolumeExtendErrorException if
# the volume status is 'error_extending'.
client = mock.Mock(spec=volumes_client.VolumesClient,
resource_type="volume",
build_interval=1)
volume1 = {'volume': {'status': 'extending'}}
volume2 = {'volume': {'status': 'error_extending'}}
mock_show = mock.Mock(side_effect=(volume1, volume2))
client.show_volume = mock_show
volume_id = '7532b91e-aa0a-4e06-b3e5-20c0c5ee1caa'
self.assertRaises(exceptions.VolumeExtendErrorException,
waiters.wait_for_volume_resource_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)
class TestInterfaceWaiters(base.TestCase):

Loading…
Cancel
Save