blob: 4e8b868a26d2f11e6970a40623e32e2840dc0d69 [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
Rabi Mishra81ca6bc2016-06-16 15:09:20 +053097 self.check_input_values(group_resources, 'foo', 'foo_input')
Steven Hardyd448dae2016-06-14 14:57:28 +010098
99 self.update_stack(stack_identifier,
Rabi Mishra81ca6bc2016-06-16 15:09:20 +0530100 template=template,
Steven Hardyd448dae2016-06-14 14:57:28 +0100101 environment={'parameters': {'input': 'input2'}},
102 expected_status='UPDATE_IN_PROGRESS')
103 nested_identifier = self.assert_resource_is_a_stack(
104 stack_identifier, 'deployment')
105 self.assertEqual(4, len(group_resources))
Rabi Mishra81ca6bc2016-06-16 15:09:20 +0530106 self._wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE',
107 signal_required=True,
108 resources_to_signal=group_resources)
Steven Hardyd448dae2016-06-14 14:57:28 +0100109
Rabi Mishra81ca6bc2016-06-16 15:09:20 +0530110 self.check_input_values(group_resources, 'foo', 'input2')
Steven Hardyd448dae2016-06-14 14:57:28 +0100111
112 # We explicitly test delete here, vs just via cleanup and check
113 # the nested stack is gone
114 self._stack_delete(stack_identifier)
115 self._wait_for_stack_status(
116 nested_identifier, 'DELETE_COMPLETE',
117 success_on_not_found=True)
118
Rabi Mishra81ca6bc2016-06-16 15:09:20 +0530119 def test_deployment_crud(self):
120 self.deployment_crud(self.sd_template)
121
122 def test_deployment_crud_with_rolling_update(self):
123 self.deployment_crud(self.sd_template_with_upd_policy)
124
Steven Hardyd448dae2016-06-14 14:57:28 +0100125 def test_deployments_create_delete_in_progress(self):
126 stack_identifier = self.stack_create(
127 template=self.sd_template,
128 enable_cleanup=self.enable_cleanup,
129 expected_status='CREATE_IN_PROGRESS')
130 self._wait_for_resource_status(
131 stack_identifier, 'deployment', 'CREATE_IN_PROGRESS')
132 nested_identifier = self.assert_resource_is_a_stack(
133 stack_identifier, 'deployment')
134 group_resources = self.list_group_resources(
135 stack_identifier, 'deployment', minimal=False)
136
137 self.assertEqual(4, len(group_resources))
138 # Now test delete while the stacks are still IN_PROGRESS
139 self._stack_delete(stack_identifier)
140 self._wait_for_stack_status(
141 nested_identifier, 'DELETE_COMPLETE',
142 success_on_not_found=True)