From 97df8bb6ca82b2a225226340b118a93bf1cf1120 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Wed, 5 Sep 2018 19:25:52 -0400 Subject: Improve best existing resource selection Rank all existing versions of a resource in a convergence stack to improve the likelihood that we find the best one to update. This allows us to roll back to the original version of a resource (or even attempt an in-place update of it) when replacing it has failed. Previously this only worked during automatic rollback; on subsequent updates we would always work on the failed replacement (which inevitably meant attempting another replacement in almost all cases). Change-Id: Ia231fae85d1ddb9fc7b7de4e82cec0c0e0fd06b7 Story: #2003579 Task: 24881 --- .../functional/test_create_update.py | 30 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'heat_integrationtests') diff --git a/heat_integrationtests/functional/test_create_update.py b/heat_integrationtests/functional/test_create_update.py index b5793685f..a84dcde0e 100644 --- a/heat_integrationtests/functional/test_create_update.py +++ b/heat_integrationtests/functional/test_create_update.py @@ -68,9 +68,8 @@ def _change_rsrc_properties(template, rsrcs, values): for rsrc_name in rsrcs: rsrc_prop = modified_template['resources'][ rsrc_name]['properties'] - for prop in rsrc_prop: - if prop in values: - rsrc_prop[prop] = values[prop] + for prop, new_val in values.items(): + rsrc_prop[prop] = new_val return modified_template @@ -280,6 +279,31 @@ resources: self.assertEqual(updated_resources, self.list_resources(stack_identifier)) + @test.requires_convergence + def test_stack_update_replace_manual_rollback(self): + template = _change_rsrc_properties(test_template_one_resource, + ['test1'], + {'update_replace_value': '1'}) + stack_identifier = self.stack_create(template=template) + original_resource_id = self.get_physical_resource_id(stack_identifier, + 'test1') + + tmpl_update = _change_rsrc_properties(test_template_one_resource, + ['test1'], + {'update_replace_value': '2', + 'fail': True}) + # Update with bad template, we should fail + self.update_stack(stack_identifier, tmpl_update, + expected_status='UPDATE_FAILED', + disable_rollback=True) + # Manually roll back to previous template + self.update_stack(stack_identifier, template) + final_resource_id = self.get_physical_resource_id(stack_identifier, + 'test1') + # Original resource was good, and replacement was never created, so it + # should be kept. + self.assertEqual(original_resource_id, final_resource_id) + def test_stack_update_provider(self): template = _change_rsrc_properties( test_template_one_resource, ['test1'], -- cgit v1.2.1