diff options
author | Zuul <zuul@review.openstack.org> | 2018-07-30 18:06:36 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2018-07-30 18:06:37 +0000 |
commit | 15554a2debda84e3f49d3c0b2e056a1372f3de13 (patch) | |
tree | 8bebb6c973152b5737b6e030308345505173ac46 /heat/tests | |
parent | 3fffd382e912bdd3df21c4c99a4058146c3dfe5e (diff) | |
parent | 5ec5a061ea48efb8407b7da5b6a9055b56132ea3 (diff) | |
download | heat-15554a2debda84e3f49d3c0b2e056a1372f3de13.tar.gz |
Merge "Delete snapshots using contemporary resources"
Diffstat (limited to 'heat/tests')
-rw-r--r-- | heat/tests/test_convg_stack.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/heat/tests/test_convg_stack.py b/heat/tests/test_convg_stack.py index df24fb2e9..8e6c5d87f 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 @@ -509,6 +510,37 @@ 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() + stack.thread_group_mgr = tools.DummyThreadGroupManager() + 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): |