1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/brightbox/requests/compute/server_tests.rb
Paul Thornthwaite 41b0a3e754 [Brightbox] Correct server snapshot test
Had a mistake in it was trying to use the Server's ID for the get image
request and resulted in calling destroy on a nil.

Also had to add a wait since the API does not allow deleting an image
that is being prepared.
2012-02-07 17:14:29 +00:00

96 lines
3.2 KiB
Ruby

Shindo.tests('Fog::Compute[:brightbox] | server requests', ['brightbox']) do
tests('success') do
unless Fog.mocking?
image_id = Brightbox::Compute::TestSupport.image_id
server_id = nil
end
tests("#create_server(:image => '#{image_id}')") do
pending if Fog.mocking?
result = Fog::Compute[:brightbox].create_server(:image => image_id)
server_id = result["id"]
formats(Brightbox::Compute::Formats::Full::SERVER, false) { result }
end
unless Fog.mocking?
Fog::Compute[:brightbox].servers.get(server_id).wait_for { ready? }
end
tests("#list_servers") do
pending if Fog.mocking?
result = Fog::Compute[:brightbox].list_servers
formats(Brightbox::Compute::Formats::Collection::SERVERS, false) { result }
end
tests("#get_server('#{server_id}')") do
pending if Fog.mocking?
result = Fog::Compute[:brightbox].get_server(server_id)
formats(Brightbox::Compute::Formats::Full::SERVER, false) { result }
end
tests("#update_server('#{server_id}')") do
pending if Fog.mocking?
result = Fog::Compute[:brightbox].update_server(server_id, :name => "Fog@#{Time.now.iso8601}")
formats(Brightbox::Compute::Formats::Full::SERVER, false) { result }
end
tests("#activate_console_server('#{server_id}')") do
pending if Fog.mocking?
result = Fog::Compute[:brightbox].activate_console_server(server_id)
formats(Brightbox::Compute::Formats::Full::SERVER, false) { result }
end
tests("#stop_server('#{server_id}')") do
pending if Fog.mocking?
result = Fog::Compute[:brightbox].stop_server(server_id)
formats(Brightbox::Compute::Formats::Full::SERVER, false) { result }
end
tests("#start_server('#{server_id}')") do
pending if Fog.mocking?
result = Fog::Compute[:brightbox].start_server(server_id)
formats(Brightbox::Compute::Formats::Full::SERVER, false) { result }
end
tests("#shutdown_server('#{server_id}')") do
pending if Fog.mocking?
result = Fog::Compute[:brightbox].shutdown_server(server_id)
formats(Brightbox::Compute::Formats::Full::SERVER, false) { 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, false) { result }
# Server should be exclusively for our test so assume we can delete the snapshot
snapshot_id = result["snapshots"].first["id"]
@snapshot = Fog::Compute[:brightbox].images.get(snapshot_id)
@snapshot.wait_for { ready? }
@snapshot.destroy
end
tests("#destroy_server('#{server_id}')") do
pending if Fog.mocking?
result = Fog::Compute[:brightbox].destroy_server(server_id)
formats(Brightbox::Compute::Formats::Full::SERVER, false) { result }
end
end
tests('failure') do
tests("#get_server('srv-00000')").raises(Excon::Errors::NotFound) do
pending if Fog.mocking?
Fog::Compute[:brightbox].get_server('srv-00000')
end
tests("#get_server").raises(ArgumentError) do
pending if Fog.mocking?
Fog::Compute[:brightbox].get_server
end
end
end