Correct behaviour of update_replace property in test resource

When the update_replace property is set to True, we should replace
the resource on every update where the 'value' property is
modified.

This was the original semantics of the resource, before it was
erroneously changed in 113b0a4948.

Change-Id: Icb5c3f3078a748359ee954b51f996ef08e9bc0ec
Closes-Bug: #1548356
This commit is contained in:
Zane Bitter 2018-03-08 17:15:40 -05:00
parent f0648502da
commit a90bc68e76
3 changed files with 8 additions and 5 deletions

View File

@ -178,8 +178,8 @@ class TestResource(resource.Resource):
def needs_replace_with_prop_diff(self, changed_properties_set,
after_props, before_props):
if self.UPDATE_REPLACE in changed_properties_set:
return bool(after_props.get(self.UPDATE_REPLACE))
if self.VALUE in changed_properties_set:
return after_props[self.UPDATE_REPLACE]
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
self.properties = json_snippet.properties(self.properties_schema,

View File

@ -4366,7 +4366,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
ev.assert_called_with(res.UPDATE, res.FAILED,
'update is restricted for resource.')
def test_replace_rstricted(self):
def test_replace_restricted(self):
self.env_snippet = {u'resource_registry': {
u'resources': {
'bar': {'restricted_actions': 'replace'}
@ -4378,6 +4378,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
res = self.create_resource()
ev = self.patchobject(res, '_add_event')
props = self.tmpl['resources']['bar']['properties']
props['value'] = '4567'
props['update_replace'] = True
snippet = rsrc_defn.ResourceDefinition('bar',
'TestResourceType',
@ -4392,7 +4393,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
ev.assert_called_with(res.UPDATE, res.FAILED,
'replace is restricted for resource.')
def test_update_with_replace_rstricted(self):
def test_update_with_replace_restricted(self):
self.env_snippet = {u'resource_registry': {
u'resources': {
'bar': {'restricted_actions': 'replace'}
@ -4413,7 +4414,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
ev.assert_called_with(res.UPDATE, res.COMPLETE,
'state changed')
def test_replace_with_update_rstricted(self):
def test_replace_with_update_restricted(self):
self.env_snippet = {u'resource_registry': {
u'resources': {
'bar': {'restricted_actions': 'update'}
@ -4426,6 +4427,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
ev = self.patchobject(res, '_add_event')
prep_replace = self.patchobject(res, 'prepare_for_replace')
props = self.tmpl['resources']['bar']['properties']
props['value'] = '4567'
props['update_replace'] = True
snippet = rsrc_defn.ResourceDefinition('bar',
'TestResourceType',

View File

@ -96,6 +96,7 @@ class UpdateRestrictedStackTest(functional_base.FunctionalTestsBase):
update_template = test_template.copy()
props = update_template['resources']['bar']['properties']
props['value'] = '4567'
props['update_replace'] = True
# check replace fails - with 'both' restricted