Jay Dobies | 39c4ce4 | 2015-11-04 10:49:08 -0500 | [diff] [blame] | 1 | # |
| 2 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 3 | # not use this file except in compliance with the License. You may obtain |
| 4 | # a copy of the License at |
| 5 | # |
| 6 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | # |
| 8 | # Unless required by applicable law or agreed to in writing, software |
| 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 11 | # License for the specific language governing permissions and limitations |
| 12 | # under the License. |
| 13 | |
| 14 | from heat_integrationtests.functional import functional_base |
| 15 | |
| 16 | |
| 17 | TEMPLATE = ''' |
| 18 | heat_template_version: 2015-04-30 |
| 19 | parameters: |
| 20 | p0: |
| 21 | type: string |
| 22 | default: CORRECT |
| 23 | p1: |
| 24 | type: string |
| 25 | default: INCORRECT |
| 26 | p2: |
| 27 | type: string |
| 28 | default: INCORRECT |
| 29 | resources: |
| 30 | r1: |
| 31 | type: test::R1 |
| 32 | r2: |
| 33 | type: test::R2 |
| 34 | r3a: |
| 35 | type: test::R3 |
| 36 | r3b: |
| 37 | type: test::R3 |
| 38 | ''' |
| 39 | |
| 40 | ENV_1 = ''' |
| 41 | parameters: |
| 42 | p1: CORRECT |
| 43 | p2: INCORRECT-E1 |
| 44 | resource_registry: |
| 45 | test::R1: OS::Heat::RandomString |
| 46 | test::R2: BROKEN |
| 47 | test::R3: OS::Heat::None |
| 48 | ''' |
| 49 | |
| 50 | ENV_2 = ''' |
| 51 | parameters: |
| 52 | p2: CORRECT |
| 53 | resource_registry: |
| 54 | test::R2: OS::Heat::RandomString |
| 55 | resources: |
| 56 | r3b: |
| 57 | test::R3: OS::Heat::RandomString |
| 58 | ''' |
| 59 | |
| 60 | |
| 61 | class EnvironmentMergingTests(functional_base.FunctionalTestsBase): |
| 62 | |
| 63 | def test_server_environment_merging(self): |
| 64 | |
| 65 | # Setup |
| 66 | files = {'env1.yaml': ENV_1, 'env2.yaml': ENV_2} |
| 67 | environment_files = ['env1.yaml', 'env2.yaml'] |
| 68 | |
| 69 | # Test |
| 70 | stack_id = self.stack_create(stack_name='env_merge', |
| 71 | template=TEMPLATE, |
| 72 | files=files, |
| 73 | environment_files=environment_files) |
| 74 | |
| 75 | # Verify |
| 76 | |
| 77 | # Since there is no environment show, the registry overriding |
| 78 | # is partially verified by there being no error. If it wasn't |
| 79 | # working, test::R2 would remain mapped to BROKEN in env1. |
| 80 | |
| 81 | # Sanity check |
| 82 | resources = self.list_resources(stack_id) |
| 83 | self.assertEqual(4, len(resources)) |
| 84 | |
| 85 | # Verify the parameters are correctly set |
| 86 | stack = self.client.stacks.get(stack_id) |
| 87 | self.assertEqual('CORRECT', stack.parameters['p0']) |
| 88 | self.assertEqual('CORRECT', stack.parameters['p1']) |
| 89 | self.assertEqual('CORRECT', stack.parameters['p2']) |
| 90 | |
| 91 | # Verify that r3b has been overridden into a RandomString |
| 92 | # by checking to see that it has a value |
| 93 | r3b = self.client.resources.get(stack_id, 'r3b') |
| 94 | r3b_attrs = r3b.attributes |
Bin Zhou | 2b642c2 | 2016-09-02 13:10:32 +0800 | [diff] [blame^] | 95 | self.assertIn('value', r3b_attrs) |