fix(测试计划): 修复测试计划查询模块id错误的问题
This commit is contained in:
parent
93ace7f9fd
commit
ebb42a6193
|
@ -5,7 +5,10 @@ import io.metersphere.plan.domain.*;
|
|||
import io.metersphere.plan.dto.request.TestPlanBatchExecuteRequest;
|
||||
import io.metersphere.plan.dto.request.TestPlanExecuteRequest;
|
||||
import io.metersphere.plan.dto.request.TestPlanReportGenRequest;
|
||||
import io.metersphere.plan.mapper.*;
|
||||
import io.metersphere.plan.mapper.TestPlanCollectionMapper;
|
||||
import io.metersphere.plan.mapper.TestPlanConfigMapper;
|
||||
import io.metersphere.plan.mapper.TestPlanMapper;
|
||||
import io.metersphere.plan.mapper.TestPlanReportMapper;
|
||||
import io.metersphere.sdk.constants.ApiBatchRunMode;
|
||||
import io.metersphere.sdk.constants.CaseType;
|
||||
import io.metersphere.sdk.constants.TaskTriggerMode;
|
||||
|
@ -17,10 +20,10 @@ import io.metersphere.sdk.util.LogUtils;
|
|||
import io.metersphere.system.uid.IDGenerator;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -37,8 +40,6 @@ public class TestPlanExecuteService {
|
|||
@Resource
|
||||
private TestPlanMapper testPlanMapper;
|
||||
@Resource
|
||||
private ExtTestPlanReportMapper extTestPlanReportMapper;
|
||||
@Resource
|
||||
private TestPlanConfigMapper testPlanConfigMapper;
|
||||
@Resource
|
||||
private TestPlanService testPlanService;
|
||||
|
@ -226,9 +227,8 @@ public class TestPlanExecuteService {
|
|||
genReportRequest.setTestPlanId(executionQueue.getSourceID());
|
||||
genReportRequest.setProjectId(testPlan.getProjectId());
|
||||
if (StringUtils.equalsIgnoreCase(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_GROUP)) {
|
||||
|
||||
testPlanService.setActualStartTime(executionQueue.getSourceID());
|
||||
testPlanService.setTestPlanUnderway(executionQueue.getSourceID());
|
||||
//更改测试计划组的状态
|
||||
testPlanService.setExecuteConfig(executionQueue.getSourceID());
|
||||
List<TestPlan> children = testPlanService.selectNotArchivedChildren(testPlan.getId());
|
||||
// 预生成计划组报告
|
||||
Map<String, String> reportMap = testPlanReportService.genReportByExecution(executionQueue.getPrepareReportId(), genReportRequest, executionQueue.getCreateUser());
|
||||
|
@ -263,18 +263,17 @@ public class TestPlanExecuteService {
|
|||
} else {
|
||||
testPlanExecuteSupportService.setRedisForList(testPlanExecuteSupportService.genQueueKey(queueId, queueType), childrenQueue.stream().map(JSON::toJSONString).toList());
|
||||
|
||||
// 更新报告的执行时间
|
||||
if (MapUtils.isNotEmpty(reportMap)) {
|
||||
extTestPlanReportMapper.batchUpdateExecuteTimeAndStatus(System.currentTimeMillis(), reportMap.values().stream().toList());
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(executionQueue.getRunMode(), ApiBatchRunMode.SERIAL.name())) {
|
||||
//串行
|
||||
TestPlanExecutionQueue nextQueue = testPlanExecuteSupportService.getNextQueue(queueId, queueType);
|
||||
testPlanReportService.updateExecuteTimeAndStatus(nextQueue.getPrepareReportId());
|
||||
testPlanService.setExecuteConfig(nextQueue.getSourceID());
|
||||
executeTestPlan(nextQueue);
|
||||
} else {
|
||||
//并行
|
||||
childrenQueue.forEach(childQueue -> {
|
||||
testPlanReportService.updateExecuteTimeAndStatus(childQueue.getPrepareReportId());
|
||||
testPlanService.setExecuteConfig(childQueue.getSourceID());
|
||||
executeTestPlan(childQueue);
|
||||
});
|
||||
}
|
||||
|
@ -284,23 +283,21 @@ public class TestPlanExecuteService {
|
|||
} else {
|
||||
Map<String, String> reportMap = testPlanReportService.genReportByExecution(executionQueue.getPrepareReportId(), genReportRequest, executionQueue.getCreateUser());
|
||||
executionQueue.setPrepareReportId(reportMap.get(executionQueue.getSourceID()));
|
||||
if (MapUtils.isNotEmpty(reportMap)) {
|
||||
extTestPlanReportMapper.batchUpdateExecuteTimeAndStatus(System.currentTimeMillis(), reportMap.values().stream().toList());
|
||||
}
|
||||
testPlanReportService.updateExecuteTimeAndStatus(executionQueue.getPrepareReportId());
|
||||
testPlanService.setExecuteConfig(executionQueue.getSourceID());
|
||||
this.executeTestPlan(executionQueue);
|
||||
return executionQueue.getPrepareReportId();
|
||||
}
|
||||
}
|
||||
|
||||
//执行测试计划里不同类型的用例 回调:caseTypeExecuteQueueFinish
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public void executeTestPlan(TestPlanExecutionQueue executionQueue) {
|
||||
boolean testPlanStopped = testPlanExecuteSupportService.checkTestPlanStopped(executionQueue.getPrepareReportId());
|
||||
if (testPlanStopped) {
|
||||
//测试计划报告状态已停止的话便不再执行。执行下一个队列。
|
||||
this.testPlanExecuteQueueFinish(executionQueue.getQueueId(), executionQueue.getQueueType());
|
||||
} else {
|
||||
testPlanService.setActualStartTime(executionQueue.getSourceID());
|
||||
testPlanService.setTestPlanUnderway(executionQueue.getSourceID());
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(executionQueue.getSourceID());
|
||||
TestPlanCollectionExample testPlanCollectionExample = new TestPlanCollectionExample();
|
||||
testPlanCollectionExample.createCriteria().andTestPlanIdEqualTo(testPlan.getId()).andParentIdEqualTo("NONE");
|
||||
|
@ -473,6 +470,7 @@ public class TestPlanExecuteService {
|
|||
//并行时,调用回调时意味着执行结束,所以判断是否是当前队列最后一个从而结束队列
|
||||
this.queueExecuteFinish(nextQueue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//测试计划中当前用例类型的全部执行完成
|
||||
|
@ -558,7 +556,6 @@ public class TestPlanExecuteService {
|
|||
//并行时,调用回调时意味着执行结束,所以判断是否是当前队列最后一个从而结束队列
|
||||
this.queueExecuteFinish(nextQueue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void executeNextNode(TestPlanExecutionQueue queue) {
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.springframework.data.redis.core.ListOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -56,7 +57,7 @@ public class TestPlanExecuteSupportService {
|
|||
redisTemplate.delete(genQueueKey(redisKey, LAST_QUEUE_PREFIX));
|
||||
}
|
||||
|
||||
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public void summaryTestPlanReport(String reportId, boolean isGroupReport, boolean isStop) {
|
||||
LogUtils.info("开始合并报告: --- 报告ID[{}],是否是报告组[{}]", reportId, isGroupReport);
|
||||
try {
|
||||
|
@ -80,7 +81,12 @@ public class TestPlanExecuteSupportService {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error("Cannot find test plan report for " + reportId, e);
|
||||
LogUtils.error("测试计划报告汇总失败!reportId:" + reportId, e);
|
||||
TestPlanReport stopReport = testPlanReportService.selectById(reportId);
|
||||
stopReport.setId(reportId);
|
||||
stopReport.setExecStatus(ExecStatus.ERROR.name());
|
||||
stopReport.setEndTime(System.currentTimeMillis());
|
||||
testPlanReportMapper.updateByPrimaryKeySelective(stopReport);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -982,4 +982,9 @@ public class TestPlanReportService {
|
|||
public List<TestPlanReportDetailResponse> planReportList(TestPlanReportDetailPageRequest request) {
|
||||
return extTestPlanReportMapper.getPlanReportListById(request);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NOT_SUPPORTED)
|
||||
public void updateExecuteTimeAndStatus(String prepareReportId) {
|
||||
extTestPlanReportMapper.batchUpdateExecuteTimeAndStatus(System.currentTimeMillis(), Collections.singletonList(prepareReportId));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -480,8 +481,8 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
|||
TestPlanDetailResponse response = new TestPlanDetailResponse();
|
||||
|
||||
String moduleName = Translator.get("unplanned.plan");
|
||||
if (!ModuleConstants.DEFAULT_NODE_ID.equals(id)) {
|
||||
TestPlanModule module = testPlanModuleMapper.selectByPrimaryKey(id);
|
||||
if (!ModuleConstants.DEFAULT_NODE_ID.equals(testPlan.getModuleId())) {
|
||||
TestPlanModule module = testPlanModuleMapper.selectByPrimaryKey(testPlan.getModuleId());
|
||||
moduleName = module == null ? Translator.get("unplanned.plan") : module.getName();
|
||||
response.setModuleId(module == null ? ModuleConstants.DEFAULT_NODE_ID : module.getId());
|
||||
}
|
||||
|
@ -993,4 +994,10 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
|||
// 删除测试集
|
||||
testPlanCollectionMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NOT_SUPPORTED)
|
||||
public void setExecuteConfig(String sourceID) {
|
||||
this.setActualStartTime(sourceID);
|
||||
this.setTestPlanUnderway(sourceID);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue