Skip to content

test(h1): cover the 400 arm that ends a linked backend stream - #1754

Merged
FlorentinDUBOIS merged 3 commits into
mainfrom
test/h1-400-arm-ends-backend-stream
Oct 1, 2026
Merged

FlorentinDUBOIS merged 3 commits into
mainfrom
test/h1-400-arm-ends-backend-stream

Conversation

@FlorentinDUBOIS

@FlorentinDUBOIS FlorentinDUBOIS commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

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.

…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]>
#1719 made both Position::Server arms of the parse-error branch in
ConnectionH1::readable end the linked backend stream. Only the
cut-response arm had 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.

a_request_error_answered_400_after_linking_ends_the_backend_stream links
a pooled mock H1 backend, reads its complete response without starting
it on the client's wire, then sends a malformed chunk. It asserts that
the stream leaves backend_streams, and that the backend no longer
carries it and is Disconnecting, not pooled.

Seen red with the 400-arm block removed: "the rejected stream must leave
the backend reverse index". Green with it.

CHANGELOG: the #1716 entry names the new test.

Follow-up to #1719.

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the test/h1-400-arm-ends-backend-stream branch from 082e805 to 9d568be Compare October 1, 2026 11:23
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 4f0fc93 into main Oct 1, 2026
28 checks passed
FlorentinDUBOIS added a commit that referenced this pull request Oct 1, 2026
On an HTTP/1.1 frontend, `ConnectionH1::writable` handled only 100 and 103 from an HTTP/1.1 backend as interim. Any other 1xx (102, or an unassigned 104-199) took the final-response path: the stream was unlinked and the backend returned to the keep-alive pool while its final response was still due.

RFC 9110 §15.2 makes every 1xx interim. The 103 arm now covers 102-199, so the stream stays linked and the final response follows on the same backend connection. 100 and 101 keep their own handling. The access-log tag of an interim response on an unlinked stream becomes `H1::Interim`.

Tests: `test_h1_interim_102_before_final` and `test_h1_interim_150_before_final` (e2e) send an interim then a 200 on a keep-alive backend, then a second exchange on the same connections.

Fixes #1733


Stacked on #1754.



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