blob: b2d347b03049b1feec8e94ea3cf1503e7d5eca6f [file] [log] [blame]
Steven Hardy00de7582014-05-07 15:18:52 +01001# 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 tempest.api.orchestration import base
16from tempest.common.utils import data_utils
17from tempest import config
18from tempest import test
19
20
21CONF = config.CONF
22LOG = logging.getLogger(__name__)
23
24
25class StackEnvironmentTest(base.BaseOrchestrationTest):
26
27 @test.attr(type='gate')
28 def test_environment_parameter(self):
29 """Test passing a stack parameter via the environment."""
30 stack_name = data_utils.rand_name('heat')
31 template = self.load_template('random_string')
32 environment = {'parameters': {'random_length': 20}}
33
34 stack_identifier = self.create_stack(stack_name, template,
35 environment=environment)
36 self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
37
38 random_len = self.get_stack_output(stack_identifier, 'random_length')
39 self.assertEqual(20, random_len)
40
41 random_value = self.get_stack_output(stack_identifier, 'random_value')
42 self.assertEqual(20, len(random_value))
Steven Hardy1b25fe02014-05-07 16:21:28 +010043
44 @test.attr(type='gate')
45 def test_environment_provider_resource(self):
46 """Test passing resource_registry defining a provider resource."""
47 stack_name = data_utils.rand_name('heat')
48 template = '''
49heat_template_version: 2013-05-23
50resources:
51 random:
52 type: My:Random::String
53outputs:
54 random_value:
55 value: {get_attr: [random, random_value]}
56'''
57 environment = {'resource_registry':
58 {'My:Random::String': 'my_random.yaml'}}
59 files = {'my_random.yaml': self.load_template('random_string')}
60
61 stack_identifier = self.create_stack(stack_name, template,
62 environment=environment,
63 files=files)
64 self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
65
66 # random_string.yaml specifies a length of 10
67 random_value = self.get_stack_output(stack_identifier, 'random_value')
68 self.assertEqual(10, len(random_value))