Thomas Herve | 0f70c28 | 2015-12-09 16:45:30 +0100 | [diff] [blame] | 1 | # 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 Baker | 6f68c36 | 2016-06-22 10:42:43 +1200 | [diff] [blame^] | 13 | import time |
| 14 | |
Thomas Herve | 0f70c28 | 2015-12-09 16:45:30 +0100 | [diff] [blame] | 15 | from oslo_concurrency import processutils |
| 16 | |
| 17 | from heat_integrationtests.functional import functional_base |
| 18 | |
| 19 | |
| 20 | class PurgeTest(functional_base.FunctionalTestsBase): |
| 21 | template = ''' |
| 22 | heat_template_version: 2014-10-16 |
| 23 | parameters: |
| 24 | resources: |
| 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 Baker | 6f68c36 | 2016-06-22 10:42:43 +1200 | [diff] [blame^] | 35 | time.sleep(1) |
Thomas Herve | 0f70c28 | 2015-12-09 16:45:30 +0100 | [diff] [blame] | 36 | 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 Baker | 6f68c36 | 2016-06-22 10:42:43 +1200 | [diff] [blame^] | 46 | time.sleep(1) |
Thomas Herve | 0f70c28 | 2015-12-09 16:45:30 +0100 | [diff] [blame] | 47 | 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) |