liucongjy commented on code in PR #9951:
URL: https://github.com/apache/seatunnel/pull/9951#discussion_r2532843189
##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/rest/RestApiHttpsTest.java:
##########
@@ -126,4 +136,242 @@ 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(30000, TimeUnit.MILLISECONDS)
+ .untilAsserted(
+ () -> {
+ while (jobInformation
+ .coordinatorService
+ .getJobCountMetrics()
+ .getFinishedJobCount()
+ != jobNum) {
+ Thread.sleep(1000);
+ }
+ });
+
+ // pagination test
+ // page 1
+ restApiRequestHttp(
+ "http://localhost:" + HTTP_PORT2 +
"/finished-jobs?page=1&rows=" + pageSize,
+ (code, content) -> {
+ Assertions.assertEquals(200, code);
+ JsonObject resultJson = (JsonObject) Json.parse(content);
+ Assertions.assertTrue(
+ resultJson.get("data") != null &&
resultJson.get("total") != null);
+ int total = resultJson.getInt("total", 0);
+ JsonArray data = (JsonArray) resultJson.get("data");
+ Assertions.assertTrue(total == jobNum && data.size() ==
pageSize);
+ });
+ // page 2
+ restApiRequestHttp(
+ "http://localhost:" + HTTP_PORT2 +
"/finished-jobs?page=2&rows=" + pageSize,
+ (code, content) -> {
+ Assertions.assertEquals(200, code);
+ JsonObject resultJson = (JsonObject) Json.parse(content);
+ Assertions.assertTrue(
+ resultJson.get("data") != null &&
resultJson.get("total") != null);
+ int total = resultJson.getInt("total", 0);
+ JsonArray data = (JsonArray) resultJson.get("data");
+ Assertions.assertTrue(total == jobNum && data.size() == 2);
+ });
+ // no pagination test
+ restApiRequestHttp(
+ "http://localhost:" + HTTP_PORT2 + "/finished-jobs",
+ (code, content) -> {
+ Assertions.assertEquals(200, code);
+ JsonArray resultJson = (JsonArray) Json.parse(content);
+ Assertions.assertTrue(resultJson != null);
+ Assertions.assertTrue(resultJson.size() == jobNum);
+ });
+ shutdown(jobInformation);
+ }
+
+ @Test
+ public void testRunningJobsApi() throws Exception {
+ JobInformation jobInformation = getSeatunnelServer("testRunningJobs");
+ int jobNum = 20;
+ int pageSize = 5;
+ long jobId = 2000L;
+ for (int i = 0; i < jobNum; i++) {
+ startJob(i + jobId, "fake_to_console.conf", jobInformation);
+ }
+
+ // wait until all jobs are running
+ await().atMost(30000, TimeUnit.MILLISECONDS)
+ .untilAsserted(
+ () -> {
+ while
(jobInformation.coordinatorService.getRunningJobMetrics().size()
+ != jobNum) {
+ Thread.sleep(100);
+ }
+ });
Review Comment:
have been modify
--
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]