Fix NeutronLoadBalancerTest.test_neutron_loadbalancer timeout

NeutronLoadBalancerTest.test_neutron_loadbalancer timeout
happens occasionally. Added WaitCondition resource to
signal back after SimpleHTTPServer is started.

Change-Id: I73085d1b20277fba9f28460abaa991d489d2447a
Closes-Bug: #1437203
diff --git a/scenario/templates/test_neutron_loadbalancer.yaml b/scenario/templates/test_neutron_loadbalancer.yaml
index a7e9f9c..a8c4769 100644
--- a/scenario/templates/test_neutron_loadbalancer.yaml
+++ b/scenario/templates/test_neutron_loadbalancer.yaml
@@ -17,6 +17,8 @@
   port:
     type: string
     default: '80'
+  timeout:
+    type: number
 
 resources:
   sec_group:
@@ -32,6 +34,31 @@
         - remote_ip_prefix: 0.0.0.0/0
           protocol: icmp
 
+  wait_condition:
+    type: OS::Heat::WaitCondition
+    properties:
+      handle: { get_resource: wait_condition_handle }
+      count: 2
+      timeout: { get_param: timeout }
+
+  wait_condition_handle:
+    type: OS::Heat::WaitConditionHandle
+
+  config:
+    type: OS::Heat::SoftwareConfig
+    properties:
+      group: ungrouped
+      config:
+        str_replace:
+          template: |
+            #!/bin/bash -v
+            echo  $(hostname) > index.html
+            python -m SimpleHTTPServer port &
+            wc_notify --data-binary '{"status": "SUCCESS"}'
+          params:
+            wc_notify: { get_attr: ['wait_condition_handle', 'curl_cli'] }
+            port: { get_param: port }
+
   server1:
     type: OS::Nova::Server
     properties:
@@ -40,17 +67,8 @@
       flavor: { get_param: flavor }
       key_name: { get_param: key_name }
       security_groups: [{ get_resource: sec_group }]
-      user_data:
-        list_join:
-        - ''
-        - - '#!/bin/bash -v
-
-            '
-          - 'echo  $(hostname) > index.html
-
-            '
-          - 'python -m SimpleHTTPServer '
-          - { get_param: port }
+      user_data_format: SOFTWARE_CONFIG
+      user_data: { get_resource: config }
 
   server2:
     type: OS::Nova::Server
@@ -60,17 +78,8 @@
       flavor: { get_param: flavor }
       key_name: { get_param: key_name }
       security_groups: [{ get_resource: sec_group }]
-      user_data:
-        list_join:
-        - ''
-        - - '#!/bin/bash -v
-
-            '
-          - 'echo  $(hostname) > index.html
-
-            '
-          - 'python -m SimpleHTTPServer '
-          - { get_param: port }
+      user_data_format: SOFTWARE_CONFIG
+      user_data: { get_resource: config }
 
   health_monitor:
     type: OS::Neutron::HealthMonitor
@@ -100,6 +109,7 @@
 
   LBaaS:
     type: OS::Neutron::LoadBalancer
+    depends_on: wait_condition
     properties:
       pool_id: { get_resource: test_pool }
       protocol_port: { get_param: port }
diff --git a/scenario/test_neutron_loadbalancer.py b/scenario/test_neutron_loadbalancer.py
index bbe85bc..fafa9be 100644
--- a/scenario/test_neutron_loadbalancer.py
+++ b/scenario/test_neutron_loadbalancer.py
@@ -55,7 +55,8 @@
             'flavor': self.conf.minimal_instance_type,
             'image': self.conf.image_ref,
             'private_subnet_id': self.net['subnets'][0],
-            'external_network_id': self.public_net['id']
+            'external_network_id': self.public_net['id'],
+            'timeout': self.conf.build_timeout
         }
 
         # Launch stack
@@ -70,7 +71,7 @@
         server1_ip = self._stack_output(stack, 'serv1_ip')
         server2_ip = self._stack_output(stack, 'serv2_ip')
 
-        # Check connection and info about received responces
+        # Check connection and info about received responses
         self.check_connectivity(server1_ip)
         self.collect_responses(server1_ip, {'server1\n'})