Skip to content

Commit

Permalink
Fix not correct AWS::StackId value
Browse files Browse the repository at this point in the history
Add call of method _set_param_stackid() to method update_task() in class
parser.Stack. This ensures that an updated stack still has the right
AWS::StackId param.
Add a unit test for this case.

Change-Id: I0d28346631546577a85735292a24c2512476d4b4
Closes-Bug: #1240888
  • Loading branch information
AlexanderChudnovets committed Nov 27, 2013
1 parent ac14ece commit c4f0be3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions heat/engine/parser.py
Expand Up @@ -486,6 +486,7 @@ def update_task(self, newstack, action=UPDATE):

self.env = newstack.env
self.parameters = newstack.parameters
self._set_param_stackid()

try:
updater.start(timeout=self.timeout_secs())
Expand Down
31 changes: 31 additions & 0 deletions heat/tests/test_parser.py
Expand Up @@ -763,6 +763,37 @@ def test_set_param_id(self):
identifier.arn())
self.m.VerifyAll()

@utils.stack_delete_after
def test_set_param_id_update(self):
tmpl = {'Resources': {
'AResource': {'Type': 'ResourceWithPropsType',
'Metadata': {'Bar': {'Ref': 'AWS::StackId'}},
'Properties': {'Foo': 'abc'}}}}

self.stack = parser.Stack(self.ctx, 'update_stack_arn_test',
template.Template(tmpl))
self.stack.store()
self.stack.create()
self.assertEqual(self.stack.state,
(parser.Stack.CREATE, parser.Stack.COMPLETE))

stack_arn = self.stack.parameters['AWS::StackId']

tmpl2 = {'Resources': {
'AResource': {'Type': 'ResourceWithPropsType',
'Metadata': {'Bar': {'Ref': 'AWS::StackId'}},
'Properties': {'Foo': 'xyz'}}}}

updated_stack = parser.Stack(self.ctx, 'updated_stack',
template.Template(tmpl2))

self.stack.update(updated_stack)
self.assertEqual(self.stack.state,
(parser.Stack.UPDATE, parser.Stack.COMPLETE))
self.assertEqual(self.stack['AResource'].properties['Foo'], 'xyz')

self.assertEqual(self.stack['AResource'].metadata['Bar'], stack_arn)

@utils.stack_delete_after
def test_load_param_id(self):
self.stack = parser.Stack(self.ctx, 'param_load_arn_test',
Expand Down

0 comments on commit c4f0be3

Please sign in to comment.