From 98264148e1041d08d80effdc9e7574dc8cf1b93f Mon Sep 17 00:00:00 2001 From: Jack Danger Canty Date: Wed, 31 May 2017 15:11:42 -0700 Subject: [PATCH 1/2] ELB connection draining timeout defaults to 300 seconds --- moto/elb/responses.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moto/elb/responses.py b/moto/elb/responses.py index ed8d6d03..2bc76385 100644 --- a/moto/elb/responses.py +++ b/moto/elb/responses.py @@ -159,7 +159,7 @@ class ELBResponse(BaseResponse): if connection_draining: attribute = ConnectionDrainingAttribute() attribute.enabled = connection_draining["enabled"] == "true" - attribute.timeout = connection_draining["timeout"] + attribute.timeout = connection_draining.get("timeout") self.elb_backend.set_connection_draining_attribute( load_balancer_name, attribute) From b0c83c4e70999c9230b2d1fc922e6aae4ea5ebc8 Mon Sep 17 00:00:00 2001 From: Jack Danger Canty Date: Wed, 31 May 2017 15:53:31 -0700 Subject: [PATCH 2/2] Testing ELB connection draining timeouts --- moto/elb/responses.py | 17 ++++++++++------- tests/test_elb/test_elb.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/moto/elb/responses.py b/moto/elb/responses.py index 2bc76385..ec20486f 100644 --- a/moto/elb/responses.py +++ b/moto/elb/responses.py @@ -159,9 +159,8 @@ class ELBResponse(BaseResponse): if connection_draining: attribute = ConnectionDrainingAttribute() attribute.enabled = connection_draining["enabled"] == "true" - attribute.timeout = connection_draining.get("timeout") - self.elb_backend.set_connection_draining_attribute( - load_balancer_name, attribute) + attribute.timeout = connection_draining.get("timeout", 300) + self.elb_backend.set_connection_draining_attribute(load_balancer_name, attribute) connection_settings = self._get_dict_param( "LoadBalancerAttributes.ConnectionSettings.") @@ -172,7 +171,7 @@ class ELBResponse(BaseResponse): load_balancer_name, attribute) template = self.response_template(MODIFY_ATTRIBUTES_TEMPLATE) - return template.render(attributes=load_balancer.attributes) + return template.render(load_balancer=load_balancer, attributes=load_balancer.attributes) def create_load_balancer_policy(self): load_balancer_name = self._get_param('LoadBalancerName') @@ -592,9 +591,11 @@ DESCRIBE_ATTRIBUTES_TEMPLATE = """{{ attributes.cross_zone_load_balancing.enabled }} - {{ attributes.connection_draining.enabled }} {% if attributes.connection_draining.enabled %} + true {{ attributes.connection_draining.timeout }} + {% else %} + false {% endif %} @@ -607,7 +608,7 @@ DESCRIBE_ATTRIBUTES_TEMPLATE = """ - my-loadbalancer + {{ load_balancer.name }} {{ attributes.access_log.enabled }} @@ -624,9 +625,11 @@ MODIFY_ATTRIBUTES_TEMPLATE = """