Skip to content

Conversation

pau-hedgehog
Copy link
Contributor

No description provided.

Signed-off-by: Pau Capdevila <pau@githedgehog.com>
Signed-off-by: Pau Capdevila <pau@githedgehog.com>
Until testing.go gets NAT support, the following tests
are expected to fail:

- gatewayPeeringNATTest
- gatewayPeeringOverlapNATTest

Signed-off-by: Pau Capdevila <pau@githedgehog.com>
@pau-hedgehog pau-hedgehog self-assigned this Sep 18, 2025
@pau-hedgehog pau-hedgehog added ci:-upgrade Disable VLAB upgrade tests ci:+release Enable VLAB release tests labels Sep 18, 2025
Copy link

@Copilot 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

This PR adds comprehensive test coverage for NAT (Network Address Translation) functionality in gateway peering configurations. The changes extend the existing VPC peering test framework to support NAT scenarios including basic NAT peering and overlapping subnet resolution using NAT.

  • Extends existing gateway peering functions to accept NAT CIDR parameters
  • Adds two new test cases for NAT functionality with expected failure markers
  • Enhances test reporting infrastructure to support expected failures (XFAIL)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

return false, nil, fmt.Errorf("listing VPCs: %w", err)
}
if len(vpcs.Items) < 2 {
return true, nil, fmt.Errorf("not enough VPCs for NAT gateway peering test") //nolint:goerr113
Copy link
Preview

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

Returning true (skip) with a non-nil error is inconsistent. When skipping due to insufficient resources, return true, nil, nil and log the reason instead of returning an error.

Suggested change
return true, nil, fmt.Errorf("not enough VPCs for NAT gateway peering test") //nolint:goerr113
slog.Info("Skipping NAT gateway peering test: not enough VPCs")
return true, nil, nil

Copilot uses AI. Check for mistakes.


vpcPeerings := make(map[string]*vpcapi.VPCPeeringSpec, 0)
externalPeerings := make(map[string]*vpcapi.ExternalPeeringSpec, 0)
gwPeerings := make(map[string]*gwapi.PeeringSpec, 1)
Copy link
Preview

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

[nitpick] The capacity parameter for map initialization should be consistent. Either use 0 for all maps or use meaningful capacities based on expected usage. Mixed capacities (0, 0, 1) suggest inconsistent initialization patterns.

Suggested change
gwPeerings := make(map[string]*gwapi.PeeringSpec, 1)
gwPeerings := make(map[string]*gwapi.PeeringSpec, 0)

Copilot uses AI. Check for mistakes.

// Set up NAT gateway peering between the overlapping VPCs
vpcPeerings := make(map[string]*vpcapi.VPCPeeringSpec, 0)
externalPeerings := make(map[string]*vpcapi.ExternalPeeringSpec, 0)
gwPeerings := make(map[string]*gwapi.PeeringSpec, 1)
Copy link
Preview

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

[nitpick] Same inconsistent map capacity initialization pattern as in the previous test function. Consider standardizing the capacity values across all test functions.

Suggested change
gwPeerings := make(map[string]*gwapi.PeeringSpec, 1)
gwPeerings := make(map[string]*gwapi.PeeringSpec, 0)

Copilot uses AI. Check for mistakes.

time.Sleep(5 * time.Second)

// Create new overlapping VPC with vpc-01's subnet CIDR in the separate namespace
newVPCName := "vpc-ovrlp" // VPC names must be ≤11 chars because they map to Linux VRF interface names
Copy link
Preview

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

[nitpick] The comment explains the 11-character limit but 'vpc-ovrlp' is only 9 characters. Consider clarifying whether this is the actual limit or if there's additional context needed for the constraint.

Suggested change
newVPCName := "vpc-ovrlp" // VPC names must be ≤11 chars because they map to Linux VRF interface names
newVPCName := "vpc-ovrlp" // Example name is 9 chars (≤11 char limit for VPC names, as they map to Linux VRF interface names)

Copilot uses AI. Check for mistakes.

Copy link

github-actions bot commented Sep 18, 2025

Test Results

 13 files  52 suites   5h 19m 36s ⏱️
 24 tests 23 ✅   1 💤 0 ❌
312 runs  93 ✅ 219 💤 0 ❌

Results for commit 18a54e6.

♻️ This comment has been updated with latest results.

@pau-hedgehog pau-hedgehog added ci:+hlab Enable hybrid VLAB tests and removed ci:-upgrade Disable VLAB upgrade tests labels Sep 19, 2025
@Frostman Frostman requested a review from Copilot September 30, 2025 20:55
Copy link

@Copilot 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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

time.Sleep(5 * time.Second)

// Create new overlapping VPC with vpc-01's subnet CIDR in the separate namespace
newVPCName := "vpc-ovrlp" // VPC names must be ≤11 chars because they map to Linux VRF interface names
Copy link
Preview

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

The magic number 11 is hardcoded without clear validation. Consider adding a constant or validation function to ensure VPC names don't exceed the VRF interface name limit.

Copilot uses AI. Check for mistakes.

Subnets: map[string]*vpcapi.VPCSubnet{
"subnet-01": {
Subnet: existingSubnetCIDR, // Same subnet as vpc-01! (10.0.1.0/24)
VLAN: 1020, // Use a known available VLAN
Copy link
Preview

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

The VLAN ID 1020 is hardcoded. Consider using a constant or dynamic allocation to avoid potential conflicts with other tests or deployments.

Copilot uses AI. Check for mistakes.

Comment on lines +2453 to +2454
vpc1NATCIDR := []string{"192.168.11.0/24"}
vpc2NATCIDR := []string{"192.168.12.0/24"}
Copy link
Preview

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

NAT CIDR ranges are hardcoded in multiple places (lines 2453-2454 and 2674-2675). Consider defining these as constants to ensure consistency and make them easier to modify.

Copilot uses AI. Check for mistakes.

func appendGwPeeringSpec(gwPeerings map[string]*gwapi.PeeringSpec, vpc1, vpc2 *vpcapi.VPC, vpc1Subnets, vpc2Subnets []string) {
// If vpc1NATCIDR or vpc2NATCIDR are provided, NAT will be configured for the respective VPC
// NOTE: vpc1Subnets/vpc2Subnets currently always receive nil in basic tests (for future multi-subnet suite)
func appendGwPeeringSpec(gwPeerings map[string]*gwapi.PeeringSpec, vpc1, vpc2 *vpcapi.VPC, vpc1Subnets, vpc2Subnets, vpc1NATCIDR, vpc2NATCIDR []string) { //nolint:unparam
Copy link
Preview

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

The function signature has grown to 7 parameters, which impacts readability and maintainability. Consider using a struct parameter to group related parameters (e.g., PeeringConfig struct with VPC1Subnets, VPC2Subnets, VPC1NATCIDR, VPC2NATCIDR fields).

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:+hlab Enable hybrid VLAB tests ci:+release Enable VLAB release tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant