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



##########
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:
       I added the timeout for test




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