This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch ci-issue-TASK-220
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f176737c3703174de4c94e37430f3a2d4aa88218
Author: Andrea Cosentino <[email protected]>
AuthorDate: Wed Apr 1 12:59:45 2026 +0200

    CAMEL-22325: Add AGENTS.md section to enforce Awaitility over Thread.sleep
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 AGENTS.md | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/AGENTS.md b/AGENTS.md
index fa6962049470..ade9d018214b 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -76,6 +76,29 @@ When creating a PR, **always identify and request reviews** 
from the most releva
 - All code must pass formatting checks (`mvn formatter:format impsort:sort`) 
before pushing.
 - All generated files must be regenerated and committed (CI checks for 
uncommitted changes).
 
+### Asynchronous Testing: Use Awaitility Instead of Thread.sleep
+
+Do **NOT** use `Thread.sleep()` in test code. It leads to flaky, slow, and 
non-deterministic tests.
+Use the [Awaitility](https://github.com/awaitility/awaitility) library 
instead, which is already
+available as a test dependency in the project.
+
+**Example — waiting for a route to be registered:**
+
+```java
+import static org.awaitility.Awaitility.await;
+
+await().atMost(20, TimeUnit.SECONDS)
+       .untilAsserted(() -> assertEquals(1, context.getRoutes().size()));
+```
+
+**Rules:**
+
+- New test code MUST NOT introduce `Thread.sleep()` calls.
+- When modifying existing test code that contains `Thread.sleep()`, migrate it 
to Awaitility.
+- Always set an explicit `atMost` timeout to avoid hanging builds.
+- Use `untilAsserted` or `until` with a clear predicate — do not replace a 
sleep with a
+  busy-wait loop.
+
 ### Issue Investigation (Before Implementation)
 
 Before implementing a fix for a JIRA issue, **thoroughly investigate** the 
issue's validity and context.

Reply via email to