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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to