Skip to content

test(e2e): expect the client connection to close after a 400 for an unfinished request - #1748

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
fix/e2e-trailer-split-close-expectation
Oct 1, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
fix/e2e-trailer-split-close-expectation

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Follow-up to #1719 and #1726.

Problem

test_h1_trailer_field_limit_exceeded_split_closes_backend fails on main since #1719 was squash-merged on top of #1726. After a 400 for an over-bound trailer section, the test expected a follow-up request on the same client connection to be served.

#1726 closes the H1 client connection when a response completes before its request was received whole (request-incomplete). An over-bound trailer section leaves the request unfinished. Its end cannot be found, so the connection cannot carry another request (RFC 9112 §6.3). The close is intended. The test expectation was wrong.

Change

Test-side only, plus doc corrections. No runtime change.

  • The test now checks that the client connection reads EOF after the 400 with no further bytes, and that a follow-up request reaches no backend. The other checks are kept: head and body forwarded, 400 answered, and the backend connection holding the cut request closed. The 400 template still omits Connection: close, so the close can only come from the incomplete request.
  • CHANGELOG (H1 request rejected after linking leaves the backend stream attached: backend holds a cut request, index desyncs #1716 entry), lib/src/protocol/kawa_h1/LIFECYCLE.md §2.3 and the 400-arm comment in lib/src/protocol/mux/h1.rs said the client connection stays as persistent as the answer's Connection header. They now say it closes.

Coverage gap: since #1726, removing the 400-arm end_stream block from ConnectionH1::readable no longer turns this test red. The client close tears the backend down as well, and no backend_streams panic fires. The test doc says so. The 400 arm of #1719 has no dedicated unit test. The cut-response arm keeps one.

Test

Unmodified test on origin/main (c2cad338..3d3f077b), red:

TRAILER-LIMIT-SPLIT-BACKEND-CLOSE: backend accepted=true received 365 bytes ending "...\r\n\r\n5\r\nHello\r\n0\r\n", client got Some("HTTP/1.1 400 Bad Request"), backend_closed=true, follow-up got ""
TRAILER-LIMIT-SPLIT-BACKEND-CLOSE: FAIL — the next request on the client connection was not served
test result: FAILED. 0 passed; 1 failed

Updated test, green (3 iterations):

TRAILER-LIMIT-SPLIT-BACKEND-CLOSE: backend accepted=true received 365 bytes ending "...\r\n\r\n5\r\nHello\r\n0\r\n", client got Some("HTTP/1.1 400 Bad Request"), backend_closed=true, client_closed=true, after the 400 "", reaccepted=false
test result: ok. 1 passed; 0 failed

Validation

Check Exit code Result
cargo +nightly fmt --all --check 0
cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings 0
RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps 0
cargo test -p sozu-e2e --locked --features opentelemetry,splice,simd -- h1_security_tests, 3 runs 0, 0, 0 41 passed each time
cargo test -p sozu-e2e ... -- test_h1_early_response_mid (#1726) 0 2 passed
cargo test -p sozu-lib --all-features --locked --lib -- protocol::mux::h1 0 21 passed, including the #1719 and #1726 unit tests
cd fuzz && cargo +nightly fuzz build 0
check_doc_citations.py --self-test, --root ., --root . --base origin/main, --audit --root . 0, 0, 0, 0

…nfinished request

test_h1_trailer_field_limit_exceeded_split_closes_backend (#1719) checked
that a follow-up request on the same client connection was served after a
400 for an over-bound trailer section. #1726, merged first, closes the H1
client connection when a response completes before its request was
received whole. An over-bound trailer section leaves the request
unfinished: its end cannot be found, so no further request can be read
from that connection (RFC 9112 §6.3). The close is the intended
behaviour, and the follow-up expectation contradicted it, which turned
main red.

The test now checks that, after the 400, the client connection reads EOF
with no further bytes and that a follow-up request reaches no backend.
The other checks are unchanged: head and body forwarded, 400 answered,
backend connection holding the cut request closed.

Since #1726, removing the block of ConnectionH1::readable that ends the
backend stream before the 400 no longer turns this test red: the client
close tears the backend down too. The test doc says so. The 400 arm of
#1719 has no dedicated unit test.

CHANGELOG (#1716 entry), kawa_h1/LIFECYCLE.md §2.3 and the 400-arm
comment in mux/h1.rs said the client connection stays as persistent as
the answer's Connection header; they now say it closes. No runtime
change.

Follow-up to #1719 and #1726.

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 5196228 into main Oct 1, 2026
51 of 52 checks passed
FlorentinDUBOIS added a commit that referenced this pull request Oct 1, 2026
…er drain test (#1739)

`test_h2_graceful_shutdown_completes_large_transfer` slept a fixed 200 ms before `soft_stop`, assuming its request had reached the backend. Under load it had not, so the worker refused the not-yet-opened connection or stream and the test failed without exercising the drain.

The backend now holds its response (`DelayedH2Backend::start_held`), the test waits until the request has reached it, issues `soft_stop`, then releases the response. The response is therefore still owed when the drain starts, independent of load. Test-only change; CHANGELOG updated.

A distinct, rarer reset of an already-completed response under heavy load remains and is out of scope for this change.

Fixes #1736


Stacked on #1748.



Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Oct 1, 2026
Follow-up to #1719.

## Problem

#1719 made both `Position::Server` arms of the parse-error branch in `ConnectionH1::readable` (`lib/src/protocol/mux/h1.rs`) end the linked backend stream. Only the cut-response arm has a unit test. The 400 arm relied on the e2e test `test_h1_trailer_field_limit_exceeded_split_closes_backend`, which no longer catches a regression there: since #1726 the client connection closes after a 400 for an unfinished request, and that close tears the backend down too (see #1748).

## Change

Test only. `a_request_error_answered_400_after_linking_ends_the_backend_stream` links a pooled mock H1 backend and reads its complete response without starting it on the client's wire, then sends a malformed chunk. It asserts that the request is answered on the client connection, that the stream leaves `backend_streams`, and that the backend no longer carries it and is `Disconnecting`, not pooled. The CHANGELOG #1716 entry names the new test.

## Test

Red, on a `git archive` copy with the 400-arm block removed:

```
test protocol::mux::h1::tests::a_request_error_answered_400_after_linking_ends_the_backend_stream ... FAILED
panicked at lib/src/protocol/mux/h1.rs:2677:9:
the rejected stream must leave the backend reverse index
test result: FAILED. 2 passed; 1 failed
```

Green, on this branch:

```
test protocol::mux::h1::tests::a_request_error_answered_400_after_linking_ends_the_backend_stream ... ok
test result: ok. 3 passed; 0 failed
```

## Validation

| Check | Exit code | Result |
|---|---|---|
| `cargo +nightly fmt --all --check` | 0 | |
| `cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings` | 0 | |
| `RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps` | 0 | |
| `cargo test -p sozu-lib --all-features --locked` | 0 | 1465 unit tests passed; integration tests passed |
| `cd fuzz && cargo +nightly fuzz build` | 0 | |
| `check_doc_citations.py` `--self-test`, `--root .`, `--root . --base origin/main`, `--audit --root .` | 0, 0, 0, 0 | |


Stacked on #1739.



Signed-off-by: Florentin Dubois <[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