[
https://issues.apache.org/jira/browse/CAMEL-23495?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Guillaume Nodet updated CAMEL-23495:
------------------------------------
Fix Version/s: 4.21.0
Summary: Replace Thread.sleep() with Awaitility and fix ~30 flaky
tests in camel-core and camel-management (was: Replace Thread.sleep() with
Awaitility in camel-core and camel-management test synchronization)
> Replace Thread.sleep() with Awaitility and fix ~30 flaky tests in camel-core
> and camel-management
> -------------------------------------------------------------------------------------------------
>
> Key: CAMEL-23495
> URL: https://issues.apache.org/jira/browse/CAMEL-23495
> Project: Camel
> Issue Type: Improvement
> Reporter: Guillaume Nodet
> Assignee: Guillaume Nodet
> Priority: Major
> Fix For: 4.21.0
>
>
> h2. Problem
> Approximately 20 test files in camel-core and camel-management use
> Thread.sleep() for test synchronization — waiting for async operations to
> complete before asserting results. These are flakiness risks under CI load,
> as fixed delays may not be sufficient when the system is under heavy
> contention.
> The project already mandates using Awaitility instead of Thread.sleep() in
> test code (see CLAUDE.md guidelines).
> h2. Scope
> The following categories of Thread.sleep() are *in scope* (test
> synchronization):
> h3. Suspend/resume tests (~4 files)
> * RouteSedaSuspendResumeTest — Thread.sleep(1000L) waiting for route suspend
> * DefaultCamelContextSuspendResumeRouteTest — Thread.sleep(1000L) same
> * TwoRouteSuspendResumeTest — Thread.sleep(1000L) same
> * SedaConsumerSuspendResumeTest — Thread.sleep(1000L) same
> h3. Management tests (~3 files)
> * ManagedInflightStatisticsTest — Thread.sleep(250) and Thread.sleep(200)
> waiting for JMX stats
> * ManagedLogEndpointTest — Thread.sleep(100) waiting for log endpoint
> * DefaultExecutorServiceManagerTest — Thread.sleep(3000) waiting for executor
> shutdown
> h3. Async/scheduler tests (~5 files)
> * SchedulerMulticastParallelGreedyTest — Thread.sleep(50) before assertions
> * XPathRouteConcurrentTest — Thread.sleep(10) between sends
> * ThreadsRejectedExecutionWithDeadLetterTest — Thread.sleep(100) waiting
> * FileConsumerThreadsInProgressIssueTest — Thread.sleep(20) synchronization
> * ValidatorEndpointClearCachedSchemaTest — Thread.sleep(100) and
> Thread.sleep(200) in threads
> h3. Other synchronization sleeps (~5-8 files)
> * Various tests with Thread.sleep(50-500) used to wait for async operations
> h2. Out of scope
> The following uses of Thread.sleep() are *not* in scope (legitimate uses):
> * Inside Processor.process() or Runnable.run() to simulate slow I/O (~30
> files)
> * Manual tests (*ManualTest.java) not run in CI (~5 files)
> * Timing-specific tests (MockEndpointTimeClauseTest, MonotonicClockTest)
> testing time behavior (~12 files)
> * Inside TaskTestSupport used for slow predicate simulation
> h2. Approach
> Replace each Thread.sleep() synchronization call with the appropriate
> Awaitility pattern:
> * await().atMost(N, TimeUnit.SECONDS).until(condition) for state checks
> * await().atMost(N, TimeUnit.SECONDS).untilAsserted(() -> assertion) for
> assertion checks
> _Claude Code on behalf of Guillaume Nodet_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)