Merge "Add wait_secs to test_stack_update_from_failed_patch"
diff --git a/common/test.py b/common/test.py
index 42fa43c..16d5920 100644
--- a/common/test.py
+++ b/common/test.py
@@ -377,7 +377,6 @@
         env = environment or {}
         env_files = files or {}
         parameters = parameters or {}
-        stack_name = stack_identifier.split('/')[0]
 
         self.updated_time[stack_identifier] = self.client.stacks.get(
             stack_identifier, resolve_outputs=False).updated_time
@@ -385,7 +384,6 @@
         self._handle_in_progress(
             self.client.stacks.update,
             stack_id=stack_identifier,
-            stack_name=stack_name,
             template=template,
             files=env_files,
             disable_rollback=disable_rollback,
@@ -410,11 +408,9 @@
         env = environment or {}
         env_files = files or {}
         parameters = parameters or {}
-        stack_name = stack_identifier.split('/')[0]
 
         return self.client.stacks.preview_update(
             stack_id=stack_identifier,
-            stack_name=stack_name,
             template=template,
             files=env_files,
             disable_rollback=disable_rollback,
@@ -558,8 +554,7 @@
                 'SUSPEND' in self.conf.skip_test_stack_action_list):
             self.addCleanup(self._stack_delete, stack_identifier)
             self.skipTest('Testing Stack suspend disabled in conf, skipping')
-        stack_name = stack_identifier.split('/')[0]
-        self._handle_in_progress(self.client.actions.suspend, stack_name)
+        self._handle_in_progress(self.client.actions.suspend, stack_identifier)
         # improve debugging by first checking the resource's state.
         self._wait_for_all_resource_status(stack_identifier,
                                            'SUSPEND_COMPLETE')
@@ -570,8 +565,7 @@
                 'RESUME' in self.conf.skip_test_stack_action_list):
             self.addCleanup(self._stack_delete, stack_identifier)
             self.skipTest('Testing Stack resume disabled in conf, skipping')
-        stack_name = stack_identifier.split('/')[0]
-        self._handle_in_progress(self.client.actions.resume, stack_name)
+        self._handle_in_progress(self.client.actions.resume, stack_identifier)
         # improve debugging by first checking the resource's state.
         self._wait_for_all_resource_status(stack_identifier,
                                            'RESUME_COMPLETE')
@@ -595,3 +589,11 @@
                 if len(matched) == num_expected:
                     return matched
             time.sleep(build_interval)
+
+    def check_autoscale_complete(self, stack_id, expected_num):
+        res_list = self.client.resources.list(stack_id)
+        all_res_complete = all(res.resource_status in ('UPDATE_COMPLETE',
+                                                       'CREATE_COMPLETE')
+                               for res in res_list)
+        all_res = len(res_list) == expected_num
+        return all_res and all_res_complete
diff --git a/functional/test_nova_server_networks.py b/functional/test_nova_server_networks.py
index ae550b2..f258f83 100644
--- a/functional/test_nova_server_networks.py
+++ b/functional/test_nova_server_networks.py
@@ -31,6 +31,16 @@
     properties:
       network: {get_resource: net}
       cidr: 11.11.11.0/24
+  security_group:
+    type: OS::Neutron::SecurityGroup
+    properties:
+      name: the_sg
+      description: Ping and SSH
+      rules:
+      - protocol: icmp
+      - protocol: tcp
+        port_range_min: 22
+        port_range_max: 22
   server:
     type: OS::Nova::Server
     properties:
@@ -39,6 +49,8 @@
       networks:
         - subnet: {get_resource: subnet}
           fixed_ip: 11.11.11.11
+      security_groups:
+        - {get_resource: security_group}
 outputs:
   networks:
     value: {get_attr: [server, networks]}
@@ -55,7 +67,7 @@
         output = self._stack_output(stack, output_key)
         return output
 
-    def test_create_server_with_subnet_fixed_ip(self):
+    def test_create_server_with_subnet_fixed_ip_sec_group(self):
         parms = {'flavor': self.conf.minimal_instance_type,
                  'image': self.conf.minimal_image_ref}
         stack_identifier = self.stack_create(
@@ -65,6 +77,12 @@
         networks = self.get_outputs(stack_identifier, 'networks')
         self.assertEqual(['11.11.11.11'], networks['my_net'])
 
+        server_resource = self.client.resources.get(
+            stack_identifier, 'server')
+        server_id = server_resource.physical_resource_id
+        server = self.compute_client.servers.get(server_id)
+        self.assertEqual([{"name": "the_sg"}], server.security_groups)
+
     def test_create_update_server_with_subnet(self):
         parms = {'flavor': self.conf.minimal_instance_type,
                  'image': self.conf.minimal_image_ref}
diff --git a/functional/test_resources_list.py b/functional/test_resources_list.py
new file mode 100644
index 0000000..257afc5
--- /dev/null
+++ b/functional/test_resources_list.py
@@ -0,0 +1,43 @@
+#    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 heat_integrationtests.functional import functional_base
+
+
+test_template_depend = {
+    'heat_template_version': '2013-05-23',
+    'resources': {
+        'test1': {
+            'type': 'OS::Heat::TestResource',
+            'properties': {
+                'value': 'Test1',
+            }
+        },
+        'test2': {
+            'type': 'OS::Heat::TestResource',
+            'depends_on': ['test1'],
+            'properties': {
+                'value': 'Test2',
+            }
+        }
+    }
+}
+
+
+class ResourcesList(functional_base.FunctionalTestsBase):
+
+    def test_filtering_with_depend(self):
+        stack_identifier = self.stack_create(template=test_template_depend)
+        [test2] = self.client.resources.list(stack_identifier,
+                                             filters={'name': 'test2'})
+
+        self.assertEqual('CREATE_COMPLETE', test2.resource_status)
diff --git a/scenario/test_autoscaling_lb.py b/scenario/test_autoscaling_lb.py
index f5b292e..833e9a8 100644
--- a/scenario/test_autoscaling_lb.py
+++ b/scenario/test_autoscaling_lb.py
@@ -48,14 +48,6 @@
                 resp.add(r.text)
         self.assertEqual(expected_num, len(resp))
 
-    def autoscale_complete(self, stack_id, expected_num):
-        res_list = self.client.resources.list(stack_id)
-        all_res_complete = all(res.resource_status in ('UPDATE_COMPLETE',
-                                                       'CREATE_COMPLETE')
-                               for res in res_list)
-        all_res = len(res_list) == expected_num
-        return all_res and all_res_complete
-
     def test_autoscaling_loadbalancer_neutron(self):
         """Check work of AutoScaing and Neutron LBaaS v1 resource in Heat.
 
@@ -111,7 +103,7 @@
         asg = self.client.resources.get(sid, 'asg')
         test.call_until_true(self.conf.build_timeout,
                              self.conf.build_interval,
-                             self.autoscale_complete,
+                             self.check_autoscale_complete,
                              asg.physical_resource_id, 2)
 
         # Check number of distinctive responses, must now be 2
diff --git a/scenario/test_autoscaling_lbv2.py b/scenario/test_autoscaling_lbv2.py
index 89c4877..b3a1842 100644
--- a/scenario/test_autoscaling_lbv2.py
+++ b/scenario/test_autoscaling_lbv2.py
@@ -48,14 +48,6 @@
                 resp.add(r.text)
         self.assertEqual(expected_num, len(resp))
 
-    def autoscale_complete(self, stack_id, expected_num):
-        res_list = self.client.resources.list(stack_id)
-        all_res_complete = all(res.resource_status in ('UPDATE_COMPLETE',
-                                                       'CREATE_COMPLETE')
-                               for res in res_list)
-        all_res = len(res_list) == expected_num
-        return all_res and all_res_complete
-
     def test_autoscaling_loadbalancer_neutron(self):
         """Check work of AutoScaing and Neutron LBaaS v2 resource in Heat.
 
@@ -109,7 +101,7 @@
         asg = self.client.resources.get(sid, 'asg')
         test.call_until_true(self.conf.build_timeout,
                              self.conf.build_interval,
-                             self.autoscale_complete,
+                             self.check_autoscale_complete,
                              asg.physical_resource_id, 2)
 
         # Check number of distinctive responses, must now be 2