blob: 06f0ce1746e26c04ff9399eb53297ccd348583e0 [file] [log] [blame]
Steven Hardyd448dae2016-06-14 14:57:28 +01001# 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 SoftwareDeploymentGroupTest(functional_base.FunctionalTestsBase):
17 sd_template = '''
18heat_template_version: 2016-10-14
19
20parameters:
21 input:
22 type: string
23 default: foo_input
24
25resources:
26 config:
27 type: OS::Heat::SoftwareConfig
28 properties:
29 group: script
30 inputs:
31 - name: foo
32
33 deployment:
34 type: OS::Heat::SoftwareDeploymentGroup
35 properties:
36 config: {get_resource: config}
37 input_values:
38 foo: {get_param: input}
39 servers:
40 '0': dummy0
41 '1': dummy1
42 '2': dummy2
43 '3': dummy3
44'''
45
Rabi Mishra81ca6bc2016-06-16 15:09:20 +053046 sd_template_with_upd_policy = '''
47heat_template_version: 2016-10-14
48
49parameters:
50 input:
51 type: string
52 default: foo_input
53
54resources:
55 config:
56 type: OS::Heat::SoftwareConfig
57 properties:
58 group: script
59 inputs:
60 - name: foo
61
62 deployment:
63 type: OS::Heat::SoftwareDeploymentGroup
64 update_policy:
65 rolling_update:
66 max_batch_size: 2
67 pause_time: 1
68 properties:
69 config: {get_resource: config}
70 input_values:
71 foo: {get_param: input}
72 servers:
73 '0': dummy0
74 '1': dummy1
75 '2': dummy2
76 '3': dummy3
77'''
Steven Hardyd448dae2016-06-14 14:57:28 +010078 enable_cleanup = True
79
Rabi Mishra81ca6bc2016-06-16 15:09:20 +053080 def deployment_crud(self, template):
Steven Hardyd448dae2016-06-14 14:57:28 +010081 stack_identifier = self.stack_create(
Rabi Mishra81ca6bc2016-06-16 15:09:20 +053082 template=template,
Steven Hardyd448dae2016-06-14 14:57:28 +010083 enable_cleanup=self.enable_cleanup,
84 expected_status='CREATE_IN_PROGRESS')
85 self._wait_for_resource_status(
86 stack_identifier, 'deployment', 'CREATE_IN_PROGRESS')
87 nested_identifier = self.assert_resource_is_a_stack(
88 stack_identifier, 'deployment')
89 group_resources = self.list_group_resources(
90 stack_identifier, 'deployment', minimal=False)
91
92 self.assertEqual(4, len(group_resources))
Rabi Mishra81ca6bc2016-06-16 15:09:20 +053093 self._wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE',
94 signal_required=True,
95 resources_to_signal=group_resources)
Steven Hardyd448dae2016-06-14 14:57:28 +010096
rabiefcd0fc2017-06-07 16:44:24 +053097 created_group_resources = self.list_group_resources(
98 stack_identifier, 'deployment', minimal=False)
99
100 self.check_input_values(created_group_resources,
101 'foo', 'foo_input')
Steven Hardyd448dae2016-06-14 14:57:28 +0100102
103 self.update_stack(stack_identifier,
Rabi Mishra81ca6bc2016-06-16 15:09:20 +0530104 template=template,
Steven Hardyd448dae2016-06-14 14:57:28 +0100105 environment={'parameters': {'input': 'input2'}},
106 expected_status='UPDATE_IN_PROGRESS')
107 nested_identifier = self.assert_resource_is_a_stack(
108 stack_identifier, 'deployment')
109 self.assertEqual(4, len(group_resources))
Rabi Mishra81ca6bc2016-06-16 15:09:20 +0530110 self._wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE',
111 signal_required=True,
112 resources_to_signal=group_resources)
Steven Hardyd448dae2016-06-14 14:57:28 +0100113
Rabi Mishra81ca6bc2016-06-16 15:09:20 +0530114 self.check_input_values(group_resources, 'foo', 'input2')
Steven Hardyd448dae2016-06-14 14:57:28 +0100115
116 # We explicitly test delete here, vs just via cleanup and check
117 # the nested stack is gone
118 self._stack_delete(stack_identifier)
119 self._wait_for_stack_status(
120 nested_identifier, 'DELETE_COMPLETE',
121 success_on_not_found=True)
122
Rabi Mishra81ca6bc2016-06-16 15:09:20 +0530123 def test_deployment_crud(self):
124 self.deployment_crud(self.sd_template)
125
126 def test_deployment_crud_with_rolling_update(self):
127 self.deployment_crud(self.sd_template_with_upd_policy)
128
Steven Hardyd448dae2016-06-14 14:57:28 +0100129 def test_deployments_create_delete_in_progress(self):
130 stack_identifier = self.stack_create(
131 template=self.sd_template,
132 enable_cleanup=self.enable_cleanup,
133 expected_status='CREATE_IN_PROGRESS')
134 self._wait_for_resource_status(
135 stack_identifier, 'deployment', 'CREATE_IN_PROGRESS')
136 nested_identifier = self.assert_resource_is_a_stack(
137 stack_identifier, 'deployment')
138 group_resources = self.list_group_resources(
139 stack_identifier, 'deployment', minimal=False)
140
141 self.assertEqual(4, len(group_resources))
142 # Now test delete while the stacks are still IN_PROGRESS
143 self._stack_delete(stack_identifier)
144 self._wait_for_stack_status(
145 nested_identifier, 'DELETE_COMPLETE',
146 success_on_not_found=True)