fix(系统管理): 测试计划组停止时对已完成的子计划不作处理

This commit is contained in:
Jianguo-Genius 2024-08-16 18:26:12 +08:00 committed by Craftsman
parent 2f64741bda
commit 4d8378c10e
2 changed files with 13 additions and 12 deletions

View File

@ -9,10 +9,7 @@ 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;
import io.metersphere.sdk.constants.TestPlanConstants;
import io.metersphere.sdk.constants.*;
import io.metersphere.sdk.dto.queue.TestPlanExecutionQueue;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.JSON;
@ -60,7 +57,9 @@ public class TestPlanExecuteService {
// 停止测试计划的执行
public void stopTestPlanRunning(String testPlanReportId) {
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportId);
if (testPlanReport == null) {
if (testPlanReport == null
|| StringUtils.equalsAnyIgnoreCase(testPlanReport.getExecStatus(), ExecStatus.COMPLETED.name(), ExecStatus.STOPPED.name())) {
// 已经执行完成或者已经停止的测试计划不再操作
return;
}
if (testPlanReport.getIntegrated()) {
@ -86,9 +85,12 @@ public class TestPlanExecuteService {
String groupExecuteQueueId = testPlanExecuteSupportService.genQueueKey(testPlanReportId, QUEUE_PREFIX_TEST_PLAN_GROUP_EXECUTE);
testPlanExecuteSupportService.deleteRedisKey(groupExecuteQueueId);
testPlanItemReport.forEach(item -> {
this.deepDeleteTestPlanCaseType(item);
//统计子测试计划报告
testPlanExecuteSupportService.summaryTestPlanReport(item.getId(), false, true);
//处理未完成的子报告
if (!StringUtils.equalsIgnoreCase(item.getExecStatus(), ExecStatus.COMPLETED.name())) {
this.deepDeleteTestPlanCaseType(item);
//统计子测试计划报告
testPlanExecuteSupportService.summaryTestPlanReport(item.getId(), false, true);
}
});
testPlanExecuteSupportService.summaryTestPlanReport(testPlanReportId, true, true);
this.testPlanExecuteQueueFinish(nextTestPlanQueue.getParentQueueId(), nextTestPlanQueue.getParentQueueType());

View File

@ -265,10 +265,6 @@ public class TestPlanExecuteTests extends BaseTest {
}
}
// 待补充
// Assertions.assertTrue(!collectionQueueIdList.isEmpty());
// Assertions.assertTrue(!allQueueIds.isEmpty());
this.checkRedisKeyEmpty(allQueueIds, collectionQueueIdList);
}
@ -285,6 +281,9 @@ public class TestPlanExecuteTests extends BaseTest {
List<String> collectionQueueIdList = new ArrayList<>();
for (String executeQueue : EXECUTE_QUEUE_PREFIX) {
Set<String> keys = stringRedisTemplate.keys("*" + executeQueue + "*");
if (CollectionUtils.isEmpty(keys)) {
continue;
}
allQueueIds.addAll(keys);
for (String key : keys) {
if (StringUtils.equalsIgnoreCase(executeQueue, QUEUE_PREFIX_TEST_PLAN_COLLECTION)) {