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/database_server_tests.rb
Paul Thornthwaite e78d09693c [Brightbox] Destroy snapshot after completion
This works around an issue where you can not detect if a Cloud SQL
Instance is being snapshotted.

A new API restriction is that you can no longer delete an instance that
is being snapshotted so this suddenly began failing.

Now we look for a new snapshot and poll until it is ready only then can
we safely issue the destroy command.
2014-02-18 12:18:39 +00:00

54 lines
2.3 KiB
Ruby

Shindo.tests('Fog::Compute[:brightbox] | database server requests', ['brightbox']) do
pending if Fog.mocking?
tests('success') do
create_options = {}
tests("#create_database_server(#{create_options.inspect})") do
result = Fog::Compute[:brightbox].create_database_server(create_options)
@database_server_id = result["id"]
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SERVER, {:allow_extra_keys => true}) { result }
end
tests("#list_database_servers") do
result = Fog::Compute[:brightbox].list_database_servers
data_matches_schema(Brightbox::Compute::Formats::Collection::DATABASE_SERVERS, {:allow_extra_keys => true}) { result }
end
tests("#get_database_server('#{@database_server_id}')") do
result = Fog::Compute[:brightbox].get_database_server(@database_server_id)
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SERVER, {:allow_extra_keys => true}) { result }
end
update_options = {
:name => "New name"
}
tests("#update_database_server('#{@database_server_id}', update_options)") do
result = Fog::Compute[:brightbox].update_database_server(@database_server_id, update_options)
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SERVER, {:allow_extra_keys => true}) { result }
end
Fog::Compute[:brightbox].database_servers.get(@database_server_id).wait_for { ready? }
tests("#reset_password_database_server('#{@database_server_id}')") do
result = Fog::Compute[:brightbox].reset_password_database_server(@database_server_id)
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SERVER, {:allow_extra_keys => true}) { result }
test("new password is visible") { ! result["admin_password"].nil? }
end
tests("#destroy_database_server('#{@database_server_id}')") do
result = Fog::Compute[:brightbox].destroy_database_server(@database_server_id)
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SERVER, {:allow_extra_keys => true}) { result }
end
end
tests('failure') do
tests("create_database_server").raises(ArgumentError) do
Fog::Compute[:brightbox].create_database_server
end
tests("get_database_server").raises(Excon::Errors::NotFound) do
Fog::Compute[:brightbox].get_database_server("dbs-00000")
end
end
end