Merge "Add lbaas v2 scenario test"
diff --git a/common/clients.py b/common/clients.py
index acbf239..8913595 100644
--- a/common/clients.py
+++ b/common/clients.py
@@ -110,7 +110,8 @@
                 password=self.conf.password)
 
     def _get_identity_client(self):
-        domain = self.conf.domain_name
+        user_domain_name = self.conf.user_domain_name
+        project_domain_name = self.conf.project_domain_name
         kwargs = {
             'username': self.conf.username,
             'password': self.conf.password,
@@ -120,8 +121,8 @@
         # keystone v2 can't ignore domain details
         if self.auth_version == '3':
             kwargs.update({
-                'project_domain_name': domain,
-                'user_domain_name': domain})
+                'user_domain_name': user_domain_name,
+                'project_domain_name': project_domain_name})
         auth = password.Password(**kwargs)
         if self.insecure:
             verify_cert = False
@@ -196,7 +197,8 @@
         return swift_client.Connection(**args)
 
     def _get_metering_client(self):
-        domain = self.conf.domain_name
+        user_domain_name = self.conf.user_domain_name
+        project_domain_name = self.conf.project_domain_name
         try:
             endpoint = self.identity_client.get_endpoint_url('metering',
                                                              self.conf.region)
@@ -218,8 +220,8 @@
             # v2 auth_url
             if self.auth_version == '3':
                 args.update(
-                    {'user_domain_name': domain,
-                     'project_domain_name': domain})
+                    {'user_domain_name': user_domain_name,
+                     'project_domain_name': project_domain_name})
 
             return ceilometer_client.Client(self.CEILOMETER_VERSION,
                                             endpoint, **args)
diff --git a/common/config.py b/common/config.py
index 3aee48f..e99d034 100644
--- a/common/config.py
+++ b/common/config.py
@@ -38,9 +38,13 @@
     cfg.StrOpt('auth_url',
                default=os.environ.get('OS_AUTH_URL'),
                help="Full URI of the OpenStack Identity API (Keystone)"),
-    cfg.StrOpt('domain_name',
-               default='default',
-               help="User/project domain name, if keystone v3 auth_url"
+    cfg.StrOpt('user_domain_name',
+               default=os.environ.get('OS_USER_DOMAIN_NAME'),
+               help="User domain name, if keystone v3 auth_url"
+                    "is used"),
+    cfg.StrOpt('project_domain_name',
+               default=os.environ.get('OS_PROJECT_DOMAIN_NAME'),
+               help="Project domain name, if keystone v3 auth_url"
                     "is used"),
     cfg.StrOpt('region',
                default=os.environ.get('OS_REGION_NAME'),
diff --git a/functional/test_os_wait_condition.py b/functional/test_os_wait_condition.py
new file mode 100644
index 0000000..5eb3294
--- /dev/null
+++ b/functional/test_os_wait_condition.py
@@ -0,0 +1,106 @@
+#    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
+
+
+class OSWaitCondition(functional_base.FunctionalTestsBase):
+
+    template = '''
+heat_template_version: 2013-05-23
+parameters:
+  flavor:
+    type: string
+  image:
+    type: string
+  network:
+    type: string
+  timeout:
+    type: number
+    default: 60
+resources:
+  instance1:
+    type: OS::Nova::Server
+    properties:
+      flavor: {get_param: flavor}
+      image: {get_param: image}
+      networks:
+      - network: {get_param: network}
+      user_data_format: RAW
+      user_data:
+        str_replace:
+          template: '#!/bin/sh
+
+            wc_notify --data-binary ''{"status": "SUCCESS"}''
+
+            # signals with reason
+
+            wc_notify --data-binary ''{"status": "SUCCESS", "reason":
+            "signal2"}''
+
+            # signals with data
+
+            wc_notify --data-binary ''{"status": "SUCCESS", "reason":
+            "signal3", "data": "data3"}''
+
+            wc_notify --data-binary ''{"status": "SUCCESS", "reason":
+            "signal4", "data": "data4"}''
+
+            # check signals with the same number
+
+            wc_notify --data-binary ''{"status": "SUCCESS", "id": "5"}''
+
+            wc_notify --data-binary ''{"status": "SUCCESS", "id": "5"}''
+
+            # loop for 25 signals without reasons and data
+
+            for i in `seq 1 25`; do wc_notify --data-binary ''{"status":
+            "SUCCESS"}'' & done
+
+            wait
+            '
+          params:
+            wc_notify:
+              get_attr: [wait_handle, curl_cli]
+
+  wait_condition:
+    type: OS::Heat::WaitCondition
+    depends_on: instance1
+    properties:
+      count: 30
+      handle: {get_resource: wait_handle}
+      timeout: {get_param: timeout}
+
+  wait_handle:
+    type: OS::Heat::WaitConditionHandle
+
+outputs:
+  curl_cli:
+    value:
+      get_attr: [wait_handle, curl_cli]
+  wc_data:
+    value:
+      get_attr: [wait_condition, data]
+'''
+
+    def setUp(self):
+        super(OSWaitCondition, self).setUp()
+        if not self.conf.minimal_image_ref:
+            raise self.skipException("No minimal image configured to test")
+        if not self.conf.minimal_instance_type:
+            raise self.skipException("No minimal flavor configured to test")
+
+    def test_create_stack_with_multi_signal_waitcondition(self):
+        params = {'flavor': self.conf.minimal_instance_type,
+                  'image': self.conf.minimal_image_ref,
+                  'network': self.conf.fixed_network_name}
+        self.stack_create(template=self.template, parameters=params)
diff --git a/functional/test_remote_stack.py b/functional/test_remote_stack.py
index 96306ac..b82958c 100644
--- a/functional/test_remote_stack.py
+++ b/functional/test_remote_stack.py
@@ -45,6 +45,9 @@
 
     def setUp(self):
         super(RemoteStackTest, self).setUp()
+        # replacing the template region with the one from the config
+        self.template = self.template.replace('RegionOne',
+                                              self.conf.region)
 
     def test_remote_stack_alone(self):
         stack_id = self.stack_create(template=self.remote_template)
@@ -78,7 +81,7 @@
         self.assertEqual(remote_resources, self.list_resources(remote_id))
 
     def test_stack_create_bad_region(self):
-        tmpl_bad_region = self.template.replace('RegionOne', 'DARKHOLE')
+        tmpl_bad_region = self.template.replace(self.conf.region, 'DARKHOLE')
         files = {'remote_stack.yaml': self.remote_template}
         kwargs = {
             'template': tmpl_bad_region,
@@ -98,8 +101,9 @@
         ex = self.assertRaises(exc.HTTPBadRequest, self.stack_create, **kwargs)
 
         error_msg = ('ERROR: Failed validating stack template using Heat '
-                     'endpoint at region "RegionOne" due to '
-                     '"ERROR: The template section is invalid: resource"')
+                     'endpoint at region "%s" due to '
+                     '"ERROR: The template section is '
+                     'invalid: resource"') % self.conf.region
         self.assertEqual(error_msg, six.text_type(ex))
 
     def test_stack_update(self):
diff --git a/functional/test_templates.py b/functional/test_templates.py
index dfc9c4f..82a1af4 100644
--- a/functional/test_templates.py
+++ b/functional/test_templates.py
@@ -54,7 +54,7 @@
         supported_template_versions = ["2013-05-23", "2014-10-16",
                                        "2015-04-30", "2015-10-15",
                                        "2012-12-12", "2010-09-09",
-                                       "2016-04-08"]
+                                       "2016-04-08", "2016-10-14"]
         for template in template_versions:
             self.assertIn(template.version.split(".")[1],
                           supported_template_versions)