refactor(测试计划): 重构测试计划执行报告状态处理
This commit is contained in:
parent
6b0337cc74
commit
5edf97a356
|
@ -14,8 +14,10 @@ import io.metersphere.base.mapper.ext.ExtApiExecutionQueueMapper;
|
|||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.constants.TestPlanReportStatus;
|
||||
import io.metersphere.commons.utils.BeanUtils;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
import io.metersphere.dto.ResultDTO;
|
||||
import io.metersphere.track.service.TestPlanReportService;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -159,6 +161,10 @@ public class ApiExecutionQueueService {
|
|||
if (StringUtils.equals(dto.getReportType(), RunModeConstants.SET_REPORT.toString())) {
|
||||
apiScenarioReportService.margeReport(dto.getReportId());
|
||||
}
|
||||
// 更新测试计划报告
|
||||
if (StringUtils.isNotEmpty(dto.getTestPlanReportId())) {
|
||||
CommonBeanFactory.getBean(TestPlanReportService.class).finishedTestPlanReport(dto.getTestPlanReportId());
|
||||
}
|
||||
queueMapper.deleteByPrimaryKey(executionQueue.getId());
|
||||
LoggerUtil.info("队列:" + dto.getQueueId() + " 执行结束");
|
||||
}
|
||||
|
@ -210,6 +216,16 @@ public class ApiExecutionQueueService {
|
|||
}
|
||||
});
|
||||
}
|
||||
// 处理测试计划报告
|
||||
List<ApiExecutionQueue> queues = extApiExecutionQueueMapper.findTestPlanReportQueue();
|
||||
if (CollectionUtils.isNotEmpty(queues)) {
|
||||
queues.forEach(item -> {
|
||||
// 更新测试计划报告
|
||||
if (StringUtils.isNotEmpty(item.getReportId())) {
|
||||
CommonBeanFactory.getBean(TestPlanReportService.class).finishedTestPlanReport(item.getReportId());
|
||||
}
|
||||
});
|
||||
}
|
||||
// 清除异常队列/一般是服务突然停止产生
|
||||
extApiExecutionQueueMapper.delete();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.base.domain.ApiExecutionQueue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtApiExecutionQueueMapper {
|
||||
void delete();
|
||||
|
||||
List<ApiExecutionQueue> findTestPlanReportQueue();
|
||||
}
|
|
@ -4,4 +4,7 @@
|
|||
<delete id="delete">
|
||||
DELETE from api_execution_queue where id not IN (SELECT t1.queue_id from api_execution_queue_detail t1);
|
||||
</delete>
|
||||
<select id="findTestPlanReportQueue" resultType="io.metersphere.base.domain.ApiExecutionQueue">
|
||||
select * from api_execution_queue where report_id !=null and run_mode='API_PLAN' and id not IN (SELECT t1.queue_id from api_execution_queue_detail t1) ;
|
||||
</select>
|
||||
</mapper>
|
|
@ -319,12 +319,12 @@ public class TestPlanReportService {
|
|||
|
||||
public TestPlanReport finishedTestPlanReport(String testPlanReportId) {
|
||||
TestPlanReport testPlanReport = this.getTestPlanReport(testPlanReportId);
|
||||
if (testPlanReport != null) {
|
||||
//初始化测试计划包含组件信息
|
||||
int[] componentIndexArr = new int[]{1, 3, 4};
|
||||
testPlanReport.setComponents(JSONArray.toJSONString(componentIndexArr));
|
||||
//计算测试计划状态
|
||||
String testPlanStatus = this.getTestPlanReportStatus(testPlanReport, null);
|
||||
testPlanReport.setStatus(testPlanStatus);
|
||||
testPlanReport.setStatus(TestPlanReportStatus.COMPLETED.name());
|
||||
//如果测试案例没有未结束的功能用例,则更新最后结束日期。
|
||||
TestPlanTestCaseMapper testPlanTestCaseMapper = CommonBeanFactory.getBean(TestPlanTestCaseMapper.class);
|
||||
TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample();
|
||||
|
@ -342,6 +342,7 @@ public class TestPlanReportService {
|
|||
testPlanReport.setIsScenarioExecuting(false);
|
||||
testPlanReport.setIsPerformanceExecuting(false);
|
||||
testPlanReport = this.update(testPlanReport);
|
||||
}
|
||||
return testPlanReport;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue