mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
fix disks and servers live tests
This commit is contained in:
parent
2518b56f40
commit
2f6dfc9ceb
7 changed files with 33 additions and 7 deletions
|
@ -1,9 +1,13 @@
|
|||
require 'securerandom'
|
||||
|
||||
# create a disk to be used in tests
|
||||
def create_test_disk(connection, zone)
|
||||
zone = 'us-central1-a'
|
||||
random_string = SecureRandom.hex
|
||||
|
||||
disk = connection.disks.create({
|
||||
:name => "fogservername",
|
||||
:size_gb => "2",
|
||||
:name => "fog-test-disk-#{random_string}",
|
||||
:size_gb => "10",
|
||||
:zone => zone,
|
||||
:source_image => "debian-7-wheezy-v20140408",
|
||||
})
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
Shindo.tests("Fog::Compute[:google] | disk model", ['google']) do
|
||||
|
||||
model_tests(Fog::Compute[:google].disks, {:name => 'fogdiskname', :zone => 'us-central1-a'})
|
||||
model_tests(Fog::Compute[:google].disks, {:name => 'fog-disk-model-tests',
|
||||
:zone => 'us-central1-a',
|
||||
:size_gb => 10}) do |model|
|
||||
Fog.wait_for do
|
||||
model.reload
|
||||
model.status != 'CREATING'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
Shindo.tests("Fog::Compute[:google] | disks", ['google']) do
|
||||
|
||||
collection_tests(Fog::Compute[:google].disks, {:name => 'fogdiskname', :zone => 'us-central1-a'})
|
||||
collection_tests(Fog::Compute[:google].disks, {:name => 'fog-disks-collections-tests',
|
||||
:zone => 'us-central1-a',
|
||||
:size_gb => 10})
|
||||
|
||||
end
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
require 'securerandom'
|
||||
|
||||
Shindo.tests("Fog::Compute[:google] | server model", ['google']) do
|
||||
|
||||
@zone = 'us-central1-a'
|
||||
@disk = create_test_disk(Fog::Compute[:google], @zone)
|
||||
random_string = SecureRandom.hex
|
||||
|
||||
model_tests(Fog::Compute[:google].servers, {:name => 'fogservername', :zone_name => @zone, :machine_type => 'n1-standard-1', :disks => [@disk]})
|
||||
model_tests(Fog::Compute[:google].servers, {:name => "fog-test-server-#{random_string}",
|
||||
:zone_name => @zone,
|
||||
:machine_type => 'n1-standard-1',
|
||||
:disks => [@disk]})
|
||||
|
||||
tests('servers') do
|
||||
@instance = nil
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
require 'securerandom'
|
||||
|
||||
Shindo.tests("Fog::Compute[:google] | servers", ['google']) do
|
||||
|
||||
@zone = 'us-central1-a'
|
||||
@disk = create_test_disk(Fog::Compute[:google], @zone)
|
||||
random_string = SecureRandom.hex
|
||||
|
||||
collection_tests(Fog::Compute[:google].servers, {:name => 'fogservername', :zone_name => @zone, :machine_type => 'n1-standard-1', :disks => [@disk]})
|
||||
collection_tests(Fog::Compute[:google].servers, {:name => "fog-test-server-#{random_string}",
|
||||
:zone_name => @zone,
|
||||
:machine_type => 'n1-standard-1',
|
||||
:disks => [@disk]})
|
||||
|
||||
end
|
||||
|
|
|
@ -75,6 +75,7 @@ def collection_tests(collection, params = {}, mocks_implemented = true)
|
|||
end
|
||||
|
||||
if !Fog.mocking? || mocks_implemented
|
||||
puts @instance.inspect
|
||||
@instance.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ def model_tests(collection, params = {}, mocks_implemented = true)
|
|||
end
|
||||
|
||||
if block_given?
|
||||
yield
|
||||
yield(@instance)
|
||||
end
|
||||
|
||||
tests("#destroy").succeeds do
|
||||
|
|
Loading…
Reference in a new issue