You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/08/16 10:24:48 UTC

[GitHub] [flink] curcur commented on a change in pull request #16797: [FLINK-23680][streaming] Wait until all expected threads would be tri…

curcur commented on a change in pull request #16797:
URL: https://github.com/apache/flink/pull/16797#discussion_r689414336



##########
File path: flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/operators/StreamTaskTimerTest.java
##########
@@ -70,11 +70,22 @@ public void teardown() throws Exception {
     }
 
     @Test
-    public void testOpenCloseAndTimestamps() {
-        // first one spawns thread
+    public void testOpenCloseAndTimestamps() throws InterruptedException {
+        // Wait for the start of threads: throughput calculation.
+        int initiallyExpectedThreads = 1;
+        waitUntilTaskTriggerThreadsOnStart(initiallyExpectedThreads);
+
+        // Spawn one more thread.
         timeService.registerTimer(System.currentTimeMillis(), timestamp -> {});
 
-        assertEquals(2, StreamTask.TRIGGER_THREAD_GROUP.activeCount());
+        assertEquals(initiallyExpectedThreads + 1, StreamTask.TRIGGER_THREAD_GROUP.activeCount());
+    }
+
+    private void waitUntilTaskTriggerThreadsOnStart(int expectedThreads)
+            throws InterruptedException {
+        while (StreamTask.TRIGGER_THREAD_GROUP.activeCount() != expectedThreads) {
+            Thread.sleep(1);
+        }

Review comment:
       Add a timeout here? 
   
   

##########
File path: flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/operators/StreamTaskTimerTest.java
##########
@@ -70,11 +70,22 @@ public void teardown() throws Exception {
     }
 
     @Test
-    public void testOpenCloseAndTimestamps() {
-        // first one spawns thread
+    public void testOpenCloseAndTimestamps() throws InterruptedException {
+        // Wait for the start of threads: throughput calculation.
+        int initiallyExpectedThreads = 1;
+        waitUntilTaskTriggerThreadsOnStart(initiallyExpectedThreads);
+
+        // Spawn one more thread.
         timeService.registerTimer(System.currentTimeMillis(), timestamp -> {});

Review comment:
       Maybe removing this line directly, and use the scheduled calculating throughput directly?
   
   I am not sure scheudle a new timer will 100% to spawn a new thread.




-- 
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: issues-unsubscribe@flink.apache.org

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