Cast desired capacity for cloudformation asg to int (#846)

Cloudformation passes MaxSize, MinSize and DesiredCapacity as strings, but
we want to store them as ints.  Also includes tests of this fix, to help
avoid regression.
This commit is contained in:
William Richard 2017-03-04 22:51:01 -05:00 committed by Steve Pulec
parent a9554924df
commit f46a24180f
2 changed files with 5 additions and 0 deletions

View File

@ -324,6 +324,7 @@ class AutoScalingBackend(BaseBackend):
max_size = make_int(max_size) max_size = make_int(max_size)
min_size = make_int(min_size) min_size = make_int(min_size)
desired_capacity = make_int(desired_capacity)
default_cooldown = make_int(default_cooldown) default_cooldown = make_int(default_cooldown)
if health_check_period is None: if health_check_period is None:
health_check_period = 300 health_check_period = 300

View File

@ -535,6 +535,7 @@ def test_autoscaling_group_with_elb():
"LaunchConfigurationName": {"Ref": "my-launch-config"}, "LaunchConfigurationName": {"Ref": "my-launch-config"},
"MinSize": "2", "MinSize": "2",
"MaxSize": "2", "MaxSize": "2",
"DesiredCapacity": "2",
"LoadBalancerNames": [{"Ref": "my-elb"}] "LoadBalancerNames": [{"Ref": "my-elb"}]
}, },
}, },
@ -614,6 +615,7 @@ def test_autoscaling_group_update():
"LaunchConfigurationName": {"Ref": "my-launch-config"}, "LaunchConfigurationName": {"Ref": "my-launch-config"},
"MinSize": "2", "MinSize": "2",
"MaxSize": "2", "MaxSize": "2",
"DesiredCapacity": "2"
}, },
}, },
@ -638,6 +640,7 @@ def test_autoscaling_group_update():
asg = autoscale_conn.get_all_groups()[0] asg = autoscale_conn.get_all_groups()[0]
asg.min_size.should.equal(2) asg.min_size.should.equal(2)
asg.max_size.should.equal(2) asg.max_size.should.equal(2)
asg.desired_capacity.should.equal(2)
asg_template['Resources']['my-as-group']['Properties']['MaxSize'] = 3 asg_template['Resources']['my-as-group']['Properties']['MaxSize'] = 3
asg_template_json = json.dumps(asg_template) asg_template_json = json.dumps(asg_template)
@ -648,6 +651,7 @@ def test_autoscaling_group_update():
asg = autoscale_conn.get_all_groups()[0] asg = autoscale_conn.get_all_groups()[0]
asg.min_size.should.equal(2) asg.min_size.should.equal(2)
asg.max_size.should.equal(3) asg.max_size.should.equal(3)
asg.desired_capacity.should.equal(2)
@mock_ec2() @mock_ec2()