Fix default ASG health check period.

This commit is contained in:
Steve Pulec 2016-01-08 16:56:10 -05:00
parent 22e7b6373e
commit fc0fb0d40e
2 changed files with 46 additions and 3 deletions

View File

@ -275,7 +275,10 @@ class AutoScalingBackend(BaseBackend):
max_size = make_int(max_size)
min_size = make_int(min_size)
default_cooldown = make_int(default_cooldown)
health_check_period = make_int(health_check_period)
if health_check_period is None:
health_check_period = 300
else:
health_check_period = make_int(health_check_period)
group = FakeAutoScalingGroup(
name=name,
@ -385,4 +388,3 @@ class AutoScalingBackend(BaseBackend):
autoscaling_backends = {}
for region, ec2_backend in ec2_backends.items():
autoscaling_backends[region] = AutoScalingBackend(ec2_backend, elb_backends[region])

View File

@ -1,5 +1,6 @@
from __future__ import unicode_literals
import boto
import boto3
import boto.ec2.autoscale
from boto.ec2.autoscale.launchconfig import LaunchConfiguration
from boto.ec2.autoscale.group import AutoScalingGroup
@ -103,7 +104,7 @@ def test_create_autoscaling_groups_defaults():
group.desired_capacity.should.equal(2)
group.vpc_zone_identifier.should.equal('')
group.default_cooldown.should.equal(300)
group.health_check_period.should.equal(None)
group.health_check_period.should.equal(300)
group.health_check_type.should.equal("EC2")
list(group.load_balancers).should.equal([])
group.placement_group.should.equal(None)
@ -378,3 +379,43 @@ def test_autoscaling_group_with_elb():
elb = elb_conn.get_all_load_balancers()[0]
elb.instances.should.have.length_of(0)
'''
Boto3
'''
@mock_autoscaling
def test_create_autoscaling_group():
client = boto3.client('autoscaling', region_name='us-east-1')
_ = client.create_launch_configuration(
LaunchConfigurationName='test_launch_configuration'
)
response = client.create_auto_scaling_group(
AutoScalingGroupName='test_asg',
LaunchConfigurationName='test_launch_configuration',
MinSize=0,
MaxSize=20,
DesiredCapacity=5
)
response['ResponseMetadata']['HTTPStatusCode'].should.equal(200)
@mock_autoscaling
def test_describe_autoscaling_groups():
client = boto3.client('autoscaling', region_name='us-east-1')
_ = client.create_launch_configuration(
LaunchConfigurationName='test_launch_configuration'
)
_ = client.create_auto_scaling_group(
AutoScalingGroupName='test_asg',
LaunchConfigurationName='test_launch_configuration',
MinSize=0,
MaxSize=20,
DesiredCapacity=5
)
response = client.describe_auto_scaling_groups(
AutoScalingGroupNames=["test_asg"]
)
response['ResponseMetadata']['HTTPStatusCode'].should.equal(200)
response['AutoScalingGroups'][0]['AutoScalingGroupName'].should.equal('test_asg')