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

[bluebox|blb] update tests

This commit is contained in:
Josh Yotty 2013-03-04 18:54:04 -08:00
parent 29e118619e
commit 6a819ce0e3
3 changed files with 69 additions and 11 deletions

View file

@ -14,7 +14,7 @@ module Fog
def update_lb_backend_machine(lb_backend_id, lb_machine_id, options = {})
# inconsistent, no?
request(
:expects => 200,
:expects => 202,
:method => 'PUT',
:path => "/api/lb_backends/#{lb_backend_id}/lb_machines/#{lb_machine_id}",
:body => options.map {|k,v| "#{CGI.escape(k)}=#{CGI.escape(v.to_s)}"}.join('&')

View file

@ -27,11 +27,37 @@ class Bluebox
LB_SERVICES = [LB_SERVICE]
ADD_MACHINE_TO_LB = {
'status' => String,
'text' => String,
LB_BACKEND = {
'id' => String,
'backend_name' => String,
'lb_machines' => Array,
'acl_name' => String,
'acl_name' => String,
'monitoring_url_hostname' => String,
'monitoring_url' => String,
'monitoring_url_hostname' => String,
'check_interval' => Integer,
'rise' => Fog::Nullable::Integer,
'order' => Fog::Nullable::Integer,
'fall' => Fog::Nullable::Integer,
}
LB_BACKENDS = [LB_BACKEND]
LB_MACHINE = {
'port' => Integer,
'id' => String,
'ip' => String,
'maxconn' => Integer,
'hostname' => String,
'created' => String,
}
ADD_MACHINE_TO_LB = [
{ 'text' => String },
{ 'status' => String },
]
REMOVE_MACHINE_FROM_BACKEND = 'Record Removed.'
end
end

View file

@ -9,8 +9,6 @@ Shindo.tests('Bluebox::BLB | lb_tests', ['bluebox']) do
@location_id = compute_providers[:bluebox][:server_attributes][:location_id]
@password = SecureRandom.base64(18)
@lb_applications = nil
tests("get_lb_applications").formats(Bluebox::BLB::Formats::LB_APPLICATIONS) do
@lb_applications = Fog::Bluebox[:blb].get_lb_applications.body
end
@ -27,17 +25,51 @@ Shindo.tests('Bluebox::BLB | lb_tests', ['bluebox']) do
Fog::Bluebox[:blb].get_lb_service(@lb_applications.first['id'], @lb_services.first['id']).body
end
tests("get_lb_backends").formats(Bluebox::BLB::Formats::LB_BACKEND) do
tests("get_lb_backends").formats(Bluebox::BLB::Formats::LB_BACKENDS) do
@lb_backends = Fog::Bluebox[:blb].get_lb_backends(@lb_services.first['id']).body
end
tests("get_lb_backend").formats(Bluebox::BLB::Formats::LB_BACKEND) do
Fog::Bluebox[:blb].get_lb_backend(@lb_services.first['id'], @lb_backends.first['id']).body
end
#data = Fog::Compute[:bluebox].create_block(@flavor_id, @image_id, @location_id, {'password' => @password}).body
#@block_id = data['id']
#Fog::Compute[:bluebox].servers.get(@block_id).wait_for { ready? }
#Fog::Compute[:bluebox].destroy_block(@block_id).body
# create block
data = Fog::Compute[:bluebox].create_block(@flavor_id, @image_id, @location_id, {'password' => @password}).body
@block_id = data['id']
Fog::Compute[:bluebox].servers.get(@block_id).wait_for { ready? }
tests("add_machine_to_lb_application").formats(Bluebox::BLB::Formats::ADD_MACHINE_TO_LB) do
Fog::Bluebox[:blb].add_machine_to_lb_application(@lb_applications.first['id'], @block_id).body
end
@default_backend = @lb_backends.select { |x| x['backend_name'] == 'default' }.first
@id_in_backend = @default_backend['lb_machines'].last['id']
@machine_opts = { 'port' => 4361, 'backup' => true };
tests("update_lb_backend_machine(#{@lb_backends.first['id']}, #{@id_in_backend}, #{@machine_opts})").formats(Bluebox::BLB::Formats::LB_MACHINE) do
Fog::Bluebox[:blb].update_lb_backend_machine(@lb_backends.first['id'], @id_in_backend, @machine_opts).body
end
tests("remove_machine_from_lb_backend(#{@default_backend['id']}, #{@id_in_backend})").formats(Bluebox::BLB::Formats::REMOVE_MACHINE_FROM_BACKEND) do
Fog::Bluebox[:blb].remove_machine_from_lb_backend(@default_backend['id'], @id_in_backend).body
end
tests("add_machine_to_lb_backend(#{@default_backend['id']}, #{@block_id})").formats(Bluebox::BLB::Formats::ADD_MACHINE_TO_LB) do
Fog::Bluebox[:blb].add_machine_to_lb_backend(@default_backend['id'], @block_id).body
end
Fog::Compute[:bluebox].destroy_block(@block_id).body
end
tests('failure') do
tests('get_lb_application').raises(Fog::Compute::Bluebox::NotFound) do
Fog::Bluebox[:blb].get_lb_application('00000000-0000-0000-0000-000000000000')
end
tests('get_lb_service').raises(Fog::Compute::Bluebox::NotFound) do
Fog::Bluebox[:blb].get_lb_service('00000000-0000-0000-0000-000000000000','00000000-0000-0000-0000-000000000000')
end
tests('get_lb_backend').raises(Fog::Compute::Bluebox::NotFound) do
Fog::Bluebox[:blb].get_lb_backend('00000000-0000-0000-0000-000000000000','00000000-0000-0000-0000-000000000000')
end
end
end