Steven Hardy | d448dae | 2016-06-14 14:57:28 +0100 | [diff] [blame] | 1 | # 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 | |
| 13 | from heat_integrationtests.functional import functional_base |
| 14 | |
| 15 | |
| 16 | class SoftwareDeploymentGroupTest(functional_base.FunctionalTestsBase): |
| 17 | sd_template = ''' |
| 18 | heat_template_version: 2016-10-14 |
| 19 | |
| 20 | parameters: |
| 21 | input: |
| 22 | type: string |
| 23 | default: foo_input |
| 24 | |
| 25 | resources: |
| 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 Mishra | 81ca6bc | 2016-06-16 15:09:20 +0530 | [diff] [blame^] | 46 | sd_template_with_upd_policy = ''' |
| 47 | heat_template_version: 2016-10-14 |
| 48 | |
| 49 | parameters: |
| 50 | input: |
| 51 | type: string |
| 52 | default: foo_input |
| 53 | |
| 54 | resources: |
| 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 Hardy | d448dae | 2016-06-14 14:57:28 +0100 | [diff] [blame] | 78 | enable_cleanup = True |
| 79 | |
Rabi Mishra | 81ca6bc | 2016-06-16 15:09:20 +0530 | [diff] [blame^] | 80 | def deployment_crud(self, template): |
Steven Hardy | d448dae | 2016-06-14 14:57:28 +0100 | [diff] [blame] | 81 | stack_identifier = self.stack_create( |
Rabi Mishra | 81ca6bc | 2016-06-16 15:09:20 +0530 | [diff] [blame^] | 82 | template=template, |
Steven Hardy | d448dae | 2016-06-14 14:57:28 +0100 | [diff] [blame] | 83 | 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 Mishra | 81ca6bc | 2016-06-16 15:09:20 +0530 | [diff] [blame^] | 93 | self._wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE', |
| 94 | signal_required=True, |
| 95 | resources_to_signal=group_resources) |
Steven Hardy | d448dae | 2016-06-14 14:57:28 +0100 | [diff] [blame] | 96 | |
Rabi Mishra | 81ca6bc | 2016-06-16 15:09:20 +0530 | [diff] [blame^] | 97 | self.check_input_values(group_resources, 'foo', 'foo_input') |
Steven Hardy | d448dae | 2016-06-14 14:57:28 +0100 | [diff] [blame] | 98 | |
| 99 | self.update_stack(stack_identifier, |
Rabi Mishra | 81ca6bc | 2016-06-16 15:09:20 +0530 | [diff] [blame^] | 100 | template=template, |
Steven Hardy | d448dae | 2016-06-14 14:57:28 +0100 | [diff] [blame] | 101 | 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 Mishra | 81ca6bc | 2016-06-16 15:09:20 +0530 | [diff] [blame^] | 106 | self._wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE', |
| 107 | signal_required=True, |
| 108 | resources_to_signal=group_resources) |
Steven Hardy | d448dae | 2016-06-14 14:57:28 +0100 | [diff] [blame] | 109 | |
Rabi Mishra | 81ca6bc | 2016-06-16 15:09:20 +0530 | [diff] [blame^] | 110 | self.check_input_values(group_resources, 'foo', 'input2') |
Steven Hardy | d448dae | 2016-06-14 14:57:28 +0100 | [diff] [blame] | 111 | |
| 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 Mishra | 81ca6bc | 2016-06-16 15:09:20 +0530 | [diff] [blame^] | 119 | 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 Hardy | d448dae | 2016-06-14 14:57:28 +0100 | [diff] [blame] | 125 | 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) |