CAMEL-24042: Fix flaky tests in camel-core (batch 10)#24650
Conversation
Use timed MockEndpoint assertions, increase Awaitility and @timeout timeouts to reduce flakiness under CI load for throttle, mock, task, file and stop-timeout tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 23 tested, 0 compile-only — current: 0 all testedMaveniverse Scalpel detected 23 affected modules (current approach: 0).
|
oscerd
left a comment
There was a problem hiding this comment.
Reviewed each changed test for the project's async-testing rules (no Thread.sleep, condition-based waits, MockEndpoint timed assertions, no Awaitility-wrapping of assertIsSatisfied) — all clean, no change requests. Notes from the verification:
- The
assertMockEndpointsSatisfied()→MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS)migrations are semantically the same latch-based wait with the implicit 10s default raised to an explicit 30s — exactly the pattern the repo guidelines prescribe. The two bareassertIsSatisfied()calls deliberately left inMockEndpointTimeClauseTestare correct as-is (one is insideassertThrows, the other gates a latch on the default wait). - The
@Timeout(10)→@Timeout(20)bumps inForegroundTaskTest/ForegroundTimeTaskTestare pure hang-guards: task time-boundedness is still asserted by each task's ownwithMaxDurationbudget and iteration-count assertions, so nothing is weakened. The arithmetic checks out (slow-predicate tests have ~6s nominal runtime, leaving only ~4s headroom under the old value). - No assertion is weakened anywhere in the batch: expected message counts, exactly-once invocation checks (
invoked.get() == 1inDistributedTimeoutTest), and upper/lower-bound duration asserts are all unchanged. - One observation for the series rather than this PR: the whole batch is timeout-headroom on waits that prior batches already made condition-based — which is the right remaining lever.
DistributedTimeoutTest:54is now on its second escalation (2s→5s in CAMEL-24037/#24635, 5s→10s here) for an aggregator with a 200ms completion timeout; if it flakes a third time, it may deserve a look at what actually stalls the timeout checker on loaded CI instead of another bump.
CI is green on both JDK 17 and 25 builds (which run the camel-core tests).
Reviewed with Claude Code (Fable 5) on behalf of oscerd. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.
Summary
Fix flaky tests identified by Develocity in camel-core:
assertMockEndpointsSatisfied()withMockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS)(2 intentional bare calls left: assertThrows and timing-critical test)assertMockEndpointsSatisfied()with timed variantassertMockEndpointsSatisfied()with timed variant@Timeoutfrom 10s to 20s (slow test predicates sleep 2s/iteration, tight under CI load)@Timeoutfrom 10s to 20sTest plan
mvn formatter:format impsort:sortClaude Code on behalf of gnodet
🤖 Generated with Claude Code