Abacn commented on code in PR #36750:
URL: https://github.com/apache/beam/pull/36750#discussion_r2556893994
##########
sdks/java/core/src/test/java/org/apache/beam/sdk/fn/splittabledofn/RestrictionTrackersTest.java:
##########
@@ -179,46 +181,37 @@ public void testClaimObserversMaintainBacklogInterfaces()
{
assertThat(hasSize, instanceOf(HasProgress.class));
}
- private void testBlocking(String testCase) throws InterruptedException {
- RestrictionTrackerWithProgress withProgress;
- if ("tryClaim".equals(testCase)) {
- withProgress = new RestrictionTrackerWithProgress(true, false);
- } else if ("trySplit".equals(testCase)) {
- withProgress = new RestrictionTrackerWithProgress(false, true);
- } else {
- throw new IllegalArgumentException("unknown test case " + testCase);
- }
+ @Test
+ public void testClaimObserversProgressNonBlockingOnTryClaim() throws
InterruptedException {
+ RestrictionTrackerWithProgress withProgress = new
RestrictionTrackerWithProgress(true, false);
RestrictionTracker<Object, Object> tracker =
RestrictionTrackers.observe(withProgress, new
RestrictionTrackers.NoopClaimObserver<>());
- Runnable runnable;
- if ("tryClaim".equals(testCase)) {
- runnable = () -> tracker.tryClaim(new Object());
- } else {
- runnable = () -> tracker.trySplit(0.5);
- }
- Thread blocking = new Thread(runnable);
+ Thread blocking = new Thread(() -> tracker.tryClaim(new Object()));
blocking.start();
- while (!withProgress.isBlocked()) {
- Thread.sleep(1);
- }
+ withProgress.waitUntil(true);
Review Comment:
changed to waitUntilBlocking
--
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]