Steven Hardy | a1e1ee8 | 2014-03-27 15:09:53 +0000 | [diff] [blame] | 1 | # 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 | |
| 13 | import logging |
| 14 | |
| 15 | from tempest.api.orchestration import base |
| 16 | from tempest.common.utils import data_utils |
Sean Dague | 0ef007a | 2014-04-16 14:53:26 -0400 | [diff] [blame] | 17 | from tempest import test |
Steven Hardy | a1e1ee8 | 2014-03-27 15:09:53 +0000 | [diff] [blame] | 18 | |
| 19 | |
| 20 | LOG = logging.getLogger(__name__) |
| 21 | |
| 22 | |
| 23 | class UpdateStackTestJSON(base.BaseOrchestrationTest): |
| 24 | _interface = 'json' |
| 25 | |
| 26 | template = ''' |
| 27 | heat_template_version: 2013-05-23 |
| 28 | resources: |
| 29 | random1: |
| 30 | type: OS::Heat::RandomString |
| 31 | ''' |
| 32 | update_template = ''' |
| 33 | heat_template_version: 2013-05-23 |
| 34 | resources: |
| 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 Dague | 0ef007a | 2014-04-16 14:53:26 -0400 | [diff] [blame] | 50 | @test.attr(type='gate') |
Steven Hardy | a1e1ee8 | 2014-03-27 15:09:53 +0000 | [diff] [blame] | 51 | 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 Dague | 0ef007a | 2014-04-16 14:53:26 -0400 | [diff] [blame] | 64 | @test.attr(type='gate') |
| 65 | @test.skip_because(bug='1308682') |
Steven Hardy | a1e1ee8 | 2014-03-27 15:09:53 +0000 | [diff] [blame] | 66 | 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)) |