[compute|glesys] added tests
This commit is contained in:
parent
0c63450e90
commit
483fde41a9
|
@ -0,0 +1,203 @@
|
|||
class Glesys
|
||||
module Compute
|
||||
module Formats
|
||||
module Servers
|
||||
|
||||
LIST = {
|
||||
'arguments' => [],
|
||||
'servers' => [{
|
||||
'serverid' => String,
|
||||
'hostname' => String
|
||||
}],
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
CREATE = {
|
||||
'arguments' => {
|
||||
"rootpw" => String,
|
||||
"disksize" => String,
|
||||
"memorysize" => String,
|
||||
"datacenter" => String,
|
||||
"cpucores" => String,
|
||||
"transfer" => String,
|
||||
"template" => String,
|
||||
"description" => String,
|
||||
"hostname" => String,
|
||||
"platform" => String
|
||||
},
|
||||
'server' => {
|
||||
'serverid' => String,
|
||||
'hostname' => String,
|
||||
'iplist' => [{
|
||||
'cost' => String,
|
||||
'version' => String,
|
||||
'ip' => String
|
||||
}]
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
DESTROY = {
|
||||
'arguments' => {
|
||||
'serverid' => String,
|
||||
'keepip' => String,
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
DETAILS = {
|
||||
'arguments' => {
|
||||
'serverid' => String
|
||||
},
|
||||
'server' => {
|
||||
'managedhosting' => String,
|
||||
'cost' => {
|
||||
'amount' => Float,
|
||||
'timeperiod' => String,
|
||||
'currency' => String
|
||||
},
|
||||
'datacenter' => String,
|
||||
'memory' => String,
|
||||
'cpucores' => String,
|
||||
'transfer' => String,
|
||||
'template' => String,
|
||||
'iplist' => [{
|
||||
'cost' => String,
|
||||
'version' => String,
|
||||
'ip' => String
|
||||
}],
|
||||
'description' => String,
|
||||
'hostname' => String,
|
||||
'disk' => String,
|
||||
'platform' => String
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
STATUS = {
|
||||
'arguments' => {
|
||||
'serverid' => String
|
||||
},
|
||||
'server' => {
|
||||
'memory' => String,
|
||||
'bandwidth' => {
|
||||
'last30days' => Integer,
|
||||
'today' => Integer,
|
||||
'max' => String
|
||||
},
|
||||
'cpu' => String,
|
||||
'disk' => String,
|
||||
'state' => String
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
START_STOP = {
|
||||
'arguments' => {
|
||||
'serverid' => String
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
end
|
||||
module Ips
|
||||
|
||||
IPLIST = {
|
||||
'arguments' => [],
|
||||
'iplist' => [{
|
||||
'price' => {
|
||||
'amount' => String,
|
||||
'timeperiod' => String,
|
||||
'currency' => String
|
||||
},
|
||||
'datacenter' => String,
|
||||
'serverid' => Fog::Nullable::String,
|
||||
'platform' => String,
|
||||
'ip' => String,
|
||||
'version' => String,
|
||||
}],
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
IPLIST_ALL = {
|
||||
'arguments' => {
|
||||
'datacenter' => String,
|
||||
'ipversion' => String,
|
||||
'platform' => String
|
||||
},
|
||||
'iplist' => [],
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
},
|
||||
'ipinfo' => {
|
||||
'datacenter' => String,
|
||||
'ipversion' => Integer,
|
||||
'platform' => String
|
||||
}
|
||||
}
|
||||
|
||||
IPLIST_CATCH_RELEASE = {
|
||||
'arguments' => {
|
||||
'ipaddress' => String,
|
||||
'ipversion'=> String,
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
module Templates
|
||||
|
||||
LIST = {
|
||||
'arguments' => [],
|
||||
'templates' => {
|
||||
'Xen' => [{
|
||||
'name' => String,
|
||||
'os' => String,
|
||||
'min_mem_size' => String,
|
||||
'min_disk_size' => String,
|
||||
'platform' => String
|
||||
}],
|
||||
'OpenVZ' => [{
|
||||
'name' => String,
|
||||
'os' => String,
|
||||
'min_mem_size' => String,
|
||||
'min_disk_size' => String,
|
||||
'platform' => String
|
||||
}]
|
||||
},
|
||||
'status' => {
|
||||
'code' => String,
|
||||
'text' => String
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,67 @@
|
|||
Shindo.tests('Fog::Compute[:Glesys] | ip requests', ['glesys']) do
|
||||
|
||||
@free_ip = nil
|
||||
@ips = nil
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#ip_list_own()").formats(Glesys::Compute::Formats::Ips::IPLIST) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:Glesys].ip_list_own.body['response']
|
||||
end
|
||||
|
||||
tests("#ip_list_free(:datcenter => 'Falkenberg, :platform => 'Xen', :ipversion => 4)"
|
||||
).formats(Glesys::Compute::Formats::Ips::IPLIST_ALL) do
|
||||
pending if Fog.mocking?
|
||||
ips = Fog::Compute[:Glesys].ip_list_free(
|
||||
:datacenter => "Falkenberg",
|
||||
:platform => "Xen",
|
||||
:ipversion => 4
|
||||
)
|
||||
@free_ip = ips.body['response']['iplist'].first
|
||||
ips.body['response']
|
||||
end
|
||||
|
||||
tests("#ip_take(:datacenter => 'Falkenberg', :platform => 'Xen', :ipversion => 4, :ipaddress => #{@free_ip})"
|
||||
).formats(Glesys::Compute::Formats::Ips::IPLIST_CATCH_RELEASE) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:Glesys].ip_take(
|
||||
:datacenter => "Falkenberg",
|
||||
:platform => "Xen",
|
||||
:ipversion => 4,
|
||||
:ipaddress => @free_ip
|
||||
).body['response']
|
||||
end
|
||||
|
||||
tests("#ip_release(:ipaddress => '#{@free_ip}', :ipversion => 4)"
|
||||
).formats(Glesys::Compute::Formats::Ips::IPLIST_CATCH_RELEASE) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:Glesys].ip_release(
|
||||
:ipaddress => @free_ip,
|
||||
:ipversion => 4
|
||||
).body['response']
|
||||
end
|
||||
|
||||
# ip_details()
|
||||
# ip_add()
|
||||
# ip_remove()
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#ip_take_argument_error()").raises(Excon::Errors::HTTPStatusError) do
|
||||
pending if Fog.mocking?
|
||||
ip = Fog::Compute[:Glesys].ips.new(
|
||||
:datacenter => "Falkenberg",
|
||||
:platform => "Xen",
|
||||
:version => 4,
|
||||
:ip => "127.0.0.1"
|
||||
)
|
||||
ip.take
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,87 @@
|
|||
Shindo.tests('Fog::Compute[:Glesys] | server requests', ['glesys']) do
|
||||
|
||||
@serverid = nil
|
||||
@hostname = "fog.#{Time.now.to_i}"
|
||||
|
||||
@create = ":hostname => #@hostname, :rootpw => 'pw#{Time.now.to_i}', "+
|
||||
":datacenter => 'Falkenberg', :platform => 'Xen', :template => 'Debian-6 x64', "+
|
||||
":disksize => '10', :memorysize => '512', :cpucores => '1', :transfer => '500'"
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#list_servers()").formats(Glesys::Compute::Formats::Servers::LIST) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:Glesys].list_servers.body['response']
|
||||
end
|
||||
|
||||
tests("#create(#{@create})").formats(Glesys::Compute::Formats::Servers::CREATE) do
|
||||
pending if Fog.mocking?
|
||||
vm = Fog::Compute[:Glesys].create(
|
||||
:hostname => @hostname,
|
||||
:rootpw => "pw#{Time.now.to_i}",
|
||||
:datacenter => "Falkenberg",
|
||||
:platform => "Xen",
|
||||
:template => "Debian-6 x64",
|
||||
:disksize => "10",
|
||||
:memorysize => "512",
|
||||
:cpucores => "1",
|
||||
:transfer => "500"
|
||||
)
|
||||
|
||||
@serverid = vm.body['response']['server']['serverid']
|
||||
vm.body['response']
|
||||
end
|
||||
|
||||
unless Fog.mocking?
|
||||
Fog::Compute[:Glesys].servers.get(@serverid).wait_for { ready? }
|
||||
end
|
||||
|
||||
tests("#server_details(#{@serverid})").formats(Glesys::Compute::Formats::Servers::DETAILS) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:Glesys].server_details(@serverid).body['response']
|
||||
end
|
||||
|
||||
tests("#server_status(#{@serverid})").formats(Glesys::Compute::Formats::Servers::STATUS) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:Glesys].server_status(@serverid).body['response']
|
||||
end
|
||||
|
||||
tests("#stop(:serverid => #{@serverid})").formats(Glesys::Compute::Formats::Servers::START_STOP) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:Glesys].stop(:serverid => @serverid).body['response']
|
||||
end
|
||||
|
||||
# Wait for stopped
|
||||
unless Fog.mocking?
|
||||
pending if Fog.mocking?
|
||||
s = Fog::Compute[:Glesys].servers.get(@serverid)
|
||||
s.wait_for { s.state == 'stopped' }
|
||||
end
|
||||
|
||||
tests("#start(:serverid => #{@serverid})").formats(Glesys::Compute::Formats::Servers::START_STOP) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:Glesys].start(:serverid => @serverid).body['response']
|
||||
end
|
||||
|
||||
# Wait for started
|
||||
unless Fog.mocking?
|
||||
Fog::Compute[:Glesys].servers.get(@serverid).wait_for { ready? }
|
||||
end
|
||||
|
||||
tests("#destroy(:serverid => #{@serverid})").formats(Glesys::Compute::Formats::Servers::DESTROY) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:Glesys].destroy(:serverid => @serverid).body['response']
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#create(:hostname => 0)").raises(Excon::Errors::HTTPStatusError) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:Glesys].create(:hostname => 0)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
Shindo.tests('Fog::Compute[:Glesys] | template requests', ['glesys']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#template_list()").formats(Glesys::Compute::Formats::Templates::LIST) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:Glesys].template_list.body['response']
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue