2012-08-11 20:55:30 +10:00
|
|
|
Shindo.tests('Fog::Compute[:ninefold] | load balancers', ['ninefold']) do
|
|
|
|
|
2012-09-25 13:28:13 +10:00
|
|
|
# NOTE: all of these tests require you to have a vm built with a public IP address.
|
2012-08-11 20:55:30 +10:00
|
|
|
tests('success') do
|
|
|
|
|
2012-09-25 14:19:14 +10:00
|
|
|
before do
|
|
|
|
@compute = Fog::Compute[:ninefold]
|
|
|
|
@public_ip_id = @compute.list_public_ip_addresses.first['id']
|
|
|
|
@server_id = @compute.servers.all.first.id
|
|
|
|
@create_load_balancer = @compute.create_load_balancer_rule(:algorithm => 'roundrobin', :name => 'test',
|
|
|
|
:privateport => 1000, :publicport => 2000,
|
|
|
|
:publicipid => @public_ip_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
2012-09-26 13:38:49 -05:00
|
|
|
delete = @compute.delete_load_balancer_ruler(:id => @create_load_balancer['id'])
|
2012-09-25 14:19:14 +10:00
|
|
|
Ninefold::Compute::TestSupport.wait_for_job(delete['jobid'])
|
|
|
|
end
|
|
|
|
|
2012-08-11 20:55:30 +10:00
|
|
|
tests("#create_load_balancer_rule()").formats(Ninefold::Compute::Formats::LoadBalancers::CREATE_LOAD_BALANCER_RULE_RESPONSE) do
|
|
|
|
pending if Fog.mocking?
|
2012-09-25 14:19:14 +10:00
|
|
|
result = Ninefold::Compute::TestSupport.wait_for_job(@create_load_balancer['jobid'])
|
|
|
|
result['jobresult']['loadbalancer']
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#assign_to_load_balancer_rule()").formats(Ninefold::Compute::Formats::LoadBalancers::ASSIGN_LOAD_BALANCER_RULE_RESPONSE) do
|
|
|
|
pending if Fog.mocking?
|
2012-09-26 13:38:49 -05:00
|
|
|
assign_load_balancer = @compute.assign_to_load_balancer_rule(:id => @create_load_balancer['id'], :virtualmachineids => @server_id)
|
2012-09-25 14:19:14 +10:00
|
|
|
result = Ninefold::Compute::TestSupport.wait_for_job(assign_load_balancer['jobid'])
|
|
|
|
result['jobresult']
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#list_to_load_balancer_rules()").formats(Ninefold::Compute::Formats::LoadBalancers::LIST_LOAD_BALANCER_RULES_RESPONSE) do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
list_load_balancer_rules = @compute.list_load_balancer_rules
|
|
|
|
list_load_balancer_rules['loadbalancerrule'].first
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#update_to_load_balancer_rule()").formats(Ninefold::Compute::Formats::LoadBalancers::UPDATE_LOAD_BALANCER_RULE_RESPONSE) do
|
|
|
|
pending if Fog.mocking?
|
2012-09-26 13:38:49 -05:00
|
|
|
update_load_balancer = @compute.update_load_balancer_rule(:id => @create_load_balancer['id'], :algorithm => 'source')
|
2012-09-25 14:19:14 +10:00
|
|
|
result = Ninefold::Compute::TestSupport.wait_for_job(update_load_balancer['jobid'])
|
2012-09-25 13:28:13 +10:00
|
|
|
result['jobresult']['loadbalancer']
|
2012-08-11 20:55:30 +10:00
|
|
|
end
|
|
|
|
|
2012-09-25 14:35:50 +10:00
|
|
|
tests('with assigned to load balancer rule') do
|
|
|
|
before do
|
2012-09-26 13:38:49 -05:00
|
|
|
assign_load_balancer = @compute.assign_to_load_balancer_rule(:id => @create_load_balancer['id'], :virtualmachineids => @server_id)
|
2012-09-25 14:35:50 +10:00
|
|
|
result = Ninefold::Compute::TestSupport.wait_for_job(assign_load_balancer['jobid'])
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#remove_from_load_balancer_rule()").formats(Ninefold::Compute::Formats::LoadBalancers::REMOVE_FROM_LOAD_BALANCER_RULE_RESPONSE) do
|
|
|
|
pending if Fog.mocking?
|
2012-09-26 13:38:49 -05:00
|
|
|
remove = @compute.remove_from_load_balancer_rule(:id => @create_load_balancer['id'], :virtualmachineids => @server_id)
|
2012-09-25 14:35:50 +10:00
|
|
|
result = Ninefold::Compute::TestSupport.wait_for_job(remove['jobid'])
|
|
|
|
result['jobresult']
|
|
|
|
end
|
|
|
|
end
|
2012-08-11 20:55:30 +10:00
|
|
|
end
|
|
|
|
end
|