You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "ammachado (via GitHub)" <gi...@apache.org> on 2026/06/18 17:52:52 UTC

[PR] CAMEL-21438: Fix flaky file-based tests (Thread.sleep, missing Awaitility guards, discarded matchesWaitTime return) [camel]

ammachado opened a new pull request, #24123:
URL: https://github.com/apache/camel/pull/24123

   # Description
   
   Fix a set of flaky tests in the file component area. Each fix addresses a specific non-determinism pattern:
   
   **1. `PollEnrichFileCustomAggregationStrategyTest`**
   Replace `Thread.sleep(500)` with `getMockEndpoint("mock:start").await(10, TimeUnit.SECONDS)`. The sleep was guessing that the route had consumed the first file and reached the `pollEnrich` step; the `await` waits for the observable proof of that (the `mock:start` latch reaching zero) before writing the enrichdata file.
   
   **2. `FileConsumeHiddenFilesTest`**
   Add explicit `atMost(10, TimeUnit.SECONDS)` to a bare `Awaitility.await()` call. Without it the test relies on Awaitility's opaque library default, violating the project guideline that every `await()` must have an explicit timeout.
   
   **3. `FileProducerFileExistFailTest`**
   Add `mock.await(10, TimeUnit.SECONDS)` before `assertMockEndpointsSatisfied()`. The `doAssertIsSatisfied` only calls `waitForCompleteLatch()` if `expectedCount != getReceivedCounter()` at the moment it is entered; on a fast machine the count is already met and the latch wait is skipped entirely, leaving `runTests()` (which evaluates `expectedFileExists`) with no stable-state guarantee.
   
   **4. `GenericFileConverterTest`**
   Same root cause as #3. The test uses `isUseRouteBuilder()=false` so each of the 7 test methods manually starts the context; `assertMockEndpointsSatisfied()` is the only timing gate but has no explicit latch wait before `runTests()`. Add `mock.await(10, TimeUnit.SECONDS)` before `assertMockEndpointsSatisfied()` in every method.
   
   **5. `FileProducerCharsetUTFtoUTFTest`, `FileProducerCharsetUTFOptimizedTest`, `FileProducerCharsetUTFtoISOConfiguredTest`**
   After `oneExchangeDone.matchesWaitTime()` confirms the exchange completed, `Files.readAllBytes` on the output file can still return 0 bytes because Camel's file producer writes via a temp file + atomic rename, and the OS may not have flushed the page to the reader yet. `FileProducerCharsetUTFtoISOTest` already carries an explicit comment about this and uses an Awaitility guard; apply the same pattern to the three missing tests.
   Additionally, `FileProducerCharsetUTFOptimizedTest` was silently discarding the boolean return value of `matchesWaitTime()`, masking any timeout before the file assertions ran.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful subject line and body.
   
   - [x] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes.
   
   _Claude Code on behalf of Adriano Machado_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-21438: Fix flaky file-based tests (Thread.sleep, missing Awaitility guards, discarded matchesWaitTime return) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #24123:
URL: https://github.com/apache/camel/pull/24123#issuecomment-4749079276

   :star2: Thank you for your contribution to the Apache Camel project! :star2:
     :robot: CI automation will test this PR automatically.
   
     :camel: Apache Camel Committers, please review the following items:
   
     * First-time contributors **require MANUAL approval** for the GitHub Actions to run
     * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
     * You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
     * Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
     
     :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-21438: Fix flaky file-based tests (Thread.sleep, missing Awaitility guards, discarded matchesWaitTime return) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #24123:
URL: https://github.com/apache/camel/pull/24123#issuecomment-4753951267

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `core/camel-core`
   
   :warning: **Some tests are disabled on GitHub Actions** (`@DisabledIfSystemProperty(named = "ci.env.name")`) and require manual verification:
   
   - `core/camel-core`: 2 test(s) disabled on GitHub Actions
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/27836538446)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-21438: Fix flaky file-based tests (Thread.sleep, missing Awaitility guards, discarded matchesWaitTime return) [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #24123:
URL: https://github.com/apache/camel/pull/24123#discussion_r3444068850


##########
core/camel-core/src/test/java/org/apache/camel/processor/throttle/concurrent/ConcurrentRequestsThrottlerTest.java:
##########
@@ -213,17 +208,11 @@ public void onFailure(Exchange ex) {
                             assertTrue(s.tryAcquire(), "'direct:expressionConstant' too many requests");
                             exchange.getExchangeExtension().addOnCompletion(new SynchronizationAdapter() {
                                 @Override
-                                public void onComplete(Exchange ex) {
-                                    s.release();
-                                }
-
-                                @Override
-                                public void onFailure(Exchange ex) {
+                                public void onDone(Exchange ex) {

Review Comment:
   `.delay(100)` is removed here from `direct:expressionConstant` but kept on the other two routes (`direct:a` and `direct:expressionHeader`). All three had the delay before this PR — the inconsistency looks unintentional.
   
   Also, this file already compiles correctly on `main` (fixed by commit `0c03b30d0f3`). The `onDone` refactoring and delay removal effectively revert that fix. Consider dropping this file from the PR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-21438: Fix flaky file-based tests (Thread.sleep, missing Awaitility guards, discarded matchesWaitTime return) [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #24123:
URL: https://github.com/apache/camel/pull/24123


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org