Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [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 | |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 13 | |
| 14 | from heat_integrationtests.common import test |
| 15 | |
| 16 | |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 17 | class StackValidationTest(test.HeatIntegrationTest): |
| 18 | |
| 19 | def setUp(self): |
| 20 | super(StackValidationTest, self).setUp() |
| 21 | self.client = self.orchestration_client |
| 22 | if not self.conf.minimal_image_ref: |
| 23 | raise self.skipException("No image configured to test") |
| 24 | |
Pavlo Shchelokovskyy | 46e5cb2 | 2015-03-23 12:01:25 +0000 | [diff] [blame] | 25 | if not self.conf.minimal_instance_type: |
| 26 | raise self.skipException( |
| 27 | "No minimal_instance_type configured to test") |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 28 | |
Sergey Kraynev | a265c13 | 2015-02-13 03:51:03 -0500 | [diff] [blame] | 29 | self.assign_keypair() |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 30 | |
| 31 | def test_stack_validate_provider_references_parent_resource(self): |
| 32 | template = ''' |
| 33 | heat_template_version: 2014-10-16 |
| 34 | parameters: |
| 35 | keyname: |
| 36 | type: string |
| 37 | flavor: |
| 38 | type: string |
| 39 | image: |
| 40 | type: string |
| 41 | resources: |
| 42 | config: |
| 43 | type: My::Config |
| 44 | properties: |
| 45 | server: {get_resource: server} |
| 46 | |
| 47 | server: |
| 48 | type: OS::Nova::Server |
| 49 | properties: |
| 50 | image: {get_param: image} |
| 51 | flavor: {get_param: flavor} |
| 52 | key_name: {get_param: keyname} |
| 53 | user_data_format: SOFTWARE_CONFIG |
| 54 | ''' |
| 55 | config_template = ''' |
| 56 | heat_template_version: 2014-10-16 |
| 57 | parameters: |
| 58 | server: |
| 59 | type: string |
| 60 | resources: |
| 61 | config: |
| 62 | type: OS::Heat::SoftwareConfig |
| 63 | |
| 64 | deployment: |
| 65 | type: OS::Heat::SoftwareDeployment |
| 66 | properties: |
| 67 | config: |
| 68 | get_resource: config |
| 69 | server: |
| 70 | get_param: server |
| 71 | ''' |
| 72 | files = {'provider.yaml': config_template} |
| 73 | env = {'resource_registry': |
| 74 | {'My::Config': 'provider.yaml'}} |
| 75 | parameters = {'keyname': self.keypair_name, |
Pavlo Shchelokovskyy | 46e5cb2 | 2015-03-23 12:01:25 +0000 | [diff] [blame] | 76 | 'flavor': self.conf.minimal_instance_type, |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 77 | 'image': self.conf.minimal_image_ref} |
| 78 | # Note we don't wait for CREATE_COMPLETE, because we're using a |
| 79 | # minimal image without the tools to apply the config. |
| 80 | # The point of the test is just to prove that validation won't |
| 81 | # falsely prevent stack creation starting, ref bug #1407100 |
| 82 | # Note that we can be sure My::Config will stay IN_PROGRESS as |
| 83 | # there's no signal sent to the deployment |
| 84 | self.stack_create(template=template, |
| 85 | files=files, |
| 86 | environment=env, |
| 87 | parameters=parameters, |
| 88 | expected_status='CREATE_IN_PROGRESS') |