1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/serverlove/requests/compute/server_tests.rb

86 lines
3.1 KiB
Ruby
Raw Normal View History

2012-07-06 08:56:46 -04:00
Shindo.tests('Fog::Compute[:serverlove] | server requests', ['serverlove']) do
2012-07-15 06:24:36 -04:00
@server_format = {
'server' => String,
'name' => String,
'user' => String,
'status' => String,
'started' => Fog::Nullable::String,
2012-07-15 06:24:36 -04:00
'cpu' => Integer,
'mem' => Integer,
'smp' => Fog::Nullable::String,
2012-07-15 06:24:36 -04:00
'persistent' => Fog::Nullable::String,
'vnc' => Fog::Nullable::String,
2012-07-15 12:04:33 -04:00
'vnc:password' => Fog::Nullable::String,
'nic:0:dhcp' => String,
'nic:0:model' => String
2012-07-15 06:24:36 -04:00
}
2012-07-06 08:56:46 -04:00
tests('success') do
2012-07-15 06:24:36 -04:00
attributes = { 'name' => 'Test', 'cpu' => '1000', 'mem' => '1000', 'persistent' => 'true' }
2012-07-15 06:24:36 -04:00
tests("#create_server").formats(@server_format) do
2012-07-15 12:04:33 -04:00
@server = Fog::Compute[:serverlove].create_server(Fog::Compute::Serverlove::Server.defaults.merge(attributes)).body
2012-07-15 06:24:36 -04:00
end
2012-07-06 08:56:46 -04:00
tests("#list_servers").succeeds do
Fog::Compute[:serverlove].servers
end
2012-07-15 06:24:36 -04:00
tests("#update_server").returns(true) do
@server['name'] = "Diff"
Fog::Compute[:serverlove].update_server(@server['server'], { :name => @server['name']})
2012-07-15 06:24:36 -04:00
Fog::Compute[:serverlove].servers.get(@server['server']).name == "Diff"
end
tests("assigns drive to server").succeeds do
@image = Fog::Compute[:serverlove].create_image('name' => 'Test', 'size' => '24234567890').body
# Load debian
Fog::Compute[:serverlove].load_standard_image(@image['drive'], 'aca2fa0b-40bc-4e06-ad99-f1467690d5de')
Fog::Compute[:serverlove].update_server(@server['server'], { 'ide:0:0' => @image['drive'], 'boot' => 'ide:0:0'})
end
2012-07-16 15:30:03 -04:00
tests("waits for imaging...").returns(true) do
while(percent_complete = Fog::Compute[:serverlove].images.get(@image['drive']).imaging)
sleep(1)
STDERR.print "#{percent_complete} "
break if percent_complete.include?("100")
end
STDERR.print "100% "
true
end
tests("#start_server").returns(true) do
Fog::Compute[:serverlove].start_server(@server['server'])
Fog::Compute[:serverlove].servers.get(@server['server']).status == "active"
end
tests("#reset_server").returns(true) do
Fog::Compute[:serverlove].reset_server(@server['server'])
Fog::Compute[:serverlove].servers.get(@server['server']).status == "active"
end
tests("#shutdown_server").succeeds do
Fog::Compute[:serverlove].shutdown_server(@server['server'])
# Can't guarantee the OS will honour this command so don't test status
end
tests("#stop_server").returns(true) do
Fog::Compute[:serverlove].start_server(@server['server'])
Fog::Compute[:serverlove].stop_server(@server['server'])
Fog::Compute[:serverlove].servers.get(@server['server']).status == "stopped"
end
2012-07-15 06:24:36 -04:00
tests("#destroy_server").succeeds do
Fog::Compute[:serverlove].destroy_server(@server['server'])
end
tests("destroy test drive").succeeds do
Fog::Compute[:serverlove].destroy_image(@image['drive'])
end
2012-07-06 08:56:46 -04:00
end
end