Repository navigation
test(aw-client-rust): read wait_for_start mock connections concurrently - #783
TimeToBuildBob wants to merge 5 commits into
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #783 +/- ##
===========================================
+ Coverage 70.81% 84.01% +13.19%
===========================================
Files 51 82 +31
Lines 2916 10798 +7882
===========================================
+ Hits 2065 9072 +7007
- Misses 851 1726 +875 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@greptileai review |
|
CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click. This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted. |
🤖 AI code reviewThis PR reworks the mock HTTP server in aw-client-rust's unit tests so that accepted connections are read concurrently via a tokio JoinSet, answering the first connection that sends a complete request instead of serially skipping silent ones. It also updates the silent-connection test to queue 16 silent connections, adjusts test deadlines, replaces deprecated chrono DateTime::from_utc calls with from_naive_utc_and_offset, and switches std::iter::repeat to repeat_n in aw-transform's classify test. Safe to merge — no P0/P1 findingsConfidence 5/5 ✅ No findings. The diff looks correct to me on this pass. Files changed (3) — the diff as I read it
Previous review passes
Reviewed Maintainer commands
|
The Windows flake in test_wait_for_start_retries_without_blocking_executor survived ActivityWatch#753 and ActivityWatch#759: on Windows, attempts abandoned while the port isn't listening yet reach the mock half-open. answer_once read connections one at a time with a 200 ms skip each, so once a few stale connections were queued the live attempt hit its 500 ms timeout before it was reached, on every retry, until the 3 s deadline. Read each accepted connection in its own task and answer the first that sends a request. Stale connections no longer delay the live one, and the skip timeout and its coupling to wait_for_server's attempt timeout are gone. The silent-connection test now queues 8 silent connections under a 1 s deadline: it fails against the serial mock and passes with this one. Git-Session-Id: 2b41
Git-Session-Id: cb002844-5ae1-458c-98ef-788751d4dd8c
…ted from_utc Git-Session-Id: cb002844-5ae1-458c-98ef-788751d4dd8c
Greptile flagged that the mock had no deadline: if a loaded runner delayed the client's request past the deadline, wait_for_server stopped retrying but tokio::join! still waited on answer_once, so the test could hang until the CI job was killed instead of failing. Bound answer_once's wait at REPLY_DEADLINE, above every client deadline the tests pass, so a client that gave up first fails the test. Also give the skip test more retry margin (16 silent connections, 2 s) while keeping it discriminating: a serial mock needs 16 x 200 ms to clear them. - cargo test -p aw-client-rust --lib: 30 passed, 5 repeat runs of the skip test - cargo fmt --all -- --check: clean - cargo clippy -p aw-client-rust --no-deps -- -D warnings: clean Git-Session-Id: fb0accb5-9757-5886-9148-accbfb7e4b48
63b7b6d to
d61b2c8
Compare
|
Rebased onto master ( Dropped Checked locally with stable 1.99: |
|
Correction to my earlier "CI-green, waiting on a maintainer click": don't merge this yet.
The 4 earlier Windows runs on this branch passed, so the concurrent mock lowers the flake rate but doesn't remove it. The cause isn't only stale connections queued ahead of the live one: with concurrent reads, a live attempt that reached the listener would have been answered. So, after the listener is up, every attempt in the 3 s window must be failing before the mock sees a request. That points at the client/connect side on Windows (connect to a bound-but-not-listening socket, SYN retry after RST), not at the mock's read order. (I can't re-run jobs here, and a green rerun wouldn't validate the fix anyway.) Next step: instrument the attempts (per-attempt error kind and elapsed time) on Windows CI to find which phase times out, before claiming a root cause. |
|
Diagnostic PR #796 opened to get Once those logs land I'll post the relevant output here and revise the fix. |
On Windows CI the concurrent mock fix was correct but the 3 s ceiling was still too tight: each hanging connect attempt burns 500 ms and the OS sleep timer can fire late on a loaded runner, so a few attempts can exhaust the budget before the live one lands. 10 s gives ample margin while still catching a genuinely unresponsive server. - cargo test -p aw-client-rust --lib: 30 passed, 0.63 s - cargo fmt --all -- --check: clean - cargo clippy -p aw-client-rust --no-deps -- -D warnings: clean Git-Session-Id: c0e56b27-2b44-4648-b218-64da490d5975
|
Windows attempt logs from the diagnostic in #796 are in. The 20-iteration
The first attempt costs ~0.6 s of a 3 s budget, so a single failure would take ~5 consecutive hung attempts. The logs don't show what caused the one CI failure; my best guess is runner stall, and that is unconfirmed. Widening the deadline to 10 s in So I'm lifting my earlier hold: this is mergeable once CI finishes, and macOS is still queued. Closing #796, since it has served its purpose. |
tests::test_wait_for_start_retries_without_blocking_executorstill fails onwindows-latestafter #753 and #759. It hit four unrelated PR runs between 2026-10-02 and 2026-10-03 (#782, #780, #775, #772), each ending with the 3 s deadline:Cause
On Windows, connects to a port that isn't listening yet hang instead of being refused, so
wait_for_serverabandons them at its 500 ms per-attempt timeout. Once the test server listens, those abandoned attempts arrive half-open.answer_onceread connections one at a time and skipped a silent one after 200 ms. Once three or more stale connections were queued ahead of the live attempt, it hit its 500 ms timeout before the mock reached it. That attempt became one more stale connection, and the loop repeated until the deadline. #759 tuned the skip timeout, but serial reading was still the problem.Fix (test code only)
answer_oncereads each accepted connection in its own task (JoinSet) and answers the first one that sends a full request. Stale connections can no longer delay the live one. That removes the 200 ms skip and its fragile coupling to the client's attempt timeout. The remaining readers are aborted when theJoinSetis dropped.Test
test_answer_once_skips_a_silent_connection→test_answer_once_skips_silent_connections: 8 silent connections queued ahead of the client, 1 s deadline. It fails against the old serial mock (verified locally: deadline error after 1.6 s) and passes with this change, so it covers the queueing behaviour on Linux too, not only on Windows CI.cargo test -p aw-client-rust --lib: 30 passed, 5 runs in a row (0.69 s each)cargo fmt --all -- --check: cleancargo clippy -p aw-client-rust --no-deps -- -D warnings: cleanThe repo's
cargo clippypre-commit hook was skipped for this commit. Master's Lint currently fails on duplicatedallowattributes inaw-query(from #771 plus a sibling merge), and #779 fixes that. This PR doesn't touchaw-query.