diff options
author | huangtianhua <huangtianhua@huawei.com> | 2016-07-26 10:58:33 +0800 |
---|---|---|
committer | Sergey Kraynev <skraynev@mirantis.com> | 2016-08-24 09:57:07 +0000 |
commit | 59476f63bc1d5da584d5d49cae44caa630a8efae (patch) | |
tree | c8c110fcaa988cbf60bbf6e7a15f756293ca4161 /heat/tests/test_stack_update.py | |
parent | f29d21ed6bb8174895ace6c8002efb7cc951401a (diff) | |
download | heat-59476f63bc1d5da584d5d49cae44caa630a8efae.tar.gz |
Support condition for resource
Support condition section in resource definition.
Change-Id: Ic63debbf71c158e397ca3d9b9047eafdd598830b
Blueprint: support-conditions-function
Closes-Bug: #1605485
Diffstat (limited to 'heat/tests/test_stack_update.py')
-rw-r--r-- | heat/tests/test_stack_update.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/heat/tests/test_stack_update.py b/heat/tests/test_stack_update.py index f414ec773..d78aeb207 100644 --- a/heat/tests/test_stack_update.py +++ b/heat/tests/test_stack_update.py @@ -1979,3 +1979,59 @@ class StackUpdateTest(common.HeatTestCase): # Bres in backup stack should have empty data. self.assertEqual({}, backup['Bres'].data()) self.assertEqual({'test': '42'}, self.stack['Bres'].data()) + + def test_update_failed_with_new_condition(self): + create_a_res = {'equals': [{'get_param': 'create_a_res'}, 'yes']} + create_b_res = {'equals': [{'get_param': 'create_b_res'}, 'yes']} + tmpl = { + 'heat_template_version': '2016-10-14', + 'parameters': { + 'create_a_res': { + 'type': 'string', + 'default': 'yes' + } + }, + 'conditions': { + 'create_a': create_a_res + }, + 'resources': { + 'Ares': {'type': 'GenericResourceType', + 'condition': 'create_a'} + } + } + + test_stack = stack.Stack(self.ctx, + 'test_update_failed_with_new_condition', + template.Template(tmpl)) + test_stack.store() + test_stack.create() + self.assertEqual((stack.Stack.CREATE, stack.Stack.COMPLETE), + test_stack.state) + self.assertIn('Ares', test_stack) + + update_tmpl = copy.deepcopy(tmpl) + update_tmpl['conditions']['create_b'] = create_b_res + update_tmpl['parameters']['create_b_res'] = { + 'type': 'string', + 'default': 'yes' + } + update_tmpl['resources']['Bres'] = { + 'type': 'OS::Heat::TestResource', + 'properties': { + 'value': 'res_b', + 'fail': True + } + } + + stack_with_new_resource = stack.Stack( + self.ctx, + 'test_update_with_new_res_cd', + template.Template(update_tmpl)) + test_stack.update(stack_with_new_resource) + self.assertEqual((stack.Stack.UPDATE, stack.Stack.FAILED), + test_stack.state) + self.assertIn('Bres', test_stack) + self.assertEqual((resource.Resource.CREATE, resource.Resource.FAILED), + test_stack['Bres'].state) + self.assertIn('create_b', test_stack.t.t['conditions']) + self.assertIn('create_b_res', test_stack.t.t['parameters']) |