CalvinKirs commented on code in PR #2366:
URL: 
https://github.com/apache/incubator-seatunnel/pull/2366#discussion_r938425943


##########
seatunnel-engine/seatunnel-engine-server/src/main/test/execution/TaskExecutionServiceTest.java:
##########
@@ -83,9 +193,78 @@ public void accept(Void unused, Throwable throwable) {
 
         stop.set(true);
 
-        Thread.sleep(1000);
+        Thread.sleep(3000);
+
 
         assertTrue(taskExecutionContext.executionFuture.isDone());
         assertTrue(futureMark.get());
     }
+
+    public void testDelay() throws InterruptedException {
+
+        AtomicBoolean stopMark = new AtomicBoolean(false);
+
+        CopyOnWriteArrayList<Long> lowLagList = new CopyOnWriteArrayList<>();
+        CopyOnWriteArrayList<Long> highLagList = new CopyOnWriteArrayList<>();
+
+        //Create low lat tasks
+        List<Task> lowLagTask = buildFixedTestTask(10,10, stopMark, 
lowLagList);
+
+        //Create high lat tasks
+        List<Task> highLagTask = buildFixedTestTask(1500, 5, stopMark, 
highLagList);
+
+        List<Task> taskTrackers = new ArrayList<>();
+        taskTrackers.addAll(highLagTask);
+        taskTrackers.addAll(lowLagTask);
+        Collections.shuffle(taskTrackers);
+
+        LinkedBlockingDeque<Task> taskQueue = new 
LinkedBlockingDeque<>(taskTrackers);
+
+
+        System.out.println("task size is : " + taskTrackers.size());
+
+        TaskExecutionService taskExecutionService = 
service.getTaskExecutionService();
+
+        List<TaskExecutionContext> collect = 
taskQueue.stream().map(taskExecutionService::submitThreadShareTask).collect(Collectors.toList());
+
+
+        //stop tasks
+        Thread.sleep(60000);
+        stopMark.set(true);
+
+        Thread.sleep(1000);
+        //Check all task ends right
+        collect.forEach(xt -> {
+            assertTrue(xt.executionFuture.isDone());

Review Comment:
   IMO,`thread-sleep` isn't a good approach, it doesn't ensure stable testing.



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