Merge "Convergence: Update if the resource is CREATE_{COMPLETE,FAILED}"

This commit is contained in:
Jenkins 2015-06-29 05:18:49 +00:00 committed by Gerrit Code Review
commit e4a72cd92c
2 changed files with 22 additions and 1 deletions

View File

@ -303,7 +303,12 @@ def check_resource_update(rsrc, template_id, data, engine_id):
'''
Create or update the Resource if appropriate.
'''
if rsrc.resource_id is None:
if (rsrc.resource_id is None
and not (rsrc.action == resource.Resource.CREATE and
rsrc.status in [
resource.Resource.COMPLETE,
resource.Resource.FAILED
])):
rsrc.create_convergence(template_id, data, engine_id)
else:
rsrc.update_convergence(template_id, data, engine_id)

View File

@ -469,6 +469,22 @@ class MiscMethodsTest(common.HeatTestCase):
{}, 'engine-id')
self.assertTrue(mock_update.called)
@mock.patch.object(resource.Resource, 'update_convergence')
def test_check_resource_update_complete(self, mock_update):
self.resource.action = 'CREATE'
self.resource.status = 'COMPLETE'
worker.check_resource_update(self.resource, self.resource.stack.t.id,
{}, 'engine-id')
self.assertTrue(mock_update.called)
@mock.patch.object(resource.Resource, 'update_convergence')
def test_check_resource_update_failed(self, mock_update):
self.resource.action = 'CREATE'
self.resource.status = 'FAILED'
worker.check_resource_update(self.resource, self.resource.stack.t.id,
{}, 'engine-id')
self.assertTrue(mock_update.called)
@mock.patch.object(resource.Resource, 'delete_convergence')
def test_check_resource_cleanup_delete(self, mock_delete):
self.resource.current_template_id = 'new-template-id'