blob: 2d9669d0043f82c178830d69c22eec6d246ea822 [file] [log] [blame]
Steven Hardy7c1f2242015-01-12 16:32:56 +00001# 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
13import logging
14
15from heat_integrationtests.common import test
16
17
18LOG = logging.getLogger(__name__)
19
20
21class 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 Krayneva265c132015-02-13 03:51:03 -050032 self.assign_keypair()
Steven Hardy7c1f2242015-01-12 16:32:56 +000033
34 def test_stack_validate_provider_references_parent_resource(self):
35 template = '''
36heat_template_version: 2014-10-16
37parameters:
38 keyname:
39 type: string
40 flavor:
41 type: string
42 image:
43 type: string
44resources:
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 = '''
59heat_template_version: 2014-10-16
60parameters:
61 server:
62 type: string
63resources:
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')