blob: 42feee3248d06e38be388d15cdb0ac88deb25f75 [file] [log] [blame]
Thomas Herve0f70c282015-12-09 16:45:30 +01001# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13from oslo_concurrency import processutils
14
15from heat_integrationtests.functional import functional_base
16
17
18class PurgeTest(functional_base.FunctionalTestsBase):
19 template = '''
20heat_template_version: 2014-10-16
21parameters:
22resources:
23 test_resource:
24 type: OS::Heat::TestResource
25'''
26
27 def test_purge(self):
28 stack_identifier = self.stack_create(template=self.template)
29 self._stack_delete(stack_identifier)
30 stacks = dict((stack.id, stack) for stack in
31 self.client.stacks.list(show_deleted=True))
32 self.assertIn(stack_identifier.split('/')[1], stacks)
33 cmd = "heat-manage purge_deleted 0"
34 processutils.execute(cmd, shell=True)
35 stacks = dict((stack.id, stack) for stack in
36 self.client.stacks.list(show_deleted=True))
37 self.assertNotIn(stack_identifier.split('/')[1], stacks)
38
39 # Test with tags
40 stack_identifier = self.stack_create(template=self.template,
41 tags="foo,bar")
42 self._stack_delete(stack_identifier)
43 cmd = "heat-manage purge_deleted 0"
44 processutils.execute(cmd, shell=True)
45 stacks = dict((stack.id, stack) for stack in
46 self.client.stacks.list(show_deleted=True))
47 self.assertNotIn(stack_identifier.split('/')[1], stacks)