Merge "Add test for template resource suspend/resume"
diff --git a/common/config.py b/common/config.py
index 0de6480..5a33590 100644
--- a/common/config.py
+++ b/common/config.py
@@ -27,7 +27,8 @@
                help="API key to use when authenticating.",
                secret=True),
     cfg.StrOpt('tenant_name',
-               default=os.environ.get('OS_TENANT_NAME'),
+               default=(os.environ.get('OS_PROJECT_NAME') or
+                        os.environ.get('OS_TENANT_NAME')),
                help="Tenant name to use for API requests."),
     cfg.StrOpt('auth_url',
                default=os.environ.get('OS_AUTH_URL'),
@@ -105,6 +106,9 @@
     cfg.BoolOpt('skip_stack_abandon_tests',
                 default=False,
                 help="Skip Stack Abandon Integration tests"),
+    cfg.BoolOpt('skip_notification_tests',
+                default=False,
+                help="Skip Notification Integration tests"),
     cfg.IntOpt('connectivity_timeout',
                default=120,
                help="Timeout in seconds to wait for connectivity to "
diff --git a/functional/test_notifications.py b/functional/test_notifications.py
index a4c419c..c729a67 100644
--- a/functional/test_notifications.py
+++ b/functional/test_notifications.py
@@ -124,6 +124,8 @@
 
     def setUp(self):
         super(NotificationTest, self).setUp()
+        if self.conf.skip_notification_tests:
+            self.skipTest('Testing Notifications disabled in conf, skipping')
 
         self.client = self.orchestration_client
         self.exchange = kombu.Exchange('heat', 'topic', durable=False)
diff --git a/functional/test_software_config.py b/functional/test_software_config.py
new file mode 100644
index 0000000..2e0ed76
--- /dev/null
+++ b/functional/test_software_config.py
@@ -0,0 +1,77 @@
+#    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.common import test
+
+
+class ParallelDeploymentsTest(test.HeatIntegrationTest):
+    template = '''
+heat_template_version: "2013-05-23"
+parameters:
+  flavor:
+    type: string
+  image:
+    type: string
+  network:
+    type: string
+resources:
+  server:
+    type: OS::Nova::Server
+    properties:
+      image: {get_param: image}
+      flavor: {get_param: flavor}
+      user_data_format: SOFTWARE_CONFIG
+      networks: [{network: {get_param: network} }]
+  config:
+    type: OS::Heat::SoftwareConfig
+    properties:
+      config: hi!
+  dep1:
+    type: OS::Heat::SoftwareDeployment
+    properties:
+      config: {get_resource: config}
+      server: {get_resource: server}
+      signal_transport: NO_SIGNAL
+  dep2:
+    type: OS::Heat::SoftwareDeployment
+    properties:
+      config: {get_resource: config}
+      server: {get_resource: server}
+      signal_transport: NO_SIGNAL
+  dep3:
+    type: OS::Heat::SoftwareDeployment
+    properties:
+      config: {get_resource: config}
+      server: {get_resource: server}
+      signal_transport: NO_SIGNAL
+  dep4:
+    type: OS::Heat::SoftwareDeployment
+    properties:
+      config: {get_resource: config}
+      server: {get_resource: server}
+      signal_transport: NO_SIGNAL
+'''
+
+    def setUp(self):
+        super(ParallelDeploymentsTest, self).setUp()
+        self.client = self.orchestration_client
+
+    def test_fail(self):
+        parms = {'flavor': self.conf.minimal_instance_type,
+                 'network': self.conf.fixed_network_name,
+                 'image': self.conf.minimal_image_ref}
+        stack_identifier = self.stack_create(
+            parameters=parms,
+            template=self.template)
+        stack = self.client.stacks.get(stack_identifier)
+        server_metadata = self.client.resources.metadata(stack.id, 'server')
+        self.assertEqual(4, len(server_metadata['deployments']))
diff --git a/scenario/templates/test_server_cfn_init.yaml b/scenario/templates/test_server_cfn_init.yaml
index ffb8e9b..9f94717 100644
--- a/scenario/templates/test_server_cfn_init.yaml
+++ b/scenario/templates/test_server_cfn_init.yaml
@@ -28,10 +28,16 @@
     Properties:
       UserName: {Ref: CfnUser}
 
-  IPAddress:
+  ElasticIp:
     Type: AWS::EC2::EIP
     Properties:
-      InstanceId: {Ref: SmokeServer}
+      Domain: vpc
+
+  SmokeServerElasticIp:
+    Type: AWS::EC2::EIPAssociation
+    Properties:
+       EIP: {Ref: ElasticIp}
+       InstanceId: {Ref: SmokeServer}
 
   SmokeServer:
     Type: AWS::EC2::Instance
@@ -81,7 +87,11 @@
     Description: Contents of /tmp/smoke-status on SmokeServer
     Value:
       Fn::GetAtt: [WaitCondition, Data]
-  SmokeServerIp:
-    Description: IP address of server
+  ElasticIp_Id:
+    Description: Elastic ip allocation id
     Value:
-      Ref: IPAddress
+      Fn::GetAtt: [ElasticIp, AllocationId]
+  SmokeServerElasticIp:
+    Description: Elastic ip address of server
+    Value:
+      Ref: ElasticIp
diff --git a/scenario/test_neutron_autoscaling.py b/scenario/test_neutron_autoscaling.py
index e7aae19..c81e22d 100644
--- a/scenario/test_neutron_autoscaling.py
+++ b/scenario/test_neutron_autoscaling.py
@@ -20,6 +20,7 @@
 
     def setUp(self):
         super(NeutronAutoscalingTest, self).setUp()
+        raise self.skipException("Skipping until bug #1479869 is fixed.")
         if not self.conf.fixed_subnet_name:
             raise self.skipException("No sub-network configured to test")
         self.template_name = 'test_neutron_autoscaling.yaml'
diff --git a/scenario/test_neutron_loadbalancer.py b/scenario/test_neutron_loadbalancer.py
index d8e0197..a890257 100644
--- a/scenario/test_neutron_loadbalancer.py
+++ b/scenario/test_neutron_loadbalancer.py
@@ -25,6 +25,7 @@
 
     def setUp(self):
         super(NeutronLoadBalancerTest, self).setUp()
+        raise self.skipException("Skipping until bug #1479869 is fixed.")
         self.public_net = self._get_network(self.conf.floating_network_name)
         self.template_name = 'test_neutron_loadbalancer.yaml'
 
diff --git a/scenario/test_server_cfn_init.py b/scenario/test_server_cfn_init.py
index b5b1e67..197e0c0 100644
--- a/scenario/test_server_cfn_init.py
+++ b/scenario/test_server_cfn_init.py
@@ -23,11 +23,12 @@
 
     def setUp(self):
         super(CfnInitIntegrationTest, self).setUp()
+        raise self.skipException("Skipping until bug #1479869 is fixed.")
 
     def check_stack(self, sid):
         # Check status of all resources
         for res in ('WaitHandle', 'SmokeSecurityGroup', 'SmokeKeys',
-                    'CfnUser', 'SmokeServer', 'IPAddress'):
+                    'CfnUser', 'SmokeServer', 'SmokeServerElasticIp'):
             self._wait_for_resource_status(
                 sid, res, 'CREATE_COMPLETE')
 
@@ -59,7 +60,22 @@
             self._stack_output(stack, 'WaitConditionStatus'))
         self.assertEqual('smoke test complete', wait_status['smoke_status'])
 
-        server_ip = self._stack_output(stack, 'SmokeServerIp')
+        # Check EIP attributes.
+        server_floatingip_id = self._stack_output(stack,
+                                                  'ElasticIp_Id')
+        self.assertIsNotNone(server_floatingip_id)
+
+        # Fetch EIP details.
+        net_show = self.network_client.show_floatingip(
+            floatingip=server_floatingip_id)
+        floating_ip = net_show['floatingip']['floating_ip_address']
+        port_id = net_show['floatingip']['port_id']
+
+        # Ensure that EIP was assigned to server.
+        port_show = self.network_client.show_port(port=port_id)
+        self.assertEqual(server.id, port_show['port']['device_id'])
+        server_ip = self._stack_output(stack, 'SmokeServerElasticIp')
+        self.assertEqual(server_ip, floating_ip)
 
         # Check that created server is reachable
         if not self._ping_ip_address(server_ip):