TPT-4368: Update integration tests due to deprecated "vpcs" for NB create#926
Conversation
7c8d1ed to
33f7afa
Compare
…-update-integration-tests-due-to-deprecated-vpcs-for-nb-create
dawiddzhafarov
left a comment
There was a problem hiding this comment.
LGTM and tests pass!
There was a problem hiding this comment.
Pull request overview
Updates Linodego integration tests/fixtures to account for the deprecation of the vpcs field on NodeBalancer create requests in favor of backend_vpcs, while also adding coverage to ensure the deprecated field remains accepted for now.
Changes:
- Updated NodeBalancer integration test setup helpers to send
backend_vpcsinstead ofvpcs. - Refreshed integration fixtures to match the new request payloads (
backend_vpcs) and updated recorded responses. - Added a new integration test + fixture to validate the deprecated
vpcscreate attribute is still accepted.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/integration/nodebalancers_test.go | Switches create options to BackendVPCs in helpers; adds a new test for deprecated VPCs usage. |
| test/integration/fixtures/TestNodeBalancer_Create_WithFrontendAndBackendInDifferentVPCs.yaml | Updates recorded POST body from vpcs to backend_vpcs (plus re-recorded fixture deltas). |
| test/integration/fixtures/TestNodeBalancer_Create_WithDeprecatedVPCsAttribute.yaml | New fixture for the deprecated vpcs attribute create path. |
| test/integration/fixtures/TestNodeBalancer_Create_WithBackendVPCOnly.yaml | Updates recorded POST body from vpcs to backend_vpcs (plus re-recorded fixture deltas). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| nodebalancer, err := client.CreateNodeBalancer(context.Background(), createOpts) | ||
| require.NoErrorf(t, err, "Error creating NodeBalancer with VPCc attribute: %v", err) |
There was a problem hiding this comment.
The failure message has a typo/inaccurate wording: "VPCc attribute" should be "VPCs attribute" (or "vpcs attribute"). This makes failures harder to interpret when the test breaks.
| require.NoErrorf(t, err, "Error creating NodeBalancer with VPCc attribute: %v", err) | |
| require.NoErrorf(t, err, "Error creating NodeBalancer with VPCs attribute: %v", err) |
| createOpts := linodego.NodeBalancerCreateOptions{ | ||
| Label: &label, | ||
| Region: vpc.Region, | ||
| Type: linodego.NBTypePremium, | ||
| VPCs: []linodego.NodeBalancerVPCOptions{{ |
There was a problem hiding this comment.
This test is meant to validate the deprecated vpcs request field still behaves correctly, but it only asserts the NodeBalancer was created. Please also assert the backend VPC attachment was actually created (e.g., list NodeBalancer VPC configs and check subnet/purpose), otherwise a regression that silently ignores vpcs could still pass.
| } | ||
|
|
||
| func TestNodeBalancer_Create_WithDeprecatedVPCsAttribute(t *testing.T) { | ||
| // To test that deprecated VPCs attribute is still valid - it will be deleted when it can no longer be used |
There was a problem hiding this comment.
The comment has an odd leading tab and reads like a sentence fragment ("//\tTo test..."). Please reformat it as a standard Go comment sentence (single space after //, capitalized) for readability and consistency.
| // To test that deprecated VPCs attribute is still valid - it will be deleted when it can no longer be used | |
| // Test that the deprecated VPCs attribute is still valid; it will be deleted when it can no longer be used. |
ezilber-akamai
left a comment
There was a problem hiding this comment.
I get this error:
nodebalancers_test.go:143:
Error Trace: /Users/ezilber/Projects/dx-devenv/repos/linodego/test/integration/nodebalancers_test.go:566
/Users/ezilber/Projects/dx-devenv/repos/linodego/test/integration/nodebalancers_test.go:143
Error: Received unexpected error:
[400] [type] User doesn't have permissions to add the requested type of NodeBalancer
Test: TestNodeBalancer_Create_WithFrontendVPCOnly
Messages: Error listing nodebalancers, expected struct, got error [400] [type] User doesn't have permissions to add the requested type of NodeBalancer
despite having (I think) all required customer tags on my account.
📝 Description
Changes related to the fact that "vpcs" attribute is deprecated (but still valid) in favor of "backend_vpcs" in POST /nodebalancers
✔️ How to Test
Without fixtures:
go test -count=1 ./test/integration/ -v -run TestNodeBalancer_Create_WithWith fixtures:
make test-int TEST_ARGS="-run TestNodeBalancer_Create_With"