Merge "Make sure UpdatePolicy is unset for Heat scaling group"

This commit is contained in:
Jenkins 2015-04-14 11:12:21 +00:00 committed by Gerrit Code Review
commit b8e15ad5dd
3 changed files with 44 additions and 3 deletions

View File

@ -123,6 +123,7 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
_("The current size of AutoscalingResourceGroup.")
),
}
update_policy_schema = {}
def _get_instance_definition(self):
rsrc = self.properties[self.RESOURCE]

View File

@ -135,10 +135,11 @@ class InstanceGroup(stack_resource.StackResource):
"""
super(InstanceGroup, self).validate()
if self.update_policy:
if self.update_policy is not None:
self.update_policy.validate()
policy_name = self.update_policy_schema.keys()[0]
if self.update_policy[policy_name]:
policy_name = self.ROLLING_UPDATE
if (policy_name in self.update_policy and
self.update_policy[policy_name] is not None):
pause_time = self.update_policy[policy_name][self.PAUSE_TIME]
if iso8601utils.parse_isoduration(pause_time) > 3600:
msg = _('Maximum %s is 1 hour.') % self.PAUSE_TIME

View File

@ -534,3 +534,42 @@ class RollingUpdatePolicyDiffTest(common.HeatTestCase):
def test_update_policy_removed(self):
self.validate_update_policy_diff(asg_tmpl_with_updt_policy(),
inline_templates.as_heat_template)
class IncorrectUpdatePolicyTest(common.HeatTestCase):
def setUp(self):
super(IncorrectUpdatePolicyTest, self).setUp()
self.stub_keystoneclient(username='test_stack.CfnLBUser')
resource._register_class('ResourceWithPropsAndAttrs',
generic_resource.ResourceWithPropsAndAttrs)
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
def test_with_update_policy_aws(self):
t = template_format.parse(inline_templates.as_heat_template)
ag = t['resources']['my-group']
ag["update_policy"] = {"AutoScalingRollingUpdate": {
"MinInstancesInService": "1",
"MaxBatchSize": "2",
"PauseTime": "PT1S"
}}
tmpl = template_format.parse(json.dumps(t))
stack = utils.parse_stack(tmpl)
exc = self.assertRaises(exception.StackValidationFailed,
stack.validate)
self.assertIn('Unknown Property AutoScalingRollingUpdate',
six.text_type(exc))
def test_with_update_policy_inst_group(self):
t = template_format.parse(inline_templates.as_heat_template)
ag = t['resources']['my-group']
ag["update_policy"] = {"RollingUpdate": {
"MinInstancesInService": "1",
"MaxBatchSize": "2",
"PauseTime": "PT1S"
}}
tmpl = template_format.parse(json.dumps(t))
stack = utils.parse_stack(tmpl)
exc = self.assertRaises(exception.StackValidationFailed,
stack.validate)
self.assertIn('Unknown Property RollingUpdate', six.text_type(exc))