fog-google 1.7.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.travis.yml +0 -3
- data/CHANGELOG.md +45 -1
- data/CONTRIBUTING.md +11 -5
- data/README.md +0 -2
- data/fog-google.gemspec +4 -5
- data/lib/fog/bin/google.rb +4 -0
- data/lib/fog/compute/google/models/addresses.rb +9 -3
- data/lib/fog/compute/google/models/backend_services.rb +3 -2
- data/lib/fog/compute/google/models/disk_types.rb +5 -6
- data/lib/fog/compute/google/models/disks.rb +10 -4
- data/lib/fog/compute/google/models/firewalls.rb +3 -2
- data/lib/fog/compute/google/models/forwarding_rules.rb +8 -12
- data/lib/fog/compute/google/models/global_addresses.rb +3 -2
- data/lib/fog/compute/google/models/global_forwarding_rules.rb +3 -2
- data/lib/fog/compute/google/models/http_health_checks.rb +4 -3
- data/lib/fog/compute/google/models/images.rb +23 -12
- data/lib/fog/compute/google/models/instance_group_managers.rb +10 -7
- data/lib/fog/compute/google/models/instance_groups.rb +21 -15
- data/lib/fog/compute/google/models/instance_templates.rb +3 -2
- data/lib/fog/compute/google/models/machine_types.rb +13 -4
- data/lib/fog/compute/google/models/networks.rb +3 -2
- data/lib/fog/compute/google/models/operations.rb +8 -8
- data/lib/fog/compute/google/models/projects.rb +3 -2
- data/lib/fog/compute/google/models/regions.rb +3 -2
- data/lib/fog/compute/google/models/routes.rb +3 -2
- data/lib/fog/compute/google/models/servers.rb +7 -7
- data/lib/fog/compute/google/models/snapshots.rb +5 -4
- data/lib/fog/compute/google/models/ssl_certificates.rb +4 -3
- data/lib/fog/compute/google/models/subnetworks.rb +13 -7
- data/lib/fog/compute/google/models/target_http_proxies.rb +3 -2
- data/lib/fog/compute/google/models/target_https_proxies.rb +3 -2
- data/lib/fog/compute/google/models/target_instances.rb +8 -8
- data/lib/fog/compute/google/models/target_pools.rb +7 -10
- data/lib/fog/compute/google/models/url_maps.rb +3 -2
- data/lib/fog/compute/google/models/zones.rb +4 -2
- data/lib/fog/compute/google/real.rb +2 -0
- data/lib/fog/compute/google/requests/list_aggregated_instance_groups.rb +1 -2
- data/lib/fog/dns/google/real.rb +1 -0
- data/lib/fog/google/models/sql/instances.rb +4 -1
- data/lib/fog/google/monitoring/real.rb +1 -0
- data/lib/fog/google/pubsub/real.rb +1 -0
- data/lib/fog/google/shared.rb +15 -1
- data/lib/fog/google/sql/real.rb +1 -0
- data/lib/fog/google/version.rb +1 -1
- data/lib/fog/storage/google_json/real.rb +2 -0
- data/test/helpers/integration_test_helper.rb +2 -0
- data/test/helpers/test_collection.rb +26 -3
- data/test/integration/compute/core_compute/test_client_options.rb +12 -0
- data/test/integration/compute/core_compute/test_disk_types.rb +9 -0
- data/test/integration/compute/core_compute/test_images.rb +21 -0
- data/test/integration/compute/core_compute/test_machine_types.rb +13 -0
- data/test/integration/compute/core_compute/test_operations.rb +19 -1
- data/test/integration/compute/instance_groups/test_instance_group_managers.rb +1 -1
- data/test/integration/factories/addresses_factory.rb +4 -0
- data/test/integration/factories/collection_factory.rb +1 -1
- data/test/integration/factories/disks_factory.rb +4 -0
- data/test/integration/factories/forwarding_rules_factory.rb +4 -0
- data/test/integration/factories/images_factory.rb +4 -0
- data/test/integration/factories/instance_group_manager_factory.rb +8 -0
- data/test/integration/factories/instance_groups_factory.rb +4 -0
- data/test/integration/factories/servers_factory.rb +8 -0
- data/test/integration/factories/subnetworks_factory.rb +4 -0
- data/test/integration/factories/target_instances_factory.rb +4 -0
- data/test/integration/factories/target_pools_factory.rb +4 -0
- data/test/unit/compute/test_common_collections.rb +19 -8
- data/test/unit/compute/test_common_models.rb +10 -11
- data/test/unit/compute/test_server.rb +2 -1
- data/test/unit/dns/test_common_collections.rb +43 -0
- data/test/unit/monitoring/test_comon_collections.rb +44 -0
- data/test/unit/pubsub/test_common_collections.rb +35 -0
- data/test/unit/sql/test_common_collections.rb +46 -0
- data/test/unit/storage/test_common_json_collections.rb +38 -0
- data/test/unit/storage/test_common_xml_collections.rb +39 -0
- metadata +33 -27
@@ -0,0 +1,12 @@
|
|
1
|
+
require "helpers/integration_test_helper"
|
2
|
+
|
3
|
+
class TestComputeClient < FogIntegrationTest
|
4
|
+
def test_client_options
|
5
|
+
# XXX This is a very rudimentary test checking that proxy option is applied
|
6
|
+
client_options = { proxy_url: "https://user:password@host:8080" }
|
7
|
+
connection = Fog::Compute::Google.new(google_client_options: client_options)
|
8
|
+
|
9
|
+
err = assert_raises(ArgumentError) { connection.servers.all }
|
10
|
+
assert_match(/unsupported proxy/, err.message)
|
11
|
+
end
|
12
|
+
end
|
@@ -16,6 +16,15 @@ class TestDiskTypes < FogIntegrationTest
|
|
16
16
|
"Number of all disk type references should be greater or equal to test zones * disk types")
|
17
17
|
end
|
18
18
|
|
19
|
+
def test_scoped_all
|
20
|
+
subject_list = @subject.all
|
21
|
+
scoped_subject_list = @subject.all(zone: TEST_ZONE)
|
22
|
+
|
23
|
+
# Assert that whatever .all(scope) returns is a subset of .all
|
24
|
+
assert(scoped_subject_list.all? { |x| subject_list.include? x },
|
25
|
+
"Output of @subject.all(zone:#{TEST_ZONE}) must be a subset of @subject.all")
|
26
|
+
end
|
27
|
+
|
19
28
|
def test_get
|
20
29
|
NAMES.each do |name|
|
21
30
|
ZONES.each do |zone|
|
@@ -8,4 +8,25 @@ class TestImages < FogIntegrationTest
|
|
8
8
|
@subject = Fog::Compute[:google].images
|
9
9
|
@factory = ImagesFactory.new(namespaced_name)
|
10
10
|
end
|
11
|
+
|
12
|
+
def test_get_specific_image
|
13
|
+
image = @subject.get(TEST_IMAGE)
|
14
|
+
refute_nil(image, "Images.get(#{TEST_IMAGE}) should not return nil")
|
15
|
+
assert_equal(image.family, TEST_IMAGE_FAMILY)
|
16
|
+
assert_equal(image.project, TEST_IMAGE_PROJECT)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_get_specific_image_from_project
|
20
|
+
image = @subject.get(TEST_IMAGE,TEST_IMAGE_PROJECT)
|
21
|
+
refute_nil(image, "Images.get(#{TEST_IMAGE}) should not return nil")
|
22
|
+
assert_equal(image.family, TEST_IMAGE_FAMILY)
|
23
|
+
assert_equal(image.project, TEST_IMAGE_PROJECT)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_get_from_family
|
27
|
+
image = @subject.get_from_family(TEST_IMAGE_FAMILY)
|
28
|
+
refute_nil(image,"Images.get_from_family(#{TEST_IMAGE_FAMILY}) should not return nil")
|
29
|
+
assert_equal(image.family, TEST_IMAGE_FAMILY)
|
30
|
+
assert_equal(image.project, TEST_IMAGE_PROJECT)
|
31
|
+
end
|
11
32
|
end
|
@@ -23,6 +23,15 @@ class TestMachineTypes < FogIntegrationTest
|
|
23
23
|
"Number of all machine types should be greater or equal to test zones * machine_types")
|
24
24
|
end
|
25
25
|
|
26
|
+
def test_scoped_all
|
27
|
+
subject_list = @subject.all
|
28
|
+
scoped_subject_list = @subject.all(zone: TEST_ZONE)
|
29
|
+
|
30
|
+
# Assert that whatever .all(scope) returns is a subset of .all
|
31
|
+
assert(scoped_subject_list.all? { |x| subject_list.include? x },
|
32
|
+
"Output of @subject.all(zone:#{TEST_ZONE}) must be a subset of @subject.all")
|
33
|
+
end
|
34
|
+
|
26
35
|
def test_get
|
27
36
|
# This tests only in last zone since not all zones contain all machine types
|
28
37
|
NAMES.each do |name|
|
@@ -39,4 +48,8 @@ class TestMachineTypes < FogIntegrationTest
|
|
39
48
|
def test_enumerable
|
40
49
|
assert_respond_to @subject, :each
|
41
50
|
end
|
51
|
+
|
52
|
+
def test_nil_get
|
53
|
+
assert_nil @subject.get(nil)
|
54
|
+
end
|
42
55
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "helpers/integration_test_helper"
|
2
2
|
|
3
|
-
class
|
3
|
+
class TestOperations < FogIntegrationTest
|
4
4
|
def setup
|
5
5
|
@subject = Fog::Compute[:google].operations
|
6
6
|
end
|
@@ -17,6 +17,24 @@ class TestRoutes < FogIntegrationTest
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
def test_zone_scoped_all
|
21
|
+
subject_list = @subject.all
|
22
|
+
scoped_subject_list = @subject.all(zone: TEST_ZONE)
|
23
|
+
|
24
|
+
# Assert that whatever .all(scope) returns is a subset of .all
|
25
|
+
assert(scoped_subject_list.all? { |x| subject_list.include? x },
|
26
|
+
"Output of @subject.all(zone:#{TEST_ZONE}) must be a subset of @subject.all")
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_region_scoped_all
|
30
|
+
subject_list = @subject.all
|
31
|
+
scoped_subject_list = @subject.all(region: TEST_REGION)
|
32
|
+
|
33
|
+
# Assert that whatever .all(scope) returns is a subset of .all
|
34
|
+
assert(scoped_subject_list.all? { |x| subject_list.include? x },
|
35
|
+
"Output of @subject.all(region:#{TEST_REGION}) must be a subset of @subject.all")
|
36
|
+
end
|
37
|
+
|
20
38
|
def test_bad_get
|
21
39
|
assert_nil @subject.get("bad-name")
|
22
40
|
end
|
@@ -12,7 +12,7 @@ class CollectionFactory
|
|
12
12
|
# @param async [FalseClass or TrueClass] perform resource destruction asynchronously
|
13
13
|
def cleanup(async = false)
|
14
14
|
suit_name = @example.gsub(/\W/, "").tr("_", "-").downcase.split('-')[0]
|
15
|
-
resources = @subject.all.select { |resource| resource.name.match
|
15
|
+
resources = @subject.all.select { |resource| resource.name.match(/#{PREFIX}-[0-9]*-#{suit_name}/) }
|
16
16
|
if DEBUG
|
17
17
|
p "Cleanup invoked in #{self} for example: #{@example}"
|
18
18
|
p "Resources to be deleted: #{resources.map { |r| r.name }}"
|
@@ -12,6 +12,14 @@ class InstanceGroupManagerFactory < CollectionFactory
|
|
12
12
|
@instance_template.cleanup
|
13
13
|
end
|
14
14
|
|
15
|
+
def get(identity)
|
16
|
+
@subject.get(identity, TEST_ZONE)
|
17
|
+
end
|
18
|
+
|
19
|
+
def all
|
20
|
+
@subject.all(zone: TEST_ZONE)
|
21
|
+
end
|
22
|
+
|
15
23
|
def params
|
16
24
|
{ :name => resource_name,
|
17
25
|
:zone => TEST_ZONE,
|
@@ -13,6 +13,14 @@ class ServersFactory < CollectionFactory
|
|
13
13
|
@disks.cleanup
|
14
14
|
end
|
15
15
|
|
16
|
+
def get(identity)
|
17
|
+
@subject.get(identity, TEST_ZONE)
|
18
|
+
end
|
19
|
+
|
20
|
+
def all
|
21
|
+
@subject.all(zone: TEST_ZONE)
|
22
|
+
end
|
23
|
+
|
16
24
|
def params
|
17
25
|
{ :name => resource_name,
|
18
26
|
:zone => TEST_ZONE,
|
@@ -3,29 +3,40 @@ require "helpers/test_helper"
|
|
3
3
|
class UnitTestCollections < MiniTest::Test
|
4
4
|
def setup
|
5
5
|
Fog.mock!
|
6
|
-
@client = Fog::Compute.new(:provider => "Google", :google_project => "foo")
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
@client = Fog::Compute.new(provider: "google",
|
8
|
+
google_project: "foo")
|
9
|
+
|
10
|
+
# Exceptions that do not pass test_common_methods:
|
11
|
+
#
|
12
|
+
# Projects do not have a "list" method in compute API, so 'all' is not implemented
|
13
|
+
@common_method_exceptions = [Fog::Compute::Google::Projects]
|
12
14
|
# Enumerate all descendants of Fog::Collection
|
13
15
|
descendants = ObjectSpace.each_object(Fog::Collection.singleton_class).to_a
|
14
16
|
|
15
|
-
@collections = descendants
|
17
|
+
@collections = descendants.select { |d| d.name.match(/Fog::Compute::Google/) }
|
16
18
|
end
|
17
19
|
|
18
20
|
def teardown
|
19
21
|
Fog.unmock!
|
20
22
|
end
|
21
23
|
|
24
|
+
# This tests whether Fog::Compute::Google collections have common lifecycle methods
|
22
25
|
def test_common_methods
|
23
|
-
|
24
|
-
|
26
|
+
subjects = @collections - @common_method_exceptions
|
27
|
+
subjects.each do |klass|
|
25
28
|
obj = klass.new
|
26
29
|
assert obj.respond_to?(:all), "#{klass} should have an .all method"
|
27
30
|
assert obj.respond_to?(:get), "#{klass} should have a .get method"
|
28
31
|
assert obj.respond_to?(:each), "#{klass} should behave like Enumerable"
|
29
32
|
end
|
30
33
|
end
|
34
|
+
|
35
|
+
def test_collection_get_arguments
|
36
|
+
@collections.each do |klass|
|
37
|
+
obj = klass.new
|
38
|
+
assert_operator(obj.method(:get).arity, :<=, 1,
|
39
|
+
"#{klass} should have at most 1 required parameter in get()")
|
40
|
+
end
|
41
|
+
end
|
31
42
|
end
|
@@ -3,22 +3,21 @@ require "helpers/test_helper"
|
|
3
3
|
class UnitTestModels < MiniTest::Test
|
4
4
|
def setup
|
5
5
|
Fog.mock!
|
6
|
-
@client = Fog::Compute.new(:
|
6
|
+
@client = Fog::Compute.new(provider: "google",
|
7
|
+
google_project: "foo")
|
7
8
|
|
8
|
-
# Top-level ancestors we do not test
|
9
|
-
common_ancestors = [Fog::Model, Fog::Compute::Server]
|
10
9
|
# Do not test models that do not have a create method in API
|
11
|
-
exceptions = [
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
exceptions = [Fog::Compute::Google::MachineType,
|
11
|
+
Fog::Compute::Google::Region,
|
12
|
+
Fog::Compute::Google::DiskType,
|
13
|
+
Fog::Compute::Google::Operation,
|
14
|
+
Fog::Compute::Google::Zone,
|
15
|
+
Fog::Compute::Google::Snapshot,
|
16
|
+
Fog::Compute::Google::Project]
|
18
17
|
# Enumerate all descendants of Fog::Model
|
19
18
|
descendants = ObjectSpace.each_object(Fog::Model.singleton_class).to_a
|
20
19
|
|
21
|
-
@models = descendants
|
20
|
+
@models = descendants.select { |d| d.name.match(/Fog::Compute::Google/) } - exceptions
|
22
21
|
end
|
23
22
|
|
24
23
|
def teardown
|
@@ -3,7 +3,8 @@ require "helpers/test_helper"
|
|
3
3
|
class UnitTestServer < MiniTest::Test
|
4
4
|
def setup
|
5
5
|
Fog.mock!
|
6
|
-
@client = Fog::Compute.new(:
|
6
|
+
@client = Fog::Compute.new(provider: "google",
|
7
|
+
google_project: "foo")
|
7
8
|
end
|
8
9
|
|
9
10
|
def teardown
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "helpers/test_helper"
|
2
|
+
|
3
|
+
class UnitTestDNSCollections < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
Fog.mock!
|
6
|
+
@client = Fog::DNS.new(provider: "google",
|
7
|
+
google_project: "foo")
|
8
|
+
|
9
|
+
# Exceptions that do not pass test_common_methods:
|
10
|
+
#
|
11
|
+
# DNS Projects API does not support 'list', so 'all' method is not possible
|
12
|
+
@common_methods_exceptions = [Fog::DNS::Google::Projects]
|
13
|
+
# Enumerate all descendants of Fog::Collection
|
14
|
+
descendants = ObjectSpace.each_object(Fog::Collection.singleton_class)
|
15
|
+
|
16
|
+
@collections = descendants.select { |d| d.name.match(/Fog::DNS::Google/) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
Fog.unmock!
|
21
|
+
end
|
22
|
+
|
23
|
+
# This tests whether Fog::Compute::Google collections have common lifecycle methods
|
24
|
+
def test_common_methods
|
25
|
+
subjects = @collections - @common_methods_exceptions
|
26
|
+
subjects.each do |klass|
|
27
|
+
obj = klass.new
|
28
|
+
assert obj.respond_to?(:all), "#{klass} should have an .all method"
|
29
|
+
assert obj.respond_to?(:get), "#{klass} should have a .get method"
|
30
|
+
assert obj.respond_to?(:each), "#{klass} should behave like Enumerable"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_collection_get_arguments
|
35
|
+
# TODO: Fixture for #352
|
36
|
+
skip
|
37
|
+
@collections.each do |klass|
|
38
|
+
obj = klass.new
|
39
|
+
assert_operator(obj.method(:get).arity, :<=, 1,
|
40
|
+
"#{klass} should have at most 1 required parameter in get()")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "helpers/test_helper"
|
2
|
+
|
3
|
+
class UnitTestMonitoringCollections < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
Fog.mock!
|
6
|
+
@client = Fog::Monitoring.new(provider: "google",
|
7
|
+
google_project: "foo")
|
8
|
+
|
9
|
+
# Exceptions that do not pass test_common_methods:
|
10
|
+
#
|
11
|
+
# TimeSeries API has no 'get' method
|
12
|
+
@common_method_exceptions = [Fog::Google::Monitoring::TimeseriesCollection]
|
13
|
+
# Enumerate all descendants of Fog::Collection
|
14
|
+
descendants = ObjectSpace.each_object(Fog::Collection.singleton_class).to_a
|
15
|
+
|
16
|
+
@collections = descendants.select { |d| d.name.match(/Fog::Google::Monitoring/) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
Fog.unmock!
|
21
|
+
end
|
22
|
+
|
23
|
+
# This tests whether Fog::Compute::Google collections have common lifecycle methods
|
24
|
+
def test_common_methods
|
25
|
+
subjects = @collections - @common_method_exceptions
|
26
|
+
|
27
|
+
subjects.each do |klass|
|
28
|
+
obj = klass.new
|
29
|
+
assert obj.respond_to?(:all), "#{klass} should have an .all method"
|
30
|
+
assert obj.respond_to?(:get), "#{klass} should have a .get method"
|
31
|
+
assert obj.respond_to?(:each), "#{klass} should behave like Enumerable"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_collection_get_arguments
|
36
|
+
@collections.each do |klass|
|
37
|
+
obj = klass.new
|
38
|
+
if obj.respond_to?(:get)
|
39
|
+
assert_operator(obj.method(:get).arity, :<=, 1,
|
40
|
+
"#{klass} should have at most 1 required parameter in get()")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "helpers/test_helper"
|
2
|
+
|
3
|
+
class UnitTestPubsubCollections < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
Fog.mock!
|
6
|
+
@client = Fog::Google::Pubsub.new(google_project: "foo")
|
7
|
+
|
8
|
+
# Enumerate all descendants of Fog::Collection
|
9
|
+
descendants = ObjectSpace.each_object(Fog::Collection.singleton_class)
|
10
|
+
|
11
|
+
@collections = descendants.select { |d| d.name.match(/Fog::Google::Pubsub/) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
Fog.unmock!
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_common_methods
|
19
|
+
# This tests whether Fog::Compute::Google collections have common lifecycle methods
|
20
|
+
@collections.each do |klass|
|
21
|
+
obj = klass.new
|
22
|
+
assert obj.respond_to?(:all), "#{klass} should have an .all method"
|
23
|
+
assert obj.respond_to?(:get), "#{klass} should have a .get method"
|
24
|
+
assert obj.respond_to?(:each), "#{klass} should behave like Enumerable"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_collection_get_arguments
|
29
|
+
@collections.each do |klass|
|
30
|
+
obj = klass.new
|
31
|
+
assert_operator(obj.method(:get).arity, :<=, 1,
|
32
|
+
"#{klass} should have at most 1 required parameter in get()")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|