From e073fcffb4528e5995692ab8697ed1806f6d017d Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Fri, 30 Sep 2011 09:56:05 +0100 Subject: [PATCH 01/13] [brightbox] Corrected deprecated argument --- tests/brightbox/requests/compute/cloud_ip_tests.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/brightbox/requests/compute/cloud_ip_tests.rb b/tests/brightbox/requests/compute/cloud_ip_tests.rb index 02d044f53..ca883784c 100644 --- a/tests/brightbox/requests/compute/cloud_ip_tests.rb +++ b/tests/brightbox/requests/compute/cloud_ip_tests.rb @@ -25,7 +25,7 @@ Shindo.tests('Fog::Compute[:brightbox] | cloud ip requests', ['brightbox']) do unless Fog.mocking? @server.wait_for { ready? } - map_options = {:interface => @server.interfaces.first["id"]} + map_options = {:destination => @server.interfaces.first["id"]} end tests("#map_cloud_ip('#{@cloud_ip_id}', #{map_options.inspect})").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do From 75f53bd6a98be277ffc174d3c2ed9c550505588a Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Fri, 30 Sep 2011 11:42:06 +0100 Subject: [PATCH 02/13] [brightbox] Dynamically select testing image --- tests/brightbox/requests/compute/helper.rb | 12 +++++++++++- .../requests/compute/load_balancer_tests.rb | 2 +- .../brightbox/requests/compute/server_group_tests.rb | 2 +- tests/brightbox/requests/compute/server_tests.rb | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/brightbox/requests/compute/helper.rb b/tests/brightbox/requests/compute/helper.rb index c9e90ef44..5350d003e 100644 --- a/tests/brightbox/requests/compute/helper.rb +++ b/tests/brightbox/requests/compute/helper.rb @@ -32,7 +32,17 @@ 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 + end module Formats module Struct diff --git a/tests/brightbox/requests/compute/load_balancer_tests.rb b/tests/brightbox/requests/compute/load_balancer_tests.rb index 84b0668c6..77cbf73bf 100644 --- a/tests/brightbox/requests/compute/load_balancer_tests.rb +++ b/tests/brightbox/requests/compute/load_balancer_tests.rb @@ -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 = Fog::Compute[:brightbox].servers.create(:image_id => Brightbox::Compute::TestSupport.image_id) node_id = @node.id end diff --git a/tests/brightbox/requests/compute/server_group_tests.rb b/tests/brightbox/requests/compute/server_group_tests.rb index 1e38f2b51..7b2c19efa 100644 --- a/tests/brightbox/requests/compute/server_group_tests.rb +++ b/tests/brightbox/requests/compute/server_group_tests.rb @@ -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 = Fog::Compute[:brightbox].servers.create(:image_id => Brightbox::Compute::TestSupport.image_id) server_id = @server.id end diff --git a/tests/brightbox/requests/compute/server_tests.rb b/tests/brightbox/requests/compute/server_tests.rb index 33f0beec9..8b73ab368 100644 --- a/tests/brightbox/requests/compute/server_tests.rb +++ b/tests/brightbox/requests/compute/server_tests.rb @@ -2,7 +2,7 @@ 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 From 5fe0d6c57f1307aa4e7afba57e5e58e1fb35fa88 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Fri, 30 Sep 2011 11:42:12 +0100 Subject: [PATCH 03/13] [brightbox] Helper to get a test server ready * Standard timeout * Errors if reported as failed by API --- tests/brightbox/requests/compute/cloud_ip_tests.rb | 8 ++------ tests/brightbox/requests/compute/helper.rb | 11 +++++++++++ .../brightbox/requests/compute/load_balancer_tests.rb | 2 +- .../brightbox/requests/compute/server_group_tests.rb | 3 +-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/brightbox/requests/compute/cloud_ip_tests.rb b/tests/brightbox/requests/compute/cloud_ip_tests.rb index ca883784c..12bbfb506 100644 --- a/tests/brightbox/requests/compute/cloud_ip_tests.rb +++ b/tests/brightbox/requests/compute/cloud_ip_tests.rb @@ -3,7 +3,7 @@ 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 @@ -23,11 +23,7 @@ Shindo.tests('Fog::Compute[:brightbox] | cloud ip requests', ['brightbox']) do Fog::Compute[:brightbox].get_cloud_ip(@cloud_ip_id) end - unless Fog.mocking? - @server.wait_for { ready? } - map_options = {:destination => @server.interfaces.first["id"]} - end - + map_options = {:destination => @server.interfaces.first["id"]} tests("#map_cloud_ip('#{@cloud_ip_id}', #{map_options.inspect})").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do pending if Fog.mocking? Fog::Compute[:brightbox].map_cloud_ip(@cloud_ip_id, map_options) diff --git a/tests/brightbox/requests/compute/helper.rb b/tests/brightbox/requests/compute/helper.rb index 5350d003e..77de25107 100644 --- a/tests/brightbox/requests/compute/helper.rb +++ b/tests/brightbox/requests/compute/helper.rb @@ -43,6 +43,17 @@ class Brightbox @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 diff --git a/tests/brightbox/requests/compute/load_balancer_tests.rb b/tests/brightbox/requests/compute/load_balancer_tests.rb index 77cbf73bf..588c52c29 100644 --- a/tests/brightbox/requests/compute/load_balancer_tests.rb +++ b/tests/brightbox/requests/compute/load_balancer_tests.rb @@ -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_id) + @node = Brightbox::Compute::TestSupport.get_test_server node_id = @node.id end diff --git a/tests/brightbox/requests/compute/server_group_tests.rb b/tests/brightbox/requests/compute/server_group_tests.rb index 7b2c19efa..77a2b3b10 100644 --- a/tests/brightbox/requests/compute/server_group_tests.rb +++ b/tests/brightbox/requests/compute/server_group_tests.rb @@ -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_id) + @server = Brightbox::Compute::TestSupport.get_test_server server_id = @server.id end @@ -62,7 +62,6 @@ Shindo.tests('Fog::Compute[:brightbox] | server group requests', ['brightbox']) end unless Fog.mocking? - @server.wait_for { ready? } @server.destroy end From e418c6540e059235ed1cb0ee3ad5b47cb4a183eb Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Thu, 29 Sep 2011 10:15:03 +0100 Subject: [PATCH 04/13] [brightbox] Revised tests structure --- .../requests/compute/account_tests.rb | 17 ++++--- .../requests/compute/api_client_tests.rb | 28 ++++++----- .../requests/compute/cloud_ip_tests.rb | 33 +++++++------ .../brightbox/requests/compute/image_tests.rb | 31 ++++++------ .../requests/compute/interface_tests.rb | 5 +- .../requests/compute/load_balancer_tests.rb | 23 +++++---- .../requests/compute/server_group_tests.rb | 43 ++++++++++------- .../requests/compute/server_tests.rb | 48 +++++++++++-------- .../requests/compute/server_type_tests.rb | 13 ++--- .../brightbox/requests/compute/user_tests.rb | 27 +++++------ .../brightbox/requests/compute/zone_tests.rb | 13 ++--- 11 files changed, 157 insertions(+), 124 deletions(-) diff --git a/tests/brightbox/requests/compute/account_tests.rb b/tests/brightbox/requests/compute/account_tests.rb index 83cdd7d83..2fb16dac1 100644 --- a/tests/brightbox/requests/compute/account_tests.rb +++ b/tests/brightbox/requests/compute/account_tests.rb @@ -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 diff --git a/tests/brightbox/requests/compute/api_client_tests.rb b/tests/brightbox/requests/compute/api_client_tests.rb index 039a5aea4..cebeab1d4 100644 --- a/tests/brightbox/requests/compute/api_client_tests.rb +++ b/tests/brightbox/requests/compute/api_client_tests.rb @@ -7,32 +7,36 @@ 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("#destroy_api_client('#{@api_client_id}')") do pending if Fog.mocking? - Fog::Compute[:brightbox].destroy_api_client(@api_client_id) + result = Fog::Compute[:brightbox].destroy_api_client(@api_client_id) + formats(Brightbox::Compute::Formats::Full::API_CLIENT) { result } end end diff --git a/tests/brightbox/requests/compute/cloud_ip_tests.rb b/tests/brightbox/requests/compute/cloud_ip_tests.rb index 12bbfb506..8af9460a2 100644 --- a/tests/brightbox/requests/compute/cloud_ip_tests.rb +++ b/tests/brightbox/requests/compute/cloud_ip_tests.rb @@ -6,41 +6,46 @@ Shindo.tests('Fog::Compute[:brightbox] | cloud ip requests', ['brightbox']) do @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 map_options = {:destination => @server.interfaces.first["id"]} - tests("#map_cloud_ip('#{@cloud_ip_id}', #{map_options.inspect})").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do + 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 + tests("#destroy_cloud_ip('#{@cloud_ip_id}')") do pending if Fog.mocking? - Fog::Compute[:brightbox].destroy_cloud_ip(@cloud_ip_id) + result = Fog::Compute[:brightbox].destroy_cloud_ip(@cloud_ip_id) + formats(Brightbox::Compute::Formats::Full::CLOUD_IP) { result } end unless Fog.mocking? diff --git a/tests/brightbox/requests/compute/image_tests.rb b/tests/brightbox/requests/compute/image_tests.rb index 8ddf3b31c..820185535 100644 --- a/tests/brightbox/requests/compute/image_tests.rb +++ b/tests/brightbox/requests/compute/image_tests.rb @@ -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 diff --git a/tests/brightbox/requests/compute/interface_tests.rb b/tests/brightbox/requests/compute/interface_tests.rb index bd05a3dd4..ce4828f9a 100644 --- a/tests/brightbox/requests/compute/interface_tests.rb +++ b/tests/brightbox/requests/compute/interface_tests.rb @@ -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 diff --git a/tests/brightbox/requests/compute/load_balancer_tests.rb b/tests/brightbox/requests/compute/load_balancer_tests.rb index 588c52c29..a0d436aa8 100644 --- a/tests/brightbox/requests/compute/load_balancer_tests.rb +++ b/tests/brightbox/requests/compute/load_balancer_tests.rb @@ -22,30 +22,33 @@ 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 + tests("#destroy_load_balancer('#{@load_balancer_id}')") do pending if Fog.mocking? - Fog::Compute[:brightbox].destroy_load_balancer(@load_balancer_id) + result = Fog::Compute[:brightbox].destroy_load_balancer(@load_balancer_id) + formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) { result } end unless Fog.mocking? diff --git a/tests/brightbox/requests/compute/server_group_tests.rb b/tests/brightbox/requests/compute/server_group_tests.rb index 77a2b3b10..fbda73265 100644 --- a/tests/brightbox/requests/compute/server_group_tests.rb +++ b/tests/brightbox/requests/compute/server_group_tests.rb @@ -14,51 +14,58 @@ 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 } 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 + 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 - 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? diff --git a/tests/brightbox/requests/compute/server_tests.rb b/tests/brightbox/requests/compute/server_tests.rb index 8b73ab368..6da7444e1 100644 --- a/tests/brightbox/requests/compute/server_tests.rb +++ b/tests/brightbox/requests/compute/server_tests.rb @@ -5,55 +5,63 @@ Shindo.tests('Fog::Compute[:brightbox] | server requests', ['brightbox']) do 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("#destroy_server('#{server_id}')") do pending if Fog.mocking? - Fog::Compute[:brightbox].destroy_server(server_id) + result = Fog::Compute[:brightbox].destroy_server(server_id) + formats(Brightbox::Compute::Formats::Full::SERVER) { result } end end diff --git a/tests/brightbox/requests/compute/server_type_tests.rb b/tests/brightbox/requests/compute/server_type_tests.rb index aa9cf41f1..4a27b9d5d 100644 --- a/tests/brightbox/requests/compute/server_type_tests.rb +++ b/tests/brightbox/requests/compute/server_type_tests.rb @@ -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 diff --git a/tests/brightbox/requests/compute/user_tests.rb b/tests/brightbox/requests/compute/user_tests.rb index ef22af5c2..e894a2ec8 100644 --- a/tests/brightbox/requests/compute/user_tests.rb +++ b/tests/brightbox/requests/compute/user_tests.rb @@ -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 diff --git a/tests/brightbox/requests/compute/zone_tests.rb b/tests/brightbox/requests/compute/zone_tests.rb index 26a31cfbb..c682bcc04 100644 --- a/tests/brightbox/requests/compute/zone_tests.rb +++ b/tests/brightbox/requests/compute/zone_tests.rb @@ -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 From 254123791bec961ecd48a494c029ddaf28d0ffd9 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Thu, 29 Sep 2011 10:17:00 +0100 Subject: [PATCH 05/13] [brightbox] Test and fix for API client secret reset * Wasn't loaded although code in place * Test format and check output isn't nil --- lib/fog/brightbox/compute.rb | 1 + tests/brightbox/requests/compute/api_client_tests.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/fog/brightbox/compute.rb b/lib/fog/brightbox/compute.rb index 66a4b83f4..5a9d26981 100644 --- a/lib/fog/brightbox/compute.rb +++ b/lib/fog/brightbox/compute.rb @@ -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 diff --git a/tests/brightbox/requests/compute/api_client_tests.rb b/tests/brightbox/requests/compute/api_client_tests.rb index cebeab1d4..8b9e43e30 100644 --- a/tests/brightbox/requests/compute/api_client_tests.rb +++ b/tests/brightbox/requests/compute/api_client_tests.rb @@ -33,6 +33,13 @@ Shindo.tests('Fog::Compute[:brightbox] | api client requests', ['brightbox']) do formats(Brightbox::Compute::Formats::Full::API_CLIENT) { result } end + tests("#reset_secret_api_client('#{@api_client_id}')") do + pending if Fog.mocking? + 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) From 3ce68e47d188cf69fd2bbdbfdb0f73f370caa879 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Thu, 29 Sep 2011 13:09:11 +0100 Subject: [PATCH 06/13] [brightbox] Test update of reverse DNS for CIP --- tests/brightbox/requests/compute/cloud_ip_tests.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/brightbox/requests/compute/cloud_ip_tests.rb b/tests/brightbox/requests/compute/cloud_ip_tests.rb index 8af9460a2..96e68ee1c 100644 --- a/tests/brightbox/requests/compute/cloud_ip_tests.rb +++ b/tests/brightbox/requests/compute/cloud_ip_tests.rb @@ -42,6 +42,14 @@ Shindo.tests('Fog::Compute[:brightbox] | cloud ip requests', ['brightbox']) do formats(Brightbox::Compute::Formats::Full::CLOUD_IP) { result } end + 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? + 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) From 6fb4247c0707dbc755ab44f8e646898e80c51cd1 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Fri, 30 Sep 2011 15:06:22 +0100 Subject: [PATCH 07/13] [brightbox] Updated default Ubuntu image --- lib/fog/brightbox/models/compute/server.rb | 2 +- tests/compute/helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fog/brightbox/models/compute/server.rb b/lib/fog/brightbox/models/compute/server.rb index 2ba860386..febbc56e7 100644 --- a/lib/fog/brightbox/models/compute/server.rb +++ b/lib/fog/brightbox/models/compute/server.rb @@ -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 diff --git a/tests/compute/helper.rb b/tests/compute/helper.rb index eb48c7c7e..53b8f69a8 100644 --- a/tests/compute/helper.rb +++ b/tests/compute/helper.rb @@ -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 }, From bea5bfe80a69f10cbe2d24b60275b399f38dae8d Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Fri, 30 Sep 2011 16:15:23 +0100 Subject: [PATCH 08/13] [brightbox] Make Cloud IP model's map nicer to use * API accepts a load balancer or interface ID * Model accepts a Server and figures out a suitable interface --- lib/fog/brightbox/models/compute/cloud_ip.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/fog/brightbox/models/compute/cloud_ip.rb b/lib/fog/brightbox/models/compute/cloud_ip.rb index 0636f1e19..dbcea802b 100644 --- a/lib/fog/brightbox/models/compute/cloud_ip.rb +++ b/lib/fog/brightbox/models/compute/cloud_ip.rb @@ -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? From 4577a80010b88884aa4a15b4a665a654d8a52718 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Fri, 30 Sep 2011 17:50:31 +0100 Subject: [PATCH 09/13] [brightbox] Correctly get Server's IP addresses as strings --- lib/fog/brightbox/models/compute/server.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/fog/brightbox/models/compute/server.rb b/lib/fog/brightbox/models/compute/server.rb index febbc56e7..25914ba44 100644 --- a/lib/fog/brightbox/models/compute/server.rb +++ b/lib/fog/brightbox/models/compute/server.rb @@ -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? From e7af149bb77d760b1ce1942b87e6184a6fb5077c Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Fri, 30 Sep 2011 17:51:30 +0100 Subject: [PATCH 10/13] [brightbox] ServerGroup association to Servers --- lib/fog/brightbox/models/compute/server_group.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/fog/brightbox/models/compute/server_group.rb b/lib/fog/brightbox/models/compute/server_group.rb index 0d7ad9471..9a0626bf6 100644 --- a/lib/fog/brightbox/models/compute/server_group.rb +++ b/lib/fog/brightbox/models/compute/server_group.rb @@ -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 From 0971fdc2cde7b978947f55f2e9c5a618e266eab8 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Fri, 30 Sep 2011 17:52:13 +0100 Subject: [PATCH 11/13] [brightbox] Replace duplicate remove with move test * Still leaves group empty to allow deletion --- tests/brightbox/requests/compute/server_group_tests.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/brightbox/requests/compute/server_group_tests.rb b/tests/brightbox/requests/compute/server_group_tests.rb index fbda73265..156af3f7c 100644 --- a/tests/brightbox/requests/compute/server_group_tests.rb +++ b/tests/brightbox/requests/compute/server_group_tests.rb @@ -25,6 +25,7 @@ Shindo.tests('Fog::Compute[:brightbox] | server group requests', ['brightbox']) pending if Fog.mocking? 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}')") do @@ -54,12 +55,12 @@ Shindo.tests('Fog::Compute[:brightbox] | server group requests', ['brightbox']) 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('#{@server_group_id}', #{remove_options.inspect})") 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? - result = 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}')") do From d7fa80f7022c4e0169818bb87a0f22539bc03dee Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Mon, 3 Oct 2011 11:49:07 +0100 Subject: [PATCH 12/13] [brightbox] Load balancer request tests expanded --- .../requests/compute/load_balancer_tests.rb | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/brightbox/requests/compute/load_balancer_tests.rb b/tests/brightbox/requests/compute/load_balancer_tests.rb index a0d436aa8..9a7bea617 100644 --- a/tests/brightbox/requests/compute/load_balancer_tests.rb +++ b/tests/brightbox/requests/compute/load_balancer_tests.rb @@ -45,6 +45,48 @@ Shindo.tests('Fog::Compute[:brightbox] | load balancer requests', ['brightbox']) formats(Brightbox::Compute::Formats::Full::LOAD_BALANCER) { result } end + update_options = {:name => "New name"} + tests("#update_load_balancer('#{@load_balancer_id}', #{update_options.inspect})") do + pending if Fog.mocking? + 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) @@ -53,6 +95,7 @@ Shindo.tests('Fog::Compute[:brightbox] | load balancer requests', ['brightbox']) unless Fog.mocking? @node.destroy + @node2.destroy end end From 1bb1c049a0bdab2b60f59ff83d4998cce96ccd6a Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Mon, 3 Oct 2011 13:18:56 +0100 Subject: [PATCH 13/13] [brightbox] Request test for snapshotting a server --- tests/brightbox/requests/compute/server_tests.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/brightbox/requests/compute/server_tests.rb b/tests/brightbox/requests/compute/server_tests.rb index 6da7444e1..bc6cb76e0 100644 --- a/tests/brightbox/requests/compute/server_tests.rb +++ b/tests/brightbox/requests/compute/server_tests.rb @@ -58,6 +58,15 @@ Shindo.tests('Fog::Compute[:brightbox] | server requests', ['brightbox']) do formats(Brightbox::Compute::Formats::Full::SERVER) { result } end + tests("#snapshot_server('#{server_id}')") do + pending if Fog.mocking? + 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)