Skip to content

test(node): settle the inbound-stream counters before one-shot metrics reads - #2716

Merged
thiras merged 4 commits into
mainfrom
claude/busy-khorana-7c1737
Oct 28, 2026
Merged

thiras merged 4 commits into
mainfrom
claude/busy-khorana-7c1737

Conversation

@yigitdot

@yigitdot yigitdot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

client_loopback tests read the encoded metrics once, as soon as the client saw the server's refusal, reset or last byte. The server meters the stream's reason, and then its completed/failed count, when its serve_stream task ends, after the client already has the reply (dispatch.rs, ServeEnd::meter then inbound_stream_ended). On a loaded runner the client wins that race and reads a counter one short.

Every read of a counter the serve task bumps now waits for the stream counts first, then reads the metrics once with the original assertions and messages:

  • refusals and resets: the existing support::assert_inbound_failures_attributed(&metrics, N), which also fails if the reason counters do not claim each failure exactly once (so an over-count times out instead of passing on its way up);
  • completed deliveries (the two first-byte-class checks): a new support::assert_inbound_streams_ended(&metrics, completed, failed) with the same deadline/sleep pattern.

28 call sites across 27 tests, including a_closing_pool_is_unfunded_to_its_lane_and_not_found_to_anyone_else (#2682), the_timestamp_gate_precedes_every_signed_refusal and stream_request_with_skewed_timestamp_resets_without_response (#2713). Left unchanged: reads of counters bumped before the reply goes out (idle close, serve cache hit) and … 0 reads, which cannot flake. The behavior under test is unchanged.

Verified: client_loopback 5× plus 2× at --test-threads 64, all 173 pass; raising one N by one times out with the metrics dump.

Closes #2682
Closes #2713

🤖 Generated with Claude Code

…k test

The test read the encoded metrics as soon as the client saw the second
refusal, but the server records the pool_closing reset reason when its
serve_stream task ends, after the response is on the wire (dispatch.rs
ServeEnd::meter). On a loaded runner the client wins that race and reads 1.

Adds a bounded wait_for_metric_line helper to tests/support (same
deadline/sleep pattern as assert_inbound_failures_attributed) and uses it
for the final counter assertion. The behavior under test is unchanged.

Closes #2682

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 28, 2026 18:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

…ck tests

the_timestamp_gate_precedes_every_signed_refusal and
stream_request_with_skewed_timestamp_resets_without_response read the
encoded metrics once, right after the client saw the reset or refusal. The
serve task meters a stream's end after the response is on the wire, so the
same race as the closing-pool test applies. Both now poll each counter line
with support::wait_for_metric_line.

Closes #2713

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yigitdot yigitdot changed the title test(node): poll the pool_closing counter in the closing-pool loopback test test(node): poll the reject counters in the client_loopback metric assertions Oct 28, 2026
@github-code-quality

github-code-quality Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main dd80ec3 claude/busy-khorana-... 4672c8d +/-
77% 77% 0%
View coverage of the 5 most impacted files.
File main dd80ec3 claude/busy-khorana-... 4672c8d +/-
crates/client/src/lib.rs 89% 89% 0%
crates/client/src/scheduler.rs 94% 94% 0%
crates/client/s...undle/engine.rs 65% 65% 0%
crates/node/src...s/client/mod.rs 91% 91% 0%
crates/protocol/src/framing.rs 92% 93% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 28, 2026 19:22 UTC

yigitdot and others added 2 commits October 28, 2026 22:06
…c1737

# Conflicts:
#	crates/node/tests/client_loopback.rs
…metrics read

The serve task meters a stream's reason and its completed/failed count after
the client has seen the stream end, so a metrics read taken right after a
refusal or delivery can see a counter one short. Polling one line for an exact
value hid that but could stop on a passing value an over-count goes through,
and split checks that belong to one snapshot.

Every client_loopback read of a counter the serve task bumps now first waits
on support::assert_inbound_failures_attributed (refusals and resets) or the new
support::assert_inbound_streams_ended (completed deliveries), then reads the
metrics once with the original assertions. wait_for_metric_line is gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yigitdot yigitdot changed the title test(node): poll the reject counters in the client_loopback metric assertions test(node): settle the inbound-stream counters before one-shot metrics reads Oct 28, 2026
@yigitdot
yigitdot requested a review from thiras October 28, 2026 19:20
@thiras
thiras merged commit f2bc01c into main Oct 28, 2026
37 checks passed
@thiras
thiras deleted the claude/busy-khorana-7c1737 branch October 28, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants