blob: a9a43b6f024670d674483485f271b000ad38f332 [file] [log] [blame]
Steven Hardya1e1ee82014-03-27 15:09:53 +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 tempest.api.orchestration import base
16from tempest.common.utils import data_utils
Sean Dague0ef007a2014-04-16 14:53:26 -040017from tempest import test
Steven Hardya1e1ee82014-03-27 15:09:53 +000018
19
20LOG = logging.getLogger(__name__)
21
22
23class UpdateStackTestJSON(base.BaseOrchestrationTest):
24 _interface = 'json'
25
26 template = '''
27heat_template_version: 2013-05-23
28resources:
29 random1:
30 type: OS::Heat::RandomString
31'''
32 update_template = '''
33heat_template_version: 2013-05-23
34resources:
35 random1:
36 type: OS::Heat::RandomString
37 random2:
38 type: OS::Heat::RandomString
39'''
40
41 def update_stack(self, stack_identifier, template):
42 stack_name = stack_identifier.split('/')[0]
43 resp = self.client.update_stack(
44 stack_identifier=stack_identifier,
45 name=stack_name,
46 template=template)
47 self.assertEqual('202', resp[0]['status'])
48 self.client.wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE')
49
Sean Dague0ef007a2014-04-16 14:53:26 -040050 @test.attr(type='gate')
Steven Hardya1e1ee82014-03-27 15:09:53 +000051 def test_stack_update_nochange(self):
52 stack_name = data_utils.rand_name('heat')
53 stack_identifier = self.create_stack(stack_name, self.template)
54 self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
55 expected_resources = {'random1': 'OS::Heat::RandomString'}
56 self.assertEqual(expected_resources,
57 self.list_resources(stack_identifier))
58
59 # Update with no changes, resources should be unchanged
60 self.update_stack(stack_identifier, self.template)
61 self.assertEqual(expected_resources,
62 self.list_resources(stack_identifier))
63
Sean Dague0ef007a2014-04-16 14:53:26 -040064 @test.attr(type='gate')
65 @test.skip_because(bug='1308682')
Steven Hardya1e1ee82014-03-27 15:09:53 +000066 def test_stack_update_add_remove(self):
67 stack_name = data_utils.rand_name('heat')
68 stack_identifier = self.create_stack(stack_name, self.template)
69 self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
70 initial_resources = {'random1': 'OS::Heat::RandomString'}
71 self.assertEqual(initial_resources,
72 self.list_resources(stack_identifier))
73
74 # Add one resource via a stack update
75 self.update_stack(stack_identifier, self.update_template)
76 updated_resources = {'random1': 'OS::Heat::RandomString',
77 'random2': 'OS::Heat::RandomString'}
78 self.assertEqual(updated_resources,
79 self.list_resources(stack_identifier))
80
81 # Then remove it by updating with the original template
82 self.update_stack(stack_identifier, self.template)
83 self.assertEqual(initial_resources,
84 self.list_resources(stack_identifier))