summaryrefslogtreecommitdiff
path: root/heat/tests/test_stack_update.py
diff options
context:
space:
mode:
authorThomas Herve <therve@redhat.com>2015-11-09 09:32:00 +0100
committerThomas Herve <therve@redhat.com>2015-11-18 16:40:16 +0100
commitc0457f17fca7004014f47f6f84ce286d3df0e0c1 (patch)
tree9ee43038039251ae780f701635cc0873d10f278f /heat/tests/test_stack_update.py
parentf9e155dd6f7ef0a04ffd2ab426badc3720a13699 (diff)
downloadheat-c0457f17fca7004014f47f6f84ce286d3df0e0c1.tar.gz
Implement pre-delete hook
Add a hook running before resource deletion. blueprint pre-delete-hook Depends-On: Ia362650261b0b6c03ce431cbcf292a1685b59883 Change-Id: I8f57cab5ea9ff54d84195add1ba5065520e83489
Diffstat (limited to 'heat/tests/test_stack_update.py')
-rw-r--r--heat/tests/test_stack_update.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/heat/tests/test_stack_update.py b/heat/tests/test_stack_update.py
index 4499212aa..f137107d8 100644
--- a/heat/tests/test_stack_update.py
+++ b/heat/tests/test_stack_update.py
@@ -404,6 +404,43 @@ class StackUpdateTest(common.HeatTestCase):
self.stack.state)
self.assertEqual('xyz', self.stack['AResource'].properties['Foo'])
+ def test_update_replace_delete_hook(self):
+ tmpl = {
+ 'HeatTemplateFormatVersion': '2012-12-12',
+ 'Parameters': {
+ 'foo': {'Type': 'String'}
+ },
+ 'Resources': {
+ 'AResource': {
+ 'Type': 'ResourceWithPropsType',
+ 'Properties': {'Foo': {'Ref': 'foo'}}
+ }
+ }
+ }
+
+ env = environment.Environment({'foo': 'abc'})
+ env.registry.load(
+ {'resources': {'AResource': {'hooks': 'pre-delete'}}})
+ self.stack = stack.Stack(
+ self.ctx, 'update_test_stack',
+ template.Template(tmpl, env=env))
+ self.stack.store()
+ self.stack.create()
+ self.assertEqual((stack.Stack.CREATE, stack.Stack.COMPLETE),
+ self.stack.state)
+
+ env2 = environment.Environment({'foo': 'xyz'})
+ env2.registry.load(
+ {'resources': {'AResource': {'hooks': 'pre-delete'}}})
+ updated_stack = stack.Stack(self.ctx, 'updated_stack',
+ template.Template(tmpl, env=env2))
+
+ self.stack.update(updated_stack)
+ # The hook is not called, and update succeeds properly
+ self.assertEqual((stack.Stack.UPDATE, stack.Stack.COMPLETE),
+ self.stack.state)
+ self.assertEqual('xyz', self.stack['AResource'].properties['Foo'])
+
def test_update_modify_update_failed(self):
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
'Resources': {'AResource': {'Type': 'ResourceWithPropsType',