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-08-16 12:56:44 -04:00
|
|
|
pending if Fog.mocking?
|
|
|
|
|
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
|
|
|
|
|
2011-08-16 22:22:24 -04:00
|
|
|
tests("#update_load_balancer(#{@lb_id}) while immutable").raises(Fog::Rackspace::LoadBalancers::ServiceError) do
|
2011-07-28 14:37:21 -04:00
|
|
|
@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
|
|
|
|
|
|
|
|
|
2011-08-17 15:44:17 -04:00
|
|
|
tests("#update_load_balancer(#{@lb_id}, { :port => 80 })").succeeds do
|
2011-07-28 14:37:21 -04:00
|
|
|
@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
|
2011-08-16 22:22:24 -04:00
|
|
|
tests('#create_load_balancer(invalid name)').raises(Fog::Rackspace::LoadBalancers::BadRequest) do
|
2011-07-28 14:37:21 -04:00
|
|
|
@service.create_load_balancer('', 'HTTP', 80, [{ :type => 'PUBLIC'}], [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}])
|
|
|
|
end
|
|
|
|
|
2011-08-16 22:22:24 -04:00
|
|
|
tests('#get_load_balancer(0)').raises(Fog::Rackspace::LoadBalancers::NotFound) do
|
2011-07-28 14:37:21 -04:00
|
|
|
@service.get_load_balancer(0)
|
|
|
|
end
|
2011-08-16 22:22:24 -04:00
|
|
|
tests('#delete_load_balancer(0)').raises(Fog::Rackspace::LoadBalancers::NotFound) do
|
2011-07-28 14:37:21 -04:00
|
|
|
@service.delete_load_balancer(0)
|
|
|
|
end
|
2011-08-16 22:22:24 -04:00
|
|
|
tests('#update_load_balancer(0)').raises(Fog::Rackspace::LoadBalancers::NotFound) do
|
2011-07-28 14:37:21 -04:00
|
|
|
@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
|