Skip to content

Commit

Permalink
Merge pull request #452 from Temikus/monitoring_test_issue
Browse files Browse the repository at this point in the history
Minor test fixes and additions
  • Loading branch information
Temikus authored Mar 28, 2019
2 parents 4efe9cc + 67d3d06 commit 4cd5962
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/fog/compute/google/models/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -86,7 +94,12 @@ def associate(nic_name, async = true)
operation.wait_for { ready? } unless async
end

def disassociate
# 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

return nil if !in_use? || users.nil? || users.empty?
Expand Down
23 changes: 23 additions & 0 deletions test/integration/compute/core_networking/test_addresses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,29 @@ 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"
)

address.server = server
address.reload
assert_equal(
server,
address.server,
"Address should be associated with a server after association"
)
end

def test_bad_get
Expand Down
4 changes: 4 additions & 0 deletions test/integration/monitoring/test_metric_descriptors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")',
Expand Down

0 comments on commit 4cd5962

Please sign in to comment.