xiaodu55 8a3a309d1c
fix(tests): make the mcp task service suite deterministic on Windows (#5995)
Follow-up to #5940/#5941: with the hang gone, 12 tests further down the
file fail on native Windows. One disease, several signatures: the tests
patch _CANCELLATION_DRAIN_TIMEOUT_SECONDS to 0.01, but on Windows +
CPython 3.12 a 10ms wait_for over an already-created task times out
immediately (Windows timer granularity, ~15.6ms default tick), so
instant claims are abandoned to the background handoff and every
claim-completes-in-the-foreground premise breaks - abandoned fresh
claims (single_flight), cancellation landing after run_once already
returned (repeated_outer), releases that never happen in the
foreground (poll_retry / notification_failure).

- raise the patched drain 0.01 -> 0.05 in the five affected tests:
  clears the granularity tick with headroom, keeps every existing 0.2s
  bound valid, and the gate-blocked-claim abandonment the single-flight
  tests exercise still drains-timeout as designed
- loosen test_run_once_releases_claim_when_driver_is_missing_or_fails'
  strict next_poll_at > now + 5s to >=: Windows datetime.now() can
  return the same tick for the whole run_once, making the strict
  comparison a clock artifact; the backoff floor is the invariant

On Windows the file now passes 126/126 in ~20s (was 12 failed). Linux
semantics unchanged: claims complete in microseconds inside a 50ms
drain there.

Fixes #5993
2026-09-28 22:47:29 +08:00
..