Repository navigation
test(e2e): give try_msg_close a failure path, and stop running 100 iterations that cannot fail - #1433
Merged
Merged
Conversation
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 22, 2026 08:49
FlorentinDUBOIS
force-pushed
the
test/e2e-msg-close
branch
from
September 22, 2026 11:01
33ecca6 to
9505520
Compare
try_msg_close had no State::Fail anywhere in its body: its only State:: expression was the State::Success it ended on, and the response it read was handed to println! and discarded. It ran 100 consecutive iterations of a check that could not go red, so its green was not evidence of the connection-close behaviour its name claims, while occupying the slot a real test would take. It now observes four things, each bounded by its own deadline and each returning State::Fail: the keep-alive exchange completes, the frontend session is still open and idle when SoftStop is sent, that SoftStop closes it with a bare half-close and no extra byte on the wire, and the worker then terminates. The production code so covered is Mux::shutting_down, reached through HttpSession::shutting_down from Server::shut_down_sessions. The liveness check is what makes the close assertion mean anything. A read that ends at EOF cannot distinguish "SoftStop closed the idle session" from "there was no idle session left to close", so a regression that dropped keep-alive and closed every frontend after one response would pass without it. It peeks the socket over a 300ms window, which makes the EOF that follows attributable to SoftStop. Not proved caused by it: the window ends before soft_stop() is sent, so a close inside that remaining gap would still read as a pass. Nothing else is in flight there, and the test records the bound as a known limitation. The worker-termination check is bounded too. Worker::wait_for_server_stop is JoinHandle::join, which returns Err only on a panic, so a worker that merely never terminates hung the process instead of failing the test; it is now reached through a JoinHandle::is_finished poll under a deadline. Every failing path also stops and joins its worker, because that join is the only site reclaiming the two scm UnixStreams and Worker has no Drop. The read loops of e2e/src/tests/tests.rs collapse from four to one: receive_with_deadline and assert_client_eof are now thin wrappers over a single read_until, which reads the TcpStream directly because Client::receive reports a half-close and an expired read timeout as the same None. A timed-out partial read is reported as an incomplete response instead of borrowing the wording of the protocol assertion, and the response budget rises from 500ms to the 1s its siblings in this file already use. n drops from 100 to 3. Every step blocks on its own deadline instead of on a thread::sleep(100ms) landing on the right side of a race, so one iteration already proves the property; nothing asserted here is statistical. Three back-to-back iterations in one process are not three independent draws of the SoftStop-versus-event-loop ordering either, since the response has just been written and the loop is parked in epoll every time. What the repetition buys is a cheap re-exercise of worker spawn, port allocation and teardown. Nothing distinguishes 3 from 2; what is being removed is 100. The choice does not rest on popularity: over the 402 real repeat_until_error_or source call sites on main, n=5 is the modal value, not n=3. Seen red three times before green, against production code that was then restored: the keep_alive_frontend arm of ConnectionH1::writable inverted (lib/src/protocol/mux/h1.rs), Mux::shutting_down_inner returning false from its final can_stop arm, and an inverted Method::Head test in HttpContext::on_response_headers. All three recipes are recorded in the test's doc comment. The seven TLS handshake tests that also run at n=100 all delegate to try_tls_with_cert, which fails on an unresolved response and on a backend that saw no request; they do not share this defect. They do share the unbounded join, which this changeset does not fix. Closes #1426 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
test/e2e-msg-close
branch
from
September 22, 2026 11:20
9505520 to
fa38080
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
try_msg_close had no State::Fail anywhere in its body: its only State::
expression was the State::Success it ended on, and the response it read was
handed to println! and discarded. It ran 100 consecutive iterations of a check
that could not go red, so its green was not evidence of the connection-close
behaviour its name claims, while occupying the slot a real test would take.
It now observes four things, each bounded by its own deadline and each returning
State::Fail: the keep-alive exchange completes, the frontend session is still
open and idle when SoftStop is sent, that SoftStop closes it with a bare
half-close and no extra byte on the wire, and the worker then terminates. The
production code so covered is Mux::shutting_down, reached through
HttpSession::shutting_down from Server::shut_down_sessions.
The liveness check is what makes the close assertion mean anything. A read that
ends at EOF cannot distinguish "SoftStop closed the idle session" from "there
was no idle session left to close", so a regression that dropped keep-alive and
closed every frontend after one response would pass without it. It peeks the
socket over a 300ms window, which makes the EOF that follows attributable to
SoftStop. Not proved caused by it: the window ends before soft_stop() is sent,
so a close inside that remaining gap would still read as a pass. Nothing else
is in flight there, and the test records the bound as a known limitation.
The worker-termination check is bounded too. Worker::wait_for_server_stop is
JoinHandle::join, which returns Err only on a panic, so a worker that merely
never terminates hung the process instead of failing the test; it is now reached
through a JoinHandle::is_finished poll under a deadline. Every failing path also
stops and joins its worker, because that join is the only site reclaiming the
two scm UnixStreams and Worker has no Drop.
The read loops of e2e/src/tests/tests.rs collapse from four to one:
receive_with_deadline and assert_client_eof are now thin wrappers over a single
read_until, which reads the TcpStream directly because Client::receive reports a
half-close and an expired read timeout as the same None. A timed-out partial
read is reported as an incomplete response instead of borrowing the wording of
the protocol assertion, and the response budget rises from 500ms to the 1s its
siblings in this file already use.
n drops from 100 to 3. Every step blocks on its own deadline instead of on a
thread::sleep(100ms) landing on the right side of a race, so one iteration
already proves the property; nothing asserted here is statistical. Three
back-to-back iterations in one process are not three independent draws of the
SoftStop-versus-event-loop ordering either, since the response has just been
written and the loop is parked in epoll every time. What the repetition buys is
a cheap re-exercise of worker spawn, port allocation and teardown. Nothing
distinguishes 3 from 2; what is being removed is 100. The choice does not rest
on popularity: over the 402 real repeat_until_error_or source call sites on
main, n=5 is the modal value, not n=3.
Seen red three times before green, against production code that was then
restored: the keep_alive_frontend arm of ConnectionH1::writable inverted
(lib/src/protocol/mux/h1.rs), Mux::shutting_down_inner returning false from its
final can_stop arm, and an inverted Method::Head test in
HttpContext::on_response_headers. All three recipes are recorded in the test's
doc comment.
The seven TLS handshake tests that also run at n=100 all delegate to
try_tls_with_cert, which fails on an unresolved response and on a backend that
saw no request; they do not share this defect. They do share the unbounded join,
which this changeset does not fix.
Closes #1426
Signed-off-by: Florentin Dubois [email protected]