mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[digitalocean|compute] tests updates
This commit is contained in:
parent
21b28ee589
commit
6fa4feacdc
6 changed files with 44 additions and 15 deletions
|
@ -30,3 +30,13 @@ def fog_test_server_destroy
|
|||
server = service.servers.find { |s| s.name == 'fog-test-server' }
|
||||
server.destroy if server
|
||||
end
|
||||
|
||||
at_exit do
|
||||
server = service.servers.find { |s| s.name == 'fog-test-server' }
|
||||
if server
|
||||
server.wait_for(120) do
|
||||
reload rescue nil; ready?
|
||||
end
|
||||
end
|
||||
fog_test_server_destroy
|
||||
end
|
||||
|
|
|
@ -21,6 +21,7 @@ Shindo.tests("Fog::Compute[:digitalocean] | server model", ['digitalocean', 'com
|
|||
:name,
|
||||
:status,
|
||||
:backups_active,
|
||||
:ip_address,
|
||||
:flavor_id,
|
||||
:region_id,
|
||||
:image_id
|
||||
|
|
|
@ -1,21 +1,25 @@
|
|||
Shindo.tests('Fog::Compute[:digitalocean] | create_server request', ['digitalocean', 'compute']) do
|
||||
|
||||
@server_format = {
|
||||
'id' => Integer,
|
||||
'name' => String,
|
||||
'image_id' => Integer,
|
||||
'size_id' => Integer,
|
||||
'event_id' => Integer
|
||||
}
|
||||
|
||||
service = Fog::Compute[:digitalocean]
|
||||
|
||||
tests('success') do
|
||||
|
||||
test('#create_server') do
|
||||
data = Fog::Compute[:digitalocean].create_server 'fog-test',
|
||||
tests('#create_server').formats({'status' => 'OK', 'droplet' => @server_format}) do
|
||||
data = Fog::Compute[:digitalocean].create_server 'fog-test-server',
|
||||
service.flavors.first.id,
|
||||
service.images.first.id,
|
||||
service.regions.first.id
|
||||
# wait some time before destroying the server
|
||||
# otherwise the request could be ignored, YMMV
|
||||
sleep 120
|
||||
data.body['status'] == 'OK' and \
|
||||
(service.destroy_server(data.body['droplet']['id']).body['status'] == 'OK')
|
||||
data.body
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
Shindo.tests('Fog::Compute[:digitalocean] | reboot_server request', ['digitalocean', 'compute']) do
|
||||
|
||||
service = Fog::Compute[:digitalocean]
|
||||
data = Fog::Compute[:digitalocean].create_server 'fog-test',
|
||||
service.flavors.first.id,
|
||||
service.images.first.id,
|
||||
service.regions.first.id
|
||||
data = fog_test_server
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ Shindo.tests('Fog::Compute[:digitalocean] | get_server_details request', ['digit
|
|||
tests('success') do
|
||||
|
||||
test('#get_server_details') do
|
||||
Fog::Compute[:digitalocean].get_server_details(nil).body.is_a? Hash
|
||||
server = fog_test_server
|
||||
body = Fog::Compute[:digitalocean].get_server_details(server.id).body
|
||||
body['droplet']['name'] == 'fog-test-server'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
Shindo.tests('Fog::Compute[:digitalocean] | list_servers request', ['digitalocean', 'compute']) do
|
||||
|
||||
@server_format = {
|
||||
'id' => Integer,
|
||||
'name' => String,
|
||||
'image_id' => Integer,
|
||||
'size_id' => Integer,
|
||||
'region_id' => Integer,
|
||||
'backups_active' => Fog::Nullable::Boolean,
|
||||
'ip_address' => String,
|
||||
'status' => String
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
|
||||
test('#list_servers') do
|
||||
Fog::Compute[:digitalocean].list_servers.body.is_a? Hash
|
||||
tests('#list_servers') do
|
||||
Fog::Compute[:digitalocean].list_servers.body['droplets'].each do |server|
|
||||
tests('format').data_matches_schema(@server_format) do
|
||||
server
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue