Skip to content

Refactor Standalone EndpointPool initialization to ensure Test/Prod parity #2174

@LukeAVanDrie

Description

@LukeAVanDrie

What would you like to be added:

I propose refactoring the logic that constructs the datalayer.EndpointPool for Standalone mode (currently residing in cmd/epp/runner/runner.go) into a reusable library function.

Current State:

  1. Production: runner.go parses CLI flags (--endpoint-selector, --endpoint-target-ports) and manually constructs the EndpointPool struct, performing logic like slice initialization and map conversion.
  2. Testing: test/integration/epp/harness.go (in WithStandaloneMode) manually reconstructs a similar EndpointPool object to inject into the Datastore, bypassing the CLI parsing logic entirely.

Proposed Change:
Extract the construction logic into a shared function (e.g., in pkg/epp/server or pkg/epp/datalayer):

func NewEndpointPoolFromOptions(namespace, name, selector string, targetPorts []int) (*datalayer.EndpointPool, error) {
    // Logic to validate, initialize slices, and return the Pool
}

Both cmd/epp/runner and test/integration/epp should use this shared function.

Why is this needed:

This addresses a wiring gap between our production binary and our hermetic integration tests.

Recently, a regression (#2092) occurred in Standalone mode where the target ports slice was copied incorrectly in runner.go, leading to a panic on startup. Even with the new integration tests for Standalone mode (#2175), this bug would not have been caught because the test harness re-implements the object construction logic instead of exercising the actual production code path.

By sharing this initialization code, we ensure that logic errors in configuration parsing are caught immediately by the integration suite.

Additional Context:
While a smoke E2E test for standalone mode (to be tracked in a separate ticket) would also catch this class of bug by running the actual binary, maintaining unit/integration parity is valuable for faster feedback loops and cheaper debugging. Both approaches are independently valuable.

Metadata

Metadata

Labels

good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions