Set default value to elbv2 FakeTargetGroup (#1349)
This commit is contained in:
parent
17b8396a9c
commit
49a2724d76
@ -61,18 +61,20 @@ class FakeTargetGroup(BaseModel):
|
|||||||
unhealthy_threshold_count='2',
|
unhealthy_threshold_count='2',
|
||||||
matcher=None,
|
matcher=None,
|
||||||
target_type=None):
|
target_type=None):
|
||||||
|
|
||||||
|
# TODO: default values differs when you add Network Load balancer
|
||||||
self.name = name
|
self.name = name
|
||||||
self.arn = arn
|
self.arn = arn
|
||||||
self.vpc_id = vpc_id
|
self.vpc_id = vpc_id
|
||||||
self.protocol = protocol
|
self.protocol = protocol
|
||||||
self.port = port
|
self.port = port
|
||||||
self.healthcheck_protocol = healthcheck_protocol
|
self.healthcheck_protocol = healthcheck_protocol or 'HTTP'
|
||||||
self.healthcheck_port = healthcheck_port
|
self.healthcheck_port = healthcheck_port
|
||||||
self.healthcheck_path = healthcheck_path
|
self.healthcheck_path = healthcheck_path or '/'
|
||||||
self.healthcheck_interval_seconds = healthcheck_interval_seconds
|
self.healthcheck_interval_seconds = healthcheck_interval_seconds or 30
|
||||||
self.healthcheck_timeout_seconds = healthcheck_timeout_seconds
|
self.healthcheck_timeout_seconds = healthcheck_timeout_seconds or 5
|
||||||
self.healthy_threshold_count = healthy_threshold_count
|
self.healthy_threshold_count = healthy_threshold_count or 5
|
||||||
self.unhealthy_threshold_count = unhealthy_threshold_count
|
self.unhealthy_threshold_count = unhealthy_threshold_count or 2
|
||||||
self.load_balancer_arns = []
|
self.load_balancer_arns = []
|
||||||
self.tags = {}
|
self.tags = {}
|
||||||
if matcher is None:
|
if matcher is None:
|
||||||
|
@ -412,6 +412,43 @@ def test_create_target_group_and_listeners():
|
|||||||
response = conn.describe_target_groups()
|
response = conn.describe_target_groups()
|
||||||
response.get('TargetGroups').should.have.length_of(0)
|
response.get('TargetGroups').should.have.length_of(0)
|
||||||
|
|
||||||
|
@mock_elbv2
|
||||||
|
@mock_ec2
|
||||||
|
def test_create_target_group_without_non_required_parameters():
|
||||||
|
conn = boto3.client('elbv2', region_name='us-east-1')
|
||||||
|
ec2 = boto3.resource('ec2', region_name='us-east-1')
|
||||||
|
|
||||||
|
security_group = ec2.create_security_group(
|
||||||
|
GroupName='a-security-group', Description='First One')
|
||||||
|
vpc = ec2.create_vpc(CidrBlock='172.28.7.0/24', InstanceTenancy='default')
|
||||||
|
subnet1 = ec2.create_subnet(
|
||||||
|
VpcId=vpc.id,
|
||||||
|
CidrBlock='172.28.7.192/26',
|
||||||
|
AvailabilityZone='us-east-1a')
|
||||||
|
subnet2 = ec2.create_subnet(
|
||||||
|
VpcId=vpc.id,
|
||||||
|
CidrBlock='172.28.7.192/26',
|
||||||
|
AvailabilityZone='us-east-1b')
|
||||||
|
|
||||||
|
response = conn.create_load_balancer(
|
||||||
|
Name='my-lb',
|
||||||
|
Subnets=[subnet1.id, subnet2.id],
|
||||||
|
SecurityGroups=[security_group.id],
|
||||||
|
Scheme='internal',
|
||||||
|
Tags=[{'Key': 'key_name', 'Value': 'a_value'}])
|
||||||
|
|
||||||
|
# request without HealthCheckIntervalSeconds parameter
|
||||||
|
# which is default to 30 seconds
|
||||||
|
response = conn.create_target_group(
|
||||||
|
Name='a-target',
|
||||||
|
Protocol='HTTP',
|
||||||
|
Port=8080,
|
||||||
|
VpcId=vpc.id,
|
||||||
|
HealthCheckProtocol='HTTP',
|
||||||
|
HealthCheckPort='8080'
|
||||||
|
)
|
||||||
|
target_group = response.get('TargetGroups')[0]
|
||||||
|
target_group.should_not.be.none
|
||||||
|
|
||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
|
Loading…
Reference in New Issue
Block a user