浏览代码

Time is too small and the task is not finished

CalvinKirs 4 年之前
父节点
当前提交
b3991d9dee

+ 10 - 4
dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java

@@ -88,11 +88,17 @@ public class TaskResponseServiceTest {
 
     @After
     public void after() {
-        try {
-            Thread.sleep(60000);
-        } catch (InterruptedException ignored) {
-            Thread.currentThread().interrupt();
+
+        long startTime = System.currentTimeMillis();
+
+        long maxWaitTime = 3 * 60 * 1000;
+
+        while (System.currentTimeMillis() - maxWaitTime - startTime < 0) {
+            if (taskResponseService.getEventQueue().size() == 0) {
+                return;
+            }
         }
+
         Assert.assertEquals(0, taskResponseService.getEventQueue().size());
         taskResponseService.stop();
     }