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 | |
Rabi Mishra | 477efc9 | 2015-07-31 13:01:45 +0530 | [diff] [blame] | 14 | from heat_integrationtests.functional import functional_base |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 15 | |
| 16 | |
Rabi Mishra | 477efc9 | 2015-07-31 13:01:45 +0530 | [diff] [blame] | 17 | class StackValidationTest(functional_base.FunctionalTestsBase): |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 18 | |
| 19 | def setUp(self): |
| 20 | super(StackValidationTest, self).setUp() |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 21 | if not self.conf.minimal_image_ref: |
| 22 | raise self.skipException("No image configured to test") |
| 23 | |
Pavlo Shchelokovskyy | 46e5cb2 | 2015-03-23 12:01:25 +0000 | [diff] [blame] | 24 | if not self.conf.minimal_instance_type: |
| 25 | raise self.skipException( |
| 26 | "No minimal_instance_type configured to test") |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 27 | |
Sergey Kraynev | a265c13 | 2015-02-13 03:51:03 -0500 | [diff] [blame] | 28 | self.assign_keypair() |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 29 | |
| 30 | def test_stack_validate_provider_references_parent_resource(self): |
| 31 | template = ''' |
| 32 | heat_template_version: 2014-10-16 |
| 33 | parameters: |
| 34 | keyname: |
| 35 | type: string |
| 36 | flavor: |
| 37 | type: string |
| 38 | image: |
| 39 | type: string |
Sergey Kraynev | daffd85 | 2015-06-22 09:49:47 -0400 | [diff] [blame] | 40 | network: |
| 41 | type: string |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 42 | resources: |
| 43 | config: |
| 44 | type: My::Config |
| 45 | properties: |
| 46 | server: {get_resource: server} |
| 47 | |
| 48 | server: |
| 49 | type: OS::Nova::Server |
| 50 | properties: |
| 51 | image: {get_param: image} |
| 52 | flavor: {get_param: flavor} |
| 53 | key_name: {get_param: keyname} |
Sergey Kraynev | daffd85 | 2015-06-22 09:49:47 -0400 | [diff] [blame] | 54 | networks: [{network: {get_param: network} }] |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 55 | user_data_format: SOFTWARE_CONFIG |
Sergey Kraynev | daffd85 | 2015-06-22 09:49:47 -0400 | [diff] [blame] | 56 | |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 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, |
Pavlo Shchelokovskyy | 46e5cb2 | 2015-03-23 12:01:25 +0000 | [diff] [blame] | 79 | 'flavor': self.conf.minimal_instance_type, |
Sergey Kraynev | daffd85 | 2015-06-22 09:49:47 -0400 | [diff] [blame] | 80 | 'image': self.conf.minimal_image_ref, |
| 81 | 'network': self.conf.fixed_network_name} |
Steven Hardy | 7c1f224 | 2015-01-12 16:32:56 +0000 | [diff] [blame] | 82 | # Note we don't wait for CREATE_COMPLETE, because we're using a |
| 83 | # minimal image without the tools to apply the config. |
| 84 | # The point of the test is just to prove that validation won't |
| 85 | # falsely prevent stack creation starting, ref bug #1407100 |
| 86 | # Note that we can be sure My::Config will stay IN_PROGRESS as |
| 87 | # there's no signal sent to the deployment |
| 88 | self.stack_create(template=template, |
| 89 | files=files, |
| 90 | environment=env, |
| 91 | parameters=parameters, |
| 92 | expected_status='CREATE_IN_PROGRESS') |