Skip to content

test(e2e): decode every H2 status probe and derive the 810 budget - #1390

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
test/e2e-assertion-correctness
Sep 21, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
test/e2e-assertion-correctness

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Three e2e assertions that passed while proving less than their names claimed. The production
diff is zero lines — git diff <base> HEAD -- lib/ bin/ command/ sim/ fuzz/ is empty — so
the "fix is test-shaped" check is vacuously N/A.

#1374 — nineteen indexed-status byte probes

All 19 (17 × contains(&0x8D), 2 × contains(&0x88)) now go through one helper built on the
decode_status from #1365. 0x8D is HPACK static index 13, which is :status 404 — not 400.
No live byte probe remains under e2e/src/tests/.

Every site turned out to mean 400; none meant 404. That was measured, not assumed: log_frames
was patched to print the decoded :status and all 18 affected tests were run at baseline. All
fifteen h2_security_tests.rs sites answer with RST_STREAM and no HEADERS frame at all, so
the term was dead under either reading.

One site was not dead, and it is the important one. test_h2_path_syntax_enforced's
deliberately accepted asterisk-with-OPTIONS case answers
HEADERS flags=0x04 stream=7 len=48 status=404, whose indexed byte is exactly 0x8D. Its inner
probe read that routed 404 as "sōzu emitted a 400". It stayed green only because the outer probe
was hardcoded to stream 1 while the case runs on stream 7 — two wrongs cancelling. Both are
now stream-scoped and decoded. That site's comment claiming 502 = 0x92 is also corrected: 0x92
is static index 18 (content-type), and 502 is not in the static table at all.

#1381 — rejection || !got_200 fail-opens

Both sites now assert the positive outcome and require that frames arrived at all.

A second fail-open turned up that the issue did not name: got_rejection_or_421 used
contains_goaway, which matches any GOAWAY — including the error_code=0x0 graceful close
that rides behind the 421 in that very test. So a 502 plus that close satisfied "a 421 or GOAWAY
was observed", which is exactly the distinction the issue says these assertions cannot make.
Narrowed to rejected_with_goaway_or_rst.

The control runs are the decisive evidence. With an empty-frames fault injected, the historical
assertions pass and the new ones fail:

injected empty frames, new assertions  -> FAILED. 0 passed; 3 failed
same fault, historical assertions       -> ok. 2 passed; 0 failed

#1376 — the 100 ms budget

Derived, not raised until green. 100 ms is exactly one tick of the two grids the shutdown path
runs on: reset_loop_time_and_get_timeout clamps the poll timeout to a 100 ms shutdown_tick
while shutting down, and the timer wheel's tick_ms is 100 with duration_to_tick rounding to
the nearest tick, displacing a step by (delay_ms + tick_ms/2) mod tick_ms ∈ [0, 99] ms. The
budget is 3 ticks = 300 ms — one re-poll, one grid displacement, one scheduler quantum —
still 1/33 of DEFAULT_REQUEST_TIMEOUT.

The test is also strengthened: four exchange counters it printed and never asserted are now
asserted. Injecting a deleted client.receive() reddens it at 3.9 ms — inside budget, so the
historical duration > 100ms bound would have passed that run.

Deliberately not done

frames.is_empty() as an accepted outcome stays in two sites where it is documented policy.
#1374 flags it as deserving its own look; tightening it is a behavioural change with its own
evidence to gather, and the commit and CHANGELOG say so.

BUILD=0 CLIPPY=0 TEST=0 FMT=0 CITATIONS=0. The 26 affected e2e tests were run by exact name
with default features: test result: ok. 26 passed; 0 failed; finished in 1409.14s, including
test_issue_810_timeout's full 100 iterations.

Closes #1374
Closes #1376
Closes #1381

Three e2e assertions that passed while proving less than their names
claimed.

Nineteen indexed-status byte probes scanned a HEADERS payload for `0x8D`
(17) or `0x88` (2), in `h2_security_tests.rs` (16) and
`h2_security_header_injection.rs` (3). `0x8D` is HPACK static index 13,
`:status 404`; `:status 400` is index 12, `0x8C`. Sōzu answers an indexed
`0x8d` 404 when the router finds no cluster, so a request it accepted and
routed satisfied a term named `got_400` and reported itself as a
rejection. A byte scan also fires on a length octet: RFC 7541 §5.1 writes
a 268-byte header value as `7f 8d 01`. All nineteen go through one
helper, `stream_status_matches`, built on the existing `decode_status`,
which reads the first field of the block so neither a later field nor a
length octet can answer for the status.

The label was right and the byte was wrong at every site: each of those
tests sends a malformed request and documents RFC 9113's "stream error or
400" contract, so every site decodes 400 and the comments are corrected
rather than the assertions retargeted at 404. Measured before converting:
every iteration of all fifteen `h2_security_tests.rs` sites reports
`400: false` and produces no HEADERS frame at all. One site was not dead.
The `asterisk-with-OPTIONS` case of `test_h2_path_syntax_enforced` — its
deliberately accepted case — answers `HEADERS stream=7 status=404`, and
its inner `protocol_error` probe read that as a 400. It stayed green only
because the outer `rejected` probe was hardcoded to stream 1 while the
case runs on stream 7; both are stream-scoped and decoded now.
`h2_400_terms_decode_the_status_field_not_the_0x8d_byte` is the negative
half. Closes #1374.

Two assertions written `rejection || !got_200` passed when the worker
returned nothing, because `got_200` is derived from frames that may never
arrive: a silent reset, a timeout collecting zero frames or a worker that
died between phases all read as success.
`try_strict_sni_binding_toggle` (`listener_update_tests.rs`) asserts
`got_rejection_or_421 && !got_200`, and narrows that term from
`contains_goaway` — which matches the `GOAWAY(NO_ERROR)` graceful close
riding behind the 421, so a 502 followed by the same close answered "a
421 or GOAWAY was observed" — to `rejected_with_goaway_or_rst`.
`try_h2_invalid_status_rejected` (`h2_security_header_injection.rs`)
asserts `got_frames && (protocol_rejection || got_502) && !got_200`.
Closes #1381.

`test_issue_810_timeout` asserted a zero-slack 100 ms shutdown budget 100
times over, one breach failing the run. 100 ms is not a margin there, it
is exactly one tick of the two grids the shutdown path runs on:
`Server::reset_loop_time_and_get_timeout` clamps the poll timeout to a
100 ms `shutdown_tick` while `shutting_down.is_some()` and
`shut_down_sessions` runs once per loop iteration, so any iteration after
the first costs a full `poll()` block; and the timer wheel's default
`tick_ms` is 100 ms with `duration_to_tick` rounding to the NEAREST tick,
displacing a timer-driven step by `(delay_ms + tick_ms / 2) mod tick_ms`
∈ [0, 99] ms. `ISSUE_810_SHUTDOWN_BUDGET` is three of those ticks — one
re-poll, one grid displacement, one scheduler quantum — still 1/33 of
`DEFAULT_REQUEST_TIMEOUT` and 1/200 of `DEFAULT_FRONT_TIMEOUT`, so a
shutdown that waits for a session timeout misses it by two orders of
magnitude. The test also asserts the four exchange counters it used to
print and never check. Closes #1376.

`log_frames` prints the decoded `:status` of every HEADERS frame, which
is what surfaced the stream-7 404. `e2e/COVERAGE.md` and `CHANGELOG.md`
carry the inventory, the 400-vs-404 decision and the tick derivation.
`frames.is_empty()` as an accepted outcome is deliberately untouched and
stays open on #1374.

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 92f51ce into main Sep 21, 2026
24 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the test/e2e-assertion-correctness branch September 21, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant