summaryrefslogtreecommitdiff
path: root/heat/tests/test_convg_stack.py
diff options
context:
space:
mode:
authortyagi <ishant.tyagi@hp.com>2016-01-27 01:36:32 -0800
committerRakesh H S <rh-s@hpe.com>2016-05-02 16:36:59 +0530
commit4b46151a640f818b08e1a87b1a4157657cced160 (patch)
tree78acd4b56825463d78431f6a21bf795770151682 /heat/tests/test_convg_stack.py
parent2f9b344c67e8522a7c8a32c8c4a9e2f5eba648a8 (diff)
downloadheat-4b46151a640f818b08e1a87b1a4157657cced160.tar.gz
Delete snaphots on deleting stack
Currently if convergence is enabled then deleting stack does not deletes the snapshots. This patch deletes the snapshots before deleting the stack. Co-Authored-By: Rakesh H S <rh-s@hpe.com> Change-Id: I1cb321a3878a0abce9b41832f76bf77c25bf7cb4 Closes-Bug: #1508299
Diffstat (limited to 'heat/tests/test_convg_stack.py')
-rw-r--r--heat/tests/test_convg_stack.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/heat/tests/test_convg_stack.py b/heat/tests/test_convg_stack.py
index 6c2c49a12..d303485f9 100644
--- a/heat/tests/test_convg_stack.py
+++ b/heat/tests/test_convg_stack.py
@@ -21,6 +21,7 @@ from heat.engine import stack as parser
from heat.engine import template as templatem
from heat.objects import raw_template as raw_template_object
from heat.objects import resource as resource_objects
+from heat.objects import snapshot as snapshot_objects
from heat.objects import stack as stack_object
from heat.objects import sync_point as sync_point_object
from heat.rpc import worker_client
@@ -525,6 +526,36 @@ class StackConvergenceCreateUpdateDeleteTest(common.HeatTestCase):
self.assertTrue(mock_syncpoint_del.called)
self.assertTrue(mock_ccu.called)
+ def test_snapshot_delete(self, mock_cr):
+ tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
+ 'Resources': {'R1': {'Type': 'GenericResourceType'}}}
+ stack = parser.Stack(utils.dummy_context(), 'updated_time_test',
+ templatem.Template(tmpl))
+ stack.current_traversal = 'prev_traversal'
+ stack.action, stack.status = stack.CREATE, stack.COMPLETE
+ stack.store()
+ snapshot_values = {
+ 'stack_id': stack.id,
+ 'name': 'fake_snapshot',
+ 'tenant': stack.context.tenant_id,
+ 'status': 'COMPLETE',
+ 'data': None
+ }
+ snapshot_objects.Snapshot.create(stack.context, snapshot_values)
+
+ # Ensure that snapshot is not deleted on stack update
+ stack.converge_stack(template=stack.t, action=stack.UPDATE)
+ db_snapshot_obj = snapshot_objects.Snapshot.get_all(
+ stack.context, stack.id)
+ self.assertEqual('fake_snapshot', db_snapshot_obj[0].name)
+ self.assertEqual(stack.id, db_snapshot_obj[0].stack_id)
+
+ # Ensure that snapshot is deleted on stack delete
+ stack.converge_stack(template=stack.t, action=stack.DELETE)
+ self.assertEqual([], snapshot_objects.Snapshot.get_all(
+ stack.context, stack.id))
+ self.assertTrue(mock_cr.called)
+
@mock.patch.object(parser.Stack, '_persist_state')
class TestConvgStackStateSet(common.HeatTestCase):