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_balancer_tests.rb

80 lines
2.4 KiB
Ruby
Raw Normal View History

Shindo.tests('Fog::Rackspace::LoadBalancer | load_balancer_tests', ['rackspace']) do
2011-07-08 16:39:22 -04:00
NODE_FORMAT = {'address' => String, 'id' => Integer, 'status' => String, 'weight' => Fog::Nullable::Integer, 'port' => Integer, 'condition' => String}
VIRTUAL_IP_FORMAT = {'type' => String, 'id' => Integer, 'type' => String, 'ipVersion' => String, 'address' => String}
STATUS_ACTIVE = 'ACTIVE'
LOAD_BALANCERS_FORMAT = {
'loadBalancers' => [
{
'name' => String,
'id' => Integer,
'port' => Integer,
'protocol' => String,
'algorithm' => String,
'status' => String,
'virtualIps' => [VIRTUAL_IP_FORMAT],
'nodes' => [NODE_FORMAT],
'created' => { 'time' => String },
'updated' => { 'time' => String }
}]
}
LOAD_BALANCER_FORMAT = {
'loadBalancer' => {
'name' => String,
'id' => Integer,
'port' => Integer,
'protocol' => String,
'algorithm' => String,
'status' => String,
'cluster' => { 'name' => String },
2011-07-08 16:39:22 -04:00
'virtualIps' => [VIRTUAL_IP_FORMAT],
'nodes' => [NODE_FORMAT],
'created' => { 'time' => String },
'updated' => { 'time' => String },
'connectionLogging' => { 'enabled' => Fog::Boolean }
}}
tests('success') do
@lb_id = nil
@lb = Fog::Rackspace::LoadBalancer.new
2011-07-08 16:39:22 -04:00
tests('#create_load_balancer()').formats(LOAD_BALANCER_FORMAT) do
data = @lb.create_load_balancer(:name => 'fog' + Time.now.to_i.to_s, :port => '80', :protocol => 'HTTP', :virtualIps => [{ :type => 'PUBLIC'}], :nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]).body
@lb_id = data['loadBalancer']['id']
data
end
2011-07-08 16:39:22 -04:00
tests("get_load_balancer(#{@lb_id})").formats(LOAD_BALANCER_FORMAT) do
@lb.get_load_balancer(@lb_id).body
end
tests("list_load_balancers()").formats(LOAD_BALANCERS_FORMAT) do
@lb.list_load_balancers.body
end
until @lb.get_load_balancer(@lb_id).body["loadBalancer"]["status"] == STATUS_ACTIVE
sleep 10
end
tests("update_load_balancer()").succeeds do
@lb.update_load_balancer(@lb_id, { :port => 80 }).body
end
until @lb.get_load_balancer(@lb_id).body["loadBalancer"]["status"] == STATUS_ACTIVE
sleep 10
end
tests("#delete_load_balancer(#{@ld_id})").succeeds do
2011-07-08 16:39:22 -04:00
@lb.delete_load_balancer(@lb_id).body
end
end
tests('failure') do
end
end