mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
e78d09693c
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.
78 lines
2.1 KiB
Ruby
78 lines
2.1 KiB
Ruby
Shindo.tests("Fog::Compute[:brightbox] | DatabaseServer model", ["brightbox"]) do
|
|
pending if Fog.mocking?
|
|
|
|
@service = Fog::Compute[:brightbox]
|
|
|
|
tests("success") do
|
|
tests("#create") do
|
|
test("a new database server is returned") do
|
|
@database_server = @service.database_servers.create
|
|
!@database_server.nil?
|
|
end
|
|
|
|
test("state is not nil") do
|
|
!@database_server.state.nil?
|
|
end
|
|
|
|
test("database_version is not nil") do
|
|
!@database_server.database_version.nil?
|
|
end
|
|
|
|
test("admin_username is not nil") do
|
|
!@database_server.admin_username.nil?
|
|
end
|
|
|
|
test("admin_password is not nil") do
|
|
!@database_server.admin_password.nil?
|
|
end
|
|
end
|
|
|
|
@sample_identifier = @database_server.id
|
|
pending if @sample_identifier.nil?
|
|
|
|
tests("#all") do
|
|
test("returns results") do
|
|
@database_servers = @service.database_servers.all
|
|
@database_servers.any? do |dbs|
|
|
dbs.identity == @database_server.identity
|
|
end
|
|
end
|
|
end
|
|
|
|
tests("#get('#{@sample_identifier}')") do
|
|
@database_server = @service.database_servers.get(@sample_identifier)
|
|
|
|
@database_server.wait_for { ready? }
|
|
|
|
test("admin_username is not nil") do
|
|
!@database_server.admin_username.nil?
|
|
end
|
|
|
|
test("admin_password is nil") do
|
|
@database_server.admin_password.nil?
|
|
end
|
|
end
|
|
|
|
@database_server.wait_for { ready? }
|
|
|
|
tests("#snapshot") do
|
|
# Very messy but there is no feedback about if snapshotting or what the ID will be
|
|
existing_snapshots = @service.database_snapshots.all.map { |snapshot| snapshot.identity }
|
|
test do
|
|
@database_server.snapshot
|
|
end
|
|
|
|
current_snapshots = @service.database_snapshots.all.map { |snapshot| snapshot.identity }
|
|
snapshot_id = (current_snapshots - existing_snapshots).last
|
|
|
|
@snapshot = @service.database_snapshots.get(snapshot_id)
|
|
@snapshot.wait_for { ready? }
|
|
@snapshot.destroy
|
|
end
|
|
|
|
# Can no longer destroy when snapshotting
|
|
tests("#destroy") do
|
|
@database_server.destroy
|
|
end
|
|
end
|
|
end
|