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