Skip to content

test(e2e): wait for the request before soft-stopping the large-transfer drain test - #1739

Merged
FlorentinDUBOIS merged 2 commits into
mainfrom
fix/e2e-h2-graceful-shutdown-race
Oct 1, 2026
Merged

FlorentinDUBOIS merged 2 commits into
mainfrom
fix/e2e-h2-graceful-shutdown-race

Conversation

@FlorentinDUBOIS

@FlorentinDUBOIS FlorentinDUBOIS commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

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.

…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]>
…er drain test

test_h2_graceful_shutdown_completes_large_transfer slept a fixed 200 ms
after starting its request and then issued soft_stop, assuming the request
had reached the backend. Under load it had not: the worker rightly refused
the not-yet-opened connection or stream, and the test failed with a
connection-level error (connection refused, broken pipe, connection
closed) without ever exercising the in-flight drain it covers.

The backend now holds its response (DelayedH2Backend::start_held), the
test waits until the request has reached it, issues soft_stop, then
releases the 512 KiB response, so the response is still owed when the
soft stop is issued at any load. No production code changed.

Fixes #1736

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the fix/e2e-h2-graceful-shutdown-race branch from f5cad40 to f611432 Compare October 1, 2026 11:23
@FlorentinDUBOIS
FlorentinDUBOIS merged commit d469b16 into main Oct 1, 2026
28 checks passed
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.

test(e2e): graceful-shutdown large-transfer test races its own soft stop under load

1 participant