blob: 22143dc4e7f12598597ff1785b9ba659eb2b9e00 [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')
Zane Bitter59426622017-06-13 19:38:39 -040087
88 # Wait for all deployment resources to become IN_PROGRESS, since only
89 # IN_PROGRESS resources get signalled
Steven Hardyd448dae2016-06-14 14:57:28 +010090 nested_identifier = self.assert_resource_is_a_stack(
91 stack_identifier, 'deployment')
Zane Bitter59426622017-06-13 19:38:39 -040092 self._wait_for_stack_status(nested_identifier, 'CREATE_IN_PROGRESS')
93 self._wait_for_all_resource_status(nested_identifier,
94 'CREATE_IN_PROGRESS')
Steven Hardyd448dae2016-06-14 14:57:28 +010095 group_resources = self.list_group_resources(
96 stack_identifier, 'deployment', minimal=False)
97
98 self.assertEqual(4, len(group_resources))
Rabi Mishra81ca6bc2016-06-16 15:09:20 +053099 self._wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE',
100 signal_required=True,
101 resources_to_signal=group_resources)
Steven Hardyd448dae2016-06-14 14:57:28 +0100102
rabiefcd0fc2017-06-07 16:44:24 +0530103 created_group_resources = self.list_group_resources(
104 stack_identifier, 'deployment', minimal=False)
Zane Bitter59426622017-06-13 19:38:39 -0400105 self.assertEqual(4, len(created_group_resources))
106 self.check_input_values(created_group_resources, 'foo', 'foo_input')
Steven Hardyd448dae2016-06-14 14:57:28 +0100107
108 self.update_stack(stack_identifier,
Rabi Mishra81ca6bc2016-06-16 15:09:20 +0530109 template=template,
Steven Hardyd448dae2016-06-14 14:57:28 +0100110 environment={'parameters': {'input': 'input2'}},
111 expected_status='UPDATE_IN_PROGRESS')
112 nested_identifier = self.assert_resource_is_a_stack(
113 stack_identifier, 'deployment')
Rabi Mishra81ca6bc2016-06-16 15:09:20 +0530114 self._wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE',
115 signal_required=True,
116 resources_to_signal=group_resources)
Steven Hardyd448dae2016-06-14 14:57:28 +0100117
Zane Bitter59426622017-06-13 19:38:39 -0400118 self.check_input_values(created_group_resources, 'foo', 'input2')
Steven Hardyd448dae2016-06-14 14:57:28 +0100119
120 # We explicitly test delete here, vs just via cleanup and check
121 # the nested stack is gone
122 self._stack_delete(stack_identifier)
123 self._wait_for_stack_status(
124 nested_identifier, 'DELETE_COMPLETE',
125 success_on_not_found=True)
126
Rabi Mishra81ca6bc2016-06-16 15:09:20 +0530127 def test_deployment_crud(self):
128 self.deployment_crud(self.sd_template)
129
130 def test_deployment_crud_with_rolling_update(self):
131 self.deployment_crud(self.sd_template_with_upd_policy)
132
Steven Hardyd448dae2016-06-14 14:57:28 +0100133 def test_deployments_create_delete_in_progress(self):
134 stack_identifier = self.stack_create(
135 template=self.sd_template,
136 enable_cleanup=self.enable_cleanup,
137 expected_status='CREATE_IN_PROGRESS')
138 self._wait_for_resource_status(
139 stack_identifier, 'deployment', 'CREATE_IN_PROGRESS')
140 nested_identifier = self.assert_resource_is_a_stack(
141 stack_identifier, 'deployment')
142 group_resources = self.list_group_resources(
143 stack_identifier, 'deployment', minimal=False)
144
145 self.assertEqual(4, len(group_resources))
146 # Now test delete while the stacks are still IN_PROGRESS
147 self._stack_delete(stack_identifier)
148 self._wait_for_stack_status(
149 nested_identifier, 'DELETE_COMPLETE',
150 success_on_not_found=True)