blob: da5cd680cfdff15a151887cebed2a494baaace21 [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
Steven Hardy7c1f2242015-01-12 16:32:56 +000013
Rabi Mishra477efc92015-07-31 13:01:45 +053014from heat_integrationtests.functional import functional_base
Steven Hardy7c1f2242015-01-12 16:32:56 +000015
16
Rabi Mishra477efc92015-07-31 13:01:45 +053017class StackValidationTest(functional_base.FunctionalTestsBase):
Steven Hardy7c1f2242015-01-12 16:32:56 +000018
19 def setUp(self):
20 super(StackValidationTest, self).setUp()
Steven Hardy7c1f2242015-01-12 16:32:56 +000021 if not self.conf.minimal_image_ref:
22 raise self.skipException("No image configured to test")
23
Pavlo Shchelokovskyy46e5cb22015-03-23 12:01:25 +000024 if not self.conf.minimal_instance_type:
25 raise self.skipException(
26 "No minimal_instance_type configured to test")
Steven Hardy7c1f2242015-01-12 16:32:56 +000027
Sergey Krayneva265c132015-02-13 03:51:03 -050028 self.assign_keypair()
Steven Hardy7c1f2242015-01-12 16:32:56 +000029
30 def test_stack_validate_provider_references_parent_resource(self):
31 template = '''
32heat_template_version: 2014-10-16
33parameters:
34 keyname:
35 type: string
36 flavor:
37 type: string
38 image:
39 type: string
Sergey Kraynevdaffd852015-06-22 09:49:47 -040040 network:
41 type: string
Steven Hardy7c1f2242015-01-12 16:32:56 +000042resources:
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 Kraynevdaffd852015-06-22 09:49:47 -040054 networks: [{network: {get_param: network} }]
Steven Hardy7c1f2242015-01-12 16:32:56 +000055 user_data_format: SOFTWARE_CONFIG
Sergey Kraynevdaffd852015-06-22 09:49:47 -040056
Steven Hardy7c1f2242015-01-12 16:32:56 +000057'''
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,
Pavlo Shchelokovskyy46e5cb22015-03-23 12:01:25 +000079 'flavor': self.conf.minimal_instance_type,
Sergey Kraynevdaffd852015-06-22 09:49:47 -040080 'image': self.conf.minimal_image_ref,
81 'network': self.conf.fixed_network_name}
Steven Hardy7c1f2242015-01-12 16:32:56 +000082 # 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')