You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2026/04/01 10:59:58 UTC

(camel) branch ci-issue-TASK-220 created (now f176737c3703)

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

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


      at f176737c3703 CAMEL-22325: Add AGENTS.md section to enforce Awaitility over Thread.sleep

This branch includes the following new commits:

     new f176737c3703 CAMEL-22325: Add AGENTS.md section to enforce Awaitility over Thread.sleep

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(camel) 01/01: CAMEL-22325: Add AGENTS.md section to enforce Awaitility over Thread.sleep

Posted by ac...@apache.org.
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 <an...@gmail.com>
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) <no...@anthropic.com>
---
 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.