m-trieu commented on code in PR #34283:
URL: https://github.com/apache/beam/pull/34283#discussion_r2015050399


##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/windmill/client/AbstractWindmillStreamTest.java:
##########
@@ -110,12 +79,75 @@ public void setMessageCompression(boolean b) {}
     // Sleep a bit to give sendExecutor time to execute the send().
     Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
 
-    sendBlocker.countDown();
+    callStreamObserver.unblockSend();
     
assertThat(sendFuture.get()).isInstanceOf(WindmillStreamShutdownException.class);
   }
 
+  @Test
+  public void testMaybeSendHealthCheck() throws InterruptedException, 
ExecutionException {
+    TestCallStreamObserver callStreamObserver = new TestCallStreamObserver();
+    Function<StreamObserver<Integer>, StreamObserver<Integer>> clientFactory =
+        ignored -> callStreamObserver;
+
+    TestStream testStream = newStream(clientFactory);
+    testStream.start();
+    ExecutorService sendExecutor = Executors.newSingleThreadExecutor();
+    Instant reportingThreshold = Instant.now().minus(Duration.millis(1));
+    Future<?> sendFuture =
+        sendExecutor.submit(() -> 
testStream.maybeSendHealthCheck(reportingThreshold));
+
+    // Sleep a bit to give sendExecutor time to execute the send().
+    Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+
+    callStreamObserver.unblockSend();
+
+    // Make sure the future completes.
+    sendFuture.get();
+
+    assertThat(testStream.numHealthChecks.get()).isEqualTo(1);

Review Comment:
   done



-- 
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: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to