Skip to content

TPT-4260 Implement integration tests for expand create linodes options and password less#944

Open
psnoch-akamai wants to merge 4 commits intolinode:proj/slade-cleofrom
psnoch-akamai:TPT-4260-linodego-implement-integration-tests-for-expand-create-linodes-options-and-password-less
Open

TPT-4260 Implement integration tests for expand create linodes options and password less#944
psnoch-akamai wants to merge 4 commits intolinode:proj/slade-cleofrom
psnoch-akamai:TPT-4260-linodego-implement-integration-tests-for-expand-create-linodes-options-and-password-less

Conversation

@psnoch-akamai
Copy link
Copy Markdown
Contributor

@psnoch-akamai psnoch-akamai commented Apr 28, 2026

✔️ How to Test

make TEST_ARGS="-run TestExpectedErrorIfFieldsAuthorizedUsersAuthorizedKeysRootPassAreNotSet"
make TEST_ARGS="-run TestCreateLinodeWithKernalAndBootSizeThenAddDiskAndRebuild"

TAG: cleo-slade-beta

@psnoch-akamai psnoch-akamai force-pushed the TPT-4260-linodego-implement-integration-tests-for-expand-create-linodes-options-and-password-less branch from 0a45a44 to 921ba51 Compare April 28, 2026 15:04
@psnoch-akamai psnoch-akamai force-pushed the TPT-4260-linodego-implement-integration-tests-for-expand-create-linodes-options-and-password-less branch from 921ba51 to 225979d Compare April 28, 2026 15:29
@psnoch-akamai psnoch-akamai marked this pull request as ready for review April 28, 2026 15:29
@psnoch-akamai psnoch-akamai requested a review from a team as a code owner April 28, 2026 15:29
@psnoch-akamai psnoch-akamai requested review from Copilot and ezilber-akamai and removed request for a team April 28, 2026 15:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds new integration test coverage around Linode instance creation edge cases (password-less validation) and creating/rebuilding instances when Kernel and BootSize are provided.

Changes:

  • Added a test asserting the API returns a 400 when root_pass/authorized_keys/authorized_users are all omitted.
  • Added an end-to-end style test that creates an instance with Kernel + BootSize, creates a disk, and rebuilds the instance.
  • Introduced testify/assert usage in instances_test.go for additional assertions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/integration/instances_test.go Outdated
Comment on lines +1196 to +1199
Kernel: linodego.Pointer("linode/latest-64bit"),
BootSize: linodego.Pointer(8192),
AuthorizedKeys: []string{"ssh-rsa"},
},
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

AuthorizedKeys: []string{"ssh-rsa"} is not a valid SSH public key (it’s missing the base64 key material). This will cause CreateInstance to fail when recording against the real API. Use a full public key string (e.g., reuse testSSHKeyCreateOpts.SSHKey from profile_sshkeys_test.go) or provide RootPass instead.

Copilot uses AI. Check for mistakes.
Comment on lines +1232 to +1233
Type: "g6-standard-2",
AuthorizedKeys: []string{"ecdsa-sha2-nistp"},
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

AuthorizedKeys: []string{"ecdsa-sha2-nistp"} is not a valid SSH public key (it’s missing the curve + base64 key material). This will likely make RebuildInstance fail when fixtures are recorded. Use a complete SSH public key string (for example testSSHKeyCreateOpts.SSHKey) or set RootPass.

Suggested change
Type: "g6-standard-2",
AuthorizedKeys: []string{"ecdsa-sha2-nistp"},
Type: "g6-standard-2",
RootPass: randPassword(),

Copilot uses AI. Check for mistakes.
Comment thread test/integration/instances_test.go Outdated
})
require.NoError(t, errCreateDisk)
assert.Equal(t, linodego.DiskNotReady, createDiskResponse.Status)

Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

This test asserts the new disk is DiskNotReady and immediately proceeds to rebuild the instance. That means the disk create action is still in progress; depending on API behavior this can be flaky or rejected, and it can also make the deferred DeleteInstance fail due to an in-progress operation. Consider waiting for the disk create event (ActionDiskCreate) or WaitForInstanceDiskStatus(..., DiskReady, ...) before calling RebuildInstance (and/or before teardown).

Suggested change
_, err = client.WaitForInstanceDiskStatus(
context.Background(),
instance.ID,
createDiskResponse.ID,
linodego.DiskReady,
180,
)
require.NoErrorf(t, err, "Error waiting for disk ready: %s", err)

Copilot uses AI. Check for mistakes.
Comment thread test/integration/instances_test.go Outdated
Copy link
Copy Markdown
Contributor

@ezilber-akamai ezilber-akamai left a comment

Choose a reason for hiding this comment

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

Tests pass locally. Nice work!

@psnoch-akamai psnoch-akamai added the testing for updates to the testing suite in the changelog. label Apr 30, 2026
Comment thread test/integration/instances_test.go Outdated
region := getRegionsWithCapsAndSiteType(
t,
client,
[]string{"Linodes", "Maintenance Policy"},
Copy link
Copy Markdown
Contributor

@mawilk90 mawilk90 May 4, 2026

Choose a reason for hiding this comment

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

Can we replace the hardcoded values with:
linodego.CapabilityLinodes and linodego.CapabilityMaintenancePolicy ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Changed

Comment thread test/integration/instances_test.go Outdated
region := getRegionsWithCapsAndSiteType(
t,
client,
[]string{"Linodes", "Maintenance Policy"},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

@psnoch-akamai psnoch-akamai requested a review from mawilk90 May 5, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing for updates to the testing suite in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants