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

   ## Description
   
   Fixes the flaky `ZipFileDataFormatTest` 
([CAMEL-27642](https://issues.apache.org/jira/browse/CAMEL-27642), flaky 34 
times in the last 90 days).
   
   ### Root cause
   
   The tests built an expected zip with `getZippedText()` and compared it 
**byte for byte** with the zip produced by the route. A zip entry stores its 
last modified time in DOS format, which has a **resolution of 2 seconds**. When 
the expected zip and the actual one are created in different 2-second slots 
(more likely on loaded CI machines with parallel builds), the time field 
differs (index `[10]` of the local file header, the actual value is always one 
less than expected) and the assertion fails.
   
   Tests using `expectedBodiesReceived(byte[])` failed for a similar reason: 
`MockEndpoint` compares `byte[]` bodies by identity (`expected: <[B@5922cff3> 
but was: <[B@2299d903>`).
   
   ### Fix (test only)
   
   A new `assertZipEquals()` helper compares the entries (name and content) of 
the zips instead of their raw bytes:
   
   - `testZipAndStreamCaching`, `testZipWithoutFileName`, 
`testZipToFileWithoutFileName`, `testZipToFileWithFileName` used 
`assertArrayEquals`
   - `testZipWithFileName`, `testZipWithPathElements`, 
`testZipWithPreservedPathElements`, `testDslZip` used `expectedBodiesReceived`. 
They now expect one message and assert the body once the mock is satisfied.
   
   `ZipFileDataFormat` is unchanged: writing the current time in the entries is 
the correct behaviour.
   
   ### Verification
   
   I inserted a temporary 2.5 second `Thread.sleep` between the creation of the 
expected zip and the actual one (not committed):
   
   | Version | Result |
   |---|---|
   | Original test + gap | 8 tests fail, with the same errors as in the ticket 
(`array contents differ at index [10], expected: <X> but was: <X-1>` and the 
`byte[]` identity mismatch) |
   | Fixed test + gap | 20 tests, 0 failures |
   
   Without the gap, `ZipFileDataFormatTest` passes (20 tests).
   
   ---
   _Claude Code-style AI disclosure: this PR was prepared by IBM Bob (AI 
assistant) 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