fix(接口测试): 批量执行失败停止,没有更新任务状态
--bug=1047873 --user=陈建星 【任务中心】-批量执行场景,执行方式为串行+失败停止,批量执行任务不会自动停止,失败停止的场景处于等待排队状态 https://www.tapd.cn/55049933/s/1596875
This commit is contained in:
parent
d7d57690ce
commit
1d9c4b2af7
|
@ -3,6 +3,7 @@ package io.metersphere.api.listener;
|
||||||
import io.metersphere.api.invoker.ApiExecuteCallbackServiceInvoker;
|
import io.metersphere.api.invoker.ApiExecuteCallbackServiceInvoker;
|
||||||
import io.metersphere.api.mapper.ApiReportMapper;
|
import io.metersphere.api.mapper.ApiReportMapper;
|
||||||
import io.metersphere.api.mapper.ApiScenarioReportMapper;
|
import io.metersphere.api.mapper.ApiScenarioReportMapper;
|
||||||
|
import io.metersphere.api.service.ApiBatchRunBaseService;
|
||||||
import io.metersphere.api.service.ApiReportSendNoticeService;
|
import io.metersphere.api.service.ApiReportSendNoticeService;
|
||||||
import io.metersphere.api.service.definition.ApiTestCaseBatchRunService;
|
import io.metersphere.api.service.definition.ApiTestCaseBatchRunService;
|
||||||
import io.metersphere.api.service.queue.ApiExecutionQueueService;
|
import io.metersphere.api.service.queue.ApiExecutionQueueService;
|
||||||
|
@ -30,10 +31,11 @@ public class MessageListener {
|
||||||
public static final String MESSAGE_CONSUME_ID = "MS-API-MESSAGE-CONSUME";
|
public static final String MESSAGE_CONSUME_ID = "MS-API-MESSAGE-CONSUME";
|
||||||
@Resource
|
@Resource
|
||||||
private ApiReportSendNoticeService apiReportSendNoticeService;
|
private ApiReportSendNoticeService apiReportSendNoticeService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ApiExecutionQueueService apiExecutionQueueService;
|
private ApiExecutionQueueService apiExecutionQueueService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private ApiBatchRunBaseService apiBatchRunBaseService;
|
||||||
|
@Resource
|
||||||
private ApiTestCaseBatchRunService apiTestCaseBatchRunService;
|
private ApiTestCaseBatchRunService apiTestCaseBatchRunService;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiScenarioBatchRunService apiScenarioBatchRunService;
|
private ApiScenarioBatchRunService apiScenarioBatchRunService;
|
||||||
|
@ -118,6 +120,10 @@ public class MessageListener {
|
||||||
}
|
}
|
||||||
if (isStopOnFailure(dto)) {
|
if (isStopOnFailure(dto)) {
|
||||||
ApiExecuteResourceType resourceType = EnumValidator.validateEnum(ApiExecuteResourceType.class, queue.getResourceType());
|
ApiExecuteResourceType resourceType = EnumValidator.validateEnum(ApiExecuteResourceType.class, queue.getResourceType());
|
||||||
|
if (resourceType != ApiExecuteResourceType.PLAN_RUN_API_SCENARIO && resourceType != ApiExecuteResourceType.PLAN_RUN_API_CASE) {
|
||||||
|
// 失败停止,更新任务状态
|
||||||
|
apiBatchRunBaseService.updateTaskCompletedStatus(queue.getTaskId(), ResultStatus.ERROR.name());
|
||||||
|
}
|
||||||
// 补充集成报告
|
// 补充集成报告
|
||||||
updateStopOnFailureIntegratedReport(dto, queue, resourceType);
|
updateStopOnFailureIntegratedReport(dto, queue, resourceType);
|
||||||
// 如果是失败停止,清空队列,不继续执行
|
// 如果是失败停止,清空队列,不继续执行
|
||||||
|
|
|
@ -210,6 +210,10 @@ public class ApiBatchRunBaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTaskCompletedStatus(String taskId) {
|
public void updateTaskCompletedStatus(String taskId) {
|
||||||
|
updateTaskCompletedStatus(taskId, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTaskCompletedStatus(String taskId, String result) {
|
||||||
// 删除执行缓存
|
// 删除执行缓存
|
||||||
removeRunningTaskCache(taskId);
|
removeRunningTaskCache(taskId);
|
||||||
ExecTask originExecTask = execTaskMapper.selectByPrimaryKey(taskId);
|
ExecTask originExecTask = execTaskMapper.selectByPrimaryKey(taskId);
|
||||||
|
@ -220,12 +224,16 @@ public class ApiBatchRunBaseService {
|
||||||
execTask.setEndTime(System.currentTimeMillis());
|
execTask.setEndTime(System.currentTimeMillis());
|
||||||
execTask.setId(taskId);
|
execTask.setId(taskId);
|
||||||
execTask.setStatus(ExecStatus.COMPLETED.name());
|
execTask.setStatus(ExecStatus.COMPLETED.name());
|
||||||
if (extExecTaskItemMapper.hasErrorItem(taskId)) {
|
if (StringUtils.isNotBlank(result)) {
|
||||||
execTask.setResult(ResultStatus.ERROR.name());
|
execTask.setResult(result);
|
||||||
} else if (extExecTaskItemMapper.hasFakeErrorItem(taskId)) {
|
|
||||||
execTask.setResult(ResultStatus.FAKE_ERROR.name());
|
|
||||||
} else {
|
} else {
|
||||||
execTask.setResult(ResultStatus.SUCCESS.name());
|
if (extExecTaskItemMapper.hasErrorItem(taskId)) {
|
||||||
|
execTask.setResult(ResultStatus.ERROR.name());
|
||||||
|
} else if (extExecTaskItemMapper.hasFakeErrorItem(taskId)) {
|
||||||
|
execTask.setResult(ResultStatus.FAKE_ERROR.name());
|
||||||
|
} else {
|
||||||
|
execTask.setResult(ResultStatus.SUCCESS.name());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
execTaskMapper.updateByPrimaryKeySelective(execTask);
|
execTaskMapper.updateByPrimaryKeySelective(execTask);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue