Oleksii Chuprykov | 62d9032 | 2015-12-14 15:32:58 +0200 | [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 StackOutputsTest(functional_base.FunctionalTestsBase): |
| 17 | |
| 18 | template = ''' |
| 19 | heat_template_version: 2015-10-15 |
| 20 | resources: |
| 21 | test_resource_a: |
| 22 | type: OS::Heat::TestResource |
| 23 | properties: |
| 24 | value: 'a' |
| 25 | test_resource_b: |
| 26 | type: OS::Heat::TestResource |
| 27 | properties: |
| 28 | value: 'b' |
| 29 | outputs: |
| 30 | resource_output_a: |
| 31 | description: 'Output of resource a' |
| 32 | value: { get_attr: [test_resource_a, output] } |
| 33 | resource_output_b: |
| 34 | description: 'Output of resource b' |
| 35 | value: { get_attr: [test_resource_b, output] } |
| 36 | ''' |
| 37 | |
| 38 | def test_outputs(self): |
| 39 | stack_identifier = self.stack_create( |
| 40 | template=self.template |
| 41 | ) |
| 42 | expected_list = [{u'output_key': u'resource_output_a', |
| 43 | u'description': u'Output of resource a'}, |
| 44 | {u'output_key': u'resource_output_b', |
| 45 | u'description': u'Output of resource b'}] |
| 46 | |
| 47 | actual_list = self.client.stacks.output_list( |
| 48 | stack_identifier)['outputs'] |
rabi | 4e7db09 | 2017-02-07 09:29:59 +0530 | [diff] [blame] | 49 | sorted_actual_list = sorted(actual_list, key=lambda x: x['output_key']) |
| 50 | self.assertEqual(expected_list, sorted_actual_list) |
Oleksii Chuprykov | 62d9032 | 2015-12-14 15:32:58 +0200 | [diff] [blame] | 51 | |
| 52 | expected_output_a = { |
| 53 | u'output_value': u'a', u'output_key': u'resource_output_a', |
| 54 | u'description': u'Output of resource a'} |
| 55 | expected_output_b = { |
| 56 | u'output_value': u'b', u'output_key': u'resource_output_b', |
| 57 | u'description': u'Output of resource b'} |
| 58 | actual_output_a = self.client.stacks.output_show( |
| 59 | stack_identifier, 'resource_output_a')['output'] |
| 60 | actual_output_b = self.client.stacks.output_show( |
| 61 | stack_identifier, 'resource_output_b')['output'] |
| 62 | self.assertEqual(expected_output_a, actual_output_a) |
| 63 | self.assertEqual(expected_output_b, actual_output_b) |
Zane Bitter | 7f72c40 | 2017-07-19 17:35:40 -0400 | [diff] [blame^] | 64 | |
| 65 | before_template = ''' |
| 66 | heat_template_version: 2015-10-15 |
| 67 | resources: |
| 68 | test_resource_a: |
| 69 | type: OS::Heat::TestResource |
| 70 | properties: |
| 71 | value: 'foo' |
| 72 | outputs: |
| 73 | ''' |
| 74 | |
| 75 | after_template = ''' |
| 76 | heat_template_version: 2015-10-15 |
| 77 | resources: |
| 78 | test_resource_a: |
| 79 | type: OS::Heat::TestResource |
| 80 | properties: |
| 81 | value: 'foo' |
| 82 | test_resource_b: |
| 83 | type: OS::Heat::TestResource |
| 84 | properties: |
| 85 | value: {get_attr: [test_resource_a, output]} |
| 86 | outputs: |
| 87 | output_value: |
| 88 | description: 'Output of resource b' |
| 89 | value: {get_attr: [test_resource_b, output]} |
| 90 | ''' |
| 91 | |
| 92 | def test_outputs_update_new_resource(self): |
| 93 | stack_identifier = self.stack_create(template=self.before_template) |
| 94 | self.update_stack(stack_identifier, template=self.after_template) |
| 95 | |
| 96 | expected_output_value = { |
| 97 | u'output_value': u'foo', u'output_key': u'output_value', |
| 98 | u'description': u'Output of resource b'} |
| 99 | actual_output_value = self.client.stacks.output_show( |
| 100 | stack_identifier, 'output_value')['output'] |
| 101 | self.assertEqual(expected_output_value, actual_output_value) |