Repository navigation
test: deflake seven single-OS CI failure classes under -T1C contention - #4149
Merged
Merged
Conversation
Scanned the last 5 pages of PRs (agentscope-ai#3941-agentscope-ai#4147, 125 PRs): 14 had red CI, 9 of them failed on exactly one OS while the other stayed green on the same commit — the -T1C parallel-build starvation signature. The both-OS failures were compile/spotless issues (out of scope). Fixed the distinct flaky test classes plus the shared test util and two narrowly-scoped production hardenings: - AguiMvcControllerTest: shared 30s await constant; the 5s latch deadline was hit on ubuntu twice (agentscope-ai#4112, agentscope-ai#4143) while sibling tests ran 5-9s under the same load. - SubagentRunIdChainTest: 10s -> 30s block budget; starved just past 10s on windows three times (agentscope-ai#4091, agentscope-ai#4025, agentscope-ai#4142 — 10.04-10.84s elapsed), 0.4s on ubuntu. - MockModel: recordedMessages/callCount/last* were plain fields raced by the turn thread and background memory consolidation; a lost ArrayList add made InboxMiddlewareTest match the consolidation prompt instead of the reasoning request (agentscope-ai#4093, agentscope-ai#3991). Now CopyOnWriteArrayList/AtomicInteger/volatile. - GatewayEventsWebSocketTest: the stand-in control plane closes rejected upgrade connections; a keep-alive 403 left a dying pooled socket that the next proxied socket reused and died on silently (agentscope-ai#4072, agentscope-ai#4094 — clean close, no frames, ~0.1s). - TurnLeaseServiceTest: tolerance bounds measured from lease acquisition instead of when a starved test thread resumes (agentscope-ai#4075). - GracefulShutdownManager.resetForTesting: also reset config; a PT0.1S config leaked across tests through the JVM-wide singleton and failed defaultConfig whenever filesystem class order placed it after shutdownTimeoutSignal (found during local clean-rebuild verification). - CommandExecutor: capability probe budgets floored at 2s; the probe inherited the per-attempt transport budget tuned for commands and died at 199ms on a loaded runner (agentscope-ai#4058), and the shared budget made the intended 3-attempt retry dead code. Command exchanges keep the configured budget. All widenings are failure-path deadlines only — happy-path timings are unchanged and no sleeps were added.
jujn
approved these changes
Nov 12, 2026
…et of agentscope-ai#4133) agentscope-ai#4133 landed the same recordedMessages CopyOnWriteArrayList change on main; this branch's version additionally hardens callCount/last* fields against the same recording races, so HEAD is kept for the conflicted hunk. agentscope-ai#4133's new MockModelRecordedMessagesTest merges in unchanged and stays green.
3 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Scanned the last 5 pages of PRs (#3941–#4147, 125 PRs): 14 had red CI, and 9 of those failed on exactly one OS while the other OS stayed green on the same commit — the classic
-T1Cparallel-build starvation signature (the both-OS failures were compile/spotless issues and are out of scope). This PR fixes every distinct flaky test class found that way, plus two narrowly-scoped hardenings the fixes depend on.AguiMvcControllerTest#eventStreamSignals…SubagentRunIdChainTest(both methods)InboxMiddlewareTest#notificationReaches…MockModelrecordings made thread-safe (see below)GatewayEventsWebSocketTest#sameOrigin…Connection prematurely closed BEFORE opening handshake is complete) that the next proxied socket reusedConnection: closeso the gateway pool discards the socketTurnLeaseServiceTest#heartbeatErrors…await(70ms) isFalseanchored to when the starved test thread resumes, not to lease acquisitionSandboxConnectorRedirectTest#commandWaits…GracefulShutdownManagersingleton leakresetForTesting()reset every field exceptconfig, so aPT0.1Sconfig leaked across tests and faileddefaultConfigwhenever filesystem class order placed it aftershutdownTimeoutSignalGracefulShutdownConfig.DEFAULTShared test-util fix
MockModelrecorded calls from whichever thread drives the agent — the turn thread and background memory maintenance — into a plainArrayListplus unsynchronizedint/last*fields. Two concurrent adds race theelementData[size] / size++update and can silently drop an entry; that is exactly the #4093/#3991 signature (the reasoning request vanished, only the post-call consolidation request survived). Recordings are now aCopyOnWriteArrayListwithAtomicInteger/volatilesiblings — order-preserving, atomic per add, stable to iterate while a call is in flight. Complements the iteration fix proposed in #4133.Non-test changes (called out explicitly)
CommandExecutor— the/capabilitiespre-flight probe now usesmax(configured per-attempt, 2s)for its budgets. Strictly a widening: identical for default (60s) and ≥2s configurations; only sub-2s configs change, and only for the probe — command exchanges keep the configured budget. Side benefit: the old code passed the same 200ms as the shared exchange deadline, which made the intendedCAPABILITY_MAX_ATTEMPTS = 3retry dead code; the floor lets the retry actually run. The test-only alternative (raising the test's 200ms config and the server delays to match) would add ~1.5–2s of real test wall time, so the 2-line production fix is the smaller change.GracefulShutdownManager.resetForTesting— one added line restoringconfigto default, inside a method documented "Intended for testing and demo purposes only" (no production callers; production code never callssetConfig).Constraint compliance
TurnLeaseServiceTestactually drops a forced 70ms wait).Test plan
mvn -B -T2C clean verifygreen locally (4m38s wall clock; all seven fixed areas' suites green)JsonFileAgentStateStoreTest(8 symlink cases) excluded locally only — pre-existing Windows-symlink-privilege limitation, reproduced identically on a pristinemainbaseline, unrelated to this diffFollow-up noted during review: the production control-plane hub behind
/api/v1/eventslives outside this repo; if it also answers rejected upgrades with a keep-alive 403 and closes, the gateway can still poison a subsequent proxied socket in production — worth checking against the real hub separately.