Skip to content

e2e: the CONTINUATION drain test no longer detects a forced SendInitial since #1625 #1637

Closed

Description

@FlorentinDUBOIS

Summary

Since #1625 (58550dd4), test_h2_continuation_survives_a_graceful_drain_mid_reassembly (e2e/src/tests/h2_tests.rs) no longer detects the mutation it was built to catch in sozu#1453. The paragraph in doc/testing.md that uses it as the worked example ("A test for a guarantee that protects a mid-frame window has to reach that window…") is therefore out of date.

The mutation

In H2DrainState::begin_graceful_drain (lib/src/protocol/mux/h2_drain.rs), force GracefulDrainDecision::DeferInitial to SendInitial:

let decision = if false && reassembly_in_progress {
tree e2e test with the mutation
0155d40b (before #1625) red in 7.5 s: sozu never completed stream 3's header block
58550dd4 (after #1625), unmodified test green, 2/2 runs

Runs were on one pinned CPU, in an isolated network namespace, with the test alone.

The sozu-lib unit tests still catch the mutation (4 failures, among them h2::tests::a_legitimate_continuation_survives_a_graceful_goaway and three h2_drain::tests). They catch it by asserting the internal initial_goaway_pending flag, though. No test observes it on the wire any more.

Why

Since #1625, send_initial_goaway queues the GOAWAY in ConnectionH2::output and no longer clears zero.storage. The header block is also accumulated in ConnectionH2::header_reassembly, not in zero. The module doc of h2_drain.rs already says so ("Historical since #1604 … The deferral below survives as a drain policy — it delays an advisory frame until the block completes"). So the hazard DeferInitial guarded, a GOAWAY clobbering a half-read CONTINUATION, can no longer occur. The e2e test asserts exactly that absence of corruption, so it now passes with or without the deferral.

What is still observable

The deferral now changes only when the advisory GOAWAY leaves:

  • with DeferInitial, it leaves once the block completes, after the client's second CONTINUATION chunk;
  • with SendInitial, it leaves in the same shut_down_sessions() pass that lands the drain, before that chunk.

Proposal: a discriminating e2e check without a timer

The test already waits for server.live == 0. Server::run writes that gauge and then calls shut_down_sessions() in the same loop iteration. Mux::shutting_down_inner calls graceful_goaway and then flush_output_buffer() in that call. The query that returns 0 is answered in a later iteration.

So under SendInitial, the advisory GOAWAY's TLS record has already been written to the socket by the time the test observes live == 0. At that point, and before writing the second chunk, the test can:

  1. put the socket in non-blocking mode and drain what is already readable (read_tls until WouldBlock, then process_new_packets);
  2. assert that no GOAWAY frame is present, then restore blocking mode and continue as today;
  3. keep the existing end-of-test assertion that a GOAWAY is eventually observed (drain_witnessed).

This checks the order of events through causality, not through a wait: nothing sleeps, and a wrong order is already in the kernel buffer when the check runs. It should turn red under the mutation above. That still has to be confirmed by running it, together with the assumption that flush_output_buffer() pushes the record through rustls to the socket on that pass and not only on the next writable().

Two things to decide:

  • Keep DeferInitial? If it is kept as a drain policy, the check above pins it on the wire.
  • Remove it (the h2_drain.rs doc calls that "a behaviour change of its own")? Then the flag, its unit tests and the doc paragraph go together, and the e2e test keeps only its corruption assertion.

Either way, the doc/testing.md paragraph needs to be rewritten, because its worked example no longer demonstrates what it claims.

Activity

  1. added 4 commits that reference this issue on Sep 28, 2026
    00a8f71
    c3d6999
    dbc7e25
    0664483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions