summaryrefslogtreecommitdiff
path: root/heat/tests
diff options
context:
space:
mode:
authorRabi Mishra <ramishra@redhat.com>2020-06-26 12:48:00 +0530
committerRabi Mishra <ramishra@redhat.com>2020-06-26 14:29:54 +0530
commit01c230e793043310614d5b88096476ce0eac2c78 (patch)
treec8787eee625ae768cbe3193f6f5b97c9b21c6f66 /heat/tests
parent8353fddf9ebfb0eca67d6f2b2feb529031acff89 (diff)
downloadheat-01c230e793043310614d5b88096476ce0eac2c78.tar.gz
Check for nova exception.Conflict rather than task_state
When detaching and attaching volumes nova would raise an exception.Conflict, if attach and detach can't happen. Let's use that to retry rather than using task_state. Change-Id: I50904e4254568cd807b9ff18eef482cadb626ce5 Task: 40169
Diffstat (limited to 'heat/tests')
-rw-r--r--heat/tests/openstack/cinder/test_volume.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/heat/tests/openstack/cinder/test_volume.py b/heat/tests/openstack/cinder/test_volume.py
index 6a2cc5ea9..87cc4e160 100644
--- a/heat/tests/openstack/cinder/test_volume.py
+++ b/heat/tests/openstack/cinder/test_volume.py
@@ -17,6 +17,7 @@ import json
from unittest import mock
from cinderclient import exceptions as cinder_exp
+from novaclient import exceptions as nova_exp
from oslo_config import cfg
from heat.common import exception
@@ -906,7 +907,6 @@ class CinderVolumeTest(vt_base.VolumeTestCase):
fv1, fva,
vt_base.FakeVolume('available'), fv2])
self.stub_VolumeConstraint_validate()
-
# delete script
self.fc.volumes.get_server_volume.side_effect = [
fva, fva, fakes_nova.fake_exception()]
@@ -915,10 +915,12 @@ class CinderVolumeTest(vt_base.VolumeTestCase):
stack = utils.parse_stack(self.t, stack_name=self.stack_name)
self.create_volume(self.t, stack, 'volume')
-
rsrc = self.create_attachment(self.t, stack, 'attachment')
prg_detach = mock.MagicMock(cinder_complete=True, nova_complete=True)
prg_attach = mock.MagicMock(called=False, srv_id='InstanceInResize')
+ self.fc.volumes.create_server_volume.side_effect = [
+ nova_exp.Conflict('409')]
+
self.assertEqual(False,
rsrc.check_update_complete((prg_detach, prg_attach)))
self.assertEqual(False, prg_attach.called)
@@ -1275,7 +1277,8 @@ class CinderVolumeTest(vt_base.VolumeTestCase):
self.cinder_fc.volumes.create.return_value = fv
fv_ready = vt_base.FakeVolume('available', id=fv.id)
self.cinder_fc.volumes.get.side_effect = [fv, fv_ready]
-
+ self.fc.volumes.delete_server_volume.side_effect = [
+ nova_exp.Conflict('409')]
self.t['resources']['volume']['properties'].update({
'volume_type': 'lvm',
})
@@ -1315,7 +1318,8 @@ class CinderVolumeTest(vt_base.VolumeTestCase):
self.cinder_fc.volumes.create.return_value = fv
fv_ready = vt_base.FakeVolume('available', id=fv.id)
self.cinder_fc.volumes.get.side_effect = [fv, fv_ready]
-
+ self.fc.volumes.create_server_volume.side_effect = [
+ nova_exp.Conflict('409')]
self.t['resources']['volume']['properties'].update({
'volume_type': 'lvm',
})