lhotari commented on code in PR #23811:
URL: https://github.com/apache/pulsar/pull/23811#discussion_r1906651064


##########
pulsar-functions/instance/src/test/java/org/apache/pulsar/functions/instance/JavaInstanceTest.java:
##########
@@ -24,12 +24,16 @@
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertSame;
 import static org.testng.Assert.assertTrue;
+import java.time.Clock;
+import java.time.Instant;
+import java.time.ZoneId;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Consumer;
+import java.util.function.LongSupplier;

Review Comment:
   These seem to be unused imports



##########
pulsar-functions/instance/src/test/java/org/apache/pulsar/functions/instance/JavaInstanceTest.java:
##########
@@ -309,4 +317,25 @@ public void testAsyncFunctionMaxPendingVoidResult() throws 
Exception {
         log.info("start:{} end:{} during:{}", startTime, endTime, endTime - 
startTime);
         instance.close();
     }
+
+    @Test
+    public void testAsyncFunctionTime() {

Review Comment:
   This doesn't seem to be testing an async function since it's a 
`Function<String, String>` that is the function.



##########
pulsar-functions/instance/src/test/java/org/apache/pulsar/functions/instance/JavaInstanceTest.java:
##########
@@ -309,4 +317,25 @@ public void testAsyncFunctionMaxPendingVoidResult() throws 
Exception {
         log.info("start:{} end:{} during:{}", startTime, endTime, endTime - 
startTime);
         instance.close();
     }
+
+    @Test
+    public void testAsyncFunctionTime() {
+        JavaInstance instance = new JavaInstance(
+                mock(ContextImpl.class),
+                (Function<String, String>) (input, context) -> {
+                    try {
+                        Thread.sleep(500);
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+                    return input;
+                },
+                new InstanceConfig());
+        String testString = "ABC123";
+        JavaExecutionResult result = 
instance.handleMessage(mock(Record.class), testString);
+        assertNotNull(result.getResult());
+        long beforeTime = System.nanoTime() - 500_000_000L;
+        assertTrue(Math.abs(beforeTime - result.getStartTime()) <= 20_000_000);

Review Comment:
   What is the logic behind this assertion? 



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