1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[rackspace|load balancers] fixing broken test

This commit is contained in:
Kyle Rames 2013-09-04 13:22:26 -05:00
parent d9fe97bd37
commit 810b023a47
3 changed files with 45 additions and 6 deletions

View file

@ -28,12 +28,11 @@ module Fog
class Mock
def create_load_balancer(name, protocol, port, virtual_ips, nodes, options = {})
data = {"loadBalancer"=>{"name"=>name, "id"=>uniq_id, "protocol"=>protocol, "port"=>port, "algorithm"=>"RANDOM", "status"=>"BUILD",
"cluster"=>{"name"=>"ztm-n13.dfw1.lbaas.rackspace.net"}, "timeout"=>30, "created"=>{"time"=>"2013-08-20T20:52:44Z"},
"updated"=>{"time"=>"2013-08-20T20:52:44Z"}, "halfClosed"=>false, "connectionLogging"=>{"enabled"=>false}, "contentCaching"=>{"enabled"=>false}}}
data["virtual_ips"] = virtual_ips.collect {|n| {"virtualIps"=>[{"address"=>"192.237.192.152", "id"=>uniq_id, "type"=>n[:type], "ipVersion"=>"IPV4"}, {"address"=>"2001:4800:7901:0000:ba81:a6a5:0000:0002", "id"=>9153169, "type"=>"PUBLIC", "ipVersion"=>"IPV6"}], "sourceAddresses"=>{"ipv6Public"=>"2001:4800:7901::13/64", "ipv4Servicenet"=>"10.189.254.5", "ipv4Public"=>"166.78.44.5"}}
data["nodes"] = nodes.collect {|n| {"address"=>n[:address], "id"=>uniq_id, "type"=>"PRIMARY", "port"=>n[:port], "status"=>"ONLINE", "condition"=>"ENABLED", "weight"=>1}}
data = Excon::Response.new(:body => data, :status => 202)
}
"cluster"=>{"name"=>"my-cluster.rackspace.net"}, "timeout"=>30, "created"=>{"time"=> MockData.zulu_time},
"updated"=>{"time"=>MockData.zulu_time }, "halfClosed"=>false, "connectionLogging"=>{"enabled"=>false}, "contentCaching"=>{"enabled"=>false}}}
data["virtual_ips"] = virtual_ips.collect {|n| {"virtualIps"=>[{"address"=> MockData.ipv4_address, "id"=>uniq_id, "type"=>n[:type], "ipVersion"=>"IPV4"}, {"address"=> MockData.ipv6_address, "id"=> Fog::Mock.random_numbers(4), "type"=>"PUBLIC", "ipVersion"=>"IPV6"}], "sourceAddresses"=>{"ipv6Public"=> MockData.ipv6_address, "ipv4Servicenet"=>MockData.ipv4_address, "ipv4Public"=>MockData.ipv4_address}}
data["nodes"] = nodes.collect {|n| {"address"=>n[:address], "id"=>uniq_id, "type"=>"PRIMARY", "port"=>n[:port], "status"=>"ONLINE", "condition"=>"ENABLED", "weight"=>1}}}
Excon::Response.new(:body => data, :status => 202)
end
end
end

View file

@ -1,6 +1,7 @@
module Fog
module Rackspace
class LoadBalancers
class Real
def delete_load_balancer(load_balancer_id)
request(
@ -10,6 +11,15 @@ module Fog
)
end
end
class Mock
def delete_load_balancer(load_balancer_id)
response = Excon::Response.new
response.status = 202
response.body = ""
end
end
end
end
end

View file

@ -10,6 +10,36 @@ module Fog
)
end
end
class Mock
def get_load_balancer(load_balancer_id)
response = Excon::Response.new
response.status = 200
response.body = {
"loadBalancer"=> {
"name"=>"load_balancer_#{load_balancer_id}",
"id"=> load_balancer_id,
"protocol"=>"HTTP",
"port"=>80,
"algorithm"=>"RANDOM",
"status"=>"ACTIVE",
"cluster"=>{"name"=>"my-cluster.rackspace.net"},
"nodes"=>[{"address"=> MockData.ipv4_address, "id"=> Fog::Mock.random_numbers(6), "type"=>"PRIMARY", "port"=>80, "status"=>"ONLINE", "condition"=>"ENABLED"}],
"timeout"=>30,
"created"=>{"time"=>MockData.zulu_time},
"virtualIps"=>[
{"address"=> MockData.ipv4_address, "id"=>Fog::Mock.random_numbers(4), "type"=>"PUBLIC", "ipVersion"=>"IPV4"},
{"address"=> MockData.ipv6_address, "id"=>Fog::Mock.random_numbers(4), "type"=>"PUBLIC", "ipVersion"=>"IPV6"}],
"sourceAddresses"=>{"ipv6Public"=> MockData.ipv6_address, "ipv4Servicenet"=> MockData.ipv4_address, "ipv4Public"=> MockData.ipv4_address},
"updated"=>{"time"=>"2013-09-04T06:29:09Z"},
"halfClosed"=>false,
"connectionLogging"=>{"enabled"=>false},
"contentCaching"=>{"enabled"=>false}}}
response
end
end
end
end
end