mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Move things around a bit. Separate ELB test file per concerns.
This commit is contained in:
parent
1496e3e840
commit
98961be7fc
6 changed files with 67 additions and 59 deletions
|
@ -16,7 +16,7 @@ module Fog
|
|||
def initialize(attributes={})
|
||||
attributes[:availability_zones] ||= %w(us-east-1a us-east-1b us-east-1c us-east-1d)
|
||||
attributes['ListenerDescriptions'] ||= [{
|
||||
'Listener' => {'LoadBalancerPort' => 80, 'InstancePort' => 80, 'Protocol' => 'http'},
|
||||
'Listener' => {'LoadBalancerPort' => 80, 'InstancePort' => 80, 'Protocol' => 'HTTP'},
|
||||
'PolicyNames' => []
|
||||
}]
|
||||
attributes['Policies'] ||= {'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => []}
|
||||
|
|
|
@ -51,7 +51,7 @@ module Fog
|
|||
end
|
||||
|
||||
class Mock
|
||||
def create_load_balancer(availability_zones, lb_name, listeners)
|
||||
def create_load_balancer(availability_zones, lb_name, listeners = [])
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
|
||||
|
@ -72,16 +72,7 @@ module Fog
|
|||
'Target' => 'TCP:80'
|
||||
},
|
||||
'Instances' => [],
|
||||
'ListenerDescriptions' => [
|
||||
{
|
||||
'Listener' => {
|
||||
'InstancePort' => 80,
|
||||
'Protocol' => 'HTTP',
|
||||
'LoadBalancerPort' => 80
|
||||
},
|
||||
'PolicyNames' => []
|
||||
}
|
||||
],
|
||||
'ListenerDescriptions' => [*listeners].map { |listener| {'Listener' => listener, 'PolicyNames' => []}},
|
||||
'LoadBalancerName' => lb_name,
|
||||
'Policies' => {
|
||||
'LBCookieStickinessPolicies' => [],
|
||||
|
|
|
@ -105,13 +105,11 @@ Shindo.tests('AWS::ELB | models', ['aws', 'elb']) do
|
|||
end
|
||||
|
||||
tests('listeners') do
|
||||
default_listener_description = [{"Listener"=>{"InstancePort"=>80, "Protocol"=>"HTTP", "LoadBalancerPort"=>80}, "PolicyNames"=>[]}]
|
||||
tests('default') do
|
||||
returns(1) { elb.listeners.size }
|
||||
|
||||
listener = elb.listeners.first
|
||||
returns([80,80,'HTTP', []]) { [listener.instance_port, listener.lb_port, listener.protocol, listener.policy_names] }
|
||||
|
||||
end
|
||||
|
||||
tests('#get') do
|
22
tests/aws/requests/elb/listener_tests.rb
Normal file
22
tests/aws/requests/elb/listener_tests.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
Shindo.tests('AWS::ELB | listener_tests', ['aws', 'elb']) do
|
||||
@load_balancer_id = 'fog-test-listener'
|
||||
|
||||
tests('success') do
|
||||
AWS[:elb].create_load_balancer(['us-east-1a'], @load_balancer_id, [{'LoadBalancerPort' => 80, 'InstancePort' => 80, 'Protocol' => 'HTTP'}])
|
||||
|
||||
tests("#create_load_balancer_listeners").formats(AWS::ELB::Formats::BASIC) do
|
||||
listeners = [
|
||||
{'Protocol' => 'TCP', 'LoadBalancerPort' => 443, 'InstancePort' => 443},
|
||||
{'Protocol' => 'HTTP', 'LoadBalancerPort' => 80, 'InstancePort' => 80}
|
||||
]
|
||||
AWS[:elb].create_load_balancer_listeners(@load_balancer_id, listeners).body
|
||||
end
|
||||
|
||||
tests("#delete_load_balancer_listeners").formats(AWS::ELB::Formats::BASIC) do
|
||||
ports = [80, 443]
|
||||
AWS[:elb].delete_load_balancer_listeners(@load_balancer_id, ports).body
|
||||
end
|
||||
|
||||
AWS[:elb].delete_load_balancer(@load_balancer_id)
|
||||
end
|
||||
end
|
|
@ -4,7 +4,7 @@ Shindo.tests('AWS::ELB | load_balancer_tests', ['aws', 'elb']) do
|
|||
tests('success') do
|
||||
tests("#create_load_balancer").formats(AWS::ELB::Formats::CREATE_LOAD_BALANCER) do
|
||||
zones = ['us-east-1a']
|
||||
listeners = [{'LoadBalancerPort' => 80, 'InstancePort' => 80, 'Protocol' => 'http'}]
|
||||
listeners = [{'LoadBalancerPort' => 80, 'InstancePort' => 80, 'Protocol' => 'HTTP'}]
|
||||
AWS[:elb].create_load_balancer(zones, @load_balancer_id, listeners).body
|
||||
end
|
||||
|
||||
|
@ -28,50 +28,6 @@ Shindo.tests('AWS::ELB | load_balancer_tests', ['aws', 'elb']) do
|
|||
AWS[:elb].configure_health_check(@load_balancer_id, health_check).body
|
||||
end
|
||||
|
||||
tests("#create_app_cookie_stickiness_policy").formats(AWS::ELB::Formats::BASIC) do
|
||||
cookie, policy = 'fog-app-cookie', 'fog-app-policy'
|
||||
AWS[:elb].create_app_cookie_stickiness_policy(@load_balancer_id, policy, cookie).body
|
||||
end
|
||||
|
||||
tests("#create_lb_cookie_stickiness_policy with expiry").formats(AWS::ELB::Formats::BASIC) do
|
||||
policy = 'fog-lb-expiry'
|
||||
expiry = 300
|
||||
AWS[:elb].create_lb_cookie_stickiness_policy(@load_balancer_id, policy, expiry).body
|
||||
end
|
||||
|
||||
tests("#create_lb_cookie_stickiness_policy without expiry").formats(AWS::ELB::Formats::BASIC) do
|
||||
policy = 'fog-lb-no-expiry'
|
||||
AWS[:elb].create_lb_cookie_stickiness_policy(@load_balancer_id, policy).body
|
||||
end
|
||||
|
||||
tests("#delete_load_balancer_policy").formats(AWS::ELB::Formats::BASIC) do
|
||||
policy = 'fog-lb-no-expiry'
|
||||
AWS[:elb].delete_load_balancer_policy(@load_balancer_id, policy).body
|
||||
end
|
||||
|
||||
tests("#create_load_balancer_listeners").formats(AWS::ELB::Formats::BASIC) do
|
||||
listeners = [
|
||||
{'Protocol' => 'tcp', 'LoadBalancerPort' => 443, 'InstancePort' => 443},
|
||||
{'Protocol' => 'HTTP', 'LoadBalancerPort' => 80, 'InstancePort' => 80}
|
||||
]
|
||||
AWS[:elb].create_load_balancer_listeners(@load_balancer_id, listeners).body
|
||||
end
|
||||
|
||||
tests("#set_load_balancer_policies_of_listener adds policy").formats(AWS::ELB::Formats::BASIC) do
|
||||
port, policies = 80, ['fog-lb-expiry']
|
||||
AWS[:elb].set_load_balancer_policies_of_listener(@load_balancer_id, port, policies).body
|
||||
end
|
||||
|
||||
tests("#set_load_balancer_policies_of_listener removes policy").formats(AWS::ELB::Formats::BASIC) do
|
||||
port = 80
|
||||
AWS[:elb].set_load_balancer_policies_of_listener(@load_balancer_id, port, []).body
|
||||
end
|
||||
|
||||
tests("#delete_load_balancer_listeners").formats(AWS::ELB::Formats::BASIC) do
|
||||
ports = [80, 443]
|
||||
AWS[:elb].delete_load_balancer_listeners(@load_balancer_id, ports).body
|
||||
end
|
||||
|
||||
tests("#delete_load_balancer").formats(AWS::ELB::Formats::DELETE_LOAD_BALANCER) do
|
||||
AWS[:elb].delete_load_balancer(@load_balancer_id).body
|
||||
end
|
||||
|
|
41
tests/aws/requests/elb/policy_tests.rb
Normal file
41
tests/aws/requests/elb/policy_tests.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
Shindo.tests('AWS::ELB | policy_tests', ['aws', 'elb']) do
|
||||
@load_balancer_id = 'fog-test-policies'
|
||||
|
||||
tests('success') do
|
||||
listeners = [{'LoadBalancerPort' => 80, 'InstancePort' => 80, 'Protocol' => 'HTTP'}]
|
||||
AWS[:elb].create_load_balancer(['us-east-1a'], @load_balancer_id, listeners)
|
||||
|
||||
tests("#create_app_cookie_stickiness_policy").formats(AWS::ELB::Formats::BASIC) do
|
||||
cookie, policy = 'fog-app-cookie', 'fog-app-policy'
|
||||
AWS[:elb].create_app_cookie_stickiness_policy(@load_balancer_id, policy, cookie).body
|
||||
end
|
||||
|
||||
tests("#create_lb_cookie_stickiness_policy with expiry").formats(AWS::ELB::Formats::BASIC) do
|
||||
policy = 'fog-lb-expiry'
|
||||
expiry = 300
|
||||
AWS[:elb].create_lb_cookie_stickiness_policy(@load_balancer_id, policy, expiry).body
|
||||
end
|
||||
|
||||
tests("#create_lb_cookie_stickiness_policy without expiry").formats(AWS::ELB::Formats::BASIC) do
|
||||
policy = 'fog-lb-no-expiry'
|
||||
AWS[:elb].create_lb_cookie_stickiness_policy(@load_balancer_id, policy).body
|
||||
end
|
||||
|
||||
tests("#delete_load_balancer_policy").formats(AWS::ELB::Formats::BASIC) do
|
||||
policy = 'fog-lb-no-expiry'
|
||||
AWS[:elb].delete_load_balancer_policy(@load_balancer_id, policy).body
|
||||
end
|
||||
|
||||
tests("#set_load_balancer_policies_of_listener adds policy").formats(AWS::ELB::Formats::BASIC) do
|
||||
port, policies = 80, ['fog-lb-expiry']
|
||||
AWS[:elb].set_load_balancer_policies_of_listener(@load_balancer_id, port, policies).body
|
||||
end
|
||||
|
||||
tests("#set_load_balancer_policies_of_listener removes policy").formats(AWS::ELB::Formats::BASIC) do
|
||||
port = 80
|
||||
AWS[:elb].set_load_balancer_policies_of_listener(@load_balancer_id, port, []).body
|
||||
end
|
||||
|
||||
AWS[:elb].delete_load_balancer(@load_balancer_id)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue