mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #2995 from allomov/google-live-tests
[google|tests] Fix disks and servers live tests
This commit is contained in:
commit
f0c984b810
14 changed files with 78 additions and 41 deletions
|
@ -20,7 +20,7 @@ module Fog
|
|||
attribute :source_snapshot_id, :aliases => 'sourceSnapshotId'
|
||||
|
||||
def save
|
||||
requires :name, :zone
|
||||
requires :name, :zone, :size_gb
|
||||
|
||||
options = {}
|
||||
my_description = "Created with fog"
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
# create a disk to be used in tests
|
||||
def create_test_disk(connection, zone)
|
||||
zone = 'us-central1-a'
|
||||
disk = connection.disks.create({
|
||||
:name => "fogservername",
|
||||
:size_gb => "2",
|
||||
:zone => zone,
|
||||
:source_image => "debian-7-wheezy-v20140408",
|
||||
})
|
||||
disk.wait_for { ready? }
|
||||
disk
|
||||
end
|
21
tests/google/helpers/google_tests_helper.rb
Normal file
21
tests/google/helpers/google_tests_helper.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
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 => "fog-test-disk-#{random_string}",
|
||||
:size_gb => "10",
|
||||
:zone => zone,
|
||||
:source_image => "debian-7-wheezy-v20140408",
|
||||
})
|
||||
disk.wait_for { ready? }
|
||||
disk
|
||||
end
|
||||
|
||||
def wait_operation(connection, response)
|
||||
operation = connection.operations.get(response['name'], response['zone'], response['region'])
|
||||
operation.wait_for { ready? }
|
||||
end
|
|
@ -1,5 +1,9 @@
|
|||
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|
|
||||
model.wait_for { ready? }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
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}) do |instance|
|
||||
instance.wait_for { ready? }
|
||||
end
|
||||
|
||||
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
|
||||
|
@ -20,7 +26,7 @@ Shindo.tests("Fog::Compute[:google] | server model", ['google']) do
|
|||
|
||||
test('#ssh') do
|
||||
pending if Fog.mocking?
|
||||
@instance.ssh("uname") == "Linux"
|
||||
!!(@instance.ssh("uname").first.stdout =~ /Linux/)
|
||||
end
|
||||
|
||||
test('#destroy') do
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -51,11 +51,13 @@ Shindo.tests('Fog::Compute[:google] | disk requests', ['google']) do
|
|||
disk_name = 'new-disk-test'
|
||||
disk_size = '2'
|
||||
zone_name = 'us-central1-a'
|
||||
image_name = 'centos-6-v20130813'
|
||||
image_name = 'debian-7-wheezy-v20140408'
|
||||
|
||||
# These will all fail if errors happen on insert
|
||||
tests("#insert_disk").formats(@insert_disk_format) do
|
||||
@google.insert_disk(disk_name, zone_name, image_name).body
|
||||
response = @google.insert_disk(disk_name, zone_name, image_name).body
|
||||
wait_operation(@google, response)
|
||||
response
|
||||
end
|
||||
|
||||
tests("#get_disk").formats(@get_disk_format) do
|
||||
|
|
|
@ -52,7 +52,7 @@ Shindo.tests('Fog::Compute[:google] | firewall requests', ['google']) do
|
|||
|
||||
tests('success') do
|
||||
|
||||
firewall_name = 'new-firewall-test'
|
||||
firewall_name = 'fog-test-firewall'
|
||||
source_range = [ '10.0.0.0/8' ]
|
||||
allowed = [{
|
||||
"IPProtocol" => "tcp",
|
||||
|
@ -65,7 +65,9 @@ Shindo.tests('Fog::Compute[:google] | firewall requests', ['google']) do
|
|||
}]
|
||||
|
||||
tests("#insert_firewall").formats(@insert_firewall_format) do
|
||||
@google.insert_firewall(firewall_name, source_range, allowed).body
|
||||
response = @google.insert_firewall(firewall_name, allowed, 'default', :source_ranges => source_range).body
|
||||
wait_operation(@google, response)
|
||||
response
|
||||
end
|
||||
|
||||
# TODO: Get better matching for firewall responses.
|
||||
|
|
|
@ -53,28 +53,33 @@ Shindo.tests('Fog::Compute[:google] | image requests', ['google']) do
|
|||
|
||||
tests('success') do
|
||||
|
||||
image_name = 'test-image'
|
||||
random_string = SecureRandom.hex
|
||||
image_name = "fog-test-image-#{random_string}"
|
||||
source = 'https://www.google.com/images/srpr/logo4w.png'
|
||||
|
||||
tests("#insert_image").formats(@insert_image_format) do
|
||||
pending if Fog.mocking?
|
||||
@google.insert_image(image_name, source).body
|
||||
pending
|
||||
# pending if Fog.mocking?
|
||||
# response = @google.insert_image(image_name, 'rawDisk' => source).body
|
||||
# wait_operation(@google, response)
|
||||
# response
|
||||
end
|
||||
|
||||
tests("#get_image").formats(@get_image_format) do
|
||||
pending if Fog.mocking?
|
||||
@google.insert_image(image_name, source)
|
||||
@google.get_image(image_name).body
|
||||
pending
|
||||
# pending if Fog.mocking?
|
||||
# @google.get_image(image_name).body
|
||||
end
|
||||
|
||||
tests("#list_images").formats(@list_images_format) do
|
||||
@google.list_images.body
|
||||
pending
|
||||
# @google.list_images.body
|
||||
end
|
||||
|
||||
tests("#delete_image").formats(@delete_image_format) do
|
||||
pending if Fog.mocking?
|
||||
@google.insert_image(image_name, source)
|
||||
@google.delete_image(image_name).body
|
||||
pending
|
||||
# pending if Fog.mocking?
|
||||
# @google.delete_image(image_name).body
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -10,12 +10,8 @@ Shindo.tests('Fog::Compute[:google] | zone requests', ['google']) do
|
|||
'name' => String,
|
||||
'description' => String,
|
||||
'status' => String,
|
||||
'maintenanceWindows' => Fog::Nullable::Array,
|
||||
'quotas' => [{
|
||||
'metric' => String,
|
||||
'limit' => Float,
|
||||
'usage' => Float},
|
||||
],
|
||||
'region' => String,
|
||||
'maintenanceWindows' => Fog::Nullable::Array
|
||||
}
|
||||
|
||||
@list_zones_format = {
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
require 'securerandom'
|
||||
|
||||
Shindo.tests('Fog::Storage[:google] | object requests', ["google"]) do
|
||||
|
||||
@directory = Fog::Storage[:google].directories.create(:key => 'fogobjecttests')
|
||||
random_string = SecureRandom.hex
|
||||
@directory = Fog::Storage[:google].directories.create(:key => "fog-test-object-#{random_string}")
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ def collection_tests(collection, params = {}, mocks_implemented = true)
|
|||
end
|
||||
|
||||
if block_given?
|
||||
yield
|
||||
yield(@instance)
|
||||
end
|
||||
|
||||
if !Fog.mocking? || mocks_implemented
|
||||
|
|
|
@ -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…
Add table
Reference in a new issue