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

   JIRA: https://issues.apache.org/jira/browse/CAMEL-26372
   
   ## Description
   
   Fixes the flaky `MailMaxMessagesPerPollTest.testBatchConsumer` 
(`mock://result Received message count. Expected: <3> but was: <1>` / `<0>` at 
the first assertion).
   
   Two sources of flakiness were identified:
   
   1. **Short result wait.** `mock.setResultWaitTime(2000)` gave the first poll 
only 2 seconds to deliver the first batch. On a slow machine the IMAP connect 
and first poll can take longer. This matches the reported failures on the first 
assertion. Reproduced locally by lowering the wait to 150ms, which gives 
`Expected: <3> but was: <0>`. The override is removed so the `MockEndpoint` 
default wait applies.
   2. **`mock.reset()` race between the two batches.** The test asserted the 
first batch, called `mock.reset()` and then asserted the second batch. The 
consumer polls every 100ms and deletes consumed messages, so if the second poll 
ran before `reset()`, its exchanges were discarded and the second assertion 
failed with `Expected: <2> but was: <0>`. Reproduced locally by sleeping 3s 
before `reset()`. This is not what the reported failures hit (they fail at the 
first assertion), but it is a real race in the same test.
   
   The test now expects all 5 messages in a single assertion, checking the body 
and `Exchange.BATCH_SIZE` (3 for the first batch, 2 for the second) of each 
message, so no `reset()` is needed.
   
   ## 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.
   
   ---
   _AI-generated by IBM Bob 2.2.1 on behalf of @apupier_


-- 
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