Skip to content

Commit

Permalink
[Bug] [Seatunnel-web] Job instance delete is not working (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
arshadmohammad authored Sep 2, 2024
1 parent dd896a6 commit 3959577
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.seatunnel.server.common.SeatunnelErrorEnum;
import org.apache.seatunnel.server.common.SeatunnelException;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
Expand Down Expand Up @@ -108,4 +109,12 @@ Result<SeaTunnelJobInstanceDto> getJobExecutionDetail(
@ApiParam(value = "jobInstanceId", required = true) @RequestParam Long jobInstanceId) {
return taskInstanceService.getJobExecutionDetail(userId, jobInstanceId);
}

@DeleteMapping("/delete")
@ApiOperation(value = "Deletes given job instance id", httpMethod = "DELETE")
Result<Void> deleteJobInstance(
@ApiParam(value = "userId", required = true) @RequestAttribute("userId") Integer userId,
@ApiParam(value = "jobInstanceId", required = true) @RequestParam Long jobInstanceId) {
return taskInstanceService.deleteJobInstanceById(userId, jobInstanceId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ IPage<SeaTunnelJobInstanceDto> queryJobInstanceListPaging(
List<JobInstance> getAllJobInstance(@NonNull List<Long> jobInstanceIdList);

JobInstance getJobExecutionStatus(@NonNull Long jobInstanceId);

void deleteById(@NonNull Long jobInstanceId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@ public List<JobInstance> getAllJobInstance(@NonNull List<Long> jobInstanceIdList
public JobInstance getJobExecutionStatus(@NonNull Long jobInstanceId) {
return jobInstanceMapper.getJobExecutionStatus(jobInstanceId);
}

@Override
public void deleteById(@NonNull Long jobInstanceId) {
jobInstanceMapper.deleteById(jobInstanceId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ Result<PageInfo<T>> getSyncTaskInstancePaging(
Result<JobExecutionStatus> getJobExecutionStatus(Integer userId, long jobInstanceId);

Result<SeaTunnelJobInstanceDto> getJobExecutionDetail(Integer userId, long jobInstanceId);

Result<Void> deleteJobInstanceById(Integer userId, long jobInstanceId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,10 @@ private SeaTunnelJobInstanceDto convertToDto(JobInstance jobInstance) {
dto.setErrorMessage(jobInstance.getErrorMessage());
return dto;
}

@Override
public Result<Void> deleteJobInstanceById(Integer userId, long jobInstanceId) {
jobInstanceDao.deleteById(jobInstanceId);
return Result.success();
}
}
4 changes: 2 additions & 2 deletions seatunnel-ui/src/service/sync-task-instance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function hanldleRecoverJob(id: number): any {

export function hanldleDelJob(id: number): any {
return axios({
url: `/job/executor/del?jobInstanceId=${id}`,
method: 'get'
url: `/job/executor/delete?jobInstanceId=${id}`,
method: 'delete'
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,7 @@ export function useSyncTask(syncTaskType = 'BATCH') {
isDelete: true,
text: t('project.synchronization_instance.delete'),
icon: h(DeleteOutlined),
onClick: (row) => void handleDel(row.id),
onPositiveClick: () => {
console.log('123')
},
onPositiveClick: (row) => void handleDel(row.id),
positiveText: t('project.synchronization_instance.confirm'),
popTips: t('project.synchronization_instance.delete_confirm')
}
Expand Down Expand Up @@ -226,6 +223,7 @@ export function useSyncTask(syncTaskType = 'BATCH') {
const handleDel = (id: number) => {
hanldleDelJob(id).then(() => {
message.success(t('common.success_tips'))
getList()
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,13 @@ public Result<SeaTunnelJobInstanceDto> getJobExecutionDetail(Long jobInstanceId)
return JSONTestUtils.parseObject(
response, new TypeReference<Result<SeaTunnelJobInstanceDto>>() {});
}

public Result<Void> deleteJobInstance(long jobInstanceId) {
String response =
sendRequest(
urlWithParam("job/executor/delete?jobInstanceId=" + jobInstanceId),
null,
"DELETE");
return JSONTestUtils.parseObject(response, Result.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,36 @@ public void storeErrorMessageWhenJobFailed() throws InterruptedException {
assertEquals(404, jobExecutionDetailResult2.getCode());
}

@Test
public void testJobInstanceDelete() {
String jobName = "jobInstanceDelete" + uniqueId;
long jobVersionId = JobTestingUtils.createJob(jobName);
Result<Long> result = jobExecutorControllerWrapper.jobExecutor(jobVersionId);
assertTrue(result.isSuccess());
assertTrue(result.getData() > 0);
Long jobInstanceId = result.getData();
JobTestingUtils.waitForJobCompletion(jobInstanceId);
Result<SeaTunnelJobInstanceDto> jobExecutionDetailResult =
jobExecutorControllerWrapper.getJobExecutionDetail(jobInstanceId);
assertTrue(jobExecutionDetailResult.isSuccess());
assertNotNull(jobExecutionDetailResult.getData());

// Delete should be success
Result<Void> deleteResult = jobExecutorControllerWrapper.deleteJobInstance(jobInstanceId);
assertTrue(deleteResult.isSuccess());

// After delete job instance should not be found
jobExecutionDetailResult =
jobExecutorControllerWrapper.getJobExecutionDetail(jobInstanceId);
assertFalse(jobExecutionDetailResult.isSuccess());
assertEquals(404, jobExecutionDetailResult.getCode());

// Delete job instance which do not exist
deleteResult = jobExecutorControllerWrapper.deleteJobInstance(jobInstanceId);
// should be success as there is nothing to delete
assertTrue(deleteResult.isSuccess());
}

@AfterAll
public static void tearDown() {
seaTunnelWebCluster.stop();
Expand Down

0 comments on commit 3959577

Please sign in to comment.