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

   `testBufferStopsAcceptingItems` asserted the buffer count after a fixed 
100ms sleep and failed on loaded Windows runners with `expected:<5> but 
was:<0>`. The count is decremented in `whenComplete` as soon as a future 
finishes, so the assertion raced both the producer threads starting up and the 
buffered items completing. #38970 shortened the sleeps, which made the window 
smaller.
   
   This change makes the test deterministic instead of widening the sleep:
   
   - `BasicDofn` takes an optional `CountDownLatch` gate, so a test can keep 
elements in flight until it releases them.
   - `testBufferStopsAcceptingItems` joins all 10 producers before asserting. 
With the gate closed nothing can complete, so exactly 5 items are buffered, 10 
are in state and 0 are processed. After releasing the gate it checks that the 
first commit emits 5 and reschedules the 5 throttled items, and the second 
commit emits all 10. The scheduling timeout is shortened so throttled producers 
give up fast; the assertions do not depend on it.
   - `testBufferCount`, `testBufferWithCancellation` and `testLongItem` had the 
same sleep based race (10ms and 500ms DoFns) and now use the gate. 
`testSlowDuplicates` waits for the buffer to drain instead of sleeping.
   
   Test only, no production change. Ran the class repeatedly on Linux, 
including with the build pinned to 2 cores under extra CPU load. The Windows 
failure itself does not reproduce locally, so the fix relies on the ordering 
above rather than on a repro.
   
   Fixes #40448. This supersedes the timing based approach in #40397.
   
   ------------------------
   
    - [x] Mention the appropriate issue in your description (for example: 
`addresses #123`), if applicable. This will automatically add a link to the 
pull request in the issue. If you would like the issue to automatically close 
on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more 
tips on [how to make review process 
smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
   


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