2011-06-16 19:28:54 -04:00
|
|
|
Shindo.tests('Fog::Compute[:rackspace] | server requests', ['rackspace']) do
|
2010-05-31 11:37:26 -04:00
|
|
|
|
|
|
|
@server_format = {
|
|
|
|
'addresses' => {
|
|
|
|
'private' => [String],
|
|
|
|
'public' => [String]
|
|
|
|
},
|
|
|
|
'flavorId' => Integer,
|
|
|
|
'hostId' => String,
|
|
|
|
'id' => Integer,
|
|
|
|
'imageId' => Integer,
|
|
|
|
'metadata' => {},
|
|
|
|
'name' => String,
|
|
|
|
'progress' => Integer,
|
|
|
|
'status' => String
|
|
|
|
}
|
2012-12-20 15:00:13 -05:00
|
|
|
|
|
|
|
@service = Fog::Compute.new(:provider => :rackspace, :version => :v1)
|
2010-05-31 11:37:26 -04:00
|
|
|
|
|
|
|
tests('success') do
|
|
|
|
|
|
|
|
@server_id = nil
|
|
|
|
|
|
|
|
tests('#create_server(1, 19)').formats(@server_format.merge('adminPass' => String)) do
|
|
|
|
# 1 => 256MB, 19 => Gentoo
|
2012-12-20 15:00:13 -05:00
|
|
|
data = @service.create_server(1, 19).body['server']
|
2010-05-31 11:37:26 -04:00
|
|
|
@server_id = data['id']
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.servers.get(@server_id).wait_for { ready? }
|
2010-05-31 11:37:26 -04:00
|
|
|
|
|
|
|
tests("#get_server_details(#{@server_id})").formats(@server_format) do
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.get_server_details(@server_id).body['server']
|
2010-05-31 11:37:26 -04:00
|
|
|
end
|
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
tests('#list_servers').formats({'servers' => [Rackspace::Compute::Formats::SUMMARY]}) do
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.list_servers.body
|
2010-05-31 11:37:26 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests('#list_servers_detail').formats({'servers' => [@server_format]}) do
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.list_servers_detail.body
|
2010-05-31 11:37:26 -04:00
|
|
|
end
|
|
|
|
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.servers.get(@server_id).wait_for { ready? }
|
2010-10-12 19:01:17 -04:00
|
|
|
|
2010-05-31 11:37:26 -04:00
|
|
|
tests("#update_server(#{@server_id}, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver')").succeeds do
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.update_server(@server_id, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver')
|
2010-05-31 11:37:26 -04:00
|
|
|
end
|
|
|
|
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.servers.get(@server_id).wait_for { ready? }
|
2010-10-12 19:01:17 -04:00
|
|
|
|
2010-05-31 11:37:26 -04:00
|
|
|
tests("#reboot_server(#{@server_id}, 'HARD')").succeeds do
|
2010-10-13 20:54:14 -04:00
|
|
|
pending if Fog.mocking?
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.reboot_server(@server_id, 'HARD')
|
2010-05-31 11:37:26 -04:00
|
|
|
end
|
|
|
|
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.servers.get(@server_id).wait_for { ready? }
|
2010-10-12 19:01:17 -04:00
|
|
|
|
2010-05-31 11:37:26 -04:00
|
|
|
tests("#reboot_server(#{@server_id}, 'SOFT')").succeeds do
|
2010-10-13 20:54:14 -04:00
|
|
|
pending if Fog.mocking?
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.reboot_server(@server_id, 'SOFT')
|
2010-05-31 11:37:26 -04:00
|
|
|
end
|
|
|
|
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.servers.get(@server_id).wait_for { ready? }
|
2010-05-31 11:37:26 -04:00
|
|
|
|
|
|
|
tests("#delete_server(#{@server_id})").succeeds do
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.delete_server(@server_id)
|
2010-05-31 11:37:26 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('failure') do
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests('#delete_server(0)').raises(Fog::Compute::Rackspace::NotFound) do
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.delete_server(0)
|
2010-05-31 11:37:26 -04:00
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests('#get_server_details(0)').raises(Fog::Compute::Rackspace::NotFound) do
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.get_server_details(0)
|
2010-05-31 11:37:26 -04:00
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests("#update_server(0, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver')").raises(Fog::Compute::Rackspace::NotFound) do
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.update_server(0, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver')
|
2010-05-31 11:37:26 -04:00
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests('#reboot_server(0)').raises(Fog::Compute::Rackspace::NotFound) do
|
2010-10-13 20:54:14 -04:00
|
|
|
pending if Fog.mocking?
|
2012-12-20 15:00:13 -05:00
|
|
|
@service.reboot_server(0)
|
2010-05-31 11:37:26 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|