1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/rackspace/requests/load_balancers/node_tests.rb

87 lines
3.3 KiB
Ruby
Raw Normal View History

Shindo.tests('Fog::Rackspace::LoadBalancers | node_tests', ['rackspace']) do
2011-07-13 16:27:55 -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? }
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? }
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? }
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
@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
@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
@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
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
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
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
tests("#delete_node(#{@lb.id}, 0)").raises(Fog::Rackspace::LoadBalancers::NotFound) do
@service.delete_node(@lb.id, 0)
end
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
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