Merge "Do not pass both port-id and fixed-ip to create server"
diff --git a/functional/test_create_update.py b/functional/test_create_update.py
index c9b8add..8c78951 100644
--- a/functional/test_create_update.py
+++ b/functional/test_create_update.py
@@ -520,10 +520,8 @@
                  'image': self.conf.minimal_image_ref,
                  'network': self.conf.fixed_network_name,
                  'user_data': ''}
-        name = self._stack_rand_name()
 
         stack_identifier = self.stack_create(
-            stack_name=name,
             template=self.update_userdata_template,
             parameters=parms
         )
diff --git a/functional/test_preview_update.py b/functional/test_preview_update.py
index 85306de..0e39bc9 100644
--- a/functional/test_preview_update.py
+++ b/functional/test_preview_update.py
@@ -10,7 +10,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-
 from heat_integrationtests.functional import functional_base
 
 test_template_one_resource = {
@@ -57,12 +56,9 @@
 
 class UpdatePreviewStackTest(functional_base.FunctionalTestsBase):
 
-    def setUp(self):
-        super(UpdatePreviewStackTest, self).setUp()
+    def test_add_resource(self):
         self.stack_identifier = self.stack_create(
             template=test_template_one_resource)
-
-    def test_add_resource(self):
         result = self.preview_update_stack(self.stack_identifier,
                                            test_template_two_resource)
         changes = result['resource_changes']
@@ -78,6 +74,8 @@
             self.assertEqual([], changes[section])
 
     def test_no_change(self):
+        self.stack_identifier = self.stack_create(
+            template=test_template_one_resource)
         result = self.preview_update_stack(self.stack_identifier,
                                            test_template_one_resource)
         changes = result['resource_changes']
@@ -90,6 +88,8 @@
             self.assertEqual([], changes[section])
 
     def test_update_resource(self):
+        self.stack_identifier = self.stack_create(
+            template=test_template_one_resource)
         test_template_updated_resource = {
             'heat_template_version': '2013-05-23',
             'description': 'Test template to create one instance.',
@@ -118,19 +118,8 @@
             self.assertEqual([], changes[section])
 
     def test_replaced_resource(self):
-        orig_template = {
-            'heat_template_version': '2013-05-23',
-            'description': 'Test template to create one instance.',
-            'resources': {
-                'test1': {
-                    'type': 'OS::Heat::TestResource',
-                    'properties': {
-                        'update_replace': False,
-                    }
-                }
-            }
-        }
-
+        self.stack_identifier = self.stack_create(
+            template=test_template_one_resource)
         new_template = {
             'heat_template_version': '2013-05-23',
             'description': 'Test template to create one instance.',
@@ -144,8 +133,7 @@
             }
         }
 
-        stack_identifier = self.stack_create(template=orig_template)
-        result = self.preview_update_stack(stack_identifier, new_template)
+        result = self.preview_update_stack(self.stack_identifier, new_template)
         changes = result['resource_changes']
 
         replaced = changes['replaced'][0]['resource_name']
@@ -156,9 +144,9 @@
             self.assertEqual([], changes[section])
 
     def test_delete_resource(self):
-        stack_identifier = self.stack_create(
+        self.stack_identifier = self.stack_create(
             template=test_template_two_resource)
-        result = self.preview_update_stack(stack_identifier,
+        result = self.preview_update_stack(self.stack_identifier,
                                            test_template_one_resource)
         changes = result['resource_changes']
 
diff --git a/functional/test_purge.py b/functional/test_purge.py
new file mode 100644
index 0000000..42feee3
--- /dev/null
+++ b/functional/test_purge.py
@@ -0,0 +1,47 @@
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+from oslo_concurrency import processutils
+
+from heat_integrationtests.functional import functional_base
+
+
+class PurgeTest(functional_base.FunctionalTestsBase):
+    template = '''
+heat_template_version: 2014-10-16
+parameters:
+resources:
+  test_resource:
+    type: OS::Heat::TestResource
+'''
+
+    def test_purge(self):
+        stack_identifier = self.stack_create(template=self.template)
+        self._stack_delete(stack_identifier)
+        stacks = dict((stack.id, stack) for stack in
+                      self.client.stacks.list(show_deleted=True))
+        self.assertIn(stack_identifier.split('/')[1], stacks)
+        cmd = "heat-manage purge_deleted 0"
+        processutils.execute(cmd, shell=True)
+        stacks = dict((stack.id, stack) for stack in
+                      self.client.stacks.list(show_deleted=True))
+        self.assertNotIn(stack_identifier.split('/')[1], stacks)
+
+        # Test with tags
+        stack_identifier = self.stack_create(template=self.template,
+                                             tags="foo,bar")
+        self._stack_delete(stack_identifier)
+        cmd = "heat-manage purge_deleted 0"
+        processutils.execute(cmd, shell=True)
+        stacks = dict((stack.id, stack) for stack in
+                      self.client.stacks.list(show_deleted=True))
+        self.assertNotIn(stack_identifier.split('/')[1], stacks)
diff --git a/functional/test_remote_stack.py b/functional/test_remote_stack.py
index 91a165c..96306ac 100644
--- a/functional/test_remote_stack.py
+++ b/functional/test_remote_stack.py
@@ -78,11 +78,9 @@
         self.assertEqual(remote_resources, self.list_resources(remote_id))
 
     def test_stack_create_bad_region(self):
-        stack_name = self._stack_rand_name()
         tmpl_bad_region = self.template.replace('RegionOne', 'DARKHOLE')
         files = {'remote_stack.yaml': self.remote_template}
         kwargs = {
-            'stack_name': stack_name,
             'template': tmpl_bad_region,
             'files': files
         }
@@ -94,10 +92,9 @@
         self.assertEqual(error_msg, six.text_type(ex))
 
     def test_stack_resource_validation_fail(self):
-        stack_name = self._stack_rand_name()
         tmpl_bad_format = self.remote_template.replace('resources', 'resource')
         files = {'remote_stack.yaml': tmpl_bad_format}
-        kwargs = {'stack_name': stack_name, 'files': files}
+        kwargs = {'files': files}
         ex = self.assertRaises(exc.HTTPBadRequest, self.stack_create, **kwargs)
 
         error_msg = ('ERROR: Failed validating stack template using Heat '
diff --git a/scenario/test_server_software_config.py b/scenario/test_server_software_config.py
index ad76763..75de02e 100644
--- a/scenario/test_server_software_config.py
+++ b/scenario/test_server_software_config.py
@@ -37,15 +37,12 @@
   mode    => 0644,
   content => "The file /tmp/$::bar contains $::foo for server \
 $::deploy_server_id during $::deploy_action",
-}'''
+}
+'''
 
 
 class SoftwareConfigIntegrationTest(scenario_base.ScenarioTestsBase):
 
-    def setUp(self):
-        super(SoftwareConfigIntegrationTest, self).setUp()
-        self.stack_name = self._stack_rand_name()
-
     def check_stack(self):
         sid = self.stack_identifier
         # Check that all stack resources were created
@@ -160,7 +157,6 @@
 
         # Launch stack
         self.stack_identifier = self.launch_stack(
-            stack_name=self.stack_name,
             template_name='test_server_software_config.yaml',
             parameters=parameters,
             files=dict(list(files.items()) + list(env_files.items())),