2011-03-18 17:34:03 -04:00
|
|
|
Shindo.tests('AWS::ELB | load_balancer_tests', ['aws', 'elb']) do
|
|
|
|
@load_balancer_id = 'fog-test-elb'
|
2011-07-15 20:23:23 -04:00
|
|
|
@key_name = 'fog-test'
|
2011-03-18 17:34:03 -04:00
|
|
|
|
|
|
|
tests('success') do
|
2011-07-15 20:23:23 -04:00
|
|
|
@certificate = AWS[:iam].upload_server_certificate(AWS::IAM::SERVER_CERT_PUBLIC_KEY, AWS::IAM::SERVER_CERT_PRIVATE_KEY, @key_name).body['Certificate']
|
|
|
|
|
2011-03-18 17:34:03 -04:00
|
|
|
tests("#create_load_balancer").formats(AWS::ELB::Formats::CREATE_LOAD_BALANCER) do
|
|
|
|
zones = ['us-east-1a']
|
2011-07-07 20:32:02 -04:00
|
|
|
listeners = [{'LoadBalancerPort' => 80, 'InstancePort' => 80, 'Protocol' => 'HTTP'}]
|
2011-03-18 17:34:03 -04:00
|
|
|
AWS[:elb].create_load_balancer(zones, @load_balancer_id, listeners).body
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#describe_load_balancers").formats(AWS::ELB::Formats::DESCRIBE_LOAD_BALANCERS) do
|
|
|
|
AWS[:elb].describe_load_balancers.body
|
|
|
|
end
|
|
|
|
|
2011-05-05 12:16:14 -04:00
|
|
|
tests('#describe_load_balancers with bad lb') do
|
|
|
|
raises(Fog::AWS::ELB::NotFound) { AWS[:elb].describe_load_balancers('none-such-lb') }
|
|
|
|
end
|
|
|
|
|
2011-07-15 20:23:23 -04:00
|
|
|
tests("#describe_load_balancers with SSL listener") do
|
|
|
|
sleep 5 unless Fog.mocking?
|
|
|
|
listeners = [
|
|
|
|
{'Protocol' => 'HTTPS', 'LoadBalancerPort' => 443, 'InstancePort' => 443, 'SSLCertificateId' => @certificate['Arn']},
|
|
|
|
]
|
|
|
|
AWS[:elb].create_load_balancer_listeners(@load_balancer_id, listeners)
|
|
|
|
response = AWS[:elb].describe_load_balancers(@load_balancer_id).body
|
|
|
|
tests("SSLCertificateId is set").returns(@certificate['Arn']) do
|
|
|
|
listeners = response["DescribeLoadBalancersResult"]["LoadBalancerDescriptions"].first["ListenerDescriptions"]
|
|
|
|
listeners.find {|l| l["Listener"]["Protocol"] == 'HTTPS' }["Listener"]["SSLCertificateId"]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-04-09 16:54:24 -04:00
|
|
|
tests("#configure_health_check").formats(AWS::ELB::Formats::CONFIGURE_HEALTH_CHECK) do
|
|
|
|
health_check = {
|
|
|
|
'Target' => 'HTTP:80/index.html',
|
|
|
|
'Interval' => 10,
|
|
|
|
'Timeout' => 5,
|
|
|
|
'UnhealthyThreshold' => 2,
|
|
|
|
'HealthyThreshold' => 3
|
|
|
|
}
|
|
|
|
|
|
|
|
AWS[:elb].configure_health_check(@load_balancer_id, health_check).body
|
|
|
|
end
|
|
|
|
|
2011-03-18 17:34:03 -04:00
|
|
|
tests("#delete_load_balancer").formats(AWS::ELB::Formats::DELETE_LOAD_BALANCER) do
|
|
|
|
AWS[:elb].delete_load_balancer(@load_balancer_id).body
|
|
|
|
end
|
2011-07-07 16:45:39 -04:00
|
|
|
|
|
|
|
tests("#delete_load_balancer when non existant").formats(AWS::ELB::Formats::DELETE_LOAD_BALANCER) do
|
|
|
|
AWS[:elb].delete_load_balancer('non-existant').body
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#delete_load_balancer when already deleted").formats(AWS::ELB::Formats::DELETE_LOAD_BALANCER) do
|
|
|
|
AWS[:elb].delete_load_balancer(@load_balancer_id).body
|
|
|
|
end
|
2011-07-15 20:23:23 -04:00
|
|
|
|
|
|
|
AWS[:iam].delete_server_certificate(@key_name)
|
2011-03-18 17:34:03 -04:00
|
|
|
end
|
|
|
|
end
|