fix(接口测试): 测试计划执行,资源池不可用,任务状态显示有误
--bug=1047861 --user=陈建星 【测试计划】资源池被禁用-执行计划-任务数据问题汇总 https://www.tapd.cn/55049933/s/1596223
This commit is contained in:
parent
4aabe786a0
commit
6293dd63fa
|
@ -209,24 +209,31 @@ public class ApiBatchRunBaseService {
|
|||
return runModeConfig.getEnvironmentId();
|
||||
}
|
||||
|
||||
public void updateTaskStatus(String taskId) {
|
||||
// 更新任务状态
|
||||
ExecTask execTask = new ExecTask();
|
||||
execTask.setEndTime(System.currentTimeMillis());
|
||||
execTask.setId(taskId);
|
||||
execTask.setStatus(ExecStatus.COMPLETED.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());
|
||||
public void updateTaskCompletedStatus(String taskId) {
|
||||
// 删除执行缓存
|
||||
removeRunningTaskCache(taskId);
|
||||
ExecTask originExecTask = execTaskMapper.selectByPrimaryKey(taskId);
|
||||
// 出现异常,导致任务没有开始,则不更新任务状态
|
||||
if (!StringUtils.equals(originExecTask.getStatus(), ExecStatus.PENDING.name())) {
|
||||
// 更新任务状态
|
||||
ExecTask execTask = new ExecTask();
|
||||
execTask.setEndTime(System.currentTimeMillis());
|
||||
execTask.setId(taskId);
|
||||
execTask.setStatus(ExecStatus.COMPLETED.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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理正在运行的任务缓存
|
||||
*
|
||||
* @param taskId
|
||||
*/
|
||||
public void removeRunningTaskCache(String taskId) {
|
||||
|
|
|
@ -175,8 +175,7 @@ public class TestPlanApiCaseBatchRunService {
|
|||
ExecutionQueue collectionQueue = apiExecutionQueueService.getQueue(collectionQueueId);
|
||||
if (collectionQueue == null) {
|
||||
// 失败停止,或者执行完成,更新任务状态
|
||||
apiBatchRunBaseService.updateTaskStatus(collectionQueueId);
|
||||
apiBatchRunBaseService.removeRunningTaskCache(collectionQueueId);
|
||||
apiBatchRunBaseService.updateTaskCompletedStatus(collectionQueueId);
|
||||
return;
|
||||
}
|
||||
String userId = collectionQueue.getUserId();
|
||||
|
|
|
@ -200,8 +200,7 @@ public class TestPlanApiScenarioBatchRunService {
|
|||
ExecutionQueue collectionQueue = apiExecutionQueueService.getQueue(collectionQueueId);
|
||||
if (collectionQueue == null) {
|
||||
// 失败停止,或者执行完成,更新任务状态
|
||||
apiBatchRunBaseService.updateTaskStatus(collectionQueueId);
|
||||
apiBatchRunBaseService.removeRunningTaskCache(collectionQueueId);
|
||||
apiBatchRunBaseService.updateTaskCompletedStatus(collectionQueueId);
|
||||
return;
|
||||
}
|
||||
String userId = collectionQueue.getUserId();
|
||||
|
|
|
@ -687,8 +687,7 @@ public class TestPlanExecuteService {
|
|||
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(reportId);
|
||||
if (StringUtils.equals(testPlanReport.getParentId(), reportId) && StringUtils.isNotBlank(taskId)) {
|
||||
// 执行完成,更新任务状态
|
||||
apiBatchRunBaseService.updateTaskStatus(taskId);
|
||||
apiBatchRunBaseService.removeRunningTaskCache(taskId);
|
||||
apiBatchRunBaseService.updateTaskCompletedStatus(taskId);
|
||||
}
|
||||
testPlanExecuteSupportService.summaryTestPlanReport(reportId, isGroupReport, isStop);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue