Abacn commented on code in PR #27308:
URL: https://github.com/apache/beam/pull/27308#discussion_r1248354222


##########
sdks/java/harness/src/test/java/org/apache/beam/fn/harness/logging/BeamFnLoggingClientTest.java:
##########
@@ -356,15 +358,28 @@ public StreamObserver<BeamFnApi.LogEntry.List> logging(
   @Test
   public void testClosableWhenBlockingForOnReady() throws Exception {
     BeamFnLoggingMDC.setInstructionId("instruction-1");
-    Collection<BeamFnApi.LogEntry> values = new ConcurrentLinkedQueue<>();
+    AtomicInteger testEntriesObserved = new AtomicInteger();
+    AtomicBoolean onReadyBlocking = new AtomicBoolean();
     AtomicReference<StreamObserver<BeamFnApi.LogControl>> 
outboundServerObserver =
         new AtomicReference<>();
+    PrintStream originalOutStream = System.out;
 
     final AtomicBoolean elementsAllowed = new AtomicBoolean(true);
     CallStreamObserver<BeamFnApi.LogEntry.List> inboundServerObserver =
         TestStreams.withOnNext(
-                (BeamFnApi.LogEntry.List logEntries) ->
-                    values.addAll(logEntries.getLogEntriesList()))
+                (BeamFnApi.LogEntry.List logEntries) -> {
+                  for (BeamFnApi.LogEntry entry : 
logEntries.getLogEntriesList()) {
+                    if 
(entry.toBuilder().clearCustomData().build().equals(TEST_ENTRY)) {
+                      int observed = testEntriesObserved.addAndGet(1);
+                      if (observed % 100 == 0) {
+                        originalOutStream.println("Saw test record " + 
observed);
+                      }
+                    } else {
+                      originalOutStream.println("Logging: " + entry);
+                    }
+                  }
+                })
+            .withOnCompleted(() -> outboundServerObserver.get().onCompleted())

Review Comment:
   great, observed the teat took 20 s long, now it's 2 s



##########
sdks/java/harness/src/test/java/org/apache/beam/fn/harness/logging/BeamFnLoggingClientTest.java:
##########
@@ -356,15 +358,28 @@ public StreamObserver<BeamFnApi.LogEntry.List> logging(
   @Test
   public void testClosableWhenBlockingForOnReady() throws Exception {
     BeamFnLoggingMDC.setInstructionId("instruction-1");
-    Collection<BeamFnApi.LogEntry> values = new ConcurrentLinkedQueue<>();
+    AtomicInteger testEntriesObserved = new AtomicInteger();
+    AtomicBoolean onReadyBlocking = new AtomicBoolean();
     AtomicReference<StreamObserver<BeamFnApi.LogControl>> 
outboundServerObserver =
         new AtomicReference<>();
+    PrintStream originalOutStream = System.out;
 
     final AtomicBoolean elementsAllowed = new AtomicBoolean(true);
     CallStreamObserver<BeamFnApi.LogEntry.List> inboundServerObserver =
         TestStreams.withOnNext(
-                (BeamFnApi.LogEntry.List logEntries) ->
-                    values.addAll(logEntries.getLogEntriesList()))
+                (BeamFnApi.LogEntry.List logEntries) -> {
+                  for (BeamFnApi.LogEntry entry : 
logEntries.getLogEntriesList()) {
+                    if 
(entry.toBuilder().clearCustomData().build().equals(TEST_ENTRY)) {
+                      int observed = testEntriesObserved.addAndGet(1);
+                      if (observed % 100 == 0) {
+                        originalOutStream.println("Saw test record " + 
observed);
+                      }
+                    } else {
+                      originalOutStream.println("Logging: " + entry);
+                    }
+                  }
+                })
+            .withOnCompleted(() -> outboundServerObserver.get().onCompleted())

Review Comment:
   great, observed the test took 20 s long, now it's 2 s



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