2011-08-04 17:21:22 -04:00
|
|
|
Shindo.tests('Fog::Rackspace::LoadBalancers | load_balancer_tests', ['rackspace']) do
|
2011-07-07 18:17:31 -04:00
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
given_a_load_balancer_service do
|
|
|
|
tests('success') do
|
|
|
|
|
|
|
|
@lb_id = nil
|
|
|
|
@lb_name = 'fog' + Time.now.to_i.to_s
|
|
|
|
|
|
|
|
tests('#create_load_balancer(fog, )').formats(LOAD_BALANCER_FORMAT) do
|
|
|
|
data = @service.create_load_balancer(@lb_name, 'HTTP', 80, [{ :type => 'PUBLIC'}], [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]).body
|
|
|
|
@lb_id = data['loadBalancer']['id']
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#update_load_balancer(#{@lb_id}) while immutable").raises(Fog::Rackspace::LoadBalancer::ServiceError) do
|
|
|
|
@service.update_load_balancer(@lb_id, { :port => 80 }).body
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#get_load_balancer(#{@lb_id})").formats(LOAD_BALANCER_FORMAT) do
|
|
|
|
@service.get_load_balancer(@lb_id).body
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#list_load_balancers()").formats(LOAD_BALANCERS_FORMAT) do
|
|
|
|
@service.list_load_balancers.body
|
|
|
|
end
|
|
|
|
|
|
|
|
until @service.get_load_balancer(@lb_id).body["loadBalancer"]["status"] == STATUS_ACTIVE
|
|
|
|
sleep 10
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
tests("#update_load_balancer(#{lb_id}, { :port => 80 })").succeeds do
|
|
|
|
@service.update_load_balancer(@lb_id, { :port => 80 }).body
|
|
|
|
end
|
|
|
|
|
|
|
|
until @service.get_load_balancer(@lb_id).body["loadBalancer"]["status"] == STATUS_ACTIVE
|
|
|
|
sleep 10
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#delete_load_balancer(#{@ld_id})").succeeds do
|
|
|
|
@service.delete_load_balancer(@lb_id).body
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('failure') do
|
|
|
|
tests('#create_load_balancer(invalid name)').raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
|
|
|
@service.create_load_balancer('', 'HTTP', 80, [{ :type => 'PUBLIC'}], [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}])
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#get_load_balancer(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
|
|
|
@service.get_load_balancer(0)
|
|
|
|
end
|
|
|
|
tests('#delete_load_balancer(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
|
|
|
@service.delete_load_balancer(0)
|
|
|
|
end
|
|
|
|
tests('#update_load_balancer(0)').raises(Fog::Rackspace::LoadBalancer::NotFound) do
|
|
|
|
@service.update_load_balancer(0, { :name => 'newname' })
|
|
|
|
end
|
2011-07-09 17:46:15 -04:00
|
|
|
end
|
2011-07-07 18:17:31 -04:00
|
|
|
end
|
|
|
|
end
|