2011-11-24 12:32:53 -05:00
|
|
|
Shindo.tests('Fog::Rackspace::LoadBalancers | node_tests', ['rackspace']) do
|
2011-07-13 16:27:55 -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
|
|
|
|
given_a_load_balancer do
|
|
|
|
@nodes_created = []
|
2011-07-13 16:27:55 -04:00
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
tests('success') do
|
2011-07-13 16:27:55 -04:00
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
@lb.wait_for { ready? }
|
2011-12-16 13:50:11 -05:00
|
|
|
tests("#create_node(#{@lb.id}, '10.10.10.10', 80, 'ENABLED')").formats(NODES_FORMAT) do
|
2011-07-28 14:37:21 -04:00
|
|
|
data = @service.create_node(@lb.id, '10.10.10.10', 80, 'ENABLED').body
|
|
|
|
@nodes_created << data['nodes'][0]['id']
|
|
|
|
data
|
|
|
|
end
|
2011-07-13 16:27:55 -04:00
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
@lb.wait_for { ready? }
|
|
|
|
tests('#create_node with weight').formats(NODES_FORMAT) do
|
|
|
|
data = @service.create_node(@lb.id, '10.10.10.11', 80, 'ENABLED', { :weight => 10 }).body
|
|
|
|
@nodes_created << data['nodes'][0]['id']
|
|
|
|
data
|
|
|
|
end
|
2011-07-13 16:27:55 -04:00
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
@lb.wait_for { ready? }
|
2011-12-16 13:50:11 -05:00
|
|
|
tests("#list_nodes(#{@lb.id})").formats(NODES_FORMAT) do
|
2011-07-28 14:37:21 -04:00
|
|
|
@service.list_nodes(@lb.id).body
|
|
|
|
end
|
2011-07-13 16:27:55 -04:00
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
@lb.wait_for { ready? }
|
2011-12-16 13:50:11 -05:00
|
|
|
tests("#get_node(#{@lb.id})").formats(NODE_FORMAT) do
|
2011-07-28 14:37:21 -04:00
|
|
|
@service.get_node(@lb.id, @nodes_created[0]).body
|
|
|
|
end
|
2011-07-13 16:27:55 -04:00
|
|
|
|
2011-12-16 13:50:11 -05:00
|
|
|
@lb.wait_for { ready? }
|
|
|
|
tests("#update_node(#{@lb.id}, #{@nodes_created[0]}, { :condition => 'DISABLED' })").succeeds do
|
|
|
|
@service.update_node(@lb.id, @nodes_created[0], { :condition => 'DISABLED' })
|
|
|
|
end
|
2011-07-13 16:27:55 -04:00
|
|
|
|
2011-12-16 13:50:11 -05:00
|
|
|
@lb.wait_for { ready? }
|
|
|
|
tests("#update_node(#{@lb.id}, #{@nodes_created[0]}, { :weight => 20})").succeeds do
|
|
|
|
@service.update_node(@lb.id, @nodes_created[0], { :weight => 20 })
|
|
|
|
end
|
2011-07-13 16:27:55 -04:00
|
|
|
|
2011-12-16 13:50:11 -05:00
|
|
|
@lb.wait_for { ready? }
|
|
|
|
tests("#update_node(#{@lb.id}, #{@nodes_created[0]}, { :condition => 'DISABLED', :weight => 20 })").succeeds do
|
|
|
|
@service.update_node(@lb.id, @nodes_created[0], { :condition => 'DISABLED', :weight => 20 })
|
2011-07-28 14:37:21 -04:00
|
|
|
end
|
2011-07-13 16:27:55 -04:00
|
|
|
end
|
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
tests('failure') do
|
2011-12-16 13:50:11 -05:00
|
|
|
tests('#create_node(invalid ip)').raises(Fog::Rackspace::LoadBalancers::BadRequest) do
|
2011-07-28 14:37:21 -04:00
|
|
|
@service.create_node(@lb.id, '', 80, 'ENABLED')
|
|
|
|
end
|
2011-12-16 13:50:11 -05:00
|
|
|
tests('#create_node(invalid condition)').raises(Fog::Rackspace::LoadBalancers::BadRequest) do
|
2011-07-28 14:37:21 -04:00
|
|
|
@service.create_node(@lb.id, '10.10.10.10', 80, 'EABLED')
|
|
|
|
end
|
2011-12-16 13:50:11 -05:00
|
|
|
tests("#get_node(#{@lb.id}, 0)").raises(Fog::Rackspace::LoadBalancers::NotFound) do
|
2011-07-28 14:37:21 -04:00
|
|
|
@service.get_node(@lb.id, 0)
|
|
|
|
end
|
2011-12-16 13:50:11 -05:00
|
|
|
tests("#delete_node(#{@lb.id}, 0)").raises(Fog::Rackspace::LoadBalancers::NotFound) do
|
2011-11-24 12:32:53 -05:00
|
|
|
@service.delete_node(@lb.id, 0)
|
|
|
|
end
|
2011-12-16 13:50:11 -05:00
|
|
|
tests("#delete_nodes('a', 'b')").raises(Fog::Rackspace::LoadBalancers::NotFound) do
|
|
|
|
@service.delete_nodes(@lb.id, 'a', 'b')
|
2011-07-28 14:37:21 -04:00
|
|
|
end
|
2011-12-16 13:50:11 -05:00
|
|
|
tests("#update_node(#{@lb.id}, 0, { :weight => 20 })").raises(Fog::Rackspace::LoadBalancers::NotFound) do
|
2011-07-28 14:37:21 -04:00
|
|
|
@service.update_node(@lb.id, 0, { :weight => 20 })
|
|
|
|
end
|
|
|
|
end
|
2011-07-13 16:27:55 -04:00
|
|
|
|
2011-07-28 14:37:21 -04:00
|
|
|
tests('success') do
|
|
|
|
@lb.wait_for { ready? }
|
|
|
|
tests("#delete_nodes(multiple node)").succeeds do
|
|
|
|
@service.delete_nodes(@lb.id, *@nodes_created)
|
|
|
|
end
|
|
|
|
@lb.wait_for { ready? }
|
|
|
|
tests("#delete_node()").succeeds do
|
|
|
|
node_id = @service.create_node(@lb.id, '10.10.10.12', 80, 'ENABLED').body['nodes'][0]['id']
|
|
|
|
@lb.wait_for { ready? }
|
|
|
|
@service.delete_node(@lb.id, node_id)
|
|
|
|
end
|
|
|
|
end
|
2011-07-13 16:27:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|