liucongjy commented on code in PR #9951:
URL: https://github.com/apache/seatunnel/pull/9951#discussion_r2612542028


##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/rest/RestApiHttpsTest.java:
##########
@@ -126,4 +136,245 @@ public void testRestApiHttpsFailed() {
                     conn.getResponseCode();
                 });
     }
+
+    @Test
+    public void testFinishedJobsApi() throws Exception {
+        JobInformation jobInformation = getSeatunnelServer("testFinishedJobs");
+        int jobNum = 7;
+        int pageSize = 5;
+        long jobId = 1000L;
+        for (int i = 0; i < jobNum; i++) {
+            startJob(i + jobId, "fake_to_console.conf", jobInformation);
+        }
+
+        // wait until all jobs are finished
+        await().pollDelay(5, TimeUnit.SECONDS)
+                .atMost(30, TimeUnit.SECONDS)
+                .pollInterval(100, TimeUnit.MILLISECONDS)
+                .untilAsserted(
+                        () -> {
+                            while (jobInformation
+                                            .coordinatorService
+                                            .getJobCountMetrics()
+                                            .getFinishedJobCount()
+                                    != jobNum) {
+                                Thread.sleep(1000);
+                            }
+                        });

Review Comment:
   Here, a while loop and sleep are used to wait for all tasks to complete, and 
then the API is called to query the number of completed tasks, which can then 
be compared with the number of submitted tasks for equality. If this is changed 
to an assertEquals assertion, could it be possible that the tasks have not all 
finished yet, causing the number of completed tasks queried via the API to be 
unequal to the number of submitted tasks, and thus resulting in a unit test 
failure?



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