mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge branch 'request_tests' into gh-master
This commit is contained in:
commit
9d4dcb0084
14 changed files with 723 additions and 4 deletions
|
@ -26,6 +26,10 @@ module Fog
|
|||
connection.map_cloud_ip(identity, :interface => interface_to_map)
|
||||
end
|
||||
|
||||
def mapped?
|
||||
status == "mapped"
|
||||
end
|
||||
|
||||
def unmap
|
||||
requires :identity
|
||||
connection.unmap_cloud_ip(identity)
|
||||
|
|
|
@ -26,6 +26,10 @@ module Fog
|
|||
attribute :disk_size
|
||||
attribute :created_at
|
||||
|
||||
def ready?
|
||||
status == "available"
|
||||
end
|
||||
|
||||
def save
|
||||
requires :source, :arch
|
||||
options = {
|
||||
|
|
|
@ -0,0 +1,370 @@
|
|||
module Fog
|
||||
module Brightbox
|
||||
module Nullable
|
||||
module String; end
|
||||
module Account; end
|
||||
module Image; end
|
||||
module Interface; end
|
||||
module Server; end
|
||||
module Zone; end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
String.send :include, Fog::Brightbox::Nullable::String
|
||||
NilClass.send :include, Fog::Brightbox::Nullable::String
|
||||
|
||||
Hash.send :include, Fog::Brightbox::Nullable::Account
|
||||
NilClass.send :include, Fog::Brightbox::Nullable::Account
|
||||
|
||||
Hash.send :include, Fog::Brightbox::Nullable::Image
|
||||
NilClass.send :include, Fog::Brightbox::Nullable::Image
|
||||
|
||||
Hash.send :include, Fog::Brightbox::Nullable::Interface
|
||||
NilClass.send :include, Fog::Brightbox::Nullable::Interface
|
||||
|
||||
Hash.send :include, Fog::Brightbox::Nullable::Server
|
||||
NilClass.send :include, Fog::Brightbox::Nullable::Server
|
||||
|
||||
Hash.send :include, Fog::Brightbox::Nullable::Zone
|
||||
NilClass.send :include, Fog::Brightbox::Nullable::Zone
|
||||
|
||||
class Brightbox
|
||||
module Compute
|
||||
module TestSupport
|
||||
# image img-9vxqi = Ubuntu Maverick 10.10 server
|
||||
IMAGE_IDENTIFER = "img-9vxqi"
|
||||
end
|
||||
module Formats
|
||||
module Nested
|
||||
ACCOUNT = {
|
||||
"name" => String,
|
||||
"ram_used" => Integer,
|
||||
"resource_type" => String,
|
||||
"ram_limit" => Integer,
|
||||
"url" => String,
|
||||
"id" => String,
|
||||
"status" => String,
|
||||
"limits_cloudips" => Integer
|
||||
}
|
||||
|
||||
API_CLIENT = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"name" => String,
|
||||
"description" => String
|
||||
}
|
||||
|
||||
CLOUD_IP = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"public_ip" => String,
|
||||
"status" => String,
|
||||
"reverse_dns" => String
|
||||
}
|
||||
|
||||
IMAGE = {
|
||||
"name" => String,
|
||||
"created_at" => String,
|
||||
"resource_type" => String,
|
||||
"arch" => String,
|
||||
"url" => String,
|
||||
"id" => String,
|
||||
"description" => String,
|
||||
"source" => String,
|
||||
"status" => String,
|
||||
"owner" => String
|
||||
}
|
||||
|
||||
INTERFACE = {
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"id" => String,
|
||||
"ipv4_address" => String,
|
||||
"mac_address" => String
|
||||
}
|
||||
|
||||
SERVER = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"name" => String,
|
||||
"status" => String,
|
||||
"hostname" => String,
|
||||
"created_at" => String,
|
||||
"started_at" => Fog::Brightbox::Nullable::String,
|
||||
"deleted_at" => Fog::Brightbox::Nullable::String
|
||||
}
|
||||
|
||||
SERVER_TYPE = {
|
||||
"name" => String,
|
||||
"cores" => Integer,
|
||||
"created_at" => String,
|
||||
"resource_type" => String,
|
||||
"updated_at" => String,
|
||||
"disk_size" => Integer,
|
||||
"default" => Fog::Boolean,
|
||||
"url" => String,
|
||||
"id" => String,
|
||||
"ram" => Integer,
|
||||
"status" => String
|
||||
}
|
||||
|
||||
USER = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"name" => String,
|
||||
"email_address" => String
|
||||
}
|
||||
|
||||
ZONE = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"handle" => Fog::Brightbox::Nullable::String
|
||||
}
|
||||
end
|
||||
|
||||
module Collected
|
||||
API_CLIENT = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"name" => String,
|
||||
"description" => String,
|
||||
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT
|
||||
}
|
||||
|
||||
CLOUD_IP = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"public_ip" => String,
|
||||
"status" => String,
|
||||
"reverse_dns" => String,
|
||||
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
|
||||
"interface" => Fog::Brightbox::Nullable::Interface,
|
||||
"server" => NilClass
|
||||
}
|
||||
|
||||
IMAGE = {
|
||||
"name" => String,
|
||||
"created_at" => String,
|
||||
"resource_type" => String,
|
||||
"arch" => String,
|
||||
"url" => String,
|
||||
"id" => String,
|
||||
"description" => String,
|
||||
"source" => String,
|
||||
"source_type" => String,
|
||||
"status" => String,
|
||||
"owner" => String,
|
||||
"public" => Fog::Boolean,
|
||||
"official" => Fog::Boolean,
|
||||
"compatibility_mode" => Fog::Boolean,
|
||||
"virtual_size" => Integer,
|
||||
"disk_size" => Integer,
|
||||
"ancestor" => Fog::Brightbox::Nullable::Image
|
||||
}
|
||||
|
||||
SERVER = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"name" => String,
|
||||
"status" => String,
|
||||
"hostname" => String,
|
||||
"created_at" => String,
|
||||
"started_at" => Fog::Brightbox::Nullable::String,
|
||||
"deleted_at" => Fog::Brightbox::Nullable::String,
|
||||
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
|
||||
"server_type" => Brightbox::Compute::Formats::Nested::SERVER_TYPE,
|
||||
"cloud_ips" => [Brightbox::Compute::Formats::Nested::CLOUD_IP],
|
||||
"image" => Brightbox::Compute::Formats::Nested::IMAGE,
|
||||
"snapshots" => [Brightbox::Compute::Formats::Nested::IMAGE],
|
||||
"interfaces" => [Brightbox::Compute::Formats::Nested::INTERFACE],
|
||||
"zone" => Fog::Brightbox::Nullable::Zone
|
||||
}
|
||||
|
||||
SERVER_TYPE = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"handle" => Fog::Brightbox::Nullable::String,
|
||||
"name" => String,
|
||||
"status" => String,
|
||||
"cores" => Integer,
|
||||
"ram" => Integer,
|
||||
"disk_size" => Integer
|
||||
}
|
||||
|
||||
USER = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"name" => String,
|
||||
"email_address" => String,
|
||||
"email_verified" => Fog::Boolean,
|
||||
"accounts" => [],
|
||||
"default_account" => NilClass
|
||||
}
|
||||
|
||||
ZONE = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"handle" => Fog::Brightbox::Nullable::String
|
||||
}
|
||||
end
|
||||
|
||||
module Full
|
||||
ACCOUNT = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"name" => String,
|
||||
"status" => String,
|
||||
"address_1" => String,
|
||||
"address_2" => String,
|
||||
"city" => String,
|
||||
"county" => String,
|
||||
"postcode" => String,
|
||||
"country_code" => String,
|
||||
"country_name" => String,
|
||||
"vat_registration_number" => Fog::Brightbox::Nullable::String,
|
||||
"telephone_number" => String,
|
||||
"telephone_verified" => Fog::Boolean,
|
||||
"created_at" => String,
|
||||
"ram_limit" => Integer,
|
||||
"ram_used" => Integer,
|
||||
"limits_cloudips" => Integer,
|
||||
"library_ftp_host" => String,
|
||||
"library_ftp_user" => String,
|
||||
"library_ftp_password" => Fog::Brightbox::Nullable::String,
|
||||
"owner" => Brightbox::Compute::Formats::Nested::USER,
|
||||
"users" => [Brightbox::Compute::Formats::Nested::USER],
|
||||
"clients" => [Brightbox::Compute::Formats::Nested::API_CLIENT],
|
||||
"servers" => [Brightbox::Compute::Formats::Nested::SERVER],
|
||||
"images" => [Brightbox::Compute::Formats::Nested::IMAGE],
|
||||
"zones" => [Brightbox::Compute::Formats::Nested::ZONE]
|
||||
}
|
||||
|
||||
API_CLIENT = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"name" => String,
|
||||
"description" => String,
|
||||
"secret" => Fog::Brightbox::Nullable::String,
|
||||
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT
|
||||
}
|
||||
|
||||
CLOUD_IP = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"public_ip" => String,
|
||||
"status" => String,
|
||||
"reverse_dns" => String,
|
||||
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
|
||||
"interface" => Fog::Brightbox::Nullable::Interface,
|
||||
"server" => Fog::Brightbox::Nullable::Server
|
||||
}
|
||||
|
||||
IMAGE = {
|
||||
"name" => String,
|
||||
"created_at" => String,
|
||||
"resource_type" => String,
|
||||
"arch" => String,
|
||||
"url" => String,
|
||||
"id" => String,
|
||||
"description" => String,
|
||||
"source" => String,
|
||||
"source_type" => String,
|
||||
"status" => String,
|
||||
"owner" => String, # Account ID not object
|
||||
"public" => Fog::Boolean,
|
||||
"official" => Fog::Boolean,
|
||||
"compatibility_mode" => Fog::Boolean,
|
||||
"virtual_size" => Integer,
|
||||
"disk_size" => Integer,
|
||||
"ancestor" => Fog::Brightbox::Nullable::Image
|
||||
}
|
||||
|
||||
INTERFACE = {
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"id" => String,
|
||||
"ipv4_address" => String,
|
||||
"mac_address" => String,
|
||||
"server" => Brightbox::Compute::Formats::Nested::SERVER
|
||||
}
|
||||
|
||||
SERVER = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"name" => String,
|
||||
"status" => String,
|
||||
"hostname" => String,
|
||||
"created_at" => String,
|
||||
"started_at" => Fog::Brightbox::Nullable::String,
|
||||
"deleted_at" => Fog::Brightbox::Nullable::String,
|
||||
"user_data" => Fog::Brightbox::Nullable::String,
|
||||
"account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
|
||||
"server_type" => Brightbox::Compute::Formats::Nested::SERVER_TYPE,
|
||||
"cloud_ips" => [Brightbox::Compute::Formats::Nested::CLOUD_IP],
|
||||
"image" => Brightbox::Compute::Formats::Nested::IMAGE,
|
||||
"snapshots" => [Brightbox::Compute::Formats::Nested::IMAGE],
|
||||
"interfaces" => [Brightbox::Compute::Formats::Nested::INTERFACE],
|
||||
"zone" => Brightbox::Compute::Formats::Nested::ZONE
|
||||
}
|
||||
|
||||
SERVER_TYPE = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"handle" => Fog::Brightbox::Nullable::String,
|
||||
"name" => String,
|
||||
"status" => String,
|
||||
"cores" => Integer,
|
||||
"ram" => Integer,
|
||||
"disk_size" => Integer
|
||||
}
|
||||
|
||||
USER = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"name" => String,
|
||||
"email_address" => String,
|
||||
"email_verified" => Fog::Boolean,
|
||||
"accounts" => [Brightbox::Compute::Formats::Nested::ACCOUNT],
|
||||
"default_account" => Fog::Brightbox::Nullable::Account,
|
||||
"ssh_key" => Fog::Brightbox::Nullable::String
|
||||
}
|
||||
|
||||
ZONE = {
|
||||
"id" => String,
|
||||
"resource_type" => String,
|
||||
"url" => String,
|
||||
"handle" => String
|
||||
}
|
||||
end
|
||||
|
||||
module Collection
|
||||
API_CLIENTS = [Brightbox::Compute::Formats::Collected::API_CLIENT]
|
||||
CLOUD_IPS = [Brightbox::Compute::Formats::Collected::CLOUD_IP]
|
||||
IMAGES = [Brightbox::Compute::Formats::Collected::IMAGE]
|
||||
SERVERS = [Brightbox::Compute::Formats::Collected::SERVER]
|
||||
SERVER_TYPES = [Brightbox::Compute::Formats::Collected::SERVER_TYPE]
|
||||
USERS = [Brightbox::Compute::Formats::Collected::USER]
|
||||
ZONES = [Brightbox::Compute::Formats::Collected::ZONE]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
Shindo.tests('Brightbox::Compute | server model', ['brightbox']) do
|
||||
|
||||
# image img-t4p09 = Ubuntu Maverick 10.10 server
|
||||
server_tests(Brightbox[:compute], {:image_id => 'img-t4p09'}, false)
|
||||
image_id = Brightbox::Compute::TestSupport::IMAGE_IDENTIFER
|
||||
server_tests(Brightbox[:compute], {:image_id => image_id}, false)
|
||||
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Shindo.tests('Brightbox::Compute | servers collection', ['brightbox']) do
|
||||
|
||||
# image img-t4p09 = Ubuntu Maverick 10.10 server
|
||||
servers_tests(Brightbox[:compute], {:image_id => 'img-t4p09'}, false)
|
||||
image_id = Brightbox::Compute::TestSupport::IMAGE_IDENTIFER
|
||||
servers_tests(Brightbox[:compute], {:image_id => image_id}, false)
|
||||
|
||||
end
|
||||
|
|
29
tests/brightbox/requests/compute/account_tests.rb
Normal file
29
tests/brightbox/requests/compute/account_tests.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
Shindo.tests('Brightbox::Compute | account requests', ['brightbox']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#get_account()").formats(Brightbox::Compute::Formats::Full::ACCOUNT) do
|
||||
Brightbox[:compute].get_account()
|
||||
end
|
||||
|
||||
original_name = Brightbox[:compute].get_account["name"]
|
||||
update_args = {:name => "New name from Fog test"}
|
||||
tests("#update_account(#{update_args.inspect})").formats(Brightbox::Compute::Formats::Full::ACCOUNT) do
|
||||
Brightbox[:compute].update_account(update_args)
|
||||
end
|
||||
Brightbox[:compute].update_account(:name => original_name)
|
||||
|
||||
tests("#reset_ftp_password_account()").formats(Brightbox::Compute::Formats::Full::ACCOUNT) do
|
||||
Brightbox[:compute].reset_ftp_password_account()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#update_account()").returns(nil) do
|
||||
Brightbox[:compute].update_account()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
41
tests/brightbox/requests/compute/api_client_tests.rb
Normal file
41
tests/brightbox/requests/compute/api_client_tests.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
Shindo.tests('Brightbox::Compute | api client requests', ['brightbox']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
create_options = {:name => "Name from Fog test (#{Time.now.to_i})", :description => "Description from Fog test"}
|
||||
tests("#create_api_client(#{create_options.inspect})").formats(Brightbox::Compute::Formats::Full::API_CLIENT) do
|
||||
data = Brightbox[:compute].create_api_client(create_options)
|
||||
@api_client_id = data["id"]
|
||||
data
|
||||
end
|
||||
|
||||
tests("#list_api_clients()").formats(Brightbox::Compute::Formats::Collection::API_CLIENTS) do
|
||||
Brightbox[:compute].list_api_clients()
|
||||
end
|
||||
|
||||
tests("#get_api_client('#{@api_client_id}')").formats(Brightbox::Compute::Formats::Full::API_CLIENT) do
|
||||
Brightbox[:compute].get_api_client(@api_client_id)
|
||||
end
|
||||
|
||||
tests("#update_api_client('#{@api_client_id}')").formats(Brightbox::Compute::Formats::Full::API_CLIENT) do
|
||||
Brightbox[:compute].update_api_client(@api_client_id, :name => "New name from Fog test")
|
||||
end
|
||||
|
||||
tests("#destroy_api_client('#{@api_client_id}')").formats(Brightbox::Compute::Formats::Full::API_CLIENT) do
|
||||
Brightbox[:compute].destroy_api_client(@api_client_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#get_api_client('cli-00000')").raises(Excon::Errors::NotFound) do
|
||||
Brightbox[:compute].get_api_client('cli-00000')
|
||||
end
|
||||
|
||||
tests("#get_api_client()").raises(ArgumentError) do
|
||||
Brightbox[:compute].get_api_client()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
49
tests/brightbox/requests/compute/cloud_ip_tests.rb
Normal file
49
tests/brightbox/requests/compute/cloud_ip_tests.rb
Normal file
|
@ -0,0 +1,49 @@
|
|||
Shindo.tests('Brightbox::Compute | cloud ip requests', ['brightbox']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#create_cloud_ip()").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
|
||||
data = Brightbox[:compute].create_cloud_ip()
|
||||
@cloud_ip_id = data["id"]
|
||||
data
|
||||
end
|
||||
|
||||
tests("#list_cloud_ips()").formats(Brightbox::Compute::Formats::Collection::CLOUD_IPS) do
|
||||
Brightbox[:compute].list_cloud_ips()
|
||||
end
|
||||
|
||||
tests("#get_cloud_ip('#{@cloud_ip_id}')").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
|
||||
Brightbox[:compute].get_cloud_ip(@cloud_ip_id)
|
||||
end
|
||||
|
||||
server = Brightbox[:compute].servers.first
|
||||
interface_id = server.interfaces.first["id"]
|
||||
map_options = {:interface => interface_id}
|
||||
tests("#map_cloud_ip('#{@cloud_ip_id}', #{map_options.inspect})").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
|
||||
Brightbox[:compute].map_cloud_ip(@cloud_ip_id, map_options)
|
||||
end
|
||||
|
||||
Brightbox[:compute].cloud_ips.get(@cloud_ip_id).wait_for { mapped? }
|
||||
|
||||
tests("#unmap_cloud_ip('#{@cloud_ip_id}')").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
|
||||
Brightbox[:compute].unmap_cloud_ip(@cloud_ip_id)
|
||||
end
|
||||
|
||||
tests("#destroy_cloud_ip('#{@cloud_ip_id}')").formats(Brightbox::Compute::Formats::Full::CLOUD_IP) do
|
||||
Brightbox[:compute].destroy_cloud_ip(@cloud_ip_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#get_cloud_ip('cip-00000')").raises(Excon::Errors::NotFound) do
|
||||
Brightbox[:compute].get_cloud_ip('cip-00000')
|
||||
end
|
||||
|
||||
tests("#get_cloud_ip()").raises(ArgumentError) do
|
||||
Brightbox[:compute].get_cloud_ip()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
52
tests/brightbox/requests/compute/image_tests.rb
Normal file
52
tests/brightbox/requests/compute/image_tests.rb
Normal file
|
@ -0,0 +1,52 @@
|
|||
Shindo.tests('Brightbox::Compute | image requests', ['brightbox']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
## Difficult to test without having uploaded an Image to your account to register
|
||||
# creation_options = {
|
||||
# "arch" => "i686",
|
||||
# "source" => "fnord"
|
||||
# }
|
||||
# tests("#create_image(#{creation_options.inspect})").formats(Brightbox::Compute::Formats::Full::IMAGE) do
|
||||
# data = Brightbox[:compute].create_image(creation_options)
|
||||
# @image_id = data["id"]
|
||||
# data
|
||||
# end
|
||||
|
||||
# Brightbox[:compute].images.get(@image_id).wait_for { ready? }
|
||||
|
||||
tests("#list_images()").formats(Brightbox::Compute::Formats::Collection::IMAGES) do
|
||||
data = Brightbox[:compute].list_images()
|
||||
@image_id = data.first["id"]
|
||||
data
|
||||
end
|
||||
|
||||
tests("#get_image('#{@image_id}')").formats(Brightbox::Compute::Formats::Full::IMAGE) do
|
||||
Brightbox[:compute].get_image(@image_id)
|
||||
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
|
||||
# Brightbox[:compute].update_image(@image_id, :name => "New name from Fog test")
|
||||
# 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
|
||||
# Brightbox[:compute].destroy_image(@image_id)
|
||||
# end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#get_image('img-00000')").raises(Excon::Errors::NotFound) do
|
||||
Brightbox[:compute].get_image('img-00000')
|
||||
end
|
||||
|
||||
tests("#get_image()").raises(ArgumentError) do
|
||||
Brightbox[:compute].get_image()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
24
tests/brightbox/requests/compute/interface_tests.rb
Normal file
24
tests/brightbox/requests/compute/interface_tests.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
Shindo.tests('Brightbox::Compute | interface requests', ['brightbox']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
server = Brightbox[:compute].servers.first
|
||||
@interface_id = server.interfaces.first["id"]
|
||||
tests("#get_interface('#{@interface_id}')").formats(Brightbox::Compute::Formats::Full::INTERFACE) do
|
||||
Brightbox[:compute].get_interface(@interface_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#get_interface('int-00000')").raises(Excon::Errors::Forbidden) do
|
||||
Brightbox[:compute].get_interface('int-00000')
|
||||
end
|
||||
|
||||
tests("#get_interface()").raises(ArgumentError) do
|
||||
Brightbox[:compute].get_interface()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
57
tests/brightbox/requests/compute/server_tests.rb
Normal file
57
tests/brightbox/requests/compute/server_tests.rb
Normal file
|
@ -0,0 +1,57 @@
|
|||
Shindo.tests('Brightbox::Compute | server requests', ['brightbox']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
image_id = Brightbox::Compute::TestSupport::IMAGE_IDENTIFER
|
||||
server_id = nil
|
||||
|
||||
tests("#create_server(:image => '#{image_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
data = Brightbox[:compute].create_server(:image => image_id)
|
||||
server_id = data["id"]
|
||||
data
|
||||
end
|
||||
|
||||
Brightbox[:compute].servers.get(server_id).wait_for { ready? }
|
||||
|
||||
tests("#list_servers()").formats(Brightbox::Compute::Formats::Collection::SERVERS) do
|
||||
Brightbox[:compute].list_servers()
|
||||
end
|
||||
|
||||
tests("#get_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
Brightbox[:compute].get_server(server_id)
|
||||
end
|
||||
|
||||
tests("#update_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
Brightbox[:compute].update_server(server_id, :name => "New name from Fog test")
|
||||
end
|
||||
|
||||
tests("#stop_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
Brightbox[:compute].stop_server(server_id)
|
||||
end
|
||||
|
||||
tests("#start_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
Brightbox[:compute].start_server(server_id)
|
||||
end
|
||||
|
||||
tests("#shutdown_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
Brightbox[:compute].shutdown_server(server_id)
|
||||
end
|
||||
|
||||
tests("#destroy_server('#{server_id}')").formats(Brightbox::Compute::Formats::Full::SERVER) do
|
||||
Brightbox[:compute].destroy_server(server_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#get_server('srv-00000')").raises(Excon::Errors::NotFound) do
|
||||
Brightbox[:compute].get_server('srv-00000')
|
||||
end
|
||||
|
||||
tests("#get_server()").raises(ArgumentError) do
|
||||
Brightbox[:compute].get_server()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
28
tests/brightbox/requests/compute/server_type_tests.rb
Normal file
28
tests/brightbox/requests/compute/server_type_tests.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
Shindo.tests('Brightbox::Compute | server type requests', ['brightbox']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#list_server_types()").formats(Brightbox::Compute::Formats::Collection::SERVER_TYPES) do
|
||||
data = Brightbox[:compute].list_server_types()
|
||||
@server_type_id = data.first["id"]
|
||||
data
|
||||
end
|
||||
|
||||
tests("#get_server_type('#{@server_type_id}')").formats(Brightbox::Compute::Formats::Full::SERVER_TYPE) do
|
||||
Brightbox[:compute].get_server_type(@server_type_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#get_server_type('typ-00000')").raises(Excon::Errors::NotFound) do
|
||||
Brightbox[:compute].get_server_type('typ-00000')
|
||||
end
|
||||
|
||||
tests("#get_server()").raises(ArgumentError) do
|
||||
Brightbox[:compute].get_server_type()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
33
tests/brightbox/requests/compute/user_tests.rb
Normal file
33
tests/brightbox/requests/compute/user_tests.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
Shindo.tests('Brightbox::Compute | user requests', ['brightbox']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#list_users()").formats(Brightbox::Compute::Formats::Collection::USERS) do
|
||||
data = Brightbox[:compute].list_users()
|
||||
@user_id = data.first["id"]
|
||||
data
|
||||
end
|
||||
|
||||
tests("#get_user('#{@user_id}')").formats(Brightbox::Compute::Formats::Full::USER) do
|
||||
data = Brightbox[:compute].get_user(@user_id)
|
||||
@original_name = data["name"]
|
||||
data
|
||||
end
|
||||
|
||||
update_options = { :name => "New name from Fog" }
|
||||
tests("#update_user('#{@user_id}', #{update_options.inspect})").formats(Brightbox::Compute::Formats::Full::USER) do
|
||||
Brightbox[:compute].update_user(@user_id, update_options)
|
||||
end
|
||||
Brightbox[:compute].update_user(@user_id, :name => @original_name)
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#update_user()").raises(ArgumentError) do
|
||||
Brightbox[:compute].update_user()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
28
tests/brightbox/requests/compute/zone_tests.rb
Normal file
28
tests/brightbox/requests/compute/zone_tests.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
Shindo.tests('Brightbox::Compute | zone requests', ['brightbox']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#list_zones()").formats(Brightbox::Compute::Formats::Collection::ZONES) do
|
||||
data = Brightbox[:compute].list_zones()
|
||||
@zone_id = data.first["id"]
|
||||
data
|
||||
end
|
||||
|
||||
tests("#get_zone('#{@zone_id}')").formats(Brightbox::Compute::Formats::Full::ZONE) do
|
||||
Brightbox[:compute].get_zone(@zone_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#get_zone('zon-00000')").raises(Excon::Errors::NotFound) do
|
||||
Brightbox[:compute].get_zone('zon-00000')
|
||||
end
|
||||
|
||||
tests("#get_zone()").raises(ArgumentError) do
|
||||
Brightbox[:compute].get_zone()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue