2011-08-04 17:21:22 -04:00
|
|
|
Shindo.tests('Fog::Rackspace::LoadBalancers | load_balancer', ['rackspace']) do
|
2011-07-10 16:35:30 -04:00
|
|
|
|
2011-08-16 12:56:44 -04:00
|
|
|
pending if Fog.mocking?
|
|
|
|
|
2011-07-19 18:48:21 -04:00
|
|
|
LOAD_BALANCER_ATTRIBUTES = {
|
|
|
|
:name => 'fog' + Time.now.to_i.to_s,
|
2011-07-10 16:35:30 -04:00
|
|
|
:protocol => 'HTTP',
|
|
|
|
:port => 80,
|
|
|
|
:virtual_ips => [{ :type => 'PUBLIC'}],
|
|
|
|
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
2011-07-19 18:48:21 -04:00
|
|
|
}
|
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
given_a_load_balancer_service do
|
|
|
|
model_tests(@service.load_balancers, LOAD_BALANCER_ATTRIBUTES, false) do
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests('#save => saving existing with port = 88').succeeds do
|
|
|
|
@instance.port = 88
|
|
|
|
@instance.save
|
|
|
|
end
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests('#enable_connection_logging').succeeds do
|
|
|
|
@instance.enable_connection_logging
|
|
|
|
returns(true) { @instance.connection_logging }
|
|
|
|
end
|
|
|
|
|
2011-12-13 19:19:28 -05:00
|
|
|
tests('#enable_connection_logging after reload').succeeds do
|
|
|
|
@instance.reload
|
|
|
|
returns(true) { @instance.connection_logging }
|
|
|
|
end
|
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests('#disable_connection_logging').succeeds do
|
|
|
|
@instance.disable_connection_logging
|
|
|
|
returns(false) { @instance.connection_logging }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#usage').succeeds do
|
|
|
|
@instance.usage
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#usage(:start_time => '2010-05-10', :end_time => '2010-05-11')").succeeds do
|
|
|
|
@instance.usage(:start_time => '2010-05-10', :end_time => '2010-05-11')
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#health_monitor").returns(nil) do
|
|
|
|
@instance.health_monitor
|
|
|
|
end
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#enable_health_monitor('CONNECT', 5, 5, 5)").succeeds do
|
|
|
|
@instance.enable_health_monitor('CONNECT', 5, 5, 5)
|
|
|
|
end
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#health_monitor").succeeds do
|
|
|
|
monitor = @instance.health_monitor
|
|
|
|
returns('CONNECT') { monitor['type'] }
|
|
|
|
end
|
|
|
|
|
2011-12-08 10:46:43 -05:00
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#enable_health_monitor('HTTP', 10, 5, 2, {:status_regex => '^[234][0-9][0-9]$', :path=>'/', :body_regex=>' '})").succeeds do
|
|
|
|
@instance.enable_health_monitor('HTTP', 10, 5, 2, {:status_regex => '^[234][0-9][0-9]$', :path=>'/', :body_regex=>' '})
|
|
|
|
end
|
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#disable_health_monitor").succeeds do
|
|
|
|
@instance.disable_health_monitor
|
|
|
|
end
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#connection_throttling").returns(nil) do
|
|
|
|
@instance.connection_throttling
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#enable_connection_throttling(5, 5, 5, 5)").succeeds do
|
|
|
|
@instance.enable_connection_throttling(5, 5, 5, 5)
|
|
|
|
end
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#connection_throttling").succeeds do
|
|
|
|
throttle = @instance.connection_throttling
|
|
|
|
returns(5) { throttle['maxConnections'] }
|
|
|
|
end
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#disable_connection_throttling").succeeds do
|
|
|
|
@instance.disable_connection_throttling
|
|
|
|
end
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#session_persistence").returns(nil) do
|
|
|
|
@instance.session_persistence
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#enable_session_persistence('HTTP_COOKIE')").succeeds do
|
|
|
|
@instance.enable_session_persistence('HTTP_COOKIE')
|
|
|
|
end
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#connction_throttling").succeeds do
|
|
|
|
persistence = @instance.session_persistence
|
|
|
|
returns('HTTP_COOKIE') { persistence['persistenceType'] }
|
|
|
|
end
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#disable_session_persistence").succeeds do
|
|
|
|
@instance.disable_session_persistence
|
|
|
|
end
|
|
|
|
|
2011-12-16 11:40:44 -05:00
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#error_page").succeeds do
|
|
|
|
@instance.error_page
|
|
|
|
end
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#error_page = 'asdf'").succeeds do
|
|
|
|
@instance.error_page = 'asdf'
|
|
|
|
end
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
tests("#reset_error_page").succeeds do
|
|
|
|
@instance.reset_error_page
|
|
|
|
end
|
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
@instance.wait_for { ready? }
|
|
|
|
end
|
|
|
|
|
2012-03-31 16:07:27 -04:00
|
|
|
tests('create(...with algorithm...)') do
|
|
|
|
attributes = LOAD_BALANCER_ATTRIBUTES.clone
|
|
|
|
attributes[:algorithm] = 'LEAST_CONNECTIONS'
|
|
|
|
@lb = @service.load_balancers.create attributes
|
|
|
|
returns('LEAST_CONNECTIONS') { @lb.algorithm }
|
|
|
|
|
|
|
|
@lb.wait_for { ready? }
|
|
|
|
|
|
|
|
@lb.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
tests('failure') do
|
|
|
|
@lb = @service.load_balancers.new LOAD_BALANCER_ATTRIBUTES
|
|
|
|
tests('#usage => Requires ID').raises(ArgumentError) do
|
|
|
|
@lb.usage
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#health_monitor => Requires ID').raises(ArgumentError) do
|
|
|
|
@lb.health_monitor
|
|
|
|
end
|
2011-07-28 10:15:51 -04:00
|
|
|
end
|
2011-07-10 16:35:30 -04:00
|
|
|
end
|
|
|
|
end
|