blob: fd652a971c101fbe17f744f01124a3b9e037abde [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
Steve Baker6f68c362016-06-22 10:42:43 +120013import time
14
Thomas Herve0f70c282015-12-09 16:45:30 +010015from oslo_concurrency import processutils
16
17from heat_integrationtests.functional import functional_base
18
19
20class PurgeTest(functional_base.FunctionalTestsBase):
21 template = '''
22heat_template_version: 2014-10-16
23parameters:
24resources:
25 test_resource:
26 type: OS::Heat::TestResource
27'''
28
29 def test_purge(self):
30 stack_identifier = self.stack_create(template=self.template)
31 self._stack_delete(stack_identifier)
32 stacks = dict((stack.id, stack) for stack in
33 self.client.stacks.list(show_deleted=True))
34 self.assertIn(stack_identifier.split('/')[1], stacks)
Steve Baker6f68c362016-06-22 10:42:43 +120035 time.sleep(1)
Thomas Herve0f70c282015-12-09 16:45:30 +010036 cmd = "heat-manage purge_deleted 0"
37 processutils.execute(cmd, shell=True)
38 stacks = dict((stack.id, stack) for stack in
39 self.client.stacks.list(show_deleted=True))
40 self.assertNotIn(stack_identifier.split('/')[1], stacks)
41
42 # Test with tags
43 stack_identifier = self.stack_create(template=self.template,
44 tags="foo,bar")
45 self._stack_delete(stack_identifier)
Steve Baker6f68c362016-06-22 10:42:43 +120046 time.sleep(1)
Thomas Herve0f70c282015-12-09 16:45:30 +010047 cmd = "heat-manage purge_deleted 0"
48 processutils.execute(cmd, shell=True)
49 stacks = dict((stack.id, stack) for stack in
50 self.client.stacks.list(show_deleted=True))
51 self.assertNotIn(stack_identifier.split('/')[1], stacks)