Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improve][RestAPI] always return jobId when call getJobInfoById API #6422

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/en/seatunnel-engine/rest-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ network:
}
```

When we can't get the job info, the response will be:

```json
{
"jobId" : ""
}
```

</details>

------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,40 @@ public void testGetRunningJobById() {
});
}

@Test
public void testGetAnNotExistJobById() {
Arrays.asList(node2, node1)
.forEach(
instance -> {
given().get(
HOST
+ instance.getCluster()
.getLocalMember()
.getAddress()
.getPort()
+ RestConstant.RUNNING_JOB_URL
+ "/"
+ 123)
.then()
.statusCode(200)
.body("jobId", equalTo("123"));
});
Arrays.asList(node2, node1)
.forEach(
instance -> {
given().get(
HOST
+ instance.getCluster()
.getLocalMember()
.getAddress()
.getPort()
+ RestConstant.RUNNING_JOB_URL
+ "/")
.then()
.statusCode(500);
});
}

@Test
public void testGetRunningJobs() {
Arrays.asList(node2, node1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private void handleJobInfoById(HttpGetCommand command, String uri) {
if (!jobId.isEmpty() && jobInfo != null) {
this.prepareResponse(command, convertToJson(jobInfo, Long.parseLong(jobId)));
} else {
this.prepareResponse(command, new JsonObject());
this.prepareResponse(command, new JsonObject().add(RestConstant.JOB_ID, jobId));
}
}

Expand Down