tkaymak opened a new pull request, #38971:
URL: https://github.com/apache/beam/pull/38971

   ## What
   
   Fixes the flaky `SqsIOWriteBatchesTest` (#38946).
   
   ## Why
   
   The four timeout-related tests (`testWriteBatchesWithTimeout`, 
`testWriteBatchesWithStrictTimeout`, `testWriteBatchesToDynamicWithTimeout`, 
`testWriteBatchesToDynamicWithStrictTimeout`) asserted the *exact* grouping of 
messages into `SendMessageBatch` calls. Those groupings depend on wall-clock 
timing — the per-message `Thread.sleep` delay racing the configured 
`withBatchTimeout` — so on loaded CI runners the batches form differently and 
the strict `verify(sqs).sendMessageBatch(request(exact entries))` checks fail 
with Mockito `ArgumentsAreDifferent`.
   
   ## How
   
   Replace the exact-grouping assertions with timing-independent invariants:
   - every expected message body is sent exactly once (captured via 
`ArgumentCaptor`, grouped by queue),
   - no batch exceeds the size implied by the timeout cadence,
   - at least the minimum number of batches is produced (`verify(sqs, 
atLeast(n))`).
   
   This still exercises timeout-driven flushing (both the synchronous on-append 
path and the strict separate-thread variant) without depending on exact 
wall-clock behavior. The non-timeout tests are unchanged.
   
   ## Testing
   
   Ran the class 6 times under deliberate 4-core CPU saturation (load avg ~12) 
with no failures; previously the timeout tests would flake under load.
   
   Fixes #38946
   


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