Skip to content

test(e2e): kind harness for Gateway API L4 routes — TCPRoute leg (#868) - #879

Merged
bpalermo merged 2 commits into
mainfrom
test/868-l4-harness-tcproute
Sep 20, 2026
Merged

bpalermo merged 2 commits into
mainfrom
test/868-l4-harness-tcproute

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

PR2 of #868. Adds the kind e2e harness and the TCPRoute leg only — test/envoy_validate
(PR1), TLSRoute (PR3) and UDPRoute (PR4) are untouched here.

What lands

  • e2e/l4routes.sh — one kind cluster, the real chart, the real aether-proxy, CNI
    transparent capture on by default, up|verify|down, dump_state on every failure.
    Modelled on e2e/uds.sh.
  • e2e/l4echo — the test backend. --mode=tcp today (reads a line, writes
    <marker> <line>, closes); --mode=tls and --mode=udp are implemented behind the
    same flag surface so the later legs are a harness change only. Closing after the echo is
    the point: istio/tcp-echo-server holds the connection open, which is what forced the
    Gateway API Phase 3 — TCP-over-mTLS floor + L4 routes (proposal 018) #460 work to score probes from captured payload after a full timeout.
  • l4-routes job in .github/workflows/e2e.yaml — hard by default, soft under the
    existing soft input, added to the only choice list and to report-failure's
    needs: + RESULTS (a job missing from that list fails silently at 04:17 UTC — the
    Nightly e2e (waypoint + replicator) red since the mesh-DNS decoupling — harnesses never wait for aether-mesh-dns #589 failure mode). //e2e/l4echo:image_load joins the build job's target loop and
    the docker save list.

No charts/ change, so no Chart.yaml bump: agent RBAC already grants tcproutes, and
L4 routing has had no values gate since proposal 031.

The assertions

state assertion
T1.0 no TCPRoute 20/20 probes reach the floor
T1.1 l4-a 75 / l4-b 25 200 probes, zero floor, both backends non-zero, alpha/200 ∈ [0.60, 0.90]
T1.2a l4-a 100 / l4-b 0 bravo == 0 and alpha == 200, exactly
T1.2b l4-a 0 / l4-b 100 mirrored: alpha == 0, bravo == 200
T1.3 both 0 50/50 probes back on the floor
T1.4 route deleted 20/20 probes back on the floor

T1.0 / T1.3 / T1.4 are the permanent built-in negative control, not setup. The same
probe, the same client, the same port must produce a different named answer in each
state, so the suite re-proves its own discriminating power on every nightly run instead
of once at review time — the #853 trap, where a gate passed because it could not fail.

The T1.1 band is derived, not guessed, and the maths is in the script beside the
numbers: alpha ~ Binomial(200, 0.75), sd = 6.12 connections = 3.06 points, so
[0.60, 0.90] is ±4.9σ (≈1e-6 flake per run) while still catching a 50/50 implementation
~99.7% of the time and a 100/0 one deterministically.

T1.2 is mirrored on purpose. A one-direction drain assertion passes trivially if the
projector were dropping l4-b for an unrelated reason — a bad ReferenceGrant decision, a
typo, an unclassified backend with no tcp: cluster. The mirror makes each backend prove
it can be both the only target and the only drained one.

Every assertion seen RED — by reproducing #492, not by a synthetic break

Reverted the #492 hunk locally (if w == 0 { w = 1 } restored in both
l4RulesToWeightedClusters and l4BackendsToWeightedClusters), rebuilt the agent image,
rolled the DaemonSet, re-ran the suite:

==> T1.0 control: no TCPRoute — every probe must reach the FLOOR (l4-front itself)
  ✓ 20/20 probes reached the floor: the probe distinguishes the parent from its backends

==> T1.1 split: TCPRoute l4-split, l4-a weight 75 / l4-b weight 25, 200 probes
  ✓ alpha 142/200, bravo 58/200, floor 0 — inside the 75/25 band

==> T1.2a drain: l4-a weight 100 / l4-b weight 0 — bravo must be EXACTLY 0
  ✗ T1.2a: bravo took 1/200 connections at weight 0 — an explicit weight 0 must mean
    DRAIN, not a share (this is exactly #492): alpha=199 bravo=1

The harness reproduces the bug that actually shipped, and the dump_state that follows
prints the TCPRoute with its Accepted=True status — i.e. it says "the agent saw this
route and routed it wrong", not "something failed".

T1.3's state under the same buggy agent, measured directly (the suite had already exited
at T1.2a):

both weights 0, 50 probes -> alpha=19 bravo=31        # expected: floor=50

That is the ~50/50 the #492 report describes, and it matters for the suite's power:
with the bug the weights become 100 and 1, so T1.2a alone misses it ~14% of the time
((100/101)^200 ≈ 0.138 that the drained backend draws nothing in 200 connections), while
T1.3 is deterministic. The two together catch #492 every run. That reasoning is now a
comment in verify_drain, so nobody later "simplifies" T1.3 away.

Reverting the revert, rebuilding and rolling returns the suite to green:

  ✓ 20/20 probes reached the floor: the probe distinguishes the parent from its backends
  ✓ alpha 155/200, bravo 45/200, floor 0 — inside the 75/25 band
  ✓ alpha 200/200, bravo 0/200 — weight 0 drains l4-b completely
  ✓ bravo 200/200, alpha 0/200 — the drain is symmetric, so the counts come from the weights
  ✓ 50/50 probes on the floor: an all-zero weighted set collapses to the passthrough chain
  ✓ 20/20 probes back on the floor: the route, not the fixture, was doing the routing
==> all TCPRoute assertions passed

Working tree is clean of the revert; only the three new files and the workflow are in the
diff.

Two deviations from the plan in #868, both forced, both filed

The plan said "SPIRE off, like uds.sh". That does not work, and the reason is worth
recording rather than working around silently.

  1. SPIRE must be ON — TCP mesh services are silently unroutable when SPIRE is disabled #877. With --spire-enabled=false the mesh has no TCP path at
    either end. Source: captureTCPClusters() returns nil unless the node SVID is known,
    and SetNodeIdentity is only ever called by the SPIRE bridge, which is not wired when
    SPIRE is off — so no tcp: clusters are published at all, while the capture
    listener still gets its cap_tcp_* chain naming a cluster that does not exist.
    Destination: NewInboundListener(cleartext=true) emits a single default HCM chain; the
    inbound TCP floor chain exists only on the mTLS path. An L4 suite copied from uds.sh
    would have been a test of nothing.
    Silver lining: because SPIRE is on, this harness does exercise the tcp: cluster's
    server-SAN pin end to end — the shape of fix(xds): TCP-floor SAN pin must use the bare SA name (020 regression) #464, which the plan had explicitly listed as
    out of scope.

  2. The registry backend must be etcd — endpoint.aether.io/protocol: tcp is silently downgraded to http on the kubernetes registry backend #878. The chart-default kubernetes backend
    returns nothing for PROTOCOL_TCP on purpose
    (KubernetesRegistry.ListEndpoints/ListAllEndpoints), so a pod annotated
    endpoint.aether.io/protocol: tcp is registered, then invisible: the registrar stamps
    app-protocol: http on the generated mesh Service, the capture reconciler classifies it
    HTTP, and there is no TCP floor chain for a route to replace. Observed directly:

    NAME       PROTO      # kubernetes backend, pods annotated protocol: tcp
    l4-front   http
    l4-a       http
    
    NAME       PROTO      # same manifests, etcd backend
    l4-front   tcp
    l4-a       tcp
    

    etcd runs as a plain docker container on kind's network, exactly as the multicluster
    harnesses run theirs.

Both are "configured, accepted and silently inert" — the failure mode this repo keeps
paying for — so each is filed as its own issue (#877, #878) rather than buried in a script
comment, and both are explained in the script header so the next reader does not repeat
the afternoon.

Other implementation notes worth a reviewer's eye

  • Gateway API CRDs go in before the agent starts, from the experimental channel.
    Reconciler.SetupWithManager gates each L4 type on a RESTMapper lookup at setup time,
    at v1 only — a CRD applied later needs an agent restart, and the suite would fail with
    a perfectly healthy agent that simply never watched the type. The script also asserts
    TCPRoute actually serves v1.
  • parentRefs[].group: "" is explicit. ParentReference.group defaults to
    gateway.networking.k8s.io in the CRD schema and serviceParents skips any non-empty
    group, so an omitted group silently yields a route attached to nothing.
  • Convergence is gated on route status, then on the data path. Every apply waits for
    our own gateway.aether.io/mesh Accepted=True with a matching observedGeneration
    (which separates "the agent never saw it" from "it routed wrong"), then polls small
    probe batches until the expected state holds before running the measured batch — an
    exact assertion must not straddle a config swap. Status alone is deliberately a gate and
    not an assertion: backendsResolve does not check that the backend Services exist.
  • One kubectl exec per batch, not per probe; 200 exec round trips would dominate
    both the runtime and the failure modes. Probe payloads are ≥6 bytes because a shorter
    first write stalls the capture listener's inspectors (fix(capture): don't close short-first-write TCP conns stalled in the inspectors #466).
  • bash -n clean, and bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //e2e:all
    passes. Verified the gate is not vacuous: the first run of it failed on this very file
    with SC2016 at probe_batch, which is now an explained # shellcheck disable.
  • //e2e/l4echo:image_test (container structure test) passes; make gazelle run, no
    go mod tidy.

Closes nothing on its own — #868 stays open for the TLSRoute and UDPRoute legs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 2 commits September 20, 2026 16:17
Adds e2e/l4routes.sh, the e2e/l4echo test backend, and a hard-gated `l4-routes`
job in the nightly e2e workflow. Proposal 018 Phase 3b has had no end-to-end
coverage at all: #492 (an explicit backendRef weight:0 normalised to 1, so
"drain" meant "equal share") shipped and was found by hand, and no upstream
conformance profile can express a Service-parented mesh L4 route.

The TCPRoute leg only; TLSRoute and UDPRoute follow as separate PRs.

Assertions, all against a real data path (kind + the real chart + the real
aether-proxy + the CNI's transparent capture):

  T1.0  control      no TCPRoute             -> 20/20 probes reach the FLOOR
  T1.1  split        75/25 over 200 probes   -> a justified band, never `floor`
  T1.2  drain        weight 0 is DRAIN, asserted EXACTLY and in BOTH directions
  T1.3  all drained  every weight 0          -> back to the FLOOR
  T1.4  delete       no TCPRoute again       -> back to the FLOOR

T1.0/T1.3/T1.4 are permanent built-in negative controls, not setup: the same
probe must produce a different NAMED answer in each state, so the suite
re-demonstrates its own discriminating power on every run rather than once at
review time (the #853 trap). The T1.1 band is derived, not guessed — the
sampling maths is in the script next to the numbers.

Seen RED by reverting the #492 hunk and rebuilding the agent image: T1.2a went
red with "bravo took 1/200 connections at weight 0", and T1.3's state measured
alpha=19 bravo=31 of 50 instead of 50 floor — the ~50/50 the original bug report
describes. Reverting the revert returns the suite to green.

Two preconditions the harness had to discover the hard way, both filed as their
own issues and both documented in the script header:

  * SPIRE must be ON (#877). With --spire-enabled=false captureTCPClusters()
    publishes no "tcp:" clusters (no node SVID) and the cleartext inbound
    listener has no TCP floor chain, so an L4 suite copied from uds.sh tests
    nothing. Paying for SPIRE also buys coverage of the "tcp:" cluster's server
    SAN pin — the shape of #464.
  * The registry backend must be etcd (#878). The chart-default kubernetes
    backend returns nothing for PROTOCOL_TCP by design, so a pod annotated
    endpoint.aether.io/protocol: tcp is silently classified http and no TCP
    floor chain exists for a route to replace.

No chart change, so no Chart.yaml bump: agent RBAC already covers tcproutes and
L4 routing has had no values gate since proposal 031.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit e3b58e6 into main Sep 20, 2026
22 checks passed
@bpalermo
bpalermo deleted the test/868-l4-harness-tcproute branch September 20, 2026 19:41
bpalermo added a commit that referenced this pull request Sep 23, 2026
The kind L4 harness has covered TCPRoute since #879. This adds the two
remaining legs, which is the rest of #868's acceptance.

TLSRoute (T2.0-T2.4). The parent and both backends now speak TLS, so
#868's corrected fall-through criterion can be asserted POSITIVELY: a
third, unmatched SNI must reach the FLOOR backend by name, not merely
fail to reach A or B (an absence is also satisfied by a dropped
connection). SNI selection is asserted in both directions, because a
one-way assertion stays green if the SNI chains are ignored entirely and
chain 0 always wins.

The probes dial a port NO filter chain claims, and that is load-bearing.
BuildCaptureTLSRouteFilterChains matches ClusterIP/32 + server_names with
no destination_port; proposal 037 then gave every TCP-primary service
destination_port-qualified floor chains for :18082 and its own primary
port. Envoy resolves destination_port first and consults the portless
bucket only when no chain claims the exact port, so a TLS dial to either
of those ports lands on the floor and the SNI chains are never
considered. Dialing an unclaimed port leaves exactly the portless
candidates -- the SNI chains and 037's any-port shim -- which is what
makes T2.1/T2.2 and T2.3 a real comparison. Two consequences are stated
in the header rather than left to be rediscovered: TLSRoute is reachable
today only through a shim 037 Phase 4 proposes to remove, and
port-qualifying the SNI chains would move this dial port.

UDPRoute (T3.0-T3.2). Delivery only, per #868's scope note: the per-pod
udp_proxy carries a bare single-cluster RouteSpecifier, so asserting
backend selection would fail by design rather than find a bug (#873).
The 100/0 shape T3.1 uses is the one shape both implementations must
agree on -- today's path takes backends[0] and a weight-honouring one
must DRAIN the weight-0 backend (#492) -- so the assertion survives
#873's fix unchanged. The mirror is deliberately absent: it IS the #873
case. UDP rides the mesh in plaintext and the header says so; a passing
T3 is not evidence of an authenticated UDP path.

Every leg keeps the suite's negative controls, so each probe re-proves
its own discriminating power on every run rather than once at review
time (#853): three `floor` states for TCP, three for TLS, and two
`unanswered` states for UDP.

A missing CRD is a hard failure here rather than a clean skip. `up`
installs all three and now gates on all three being served at v1; a leg
that skips itself green cannot fail, which is the defect this suite
exists to avoid.

NOT EXECUTED AGAINST A CLUSTER. bash -n and the shellcheck gate are
green, the rendered manifests were validated against the gateway-api
v1.6.2 CRD schemas offline, and the chain-selection reasoning above is
read from the generators -- but no run has happened. The UDP data path
in particular has never been exercised anywhere (parked 2026-07-02), so
T3 is the leg most likely to be red first.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo added a commit that referenced this pull request Sep 23, 2026
The kind L4 harness has covered TCPRoute since #879. This adds the two
remaining legs, which is the rest of #868's acceptance.

TLSRoute (T2.0-T2.4). The parent and both backends now speak TLS, so
#868's corrected fall-through criterion can be asserted POSITIVELY: a
third, unmatched SNI must reach the FLOOR backend by name, not merely
fail to reach A or B (an absence is also satisfied by a dropped
connection). SNI selection is asserted in both directions, because a
one-way assertion stays green if the SNI chains are ignored entirely and
chain 0 always wins.

The probes dial a port NO filter chain claims, and that is load-bearing.
BuildCaptureTLSRouteFilterChains matches ClusterIP/32 + server_names with
no destination_port; proposal 037 then gave every TCP-primary service
destination_port-qualified floor chains for :18082 and its own primary
port. Envoy resolves destination_port first and consults the portless
bucket only when no chain claims the exact port, so a TLS dial to either
of those ports lands on the floor and the SNI chains are never
considered. Dialing an unclaimed port leaves exactly the portless
candidates -- the SNI chains and 037's any-port shim -- which is what
makes T2.1/T2.2 and T2.3 a real comparison. Two consequences are stated
in the header rather than left to be rediscovered: TLSRoute is reachable
today only through a shim 037 Phase 4 proposes to remove, and
port-qualifying the SNI chains would move this dial port.

UDPRoute (T3.0-T3.2). Delivery only, per #868's scope note: the per-pod
udp_proxy carries a bare single-cluster RouteSpecifier, so asserting
backend selection would fail by design rather than find a bug (#873).
The 100/0 shape T3.1 uses is the one shape both implementations must
agree on -- today's path takes backends[0] and a weight-honouring one
must DRAIN the weight-0 backend (#492) -- so the assertion survives
#873's fix unchanged. The mirror is deliberately absent: it IS the #873
case. UDP rides the mesh in plaintext and the header says so; a passing
T3 is not evidence of an authenticated UDP path.

Every leg keeps the suite's negative controls, so each probe re-proves
its own discriminating power on every run rather than once at review
time (#853): three `floor` states for TCP, three for TLS, and two
`unanswered` states for UDP.

A missing CRD is a hard failure here rather than a clean skip. `up`
installs all three and now gates on all three being served at v1; a leg
that skips itself green cannot fail, which is the defect this suite
exists to avoid.

NOT EXECUTED AGAINST A CLUSTER. bash -n and the shellcheck gate are
green, the rendered manifests were validated against the gateway-api
v1.6.2 CRD schemas offline, and the chain-selection reasoning above is
read from the generators -- but no run has happened. The UDP data path
in particular has never been exercised anywhere (parked 2026-07-02), so
T3 is the leg most likely to be red first.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo added a commit that referenced this pull request Sep 23, 2026
…#912)

The kind L4 harness has covered TCPRoute since #879. This adds the two
remaining legs, which is the rest of #868's acceptance.

TLSRoute (T2.0-T2.4). The parent and both backends now speak TLS, so
#868's corrected fall-through criterion can be asserted POSITIVELY: a
third, unmatched SNI must reach the FLOOR backend by name, not merely
fail to reach A or B (an absence is also satisfied by a dropped
connection). SNI selection is asserted in both directions, because a
one-way assertion stays green if the SNI chains are ignored entirely and
chain 0 always wins.

The probes dial a port NO filter chain claims, and that is load-bearing.
BuildCaptureTLSRouteFilterChains matches ClusterIP/32 + server_names with
no destination_port; proposal 037 then gave every TCP-primary service
destination_port-qualified floor chains for :18082 and its own primary
port. Envoy resolves destination_port first and consults the portless
bucket only when no chain claims the exact port, so a TLS dial to either
of those ports lands on the floor and the SNI chains are never
considered. Dialing an unclaimed port leaves exactly the portless
candidates -- the SNI chains and 037's any-port shim -- which is what
makes T2.1/T2.2 and T2.3 a real comparison. Two consequences are stated
in the header rather than left to be rediscovered: TLSRoute is reachable
today only through a shim 037 Phase 4 proposes to remove, and
port-qualifying the SNI chains would move this dial port.

UDPRoute (T3.0-T3.2). Delivery only, per #868's scope note: the per-pod
udp_proxy carries a bare single-cluster RouteSpecifier, so asserting
backend selection would fail by design rather than find a bug (#873).
The 100/0 shape T3.1 uses is the one shape both implementations must
agree on -- today's path takes backends[0] and a weight-honouring one
must DRAIN the weight-0 backend (#492) -- so the assertion survives
#873's fix unchanged. The mirror is deliberately absent: it IS the #873
case. UDP rides the mesh in plaintext and the header says so; a passing
T3 is not evidence of an authenticated UDP path.

Every leg keeps the suite's negative controls, so each probe re-proves
its own discriminating power on every run rather than once at review
time (#853): three `floor` states for TCP, three for TLS, and two
`unanswered` states for UDP.

A missing CRD is a hard failure here rather than a clean skip. `up`
installs all three and now gates on all three being served at v1; a leg
that skips itself green cannot fail, which is the defect this suite
exists to avoid.

NOT EXECUTED AGAINST A CLUSTER. bash -n and the shellcheck gate are
green, the rendered manifests were validated against the gateway-api
v1.6.2 CRD schemas offline, and the chain-selection reasoning above is
read from the generators -- but no run has happened. The UDP data path
in particular has never been exercised anywhere (parked 2026-07-02), so
T3 is the leg most likely to be red first.


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant