-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support for Adding Additional Reserved IP to Existing Linodes #5
Conversation
test/integration/instances_test.go
Outdated
} | ||
defer instanceTeardown() | ||
|
||
fmt.Println(instance.IPv4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll want to verify that the linode instnace IP matches the reserved IP adddress.
test/integration/instances_test.go
Outdated
t.Logf("Correctly received error when using non-reserved address: %v", err) | ||
} | ||
|
||
// Test: Non-owned reserved address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider doing the tests in a way that ensures the IP passed in is 'on-owned', probably with multiple accounts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will push this change once I get a reserved IP address that doesnt belong to the same account.
test/integration/fixtures/TestInstance_AddReservedIPToInstance.yaml
Outdated
Show resolved
Hide resolved
test/integration/instances_test.go
Outdated
defer instanceTeardown() | ||
|
||
// Now try to create another instance with the same IP | ||
_, _, err = createInstanceWithReservedIP(t, client, reservedIP.Address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No tear-down for this creation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added teardown function to handle accidental instance creation
test/integration/instances_test.go
Outdated
|
||
_, _, err := createInstanceWithReservedIP(t, client, "198.51.100.1") | ||
if err == nil { | ||
t.Errorf("Expected error with non-owned reserved address, but got none") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No tear-down for this creation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added teardown function to handle accidental instance creation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above move it right after createInstanceWithReservedIP and before the error checks. Also, use defer
test/integration/instances_test.go
Outdated
|
||
_, _, err := createInstanceWithReservedIP(t, client, "") | ||
if err == nil { | ||
t.Errorf("Expected error with empty IP address, but got none") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No tear-down for this creation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added teardown function to handle accidental instance creation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above move it right after createInstanceWithReservedIP and before the error checks. Also, use defer
…th associated tests
… the corresponding tests and fixtures
…tance to instance_ips.go
…ual test funcitons and removed debugging log statements
…st functions, made changes to error messages
57d6ddf
to
8909bd6
Compare
test/integration/instances_test.go
Outdated
if err != nil { | ||
t.Fatalf("Error creating instance with reserved IP: %s", err) | ||
} | ||
defer instanceTeardown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be before the error check, so that the tear down still happens even when the t.Fatal
is executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added defer statement immediately after the creation statement.
test/integration/instances_test.go
Outdated
if err != nil { | ||
t.Errorf("Unexpected error with owned non-assigned reserved IP: %v", err) | ||
} else { | ||
instanceTeardown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above, you should run/defer the teardown before you do any of the checks since it's good practice. (createInstanceWithReservedIP
returns an empty function for instanceTeardown
if it encounters an error so it should be safe to call defer
on it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added defer statement immediately after the creation statement.
test/integration/instances_test.go
Outdated
if err != nil { | ||
t.Fatalf("Failed to create initial instance: %v", err) | ||
} | ||
defer instanceTeardown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above move it right after createInstanceWithReservedIP
and before the error checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added defer statement immediately after the creation statement.
test/integration/instances_test.go
Outdated
_, secondInstanceTeardown, err := createInstanceWithReservedIP(t, client, reservedIP.Address) | ||
if err == nil { | ||
t.Errorf("Expected error with already assigned reserved IP, but got none") | ||
secondInstanceTeardown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above move it right after createInstanceWithReservedIP
and before the error checks. Also, use defer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added defer statement immediately after the creation statement.
test/integration/instances_test.go
Outdated
|
||
_, _, err := createInstanceWithReservedIP(t, client, "198.51.100.1") | ||
if err == nil { | ||
t.Errorf("Expected error with non-owned reserved address, but got none") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above move it right after createInstanceWithReservedIP and before the error checks. Also, use defer
test/integration/instances_test.go
Outdated
|
||
_, _, err := createInstanceWithReservedIP(t, client, "") | ||
if err == nil { | ||
t.Errorf("Expected error with empty IP address, but got none") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above move it right after createInstanceWithReservedIP and before the error checks. Also, use defer
test/integration/instances_test.go
Outdated
if err != nil { | ||
t.Errorf("Unexpected error with null IP address: %v", err) | ||
} else { | ||
instanceTeardown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above move it right after createInstanceWithReservedIP and before the error checks. Also, use defer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added defer statement immediately after the creation statement.
test/integration/instances_test.go
Outdated
}) | ||
if err == nil { | ||
t.Errorf("Expected error with multiple IP addresses, but got none") | ||
instanceTeardown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above move it right after createInstanceWithReservedIP and before the error checks. Also, use defer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added defer statement immediately after the creation statement.
test/integration/instances_test.go
Outdated
if err != nil { | ||
t.Errorf("Unexpected error when omitting IPv4 field: %v", err) | ||
} else { | ||
instanceTeardown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above move it right after createInstanceWithReservedIP and before the error checks. Also, use defer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added defer statement immediately after the creation statement.
test/integration/instances_test.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move these tests to a new file? instances_reserved_ips_test.go
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved all the related tests to a new file
…additonal reserved IPs to a linode to a separate file
test/Makefile
Outdated
@@ -2,7 +2,7 @@ | |||
|
|||
testint: | |||
@LINODE_FIXTURE_MODE="play" \ | |||
LINODE_TOKEN="awesometokenawesometokenawesometoken" \ | |||
LINODE_TOKEN="9f08d4534157252421c964c7b9bf53dd545a242c1f7ef4fe1ada1701366acf7f" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah need to remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This token is no longer valid. It has been revoked.
📝 Description
This PR introduces functionality and tests for creating Linodes with reserved IP addresses and adding additional reserved IPs to existing Linodes in the Linodego client. These changes are necessary to provide comprehensive support for managing Linodes with reserved IP addresses through the Linode API. The changes include:
✔️ How to Test
What are the steps to reproduce the issue or verify the changes?
Ensure you have a valid Linode API token. Set up your environment:
export LINODE_TOKEN="your_token_here"
Additionally you need to set the following if you want to test it in a different environment:
Navigate to the test directory within the linodego project. Update the LINODE_TOKEN in the Makefile:
LINODE_TOKEN="your_token_here"
Run the tests using one of the following commands: To run all integration tests:
make testint
To run a specific test:
go test -v ./integration -run TestInstance_CreateWithReservedIPAddressVariants
Verify the test output for any failures or unexpected behavior.
Note:
Ensure that you have enough quota to reserve IP before adding it to an existing linode. Ensure the IPMAX limit is enough to add additional reserved IP addresses to the linode.