Merge pull request #1413 from captainkerk/autoscaling-subnet-or-az-is-required
AWS API raises an exception if both AZ and VPCZoneIdentifier params a…
This commit is contained in:
commit
9e0b8da6cb
6 changed files with 148 additions and 64 deletions
|
|
@ -4,22 +4,21 @@ import boto3
|
|||
import sure # noqa
|
||||
from moto import mock_autoscaling, mock_ec2, mock_elbv2
|
||||
|
||||
from utils import setup_networking
|
||||
|
||||
@mock_elbv2
|
||||
@mock_ec2
|
||||
@mock_autoscaling
|
||||
def test_attach_detach_target_groups():
|
||||
mocked_networking = setup_networking()
|
||||
INSTANCE_COUNT = 2
|
||||
client = boto3.client('autoscaling', region_name='us-east-1')
|
||||
elbv2_client = boto3.client('elbv2', region_name='us-east-1')
|
||||
ec2 = boto3.resource('ec2', region_name='us-east-1')
|
||||
|
||||
vpc = ec2.create_vpc(CidrBlock='172.28.7.0/24', InstanceTenancy='default')
|
||||
|
||||
response = elbv2_client.create_target_group(
|
||||
Name='a-target',
|
||||
Protocol='HTTP',
|
||||
Port=8080,
|
||||
VpcId=vpc.id,
|
||||
VpcId=mocked_networking['vpc'],
|
||||
HealthCheckProtocol='HTTP',
|
||||
HealthCheckPort='8080',
|
||||
HealthCheckPath='/',
|
||||
|
|
@ -41,7 +40,7 @@ def test_attach_detach_target_groups():
|
|||
MaxSize=INSTANCE_COUNT,
|
||||
DesiredCapacity=INSTANCE_COUNT,
|
||||
TargetGroupARNs=[target_group_arn],
|
||||
VPCZoneIdentifier=vpc.id)
|
||||
VPCZoneIdentifier=mocked_networking['subnet1'])
|
||||
# create asg without attaching to target group
|
||||
client.create_auto_scaling_group(
|
||||
AutoScalingGroupName='test_asg2',
|
||||
|
|
@ -49,7 +48,7 @@ def test_attach_detach_target_groups():
|
|||
MinSize=0,
|
||||
MaxSize=INSTANCE_COUNT,
|
||||
DesiredCapacity=INSTANCE_COUNT,
|
||||
VPCZoneIdentifier=vpc.id)
|
||||
VPCZoneIdentifier=mocked_networking['subnet2'])
|
||||
|
||||
response = client.describe_load_balancer_target_groups(
|
||||
AutoScalingGroupName='test_asg')
|
||||
|
|
@ -75,21 +74,18 @@ def test_attach_detach_target_groups():
|
|||
list(response['TargetHealthDescriptions']).should.have.length_of(INSTANCE_COUNT)
|
||||
|
||||
@mock_elbv2
|
||||
@mock_ec2
|
||||
@mock_autoscaling
|
||||
def test_detach_all_target_groups():
|
||||
mocked_networking = setup_networking()
|
||||
INSTANCE_COUNT = 2
|
||||
client = boto3.client('autoscaling', region_name='us-east-1')
|
||||
elbv2_client = boto3.client('elbv2', region_name='us-east-1')
|
||||
ec2 = boto3.resource('ec2', region_name='us-east-1')
|
||||
|
||||
vpc = ec2.create_vpc(CidrBlock='172.28.7.0/24', InstanceTenancy='default')
|
||||
|
||||
response = elbv2_client.create_target_group(
|
||||
Name='a-target',
|
||||
Protocol='HTTP',
|
||||
Port=8080,
|
||||
VpcId=vpc.id,
|
||||
VpcId=mocked_networking['vpc'],
|
||||
HealthCheckProtocol='HTTP',
|
||||
HealthCheckPort='8080',
|
||||
HealthCheckPath='/',
|
||||
|
|
@ -110,7 +106,7 @@ def test_detach_all_target_groups():
|
|||
MaxSize=INSTANCE_COUNT,
|
||||
DesiredCapacity=INSTANCE_COUNT,
|
||||
TargetGroupARNs=[target_group_arn],
|
||||
VPCZoneIdentifier=vpc.id)
|
||||
VPCZoneIdentifier=mocked_networking['vpc'])
|
||||
|
||||
response = client.describe_load_balancer_target_groups(
|
||||
AutoScalingGroupName='test_asg')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue