Permalink
Browse files

Merge branch 'elb-policy-test' of https://github.com/jimbrowne/boto i…

…nto jimbrowne-elb-policy-test
  • Loading branch information...
2 parents 6c1aacd + ec228f9 commit ebbf38fcfdb6e519086a9f29902e534ce4ecda16 @garnaat garnaat committed Jun 5, 2012
Showing with 34 additions and 1 deletion.
  1. +5 −0 boto/ec2/elb/listener.py
  2. +2 −0 boto/ec2/elb/policies.py
  3. +27 −1 tests/ec2/elb/test_connection.py
View
@@ -19,6 +19,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+from boto.ec2.elb.listelement import ListElement
+
class Listener(object):
"""
Represents an EC2 Load Balancer Listener tuple
@@ -31,6 +33,7 @@ def __init__(self, load_balancer=None, load_balancer_port=0,
self.instance_port = instance_port
self.protocol = protocol
self.ssl_certificate_id = ssl_certificate_id
+ self.policy_names = ListElement()
def __repr__(self):
r = "(%d, %d, '%s'" % (self.load_balancer_port, self.instance_port, self.protocol)
@@ -40,6 +43,8 @@ def __repr__(self):
return r
def startElement(self, name, attrs, connection):
+ if name == 'PolicyNames':
+ return self.policy_names
return None
def endElement(self, name, value, connection):
View
@@ -78,9 +78,11 @@ def startElement(self, name, attrs, connection):
if name == 'AppCookieStickinessPolicies':
rs = ResultSet([('member', AppCookieStickinessPolicy)])
self.app_cookie_stickiness_policies = rs
+ return rs
elif name == 'LBCookieStickinessPolicies':
rs = ResultSet([('member', LBCookieStickinessPolicy)])
self.lb_cookie_stickiness_policies = rs
+ return rs
def endElement(self, name, value, connection):
return
@@ -99,6 +99,32 @@ def test_delete_load_balancer_listeners(self):
listeners[:1]
)
+ def test_create_load_balancer_listeners_with_policies(self):
+ c = ELBConnection()
+ name = 'elb-boto-unit-test-policy'
+ availability_zones = ['us-east-1a']
+ listeners = [(80, 8000, 'HTTP')]
+ balancer = c.create_load_balancer(name, availability_zones, listeners)
+
+ more_listeners = [(443, 8001, 'HTTP')]
+ c.create_load_balancer_listeners(name, more_listeners)
+
+ lb_policy_name = 'lb-policy'
+ c.create_lb_cookie_stickiness_policy(1000, name, lb_policy_name)
+ c.set_lb_policies_of_listener(name, listeners[0][0], lb_policy_name)
+
+ app_policy_name = 'app-policy'
+ c.create_app_cookie_stickiness_policy('appcookie', name, app_policy_name)
+ c.set_lb_policies_of_listener(name, more_listeners[0][0], app_policy_name)
+
+ balancers = c.get_all_load_balancers()
+ self.assertEqual([lb.name for lb in balancers], [name])
+ self.assertEqual(
+ sorted(l.get_tuple() for l in balancers[0].listeners),
+ sorted(listeners + more_listeners)
+ )
+ # Policy names should be checked here once they are supported
+ # in the Listener object.
if __name__ == '__main__':
- unittest.main()
+ unittest.main()

0 comments on commit ebbf38f

Please sign in to comment.