blob: 52309cd1e6a1ac6784a8e70edb9a95567b76d4b1 [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
32 if self.conf.keypair_name:
33 self.keypair_name = self.conf.keypair_name
34 else:
35 self.keypair = self.create_keypair()
36 self.keypair_name = self.keypair.id
37
38 def test_stack_validate_provider_references_parent_resource(self):
39 template = '''
40heat_template_version: 2014-10-16
41parameters:
42 keyname:
43 type: string
44 flavor:
45 type: string
46 image:
47 type: string
48resources:
49 config:
50 type: My::Config
51 properties:
52 server: {get_resource: server}
53
54 server:
55 type: OS::Nova::Server
56 properties:
57 image: {get_param: image}
58 flavor: {get_param: flavor}
59 key_name: {get_param: keyname}
60 user_data_format: SOFTWARE_CONFIG
61'''
62 config_template = '''
63heat_template_version: 2014-10-16
64parameters:
65 server:
66 type: string
67resources:
68 config:
69 type: OS::Heat::SoftwareConfig
70
71 deployment:
72 type: OS::Heat::SoftwareDeployment
73 properties:
74 config:
75 get_resource: config
76 server:
77 get_param: server
78'''
79 files = {'provider.yaml': config_template}
80 env = {'resource_registry':
81 {'My::Config': 'provider.yaml'}}
82 parameters = {'keyname': self.keypair_name,
83 'flavor': self.conf.instance_type,
84 'image': self.conf.minimal_image_ref}
85 # Note we don't wait for CREATE_COMPLETE, because we're using a
86 # minimal image without the tools to apply the config.
87 # The point of the test is just to prove that validation won't
88 # falsely prevent stack creation starting, ref bug #1407100
89 # Note that we can be sure My::Config will stay IN_PROGRESS as
90 # there's no signal sent to the deployment
91 self.stack_create(template=template,
92 files=files,
93 environment=env,
94 parameters=parameters,
95 expected_status='CREATE_IN_PROGRESS')