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


##########
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:
   Inside `untilAsserted`, it's better to use `assertEquals` instead of a 
`while` loop with `sleep`. A blocking loop prevents Awaitility from polling 
properly and may lead to indefinite hangs.



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