blob: 5c1783af7f5245ff482668fa0267b6336e4a5ed1 [file] [log] [blame]
Sergey Kraynev86a6a412016-03-10 21:39:48 -05001# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13from heat_integrationtests.functional import functional_base
14
15
16class OSWaitCondition(functional_base.FunctionalTestsBase):
17
18 template = '''
19heat_template_version: 2013-05-23
20parameters:
21 flavor:
22 type: string
23 image:
24 type: string
25 network:
26 type: string
27 timeout:
28 type: number
29 default: 60
30resources:
31 instance1:
32 type: OS::Nova::Server
33 properties:
34 flavor: {get_param: flavor}
35 image: {get_param: image}
36 networks:
37 - network: {get_param: network}
38 user_data_format: RAW
39 user_data:
40 str_replace:
41 template: '#!/bin/sh
42
43 wc_notify --data-binary ''{"status": "SUCCESS"}''
44
45 # signals with reason
46
47 wc_notify --data-binary ''{"status": "SUCCESS", "reason":
48 "signal2"}''
49
50 # signals with data
51
52 wc_notify --data-binary ''{"status": "SUCCESS", "reason":
53 "signal3", "data": "data3"}''
54
55 wc_notify --data-binary ''{"status": "SUCCESS", "reason":
56 "signal4", "data": "data4"}''
57
58 # check signals with the same number
59
60 wc_notify --data-binary ''{"status": "SUCCESS", "id": "5"}''
61
62 wc_notify --data-binary ''{"status": "SUCCESS", "id": "5"}''
63
Sergey Kraynev742d61a2016-03-24 04:30:39 -040064 # loop for 20 signals without reasons and data
Sergey Kraynev86a6a412016-03-10 21:39:48 -050065
Sergey Kraynev742d61a2016-03-24 04:30:39 -040066 for i in `seq 1 20`; do wc_notify --data-binary ''{"status":
Sergey Kraynev86a6a412016-03-10 21:39:48 -050067 "SUCCESS"}'' & done
68
69 wait
70 '
71 params:
72 wc_notify:
73 get_attr: [wait_handle, curl_cli]
74
75 wait_condition:
76 type: OS::Heat::WaitCondition
77 depends_on: instance1
78 properties:
Sergey Kraynev742d61a2016-03-24 04:30:39 -040079 count: 25
Sergey Kraynev86a6a412016-03-10 21:39:48 -050080 handle: {get_resource: wait_handle}
81 timeout: {get_param: timeout}
82
83 wait_handle:
84 type: OS::Heat::WaitConditionHandle
85
86outputs:
87 curl_cli:
88 value:
89 get_attr: [wait_handle, curl_cli]
90 wc_data:
91 value:
92 get_attr: [wait_condition, data]
93'''
94
95 def setUp(self):
96 super(OSWaitCondition, self).setUp()
97 if not self.conf.minimal_image_ref:
98 raise self.skipException("No minimal image configured to test")
99 if not self.conf.minimal_instance_type:
100 raise self.skipException("No minimal flavor configured to test")
101
102 def test_create_stack_with_multi_signal_waitcondition(self):
103 params = {'flavor': self.conf.minimal_instance_type,
104 'image': self.conf.minimal_image_ref,
Sergey Kraynev742d61a2016-03-24 04:30:39 -0400105 'network': self.conf.fixed_network_name,
106 'timeout': 120}
Sergey Kraynev86a6a412016-03-10 21:39:48 -0500107 self.stack_create(template=self.template, parameters=params)