From 7d28916650f499e3f2484d84e78eb38c0c8cb5d8 Mon Sep 17 00:00:00 2001 From: Artem Yakimenko Date: Thu, 28 Mar 2019 20:13:03 +1100 Subject: [PATCH 1/4] Insert a skip in SD pagination tests Addressing #451 --- test/integration/monitoring/test_metric_descriptors.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/integration/monitoring/test_metric_descriptors.rb b/test/integration/monitoring/test_metric_descriptors.rb index e49eb07e14..7c2ab3a559 100644 --- a/test/integration/monitoring/test_metric_descriptors.rb +++ b/test/integration/monitoring/test_metric_descriptors.rb @@ -104,6 +104,10 @@ def test_metric_descriptors_all descriptors = @client.metric_descriptors.all assert_operator(descriptors.size, :>, 0, "metric descriptor count should be positive") + end + + def test_metric_descriptors_all_page_size + skip("Skipping until API-side issue is resolved, see #451") descriptors = @client.metric_descriptors.all( :filter => 'metric.type = starts_with("compute.googleapis.com")', From 7232ebbf730c06384c8ac28880dbd261059ff2ba Mon Sep 17 00:00:00 2001 From: Artem Yakimenko Date: Thu, 28 Mar 2019 20:39:56 +1100 Subject: [PATCH 2/4] Fix Address.disassociate method Would otherwise error out on `unless async` Made the method synchronous by default as well --- lib/fog/compute/google/models/address.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/compute/google/models/address.rb b/lib/fog/compute/google/models/address.rb index d03d60cd27..299054930f 100755 --- a/lib/fog/compute/google/models/address.rb +++ b/lib/fog/compute/google/models/address.rb @@ -86,7 +86,7 @@ def associate(nic_name, async = true) operation.wait_for { ready? } unless async end - def disassociate + def disassociate(async = false) requires :address return nil if !in_use? || users.nil? || users.empty? From 511cea2e717df3b6b9f7cbd83cb0f482fb43373d Mon Sep 17 00:00:00 2001 From: Artem Yakimenko Date: Thu, 28 Mar 2019 20:40:31 +1100 Subject: [PATCH 3/4] Increase Address model test coverage --- .../compute/core_networking/test_addresses.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/integration/compute/core_networking/test_addresses.rb b/test/integration/compute/core_networking/test_addresses.rb index 7e1b33c760..ed659e13f6 100644 --- a/test/integration/compute/core_networking/test_addresses.rb +++ b/test/integration/compute/core_networking/test_addresses.rb @@ -32,6 +32,21 @@ def test_run_instance @subject.get(address.name, TEST_REGION).status, "Address should now be in use" ) + + address.reload + + assert_equal( + server, + address.server, + "Address.server should return an associated server object" + ) + + address.server = nil + address.reload + assert_nil( + address.server, + "Address should not be associated with a server after disassociation" + ) end def test_bad_get From 67d3d0611c1d6593083f3fe0c43f9a737c58e750 Mon Sep 17 00:00:00 2001 From: Artem Yakimenko Date: Thu, 28 Mar 2019 21:47:53 +1100 Subject: [PATCH 4/4] Fix Address.associate method This appears to have not worked before at all due to mismatched parameters. Added a test to check the behaviour going forward. --- lib/fog/compute/google/models/address.rb | 15 ++++++++++++++- .../compute/core_networking/test_addresses.rb | 8 ++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/fog/compute/google/models/address.rb b/lib/fog/compute/google/models/address.rb index 299054930f..901d0049f0 100755 --- a/lib/fog/compute/google/models/address.rb +++ b/lib/fog/compute/google/models/address.rb @@ -74,7 +74,15 @@ def ready? private - def associate(nic_name, async = true) + # Associates the ip address to a given server + # + # @param [String] server - GCE instance name + # @param [String] nic_name - NIC interface name, defaults to GCE + # standard primary nic - "nic0" + # @param [Boolean] async - whether to run the operation asynchronously + # + # @return [Fog::Compute::Google::Operation] + def associate(server, nic_name = "nic0", async = false) requires :address data = service.add_server_access_config( @@ -86,6 +94,11 @@ def associate(nic_name, async = true) operation.wait_for { ready? } unless async end + # Disassociates the ip address from a resource it's attached to + # + # @param [Boolean] async - whether to run the operation asynchronously + # + # @return [Fog::Compute::Google::Operation] def disassociate(async = false) requires :address diff --git a/test/integration/compute/core_networking/test_addresses.rb b/test/integration/compute/core_networking/test_addresses.rb index ed659e13f6..019e2d95fa 100644 --- a/test/integration/compute/core_networking/test_addresses.rb +++ b/test/integration/compute/core_networking/test_addresses.rb @@ -47,6 +47,14 @@ def test_run_instance address.server, "Address should not be associated with a server after disassociation" ) + + address.server = server + address.reload + assert_equal( + server, + address.server, + "Address should be associated with a server after association" + ) end def test_bad_get