Skip to content

e2e: test_issue_806 asserts != State::Fail, so the timing budget it measures passes the test and short-circuits its own 100 iterations #1427

Closed

Description

@FlorentinDUBOIS

test_issue_806 (e2e/src/tests/tests.rs) asserts:

assert!(
    repeat_until_error_or(
        100,
        "issue 806: timeout with invalid back token\n(not fixed)",
        || try_backend_stop(2, None)
    ) != State::Fail
);

State (e2e/src/tests/mod.rs) has three variants — Success, Fail, Undecided. != State::Fail
therefore passes on two of the three, and the outcome it silently accepts is the one this test exists
to measure.

What Undecided means here

try_backend_stop (e2e/src/tests/tests.rs) ends with:

if !success {
    State::Fail
} else if duration > Duration::from_millis(100) {
    // Reconnecting to unother backend should have lasted less that 100 miliseconds
    State::Undecided
} else {
    State::Success
}

Undecided is the 100 ms budget being blown. That budget is the property issue 806 is about, and
the assertion accepts it as a pass.

It is worth being exact about what duration measures, because the production comment sitting on
that branch is not. duration opens at e2e/src/tests/tests.rs:356 and closes at :369, so it
covers the entire request loop: both client.send() / client.receive() round trips, plus
backend1.stop_and_get_aggregator() at :366, which is the call that forces the reconnect in the
first place. The comment at :385 describes the whole span as "reconnecting to unother backend",
which is the same conflation. So Undecided means "two request round trips plus a backend teardown
plus a reconnect exceeded 100 ms", not "the reconnect blew its 100 ms budget". That makes the signal
looser than the comment claims — and a loose signal being accepted silently is worse, not better.

The 100 iterations are worse than they look

repeat_until_error_or(n, ..) is a stability check, not a retry: it stops at the first iteration that
does not return Success (#1410). Undecided is such an iteration, so one slow reconnect on trial 1
ends the check after a single trial, returns Undecided, and the assertion passes.

The advertised 100 consecutive trials therefore only actually run when every reconnect stays under
100 ms. On any box slow enough to blow the budget once, the test degenerates to "run until the first
slow reconnect, then pass". The 100 buys iterations exactly when they are cheapest and abandons them
exactly when they would be informative.

What actually survives the loose assertion

Not "the client failed to complete its requests" — the residual check is far narrower than that.

success is worker.wait_for_server_stop() (e2e/src/tests/tests.rs:372), and that returns false
only when server_job.join() comes back Err (e2e/src/sozu/worker.rs:403-409) — that is, only
when the worker thread panicked. A client that cannot send or receive sets no flag at all: both
failure paths simply break out of the request loop (:358-364), and the request/response counters
are only printed afterwards (:374-377). Nothing in the returned State depends on them.

Worse, breaking out early shortens duration (:356 → :369), which pushes the result toward the
<= 100 ms arm. A client that fails on its first request therefore makes State::Success more
likely, not less.

So what survives != State::Fail is a panic check on the worker thread, and nothing else. The defect
is worse than "the timing property is not asserted": neither of the two properties a reader would
expect this test to hold — the timing budget and the client completing its requests — is asserted at
all.

Why this is an issue and not a drive-by fix

The surrounding comment says // This should actually be a success and the description string says
(not fixed), so the loose assertion looks deliberate: the property does not hold, and a green test
was preferred to a red one. Tightening it is a decision about issue 806's status, not a cleanup.
The options, as far as I can see:

  • assert State::Success and let it fail while 806 is open, parking it with #[ignore = "..."] and a
    reason. CONTRIBUTING.md does say #[ignore] may "gate an environment dependency or a tracked
    follow-up" — but the same sentence says it "must never hide a failing test", which is exactly what
    this option does. Citing that rule in support of the option without naming the tension would be
    dishonest; whether a tracked 806 follow-up earns the exception is a maintainer call, not something
    this issue can settle;
  • keep != State::Fail but require the check to have actually completed its trials, so a pass cannot
    come from a first-trial short-circuit;
  • drop n to 1, since a check that stops at the first non-Success and accepts that outcome gains
    nothing from 100;
  • separately, and independently of which of the above is chosen: give the client failure paths at
    :358-364 a flag of their own, so that half of the test's intent is asserted rather than printed.

Whichever is chosen, the current shape reports green on the exact outcome it should be reporting.

How it was found

Reviewing every caller of repeat_until_error_or while clarifying its semantics (#1410). This is the
only != State::Fail assertion in the suite: grep -rn '!= State::Fail' e2e/src/tests/ returns one
hit.

Activity

  1. FlorentinDUBOIS commented on Sep 23, 2026

    @FlorentinDUBOIS
    CollaboratorAuthor

    Resolved on main by d8b8546e (#1460), which landed the production fix and rewrote this test around it. Closing against measurement rather than inspection.

    What the issue asked for, and where each ask stands at c9dd662a

    ask state
    Option 4 — give the client failure paths a flag of their own done: client_completed_requests (e2e/src/tests/tests.rs:563, :568, :577) returns State::Fail at :617-627
    Assert the timing budget done, and harder than this issue proposed: the assertion is now assert_eq!(.., State::Success), with no #[ignore]
    Make a blown budget visible superseded: a breach is State::Fail at :683-693 and prints duration and budget. Undecided (:661) no longer means a blown budget — it means the warm-up missed backend1, and assert_eq!(Success) rejects that too
    Fix the "reconnecting to unother backend" comment, which described the wrong span done: git grep unother origin/main -- e2e/ returns nothing, and the measured span is now the reconnect round trip alone (:566→:575) rather than two round trips plus a teardown
    Option 3 — drop n from 100 to 1 deliberately not done, and the tree now argues against it

    git log -S pins all of it to one commit: client_completed_requests, unother and RECONNECT_BUDGET all trace to d8b8546e.

    Why option 3 is not merely stale but structurally dead

    This issue's argument for dropping n was that 100 buys nothing because repeat_until_error_or stops at the first non-Success and the assertion accepts that outcome. The second half is no longer true: nothing non-Success is accepted, so n = 100 now requires exactly the 100 consecutive clean trials it advertises.

    The comment above the test states the case directly, and it is the correct one:

    The assertion must not be loosened. != State::Fail and the unasserted response status are what kept this test green across that 4.3%; restoring either would certify the defect rather than report it, and so would dropping n far enough for a 4.3% per-trial rate to stop showing.

    The worry this issue raised about asserting the budget does not survive measurement

    The concern was that asserting Success would make CI red on a loaded box. Measured at c9dd662a on a box under concurrent cargo test load (~1.5–2.4):

    20 isolated runs — 20 passed, 0 undecided, 0 failed. 2000 reconnect samples, 0 over budget. Min 0.235 ms, median 0.563 ms, p99 0.874 ms, max 1.679 ms against a 100 ms budget — the worst of 2000 samples used 1.68% of it, roughly 60× headroom. Consistent with the 2026-09-22 figures recorded in the landed comment (median 0.636 ms, max 1.462 ms).

    That headroom exists because the budget now bounds the reconnect alone. This issue's objection was calibrated against the old span, which also included two request round trips and a backend teardown — so the objection was correct when written and was answered by narrowing what is measured, not by loosening what is asserted.

    One piece of housekeeping this leaves

    d8b8546e's trailer is Closes #1442, so this issue was never auto-closed; #1427 appears only in a code comment (tests.rs:478, "the pre-#1427 shape"). Nothing else outstanding.

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