Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Minor test fixes and additions #452

Merged
merged 4 commits into from
Mar 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/FirstParameterIndentation: Indent the first parameter one step more than the start of the previous line.

address.server,
Temikus marked this conversation as resolved.
Show resolved Hide resolved
"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