mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge branch 'bb_test_enhancements'
This commit is contained in:
commit
f203e99fb1
17 changed files with 286 additions and 143 deletions
|
@ -85,6 +85,7 @@ module Fog
|
|||
request :remove_nodes_load_balancer
|
||||
request :remove_servers_server_group
|
||||
request :reset_ftp_password_account
|
||||
request :reset_secret_api_client
|
||||
request :resize_server
|
||||
request :shutdown_server
|
||||
request :snapshot_server
|
||||
|
|
|
@ -23,9 +23,17 @@ module Fog
|
|||
attribute :server_id, :aliases => "server", :squash => "id"
|
||||
attribute :load_balancer, :alias => "load_balancer", :squash => "id"
|
||||
|
||||
def map(interface_to_map)
|
||||
def map(destination)
|
||||
requires :identity
|
||||
connection.map_cloud_ip(identity, :interface => interface_to_map)
|
||||
case destination
|
||||
when Fog::Compute::Brightbox::Server
|
||||
final_destination = destination.interfaces.first["id"]
|
||||
when Fog::Compute::Brightbox::LoadBalancer
|
||||
final_destination = destination.id
|
||||
else
|
||||
final_destination = destination
|
||||
end
|
||||
connection.map_cloud_ip(identity, :destination => final_destination)
|
||||
end
|
||||
|
||||
def mapped?
|
||||
|
|
|
@ -36,7 +36,7 @@ module Fog
|
|||
attribute :server_type
|
||||
|
||||
def initialize(attributes={})
|
||||
self.image_id ||= 'img-2ab98' # Ubuntu Lucid 10.04 server (i686)
|
||||
self.image_id ||= 'img-4gqhs' # Ubuntu Lucid 10.04 server (i686)
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -108,11 +108,19 @@ module Fog
|
|||
end
|
||||
|
||||
def private_ip_address
|
||||
interfaces.first
|
||||
unless interfaces.empty?
|
||||
interfaces.first["ipv4_address"]
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def public_ip_address
|
||||
cloud_ips.first
|
||||
unless cloud_ips.empty?
|
||||
cloud_ips.first["public_ip"]
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def ready?
|
||||
|
|
|
@ -18,6 +18,8 @@ module Fog
|
|||
attribute :default
|
||||
attribute :created_at, :type => :time
|
||||
|
||||
attribute :server_ids, :aliases => "servers"
|
||||
|
||||
def save
|
||||
options = {
|
||||
:name => name,
|
||||
|
@ -28,6 +30,13 @@ module Fog
|
|||
true
|
||||
end
|
||||
|
||||
def servers
|
||||
srv_ids = server_ids.collect {|srv| srv["id"]}
|
||||
srv_ids.collect do |srv_id|
|
||||
connection.servers.get(srv_id)
|
||||
end
|
||||
end
|
||||
|
||||
# Adds specified servers to this server group
|
||||
#
|
||||
# @param [Array] identifiers array of server identifier strings to add
|
||||
|
|
|
@ -2,20 +2,25 @@ Shindo.tests('Fog::Compute[:brightbox] | account requests', ['brightbox']) do
|
|||
|
||||
tests('success') do
|
||||
|
||||
tests("#get_account").formats(Brightbox::Compute::Formats::Full::ACCOUNT) do
|
||||
tests("#get_account") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].get_account
|
||||
result = Fog::Compute[:brightbox].get_account
|
||||
formats(Brightbox::Compute::Formats::Full::ACCOUNT) { result }
|
||||
test("ftp password is blanked") { result["library_ftp_password"].nil? }
|
||||
end
|
||||
|
||||
update_options = {:name => "Fog@#{Time.now.iso8601}"}
|
||||
tests("#update_account(#{update_options.inspect})").formats(Brightbox::Compute::Formats::Full::ACCOUNT) do
|
||||
tests("#update_account(#{update_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].update_account(update_options)
|
||||
result = Fog::Compute[:brightbox].update_account(update_options)
|
||||
formats(Brightbox::Compute::Formats::Full::ACCOUNT) { result }
|
||||
end
|
||||
|
||||
tests("#reset_ftp_password_account").formats(Brightbox::Compute::Formats::Full::ACCOUNT) do
|
||||
tests("#reset_ftp_password_account") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].reset_ftp_password_account
|
||||
result = Fog::Compute[:brightbox].reset_ftp_password_account
|
||||
formats(Brightbox::Compute::Formats::Full::ACCOUNT) { result }
|
||||
test("new ftp password is visible") { ! result["library_ftp_password"].nil? }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -7,32 +7,43 @@ Shindo.tests('Fog::Compute[:brightbox] | api client requests', ['brightbox']) do
|
|||
:description => "Description from Fog test"
|
||||
}
|
||||
|
||||
tests("#create_api_client(#{create_options.inspect})").formats(Brightbox::Compute::Formats::Full::API_CLIENT) do
|
||||
tests("#create_api_client(#{create_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
data = Fog::Compute[:brightbox].create_api_client(create_options)
|
||||
@api_client_id = data["id"]
|
||||
data
|
||||
result = Fog::Compute[:brightbox].create_api_client(create_options)
|
||||
@api_client_id = result["id"]
|
||||
formats(Brightbox::Compute::Formats::Full::API_CLIENT) { result }
|
||||
end
|
||||
|
||||
tests("#list_api_clients").formats(Brightbox::Compute::Formats::Collection::API_CLIENTS) do
|
||||
tests("#list_api_clients") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].list_api_clients
|
||||
result = Fog::Compute[:brightbox].list_api_clients
|
||||
formats(Brightbox::Compute::Formats::Collection::API_CLIENTS) { result }
|
||||
end
|
||||
|
||||
tests("#get_api_client('#{@api_client_id}')").formats(Brightbox::Compute::Formats::Full::API_CLIENT) do
|
||||
tests("#get_api_client('#{@api_client_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].get_api_client(@api_client_id)
|
||||
result = Fog::Compute[:brightbox].get_api_client(@api_client_id)
|
||||
formats(Brightbox::Compute::Formats::Full::API_CLIENT) { result }
|
||||
end
|
||||
|
||||
update_options = {:name => "Fog@#{Time.now.iso8601}"}
|
||||
tests("#update_api_client('#{@api_client_id}')").formats(Brightbox::Compute::Formats::Full::API_CLIENT) do
|
||||
tests("#update_api_client('#{@api_client_id}', #{update_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].update_api_client(@api_client_id, update_options)
|
||||
result = Fog::Compute[:brightbox].update_api_client(@api_client_id, update_options)
|
||||
formats(Brightbox::Compute::Formats::Full::API_CLIENT) { result }
|
||||
end
|
||||
|
||||
tests("#destroy_api_client('#{@api_client_id}')").formats(Brightbox::Compute::Formats::Full::API_CLIENT) do
|
||||
tests("#reset_secret_api_client('#{@api_client_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].destroy_api_client(@api_client_id)
|
||||
result = Fog::Compute[:brightbox].reset_secret_api_client(@api_client_id)
|
||||
formats(Brightbox::Compute::Formats::Full::API_CLIENT) { result }
|
||||
test("new secret is visible") { ! result["secret"].nil? }
|
||||
end
|
||||
|
||||
tests("#destroy_api_client('#{@api_client_id}')") do
|
||||
pending if Fog.mocking?
|
||||
result = Fog::Compute[:brightbox].destroy_api_client(@api_client_id)
|
||||
formats(Brightbox::Compute::Formats::Full::API_CLIENT) { result }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3,48 +3,57 @@ Shindo.tests('Fog::Compute[:brightbox] | cloud ip requests', ['brightbox']) do
|
|||
tests('success') do
|
||||
|
||||
unless Fog.mocking?
|
||||
@server = Fog::Compute[:brightbox].servers.create(compute_providers[:brightbox][:server_attributes])
|
||||
@server = Brightbox::Compute::TestSupport.get_test_server
|
||||
end
|
||||
|
||||
tests("#create_cloud_ip").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
|
||||
tests("#create_cloud_ip") do
|
||||
pending if Fog.mocking?
|
||||
data = Fog::Compute[:brightbox].create_cloud_ip
|
||||
@cloud_ip_id = data["id"]
|
||||
data
|
||||
result = Fog::Compute[:brightbox].create_cloud_ip
|
||||
@cloud_ip_id = result["id"]
|
||||
formats(Brightbox::Compute::Formats::Full::CLOUD_IP) { result }
|
||||
end
|
||||
|
||||
tests("#list_cloud_ips").formats(Brightbox::Compute::Formats::Collection::CLOUD_IPS) do
|
||||
tests("#list_cloud_ips") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].list_cloud_ips
|
||||
result = Fog::Compute[:brightbox].list_cloud_ips
|
||||
formats(Brightbox::Compute::Formats::Collection::CLOUD_IPS) { result }
|
||||
end
|
||||
|
||||
tests("#get_cloud_ip('#{@cloud_ip_id}')").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
|
||||
tests("#get_cloud_ip('#{@cloud_ip_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].get_cloud_ip(@cloud_ip_id)
|
||||
result = Fog::Compute[:brightbox].get_cloud_ip(@cloud_ip_id)
|
||||
formats(Brightbox::Compute::Formats::Full::CLOUD_IP) { result }
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
@server.wait_for { ready? }
|
||||
map_options = {:interface => @server.interfaces.first["id"]}
|
||||
end
|
||||
|
||||
tests("#map_cloud_ip('#{@cloud_ip_id}', #{map_options.inspect})").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
|
||||
map_options = {:destination => @server.interfaces.first["id"]}
|
||||
tests("#map_cloud_ip('#{@cloud_ip_id}', #{map_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].map_cloud_ip(@cloud_ip_id, map_options)
|
||||
result = Fog::Compute[:brightbox].map_cloud_ip(@cloud_ip_id, map_options)
|
||||
formats(Brightbox::Compute::Formats::Full::CLOUD_IP) { result }
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
Fog::Compute[:brightbox].cloud_ips.get(@cloud_ip_id).wait_for { mapped? }
|
||||
end
|
||||
|
||||
tests("#unmap_cloud_ip('#{@cloud_ip_id}')").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
|
||||
tests("#unmap_cloud_ip('#{@cloud_ip_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].unmap_cloud_ip(@cloud_ip_id)
|
||||
result = Fog::Compute[:brightbox].unmap_cloud_ip(@cloud_ip_id)
|
||||
formats(Brightbox::Compute::Formats::Full::CLOUD_IP) { result }
|
||||
end
|
||||
|
||||
tests("#destroy_cloud_ip('#{@cloud_ip_id}')").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
|
||||
update_options = {:reverse_dns => "public.#{@server.id}.gb1.brightbox.com"}
|
||||
tests("#update_cloud_ip('#{@cloud_ip_id}', #{update_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].destroy_cloud_ip(@cloud_ip_id)
|
||||
result = Fog::Compute[:brightbox].update_cloud_ip(@cloud_ip_id, update_options)
|
||||
formats(Brightbox::Compute::Formats::Full::CLOUD_IP) { result }
|
||||
result = Fog::Compute[:brightbox].update_cloud_ip(@cloud_ip_id, {:reverse_dns => ""})
|
||||
end
|
||||
|
||||
tests("#destroy_cloud_ip('#{@cloud_ip_id}')") do
|
||||
pending if Fog.mocking?
|
||||
result = Fog::Compute[:brightbox].destroy_cloud_ip(@cloud_ip_id)
|
||||
formats(Brightbox::Compute::Formats::Full::CLOUD_IP) { result }
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
|
|
|
@ -32,7 +32,28 @@ NilClass.send :include, Fog::Brightbox::Nullable::Zone
|
|||
class Brightbox
|
||||
module Compute
|
||||
module TestSupport
|
||||
IMAGE_IDENTIFER = "img-2ab98" # Ubuntu Lucid 10.04 server (i686)
|
||||
# Find a suitable image for testing with
|
||||
# For speed of server building we're using an empty image
|
||||
def self.image_id
|
||||
return @image_id unless @image_id.nil?
|
||||
images = Fog::Compute[:brightbox].list_images
|
||||
raise "No available images!" if images.empty?
|
||||
image = images.select {|img| img.size == 0 }.first
|
||||
image = images.first if image.nil?
|
||||
@image_id = image["id"]
|
||||
end
|
||||
|
||||
# Prepare a test server, wait for it to be usable but raise if it fails
|
||||
def self.get_test_server
|
||||
test_server_options = {:image_id => image_id}
|
||||
server = Fog::Compute[:brightbox].servers.create(test_server_options)
|
||||
server.wait_for {
|
||||
raise "Test server failed to build" if state == "failed"
|
||||
ready?
|
||||
}
|
||||
server
|
||||
end
|
||||
|
||||
end
|
||||
module Formats
|
||||
module Struct
|
||||
|
|
|
@ -7,35 +7,38 @@ Shindo.tests('Fog::Compute[:brightbox] | image requests', ['brightbox']) do
|
|||
# "arch" => "i686",
|
||||
# "source" => "fnord"
|
||||
# }
|
||||
# tests("#create_image(#{creation_options.inspect})").formats(Brightbox::Compute::Formats::Full::IMAGE) do
|
||||
# data = Fog::Compute[:brightbox].create_image(creation_options)
|
||||
# @image_id = data["id"]
|
||||
# data
|
||||
# tests("#create_image(#{creation_options.inspect})")
|
||||
# result = Fog::Compute[:brightbox].create_image(creation_options)
|
||||
# @image_id = result["id"]
|
||||
# formats(Brightbox::Compute::Formats::Full::IMAGE) { result }
|
||||
# end
|
||||
|
||||
# Fog::Compute[:brightbox].images.get(@image_id).wait_for { ready? }
|
||||
|
||||
tests("#list_images").formats(Brightbox::Compute::Formats::Collection::IMAGES) do
|
||||
tests("#list_images") do
|
||||
pending if Fog.mocking?
|
||||
data = Fog::Compute[:brightbox].list_images
|
||||
@image_id = data.first["id"]
|
||||
data
|
||||
result = Fog::Compute[:brightbox].list_images
|
||||
@image_id = result.first["id"]
|
||||
formats(Brightbox::Compute::Formats::Collection::IMAGES) { result }
|
||||
end
|
||||
|
||||
tests("#get_image('#{@image_id}')").formats(Brightbox::Compute::Formats::Full::IMAGE) do
|
||||
tests("#get_image('#{@image_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].get_image(@image_id)
|
||||
result = Fog::Compute[:brightbox].get_image(@image_id)
|
||||
formats(Brightbox::Compute::Formats::Full::IMAGE) { result }
|
||||
end
|
||||
|
||||
## Until Image creation can be automated, we shouldn't be updating Images randomly
|
||||
# update_options = {}
|
||||
# tests("#update_image('#{@image_id}', #{update_options.inspect})").formats(Brightbox::Compute::Formats::Full::IMAGE) do
|
||||
# Fog::Compute[:brightbox].update_image(@image_id, :name => "New name from Fog test")
|
||||
# tests("#update_image('#{@image_id}', #{update_options.inspect})") do
|
||||
# result = Fog::Compute[:brightbox].update_image(@image_id, :name => "New name from Fog test")
|
||||
# formats(Brightbox::Compute::Formats::Full::IMAGE) { result }
|
||||
# end
|
||||
|
||||
## Same as other tests - can't be deleting them unless part of the test run
|
||||
# tests("#destroy_server('#{@image_id}')").formats(Brightbox::Compute::Formats::Full::IMAGE) do
|
||||
# Fog::Compute[:brightbox].destroy_image(@image_id)
|
||||
# tests("#destroy_server('#{@image_id}')") do
|
||||
# result = Fog::Compute[:brightbox].destroy_image(@image_id)
|
||||
# formats(Brightbox::Compute::Formats::Full::IMAGE) { result }
|
||||
# end
|
||||
|
||||
end
|
||||
|
|
|
@ -7,9 +7,10 @@ Shindo.tests('Fog::Compute[:brightbox] | interface requests', ['brightbox']) do
|
|||
@interface_id = server.interfaces.first["id"]
|
||||
end
|
||||
|
||||
tests("#get_interface('#{@interface_id}')").formats(Brightbox::Compute::Formats::Full::INTERFACE) do
|
||||
tests("#get_interface('#{@interface_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].get_interface(@interface_id)
|
||||
result = Fog::Compute[:brightbox].get_interface(@interface_id)
|
||||
formats(Brightbox::Compute::Formats::Full::INTERFACE) { result }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ Shindo.tests('Fog::Compute[:brightbox] | load balancer requests', ['brightbox'])
|
|||
tests('success') do
|
||||
|
||||
unless Fog.mocking?
|
||||
@node = Fog::Compute[:brightbox].servers.create(:image_id => Brightbox::Compute::TestSupport::IMAGE_IDENTIFER)
|
||||
@node = Brightbox::Compute::TestSupport.get_test_server
|
||||
node_id = @node.id
|
||||
end
|
||||
|
||||
|
@ -22,34 +22,80 @@ Shindo.tests('Fog::Compute[:brightbox] | load balancer requests', ['brightbox'])
|
|||
}
|
||||
}
|
||||
|
||||
tests("#create_load_balancer(#{create_options.inspect})").formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) do
|
||||
tests("#create_load_balancer(#{create_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
data = Fog::Compute[:brightbox].create_load_balancer(create_options)
|
||||
@load_balancer_id = data["id"]
|
||||
data
|
||||
result = Fog::Compute[:brightbox].create_load_balancer(create_options)
|
||||
@load_balancer_id = result["id"]
|
||||
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) { result }
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
Fog::Compute[:brightbox].load_balancers.get(@load_balancer_id).wait_for { ready? }
|
||||
end
|
||||
|
||||
tests("#list_load_balancers()").formats(Brightbox::Compute::Formats::Collection::LOAD_BALANCERS) do
|
||||
tests("#list_load_balancers()") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].list_load_balancers
|
||||
result = Fog::Compute[:brightbox].list_load_balancers
|
||||
formats(Brightbox::Compute::Formats::Collection::LOAD_BALANCERS) { result }
|
||||
end
|
||||
|
||||
tests("#get_load_balancer('#{@load_balancer_id}')").formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) do
|
||||
tests("#get_load_balancer('#{@load_balancer_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].get_load_balancer(@load_balancer_id)
|
||||
result = Fog::Compute[:brightbox].get_load_balancer(@load_balancer_id)
|
||||
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) { result }
|
||||
end
|
||||
|
||||
tests("#destroy_load_balancer('#{@load_balancer_id}')").formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) do
|
||||
update_options = {:name => "New name"}
|
||||
tests("#update_load_balancer('#{@load_balancer_id}', #{update_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].destroy_load_balancer(@load_balancer_id)
|
||||
result = Fog::Compute[:brightbox].update_load_balancer(@load_balancer_id, update_options)
|
||||
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) { result }
|
||||
end
|
||||
|
||||
add_listeners_options = {:listeners=>[{:out=>28080, :in=>8080, :protocol=>"http"}]}
|
||||
tests("#add_listeners_load_balancer('#{@load_balancer_id}', #{add_listeners_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
result = Fog::Compute[:brightbox].add_listeners_load_balancer(@load_balancer_id, add_listeners_options)
|
||||
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) { result }
|
||||
end
|
||||
|
||||
remove_listeners_options = {:listeners=>[{:out=>28080, :in=>8080, :protocol=>"http"}]}
|
||||
tests("#remove_listeners_load_balancer('#{@load_balancer_id}', #{remove_listeners_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
result = Fog::Compute[:brightbox].remove_listeners_load_balancer(@load_balancer_id, remove_listeners_options)
|
||||
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) { result }
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
@node2 = Brightbox::Compute::TestSupport.get_test_server
|
||||
second_node_id = @node2.id
|
||||
end
|
||||
|
||||
# Can't remove the last node so we need to add a second...
|
||||
add_nodes_options = {:nodes => [{:node => second_node_id}]}
|
||||
tests("#add_nodes_load_balancer('#{@load_balancer_id}', #{add_nodes_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
result = Fog::Compute[:brightbox].add_nodes_load_balancer(@load_balancer_id, add_nodes_options)
|
||||
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) { result }
|
||||
end
|
||||
|
||||
# ...before we can attempt to remove either
|
||||
remove_nodes_options = {:nodes => [{:node => node_id}]}
|
||||
tests("#remove_nodes_load_balancer('#{@load_balancer_id}', #{remove_nodes_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
result = Fog::Compute[:brightbox].remove_nodes_load_balancer(@load_balancer_id, remove_nodes_options)
|
||||
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) { result }
|
||||
end
|
||||
|
||||
tests("#destroy_load_balancer('#{@load_balancer_id}')") do
|
||||
pending if Fog.mocking?
|
||||
result = Fog::Compute[:brightbox].destroy_load_balancer(@load_balancer_id)
|
||||
formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) { result }
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
@node.destroy
|
||||
@node2.destroy
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ Shindo.tests('Fog::Compute[:brightbox] | server group requests', ['brightbox'])
|
|||
tests('success') do
|
||||
|
||||
unless Fog.mocking?
|
||||
@server = Fog::Compute[:brightbox].servers.create(:image_id => Brightbox::Compute::TestSupport::IMAGE_IDENTIFER)
|
||||
@server = Brightbox::Compute::TestSupport.get_test_server
|
||||
server_id = @server.id
|
||||
end
|
||||
|
||||
|
@ -14,55 +14,62 @@ Shindo.tests('Fog::Compute[:brightbox] | server group requests', ['brightbox'])
|
|||
}]
|
||||
}
|
||||
|
||||
tests("#create_server_group(#{create_options.inspect})").formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) do
|
||||
tests("#create_server_group(#{create_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
data = Fog::Compute[:brightbox].create_server_group(create_options)
|
||||
@server_group_id = data["id"]
|
||||
data
|
||||
result = Fog::Compute[:brightbox].create_server_group(create_options)
|
||||
@server_group_id = result["id"]
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
|
||||
end
|
||||
|
||||
tests("#list_server_groups").formats(Brightbox::Compute::Formats::Collection::SERVER_GROUPS) do
|
||||
tests("#list_server_groups") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].list_server_groups
|
||||
result = Fog::Compute[:brightbox].list_server_groups
|
||||
formats(Brightbox::Compute::Formats::Collection::SERVER_GROUPS) { result }
|
||||
@default_group_id = result.select {|grp| grp["default"] == true }.first["id"]
|
||||
end
|
||||
|
||||
tests("#get_server_group('#{@server_group_id}')").formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) do
|
||||
tests("#get_server_group('#{@server_group_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].get_server_group(@server_group_id)
|
||||
result = Fog::Compute[:brightbox].get_server_group(@server_group_id)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
|
||||
end
|
||||
|
||||
update_options = {:name => "Fog@#{Time.now.iso8601}"}
|
||||
tests("#update_server_group(#{update_options.inspect})").formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) do
|
||||
tests("#update_server_group('#{@server_group_id}', #{update_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].update_server_group(@server_group_id, update_options)
|
||||
result = Fog::Compute[:brightbox].update_server_group(@server_group_id, update_options)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
|
||||
end
|
||||
|
||||
remove_options = {:servers => [{:server => server_id}]}
|
||||
tests("#remove_servers_server_group(#{remove_options.inspect})").formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) do
|
||||
tests("#remove_servers_server_group('#{@server_group_id}', #{remove_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].remove_servers_server_group(@server_group_id, remove_options)
|
||||
result = Fog::Compute[:brightbox].remove_servers_server_group(@server_group_id, remove_options)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
|
||||
end
|
||||
|
||||
add_options = {:servers => [{:server => server_id}]}
|
||||
tests("#add_servers_server_group(#{remove_options.inspect})").formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) do
|
||||
tests("#add_servers_server_group('#{@server_group_id}', #{remove_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].add_servers_server_group(@server_group_id, add_options)
|
||||
result = Fog::Compute[:brightbox].add_servers_server_group(@server_group_id, add_options)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
|
||||
end
|
||||
|
||||
# Server Group must be empty to delete so we need to remove it again
|
||||
remove_options = {:servers => [{:server => server_id}]}
|
||||
tests("#remove_servers_server_group(#{remove_options.inspect})").formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) do
|
||||
move_options = {:destination => @default_group_id, :servers => [{:server => server_id}]}
|
||||
tests("#move_servers_server_group('#{@server_group_id}', #{move_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].remove_servers_server_group(@server_group_id, remove_options)
|
||||
result = Fog::Compute[:brightbox].move_servers_server_group(@server_group_id, move_options)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
|
||||
test("group is emptied") { result["servers"].empty? }
|
||||
end
|
||||
|
||||
tests("#destroy_server_group('#{@server_group_id}')").formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) do
|
||||
tests("#destroy_server_group('#{@server_group_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].destroy_server_group(@server_group_id)
|
||||
result = Fog::Compute[:brightbox].destroy_server_group(@server_group_id)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER_GROUP) { result }
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
@server.wait_for { ready? }
|
||||
@server.destroy
|
||||
end
|
||||
|
||||
|
|
|
@ -2,58 +2,75 @@ Shindo.tests('Fog::Compute[:brightbox] | server requests', ['brightbox']) do
|
|||
|
||||
tests('success') do
|
||||
|
||||
image_id = Brightbox::Compute::TestSupport::IMAGE_IDENTIFER
|
||||
image_id = Brightbox::Compute::TestSupport.image_id
|
||||
server_id = nil
|
||||
|
||||
tests("#create_server(:image => '#{image_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
tests("#create_server(:image => '#{image_id}')") do
|
||||
pending if Fog.mocking?
|
||||
data = Fog::Compute[:brightbox].create_server(:image => image_id)
|
||||
server_id = data["id"]
|
||||
data
|
||||
result = Fog::Compute[:brightbox].create_server(:image => image_id)
|
||||
server_id = result["id"]
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER) { result }
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
Fog::Compute[:brightbox].servers.get(server_id).wait_for { ready? }
|
||||
end
|
||||
|
||||
tests("#list_servers").formats(Brightbox::Compute::Formats::Collection::SERVERS) do
|
||||
tests("#list_servers") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].list_servers
|
||||
result = Fog::Compute[:brightbox].list_servers
|
||||
formats(Brightbox::Compute::Formats::Collection::SERVERS) { result }
|
||||
end
|
||||
|
||||
tests("#get_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
tests("#get_server('#{server_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].get_server(server_id)
|
||||
result = Fog::Compute[:brightbox].get_server(server_id)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER) { result }
|
||||
end
|
||||
|
||||
tests("#update_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
tests("#update_server('#{server_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].update_server(server_id, :name => "Fog@#{Time.now.iso8601}")
|
||||
result = Fog::Compute[:brightbox].update_server(server_id, :name => "Fog@#{Time.now.iso8601}")
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER) { result }
|
||||
end
|
||||
|
||||
tests("#activate_console_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
tests("#activate_console_server('#{server_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].activate_console_server(server_id)
|
||||
result = Fog::Compute[:brightbox].activate_console_server(server_id)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER) { result }
|
||||
end
|
||||
|
||||
tests("#stop_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
tests("#stop_server('#{server_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].stop_server(server_id)
|
||||
result = Fog::Compute[:brightbox].stop_server(server_id)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER) { result }
|
||||
end
|
||||
|
||||
tests("#start_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
tests("#start_server('#{server_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].start_server(server_id)
|
||||
result = Fog::Compute[:brightbox].start_server(server_id)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER) { result }
|
||||
end
|
||||
|
||||
tests("#shutdown_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
tests("#shutdown_server('#{server_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].shutdown_server(server_id)
|
||||
result = Fog::Compute[:brightbox].shutdown_server(server_id)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER) { result }
|
||||
end
|
||||
|
||||
tests("#destroy_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
tests("#snapshot_server('#{server_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].destroy_server(server_id)
|
||||
result = Fog::Compute[:brightbox].snapshot_server(server_id)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER) { result }
|
||||
snapshot_id = result["id"]
|
||||
@snapshot = Fog::Compute[:brightbox].images.get(snapshot_id)
|
||||
@snapshot.destroy
|
||||
end
|
||||
|
||||
tests("#destroy_server('#{server_id}')") do
|
||||
pending if Fog.mocking?
|
||||
result = Fog::Compute[:brightbox].destroy_server(server_id)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER) { result }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,16 +2,17 @@ Shindo.tests('Fog::Compute[:brightbox] | server type requests', ['brightbox']) d
|
|||
|
||||
tests('success') do
|
||||
|
||||
tests("#list_server_types").formats(Brightbox::Compute::Formats::Collection::SERVER_TYPES) do
|
||||
tests("#list_server_types") do
|
||||
pending if Fog.mocking?
|
||||
data = Fog::Compute[:brightbox].list_server_types
|
||||
@server_type_id = data.first["id"]
|
||||
data
|
||||
result = Fog::Compute[:brightbox].list_server_types
|
||||
@server_type_id = result.first["id"]
|
||||
formats(Brightbox::Compute::Formats::Collection::SERVER_TYPES) { result }
|
||||
end
|
||||
|
||||
tests("#get_server_type('#{@server_type_id}')").formats(Brightbox::Compute::Formats::Full::SERVER_TYPE) do
|
||||
tests("#get_server_type('#{@server_type_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].get_server_type(@server_type_id)
|
||||
result = Fog::Compute[:brightbox].get_server_type(@server_type_id)
|
||||
formats(Brightbox::Compute::Formats::Full::SERVER_TYPE) { result }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,29 +2,24 @@ Shindo.tests('Fog::Compute[:brightbox] | user requests', ['brightbox']) do
|
|||
|
||||
tests('success') do
|
||||
|
||||
tests("#list_users").formats(Brightbox::Compute::Formats::Collection::USERS) do
|
||||
tests("#list_users") do
|
||||
pending if Fog.mocking?
|
||||
data = Fog::Compute[:brightbox].list_users
|
||||
@user_id = data.first["id"]
|
||||
data
|
||||
result = Fog::Compute[:brightbox].list_users
|
||||
@user_id = result.first["id"]
|
||||
formats(Brightbox::Compute::Formats::Collection::USERS) { result }
|
||||
end
|
||||
|
||||
tests("#get_user('#{@user_id}')").formats(Brightbox::Compute::Formats::Full::USER) do
|
||||
tests("#get_user('#{@user_id}')") do
|
||||
pending if Fog.mocking?
|
||||
data = Fog::Compute[:brightbox].get_user(@user_id)
|
||||
@original_name = data["name"]
|
||||
data
|
||||
result = Fog::Compute[:brightbox].get_user(@user_id)
|
||||
formats(Brightbox::Compute::Formats::Full::USER) { result }
|
||||
end
|
||||
|
||||
update_options = { :name => "Fog@#{Time.now.iso8601}" }
|
||||
|
||||
tests("#update_user('#{@user_id}', #{update_options.inspect})").formats(Brightbox::Compute::Formats::Full::USER) do
|
||||
update_options = { :name => "Example User" }
|
||||
tests("#update_user('#{@user_id}', #{update_options.inspect})") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].update_user(@user_id, update_options)
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
Fog::Compute[:brightbox].update_user(@user_id, :name => @original_name)
|
||||
result = Fog::Compute[:brightbox].update_user(@user_id, update_options)
|
||||
formats(Brightbox::Compute::Formats::Full::USER) { result }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,16 +2,17 @@ Shindo.tests('Fog::Compute[:brightbox] | zone requests', ['brightbox']) do
|
|||
|
||||
tests('success') do
|
||||
|
||||
tests("#list_zones").formats(Brightbox::Compute::Formats::Collection::ZONES) do
|
||||
tests("#list_zones") do
|
||||
pending if Fog.mocking?
|
||||
data = Fog::Compute[:brightbox].list_zones
|
||||
@zone_id = data.first["id"]
|
||||
data
|
||||
result = Fog::Compute[:brightbox].list_zones
|
||||
@zone_id = result.first["id"]
|
||||
formats(Brightbox::Compute::Formats::Collection::ZONES) { result }
|
||||
end
|
||||
|
||||
tests("#get_zone('#{@zone_id}')").formats(Brightbox::Compute::Formats::Full::ZONE) do
|
||||
tests("#get_zone('#{@zone_id}')") do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:brightbox].get_zone(@zone_id)
|
||||
result = Fog::Compute[:brightbox].get_zone(@zone_id)
|
||||
formats(Brightbox::Compute::Formats::Full::ZONE) { result }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ def compute_providers
|
|||
},
|
||||
:brightbox => {
|
||||
:server_attributes => {
|
||||
:image_id => 'img-2ab98' # Ubuntu Lucid 10.04 server (i686)
|
||||
:image_id => 'img-4gqhs' # Ubuntu Lucid 10.04 server (i686)
|
||||
},
|
||||
:mocked => false
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue