Skip to content

test(e2e): print hyper's error cause chain and name large-payload conjuncts - #1395

Merged
FlorentinDUBOIS merged 2 commits into
mainfrom
test/e2e-budget-and-conjuncts
Sep 21, 2026
Merged

FlorentinDUBOIS merged 2 commits into
mainfrom
test/e2e-budget-and-conjuncts

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Addresses cause B of #1393 and the diagnosability gap that issue closes with.

Diagnostics only: no assertion, budget, conjunct or production code changes.

Cause B — client error (SendRequest) had no cause chain

Twice on CI, on different days and different crypto feature sets, a test got no response at all and
the helper printed only hyper's outer message:

Neither was a timeout — both helpers print a distinct message in that case and neither appeared. The
std::error::Error source chain underneath, which names the actual transport failure, was being
discarded.

https_client::format_error_chain now walks .source() and renders
<outer> | caused by [1]: … | caused by [2]: …, and every bare {error} print in
e2e/src/mock/https_client.rs and e2e/src/tests/protocol_pair_matrix.rs goes through it. Measured
against a closed port:

bare:    client error (Connect)
chained: client error (Connect) | caused by [1]: tcp connect error | caused by [2]: Connection refused (os error 111)

The existing distinct timeout messages are untouched — the fact that they did not appear in either
failure is load-bearing evidence.

Naming the failing conjunct in two large-payload guards

tls_tests::test_tls_connection_close_large_response had the same bare
assert_eq!(…, State::Success) shape and has never failed, so it was undiagnosable. It now names
which conjunct broke and distinguishes truncation from corruption. Verified by fault injection:

TLS-CONN-CLOSE-LARGE: FAIL - body TRUNCATED or padded: got 262134 bytes, expected 262144
TCP-SNI-LARGE-COALESCED: FAIL - payload CORRUPTED at matching length (1048832 bytes): first differing offset Some(600000)

For tcp_sni_tests, only what was previously silent is added — stopped, and the corruption offset
when the lengths match. That test already prints write_completed, backend_contacted,
byte_identical and routed_ok unconditionally, and that existing print is exactly how #1393 was
diagnosed, so it is not duplicated here.

The verdict is unchanged in both files.

Not included

Cause D of #1393, the 7 MB drain budget, is deliberately absent. Deriving it needs measured
local runs in the style of ISSUE_810_SHUTDOWN_BUDGET; raising the bound to reach green is not on
the table, and a wrong derivation would be worse than an unchanged test. It stays open on #1393.

Twice on 2026-09-21, on different crypto feature sets, an e2e request got
no response and the test printed only hyper's opaque outer message:
`hsts_tests::test_hsts_on_https_unreachable_503` printed "Could not get
response: client error (SendRequest)" and
`protocol_pair_matrix::basic_auth::test_h2_h1` printed "matrix request
failed: client error (SendRequest)". Neither was a timeout: both helpers
print a distinct timeout message at their 10 s deadline and neither
appeared, so the connection to sozu was closed before a response arrived
and the actual transport failure was discarded.

`client error (SendRequest)` is hyper's top-level Display; the
std::error::Error source chain underneath names the real cause (a TLS
alert, a ConnectionReset, an H2 GOAWAY) and was never walked. Add
`https_client::format_error_chain` -- one shared helper instead of
duplicating the walk at each call site -- and use it at every bare
`{error}` print in https_client.rs and protocol_pair_matrix.rs. An error
with no source renders identically to before, so no existing log line
loses information, and every existing distinct timeout message is
untouched.

Diagnostics only: no assertion, budget, conjunct or production code
changed.

To SEE THIS RED (probe, not committed): pointed a client at
`https://127.0.0.1:1`, an unused port.
  bare:    client error (Connect)
  chained: client error (Connect) | caused by [1]: tcp connect error |
           caused by [2]: Connection refused (os error 111)

Ran, with --nocapture:
`cargo +1.93.1 test -p sozu-e2e hsts_tests::test_hsts_on_https_unreachable_503`
and `cargo +1.93.1 test -p sozu-e2e protocol_pair_matrix::basic_auth::test_h2_h1`,
both `test result: ok. 1 passed; 0 failed`.
BUILD=0 CLIPPY=0 FMT=0 (cargo +1.93.1 build --all-features; cargo +1.93.1
clippy --all-features --all-targets -- -D warnings; cargo +nightly fmt
--all -- --check).

Ref: #1393
Signed-off-by: Florentin Dubois <[email protected]>
…ards

`tls_tests::try_tls_connection_close_large_response` collapsed six
distinguishable causes into one boolean and returned a bare `State::Fail`
with no output at all:

    let response_ok =
        headers.contains("HTTP/1.1 200") && body.len() == payload.len() && body == payload;
    if success && response_ok && requests_received == 1 && responses_sent == 1 {

Report each conjunct with its values on failure. The distinction that
matters most for a large-response delivery guard is truncation (a short
body -- the sozu#1279 close-before-flush shape) versus corruption at
equal length, which the collapsed boolean could not tell apart; they are
now reported separately, corruption with the first differing byte
offset. The verdict is unchanged: `failures.is_empty()` holds exactly
when the original conjunction did (`body_ok` true with `length_ok` false
is unreachable -- equal strings have equal length).

`tcp_sni_tests::try_tcp_sni_large_payload_coalesced_with_hello_delivered_intact`
already prints `write_completed`, `backend_contacted`, `byte_identical`,
`routed_ok` and both byte counts unconditionally, and that existing line
is exactly how sozu#1393 was diagnosed. Only the two real gaps are
closed: `stopped`, computed after that line and previously silent, and
the truncation/corruption distinction inside `byte_identical` when the
two byte counts already match. Nothing that line already names is
reprinted.

A second, already-committed branch (test/large-payload-diagnostics,
1e101690) also touches both files. Its tls_tests.rs half is
byte-identical to this change. Its tcp_sni_tests.rs half is not kept: it
additionally reprints `write_completed` and `routed_ok` on failure,
which duplicates that same unconditional line despite its own commit
message calling itself "strictly additive" -- exactly the duplication
this change avoids.

Diagnostics only: no assertion, budget or production code changed.

To SEE THIS RED (probe, not committed):
  tls_tests, 10 bytes dropped from the body before the checks:
    TLS-CONN-CLOSE-LARGE: FAIL - body TRUNCATED or padded: got 262134
    bytes, expected 262144
  tcp_sni_tests, one byte flipped at offset 600000 after the join:
    TCP-SNI-LARGE-COALESCED: FAIL - payload CORRUPTED at matching length
    (1048832 bytes): first differing offset Some(600000)

Ran, with --nocapture:
`cargo +1.93.1 test -p sozu-e2e tls_tests::test_tls_connection_close_large_response`
and `cargo +1.93.1 test -p sozu-e2e tcp_sni_tests::test_tcp_sni_large_payload_coalesced_with_hello_delivered_intact`,
both `test result: ok. 1 passed; 0 failed`.
BUILD=0 CLIPPY=0 FMT=0 (cargo +1.93.1 build --all-features; cargo +1.93.1
clippy --all-features --all-targets -- -D warnings; cargo +nightly fmt
--all -- --check).

Ref: #1393
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