Skip to content

test(e2e): cover the hardening fixes at the layer that can falsify them - #1355

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
test/e2e-hardening-coverage
Sep 19, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
test/e2e-hardening-coverage

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Tests and documentation only — no production file is touched (e2e/ and doc/, 1543 insertions,
zero deletions).

Several fixes that landed today were guarded only by unit tests inside lib/. The largest gap: the
listener slab-slot lifetime change altered all four protocols but shipped a reactivation test for
TCP alone. HTTP, HTTPS and UDP rested on the argument that the four arms are equivalent. An argument
is not a test.

Ten tests, each seen red

Every one was reddened by reverting the merged production hunk, then restored and proven
byte-identical.

  • a reactivated listener still serves — HTTP, HTTPS, TCP and UDP, one test each. Traffic is sent
    after the activation response is read, so the inline accept() backlog cannot mask a deaf
    listener.
  • three add/remove cycles at one UDP address leak no listener session.
  • a forged PROXY-v2 LOCAL header cannot set the source address a TCP session is charged against
    under max_connections_per_ip, and closes an expect_proxy HTTP session — while a PROXY header
    carrying the same block is still honoured and injected as X-Real-IP, proving the fix secures
    PROXY support rather than disabling it.
  • a TCP cluster with expect_proxy survives a client that completes the handshake and sends
    nothing
    , with a second session proving the worker is alive.
  • a --path-equals frontend is refused on re-add and stops routing when removed.
  • a listener answer template carrying an out-of-range status does not kill the worker, and stays
    unselectable.

Two judgement calls worth knowing

hard_stop in the UDP add/remove test is deliberate. Under the mutation it exists to catch, a
leaked listener session holds the session count above zero and soft_stop never returns — the
test would hang CI instead of reddening. The leak is observed before the stop either way.

The --path-equals red needs RUSTFLAGS="-C debug-assertions=off", because add_tree_rule's
post-condition predates that fix and kills the worker at add time in a debug build, masking the
routing behaviour. The test is green by default in CI's ordinary configuration; the flag only isolates
which defect it demonstrates, and pins the release-binary behaviour where the debug_assert! is
compiled out.

Two bounds on what e2e can ever reach

Now recorded in e2e/COVERAGE.md and doc/testing.md rather than left to be rediscovered:

  • MultiLineWriter is unreachable from e2e. It is constructed at exactly one site, the file://
    logging backend, and the harness hardcodes stdout with no access-log target.
  • kawa_h1's status-metric path is unreachable from any binary. Neither HttpStateMachine nor
    HttpsStateMachine has a kawa_h1::Http variant, and Http::new has no caller. A probe confirmed
    it: panic! planted at the function entry never fired across four real proxied HTTP/HTTPS sessions,
    while firing immediately in the function's own unit test — a positive control, so the negative means
    something. See kawa_h1: is the Http session state machine still reachable in any binary? #1346.

A first attempt at covering that path passed with the production assertion restored, so it was
deleted rather than kept: a test that cannot fail is worse than none. The reachable half of the same
fix — a control-plane answer template — is covered instead.

Flake

10 isolated serial runs × repeat_until_error_or(3, ..) = 30 executions per test, all clean; plus two
full-suite runs at default parallelism in which all ten passed. Every new test allocates its ports
through the mutex-guarded registry, so the only literal addresses are synthetic ones inside forged
PROXY-v2 payloads, never bound.

cargo +nightly fmt --all -- --check                                              exit 0
cargo +1.93.1 clippy --workspace --all-targets --all-features --locked -D warn   exit 0
cargo +1.93.1 test -p sozu-e2e --locked -- <the new modules>     7 passed, 0 failed

Several fixes that landed today were guarded only by unit tests inside
`lib/`. The largest gap was the listener slab-slot lifetime change, which
altered all four protocols but shipped a reactivation test for TCP alone;
HTTP, HTTPS and UDP rested on the argument that the four arms are
equivalent. An argument is not a test.

Ten tests, each seen red by reverting the merged production hunk, then
restored and proven byte-identical:

  - a reactivated listener still serves, for HTTP, HTTPS, TCP and UDP, with
    traffic sent after the activation response is read so the inline accept
    backlog cannot mask a deaf listener;
  - three add/remove cycles at one UDP address leak no listener session;
  - a forged PROXY-v2 LOCAL header cannot set the source address a TCP
    session is charged against, and closes an expect_proxy HTTP session,
    while a PROXY header carrying the same block is still honoured;
  - a TCP cluster with expect_proxy survives a client that completes the
    handshake and sends nothing;
  - a --path-equals frontend is refused on re-add and stops routing when
    removed;
  - a listener answer template carrying an out-of-range status does not kill
    the worker, and stays unselectable.

The UDP add/remove test stops the worker with `hard_stop`, deliberately:
under the mutation it is written to catch, a leaked listener session holds
the session count above zero and `soft_stop` never returns, which would hang
CI instead of reddening. The leak is observed before the stop either way.

Two bounds on what e2e can reach are now recorded in `e2e/COVERAGE.md` and
`doc/testing.md` rather than left to be rediscovered. `MultiLineWriter` is
constructed only by the `file://` logging backend, which the e2e harness
never selects. And `kawa_h1`'s status-metric path is unreachable from any
binary: neither `HttpStateMachine` nor `HttpsStateMachine` has a
`kawa_h1::Http` variant and `Http::new` has no caller, which a probe
confirmed by panicking on entry and never firing across four proxied
sessions while firing immediately in the function's own unit test.

A first attempt at covering that path passed with the production assertion
restored, so it was deleted rather than kept: a test that cannot fail is
worse than none. The reachable half of the same fix — a control-plane answer
template — is covered instead.

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit aa90ae7 into main Sep 19, 2026
40 of 41 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the test/e2e-hardening-coverage branch September 19, 2026 09:22
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