Skip to content

Commit 78cb0de

Browse files
authored
[Improve][RestAPI] always return jobId when call getJobInfoById API (#6422)
1 parent 6ec16ac commit 78cb0de

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

Diff for: docs/en/seatunnel-engine/rest-api.md

+8
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ network:
111111
}
112112
```
113113

114+
When we can't get the job info, the response will be:
115+
116+
```json
117+
{
118+
"jobId" : ""
119+
}
120+
```
121+
114122
</details>
115123

116124
------------------------------------------------------------------------------------------

Diff for: seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/java/org/apache/seatunnel/engine/e2e/RestApiIT.java

+34
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,40 @@ public void testGetRunningJobById() {
108108
});
109109
}
110110

111+
@Test
112+
public void testGetAnNotExistJobById() {
113+
Arrays.asList(node2, node1)
114+
.forEach(
115+
instance -> {
116+
given().get(
117+
HOST
118+
+ instance.getCluster()
119+
.getLocalMember()
120+
.getAddress()
121+
.getPort()
122+
+ RestConstant.RUNNING_JOB_URL
123+
+ "/"
124+
+ 123)
125+
.then()
126+
.statusCode(200)
127+
.body("jobId", equalTo("123"));
128+
});
129+
Arrays.asList(node2, node1)
130+
.forEach(
131+
instance -> {
132+
given().get(
133+
HOST
134+
+ instance.getCluster()
135+
.getLocalMember()
136+
.getAddress()
137+
.getPort()
138+
+ RestConstant.RUNNING_JOB_URL
139+
+ "/")
140+
.then()
141+
.statusCode(500);
142+
});
143+
}
144+
111145
@Test
112146
public void testGetRunningJobs() {
113147
Arrays.asList(node2, node1)

Diff for: seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/RestHttpGetCommandProcessor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ private void handleJobInfoById(HttpGetCommand command, String uri) {
275275
if (!jobId.isEmpty() && jobInfo != null) {
276276
this.prepareResponse(command, convertToJson(jobInfo, Long.parseLong(jobId)));
277277
} else {
278-
this.prepareResponse(command, new JsonObject());
278+
this.prepareResponse(command, new JsonObject().add(RestConstant.JOB_ID, jobId));
279279
}
280280
}
281281

0 commit comments

Comments
 (0)