diff options
author | Steven Hardy <shardy@redhat.com> | 2015-10-01 19:03:42 +0100 |
---|---|---|
committer | Zane Bitter <zbitter@redhat.com> | 2016-04-06 18:14:23 -0400 |
commit | a00b2f890e604b662dfc43669776435f67be217e (patch) | |
tree | f64ccf1fefd03037b07ad75c521b05d0c55c5ec3 /heat_integrationtests | |
parent | d546930c69835a1198d1d05d74f9e515cada1636 (diff) | |
download | heat-a00b2f890e604b662dfc43669776435f67be217e.tar.gz |
Add functional test coverage for PATCH updates
Adds coverage for patch updates which didn't land previously with the
code.
Change-Id: I66b721d1af787e9d64b8b942818a6c8b4412fa7b
Related-Bug: #1224828
(cherry picked from commit 4f098762d640f3c8efef6869e47f264a06f795ff)
Diffstat (limited to 'heat_integrationtests')
-rw-r--r-- | heat_integrationtests/common/test.py | 8 | ||||
-rw-r--r-- | heat_integrationtests/functional/test_create_update.py | 88 |
2 files changed, 91 insertions, 5 deletions
diff --git a/heat_integrationtests/common/test.py b/heat_integrationtests/common/test.py index 9db5eae04..06ce61f9a 100644 --- a/heat_integrationtests/common/test.py +++ b/heat_integrationtests/common/test.py @@ -333,10 +333,11 @@ class HeatIntegrationTest(testscenarios.WithScenarios, stack_identifier, 'DELETE_COMPLETE', success_on_not_found=True) - def update_stack(self, stack_identifier, template, environment=None, + def update_stack(self, stack_identifier, template=None, environment=None, files=None, parameters=None, tags=None, expected_status='UPDATE_COMPLETE', - disable_rollback=True): + disable_rollback=True, + existing=False): env = environment or {} env_files = files or {} parameters = parameters or {} @@ -358,7 +359,8 @@ class HeatIntegrationTest(testscenarios.WithScenarios, disable_rollback=disable_rollback, parameters=parameters, environment=env, - tags=tags + tags=tags, + existing=existing ) except heat_exceptions.HTTPConflict as ex: # FIXME(sirushtim): Wait a little for the stack lock to be diff --git a/heat_integrationtests/functional/test_create_update.py b/heat_integrationtests/functional/test_create_update.py index 7cb7d89c4..f607fdf31 100644 --- a/heat_integrationtests/functional/test_create_update.py +++ b/heat_integrationtests/functional/test_create_update.py @@ -102,11 +102,15 @@ class UpdateStackTest(functional_base.FunctionalTestsBase): provider_group_template = ''' heat_template_version: 2013-05-23 +parameters: + count: + type: number + default: 2 resources: test_group: type: OS::Heat::ResourceGroup properties: - count: 2 + count: {get_param: count} resource_def: type: My::TestResource ''' @@ -134,6 +138,20 @@ resources: user_data: {get_param: user_data} ''' + fail_param_template = ''' +heat_template_version: 2014-10-16 +parameters: + do_fail: + type: boolean + default: False +resources: + aresource: + type: OS::Heat::TestResource + properties: + value: Test + fail: {get_param: do_fail} +''' + def setUp(self): super(UpdateStackTest, self).setUp() @@ -416,7 +434,7 @@ resources: '''Test two-level nested update.''' # Create a ResourceGroup (which creates a nested stack), # containing provider resources (which create a nested - # stack), thus excercising an update which traverses + # stack), thus exercising an update which traverses # two levels of nesting. template = _change_rsrc_properties( test_template_one_resource, ['test1'], @@ -545,3 +563,69 @@ resources: self.assertEqual({'test1': 'OS::Heat::TestResource', 'test2': 'My::TestResource'}, self.list_resources(stack_identifier)) + + def test_stack_update_provider_group_patch(self): + '''Test two-level nested update with PATCH''' + template = _change_rsrc_properties( + test_template_one_resource, ['test1'], + {'value': 'test_provider_group_template'}) + files = {'provider.template': json.dumps(template)} + env = {'resource_registry': + {'My::TestResource': 'provider.template'}} + + stack_identifier = self.stack_create( + template=self.provider_group_template, + files=files, + environment=env + ) + + initial_resources = {'test_group': 'OS::Heat::ResourceGroup'} + self.assertEqual(initial_resources, + self.list_resources(stack_identifier)) + + # Prove the resource is backed by a nested stack, save the ID + nested_identifier = self.assert_resource_is_a_stack(stack_identifier, + 'test_group') + + # Then check the expected resources are in the nested stack + nested_resources = {'0': 'My::TestResource', + '1': 'My::TestResource'} + self.assertEqual(nested_resources, + self.list_resources(nested_identifier)) + + # increase the count, pass only the paramter, no env or template + params = {'count': 3} + self.update_stack(stack_identifier, parameters=params, existing=True) + + # Parent resources should be unchanged and the nested stack + # should have been updated in-place without replacement + self.assertEqual(initial_resources, + self.list_resources(stack_identifier)) + + # Resource group stack should also be unchanged (but updated) + nested_stack = self.client.stacks.get(nested_identifier) + self.assertEqual('UPDATE_COMPLETE', nested_stack.stack_status) + # Add a resource, as we should have added one + nested_resources['2'] = 'My::TestResource' + self.assertEqual(nested_resources, + self.list_resources(nested_identifier)) + + def test_stack_update_from_failed_patch(self): + '''Test PATCH update from a failed state.''' + + # Start with empty template + stack_identifier = self.stack_create( + template='heat_template_version: 2014-10-16') + + # Update with a good template, but bad parameter + self.update_stack(stack_identifier, + template=self.fail_param_template, + parameters={'do_fail': True}, + expected_status='UPDATE_FAILED') + + # PATCH update, only providing the parameter + self.update_stack(stack_identifier, + parameters={'do_fail': False}, + existing=True) + self.assertEqual({u'aresource': u'OS::Heat::TestResource'}, + self.list_resources(stack_identifier)) |