Fix default HealthCheckGracePeriod
This commit is contained in:
parent
5d421dc343
commit
5aca483849
@ -10,6 +10,10 @@ class AutoScalingResponse(BaseResponse):
|
|||||||
def autoscaling_backend(self):
|
def autoscaling_backend(self):
|
||||||
return autoscaling_backends[self.region]
|
return autoscaling_backends[self.region]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def boto3_request(self):
|
||||||
|
return 'Boto3' in self.headers.get('User-Agent', [])
|
||||||
|
|
||||||
def create_launch_configuration(self):
|
def create_launch_configuration(self):
|
||||||
instance_monitoring_string = self._get_param('InstanceMonitoring.Enabled')
|
instance_monitoring_string = self._get_param('InstanceMonitoring.Enabled')
|
||||||
if instance_monitoring_string == 'true':
|
if instance_monitoring_string == 'true':
|
||||||
@ -68,6 +72,11 @@ class AutoScalingResponse(BaseResponse):
|
|||||||
def describe_auto_scaling_groups(self):
|
def describe_auto_scaling_groups(self):
|
||||||
names = self._get_multi_param("AutoScalingGroupNames.member")
|
names = self._get_multi_param("AutoScalingGroupNames.member")
|
||||||
groups = self.autoscaling_backend.describe_autoscaling_groups(names)
|
groups = self.autoscaling_backend.describe_autoscaling_groups(names)
|
||||||
|
if self.boto3_request:
|
||||||
|
for group in groups:
|
||||||
|
if group.health_check_period is None:
|
||||||
|
group.health_check_period = 300
|
||||||
|
self.autoscaling_backend.autoscaling_groups[group.name] = group
|
||||||
template = self.response_template(DESCRIBE_AUTOSCALING_GROUPS_TEMPLATE)
|
template = self.response_template(DESCRIBE_AUTOSCALING_GROUPS_TEMPLATE)
|
||||||
return template.render(groups=groups)
|
return template.render(groups=groups)
|
||||||
|
|
||||||
|
41
tests/test_autoscaling/test_autoscaling_boto3.py
Normal file
41
tests/test_autoscaling/test_autoscaling_boto3.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
import boto3
|
||||||
|
import sure # noqa
|
||||||
|
|
||||||
|
from moto import mock_autoscaling
|
||||||
|
|
||||||
|
|
||||||
|
@mock_autoscaling
|
||||||
|
def test_create_autoscaling_group():
|
||||||
|
client = boto3.client('autoscaling')
|
||||||
|
_ = 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')
|
||||||
|
_ = 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')
|
23
tests/test_autoscaling/test_launch_configurations_boto3.py
Normal file
23
tests/test_autoscaling/test_launch_configurations_boto3.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
import boto3
|
||||||
|
|
||||||
|
import sure # noqa
|
||||||
|
|
||||||
|
from moto import mock_autoscaling
|
||||||
|
|
||||||
|
|
||||||
|
@mock_autoscaling
|
||||||
|
def test_create_launch_configuration():
|
||||||
|
client = boto3.client('autoscaling')
|
||||||
|
response = client.create_launch_configuration(
|
||||||
|
LaunchConfigurationName='tester',
|
||||||
|
ImageId='ami-abcd1234',
|
||||||
|
InstanceType='t1.micro',
|
||||||
|
KeyName='the_keys',
|
||||||
|
SecurityGroups=["default", "default2"],
|
||||||
|
UserData="This is some user_data",
|
||||||
|
InstanceMonitoring={'Enabled': True},
|
||||||
|
IamInstanceProfile='arn:aws:iam::123456789012:instance-profile/testing',
|
||||||
|
SpotPrice='0.1'
|
||||||
|
)
|
||||||
|
response['ResponseMetadata']['HTTPStatusCode'].should.equal(200)
|
Loading…
x
Reference in New Issue
Block a user