summaryrefslogtreecommitdiff
path: root/heat/tests/test_stack_update.py
diff options
context:
space:
mode:
authorThomas Herve <therve@redhat.com>2015-10-14 16:44:42 +0200
committerThomas Herve <therve@redhat.com>2015-10-15 09:53:30 +0200
commit117e5a0e654111de3f28900228d858cd0683cb1f (patch)
tree6227bbac78ca7e5db940c8b098a6f44c1388bbb1 /heat/tests/test_stack_update.py
parentdda94d7681c5e7c5c107aad11b6f84cd55249be8 (diff)
downloadheat-117e5a0e654111de3f28900228d858cd0683cb1f.tar.gz
Delete previous template upon update
During stack update, we flip the stack raw_template a number of times. In case of success, we leave the old active raw_template row unlinked to anything, so it needs to be deleted. This patch does so. Change-Id: I6f3ff5bfbac417e3bd6032cabfbc00bd6dec8b02 Closes-Bug: #1506077
Diffstat (limited to 'heat/tests/test_stack_update.py')
-rw-r--r--heat/tests/test_stack_update.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/heat/tests/test_stack_update.py b/heat/tests/test_stack_update.py
index 76021d36f..ca9f0fdd9 100644
--- a/heat/tests/test_stack_update.py
+++ b/heat/tests/test_stack_update.py
@@ -17,6 +17,7 @@ import mock
from heat.common import exception
from heat.common import template_format
+from heat.db.sqlalchemy import api as db_api
from heat.engine import environment
from heat.engine import resource
from heat.engine import scheduler
@@ -50,6 +51,7 @@ class StackUpdateTest(common.HeatTestCase):
template.Template(tmpl))
self.stack.store()
self.stack.create()
+ raw_template_id = self.stack.t.id
self.assertEqual((stack.Stack.CREATE, stack.Stack.COMPLETE),
self.stack.state)
@@ -63,6 +65,10 @@ class StackUpdateTest(common.HeatTestCase):
self.assertEqual((stack.Stack.UPDATE, stack.Stack.COMPLETE),
self.stack.state)
self.assertIn('BResource', self.stack)
+ self.assertNotEqual(raw_template_id, self.stack.t.id)
+ self.assertNotEqual(raw_template_id, self.stack.prev_raw_template_id)
+ self.assertRaises(exception.NotFound,
+ db_api.raw_template_get, self.ctx, raw_template_id)
def test_update_remove(self):
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
@@ -859,8 +865,9 @@ class StackUpdateTest(common.HeatTestCase):
mock_create = self.patchobject(generic_rsrc.ResourceWithProps,
'handle_create', side_effect=Exception)
- with mock.patch.object(stack_object.Stack,
- 'update_by_id') as mock_db_update:
+ with mock.patch.object(
+ stack_object.Stack, 'update_by_id',
+ wraps=stack_object.Stack.update_by_id) as mock_db_update:
self.stack.update(updated_stack)
self.assertEqual((stack.Stack.ROLLBACK, stack.Stack.COMPLETE),
self.stack.state)