test(agent): loosen flaky async-timeout deadlines to survive loaded CI#4773
Open
logicwu0 wants to merge 1 commit into
Open
test(agent): loosen flaky async-timeout deadlines to survive loaded CI#4773logicwu0 wants to merge 1 commit into
logicwu0 wants to merge 1 commit into
Conversation
stateUpdates_shouldBeCleared_onTimeoutWithCancellableTool and tool_shouldStopGracefully_whenCheckingCancellation both wait on a CountDownLatch that a task running on ForkJoinPool.commonPool() counts down. Under parallel test execution on a loaded CI runner, the task's start/scheduling latency can exceed the hard 5s/1s await deadlines, so the latch is not observed in time and the test fails even though the behavior under test is correct (these pass locally). The await() deadlines are only upper bounds: a successful run returns the instant the latch fires and never waits the full duration. Raise them to 30s so scheduling spikes no longer cause spurious failures, without weakening any assertion.
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.
Two async tests fail intermittently on CI (the
testjob), turning the check red on unrelated PRs even though the behavior under test is correct and they pass locally:AgentToolNodeAsyncExecutionTest.StateUpdateOnTimeoutTests.stateUpdates_shouldBeCleared_onTimeoutWithCancellableToolCancellableAsyncToolCallbackTest.TimeoutScenarioTests.tool_shouldStopGracefully_whenCheckingCancellationRoot cause
Both tests wait on a
CountDownLatchthat is counted down by a task submitted toCompletableFuture.supplyAsync(...)— i.e. the sharedForkJoinPool.commonPool(). On GitHub-hosted runners the common pool has very low parallelism, and under parallel test execution its start/scheduling latency can spike past the hard-coded5s/1sawait deadlines. The latch is then not observed in time andassertTrue(latch.await(...))fails.A previous attempt already bumped one knob (
// Increased from 100ms for CI stability/1s to 5s), which reduced but did not eliminate the flakiness.Fix
Raise the two
await(...)deadlines to30s. These deadlines are only upper bounds: a successful run returns the instant the latch fires and never waits the full duration, so a larger value has no effect on green runs — it only tolerates scheduling spikes before declaring failure. No assertion is weakened (the correctness checks —stateUpdates.isEmpty(),token.isCancelled(),iterationsCompleted < 100— are unchanged).Local run: both classes green (
Tests run: 29, Failures: 0);spotless:applyrun.