blob: 2c9ff6e4409f1b0724133968b33db12714bbe7c8 [file] [log] [blame]
rabifd98a472016-05-24 10:18:33 +05301# 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
13from heat_integrationtests.functional import functional_base
14
15# Simple stack
16test_template = {
17 'heat_template_version': '2013-05-23',
18 'resources': {
19 'test1': {
20 'type': 'OS::Heat::TestResource',
21 'properties': {
22 'value': 'Test1'
23 }
24 }
25 }
26}
27
28# Nested stack
29rsg_template = {
30 'heat_template_version': '2013-05-23',
31 'resources': {
32 'random_group': {
33 'type': 'OS::Heat::ResourceGroup',
34 'properties': {
35 'count': 2,
36 'resource_def': {
37 'type': 'OS::Heat::RandomString',
38 'properties': {
39 'length': 30,
40 'salt': 'initial'
41 }
42 }
43 }
44 }
45 }
46}
47
48
49class AdminActionsTest(functional_base.FunctionalTestsBase):
50
51 def setUp(self):
52 super(AdminActionsTest, self).setUp()
53 if not self.conf.admin_username or not self.conf.admin_password:
54 self.skipTest('No admin creds found, skipping')
55
56 def create_stack_setup_admin_client(self, template=test_template):
57 # Create the stack with the default user
58 self.stack_identifier = self.stack_create(template=template)
59
60 # Setup admin clients
61 self.setup_clients_for_admin()
62
63 def test_admin_simple_stack_actions(self):
64 self.create_stack_setup_admin_client()
65
66 updated_template = test_template.copy()
67 props = updated_template['resources']['test1']['properties']
68 props['value'] = 'new_value'
69
70 # Update, suspend and resume stack
71 self.update_stack(self.stack_identifier,
72 template=updated_template)
73 self.stack_suspend(self.stack_identifier)
74 self.stack_resume(self.stack_identifier)
75
76 # List stack resources
77 initial_resources = {'test1': 'OS::Heat::TestResource'}
78 self.assertEqual(initial_resources,
79 self.list_resources(self.stack_identifier))
80 # Delete stack
81 self._stack_delete(self.stack_identifier)
82
83 def test_admin_complex_stack_actions(self):
84 self.create_stack_setup_admin_client(template=rsg_template)
85
86 updated_template = rsg_template.copy()
87 props = updated_template['resources']['random_group']['properties']
88 props['count'] = 3
89
90 # Update, suspend and resume stack
91 self.update_stack(self.stack_identifier,
92 template=updated_template)
93 self.stack_suspend(self.stack_identifier)
94 self.stack_resume(self.stack_identifier)
95
96 # List stack resources
97 resources = {'random_group': 'OS::Heat::ResourceGroup'}
98 self.assertEqual(resources,
99 self.list_resources(self.stack_identifier))
100 # Delete stack
101 self._stack_delete(self.stack_identifier)