From 4d8378c10eda94e4268c458290e6fa604af06a87 Mon Sep 17 00:00:00 2001 From: Jianguo-Genius Date: Fri, 16 Aug 2024 18:26:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E7=BB=84=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E6=97=B6=E5=AF=B9=E5=B7=B2=E5=AE=8C=E6=88=90=E7=9A=84=E5=AD=90?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E4=B8=8D=E4=BD=9C=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/service/TestPlanExecuteService.java | 18 ++++++++++-------- .../plan/controller/TestPlanExecuteTests.java | 7 +++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanExecuteService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanExecuteService.java index 2a499680a2..dca719280f 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanExecuteService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanExecuteService.java @@ -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()); diff --git a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanExecuteTests.java b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanExecuteTests.java index 7057da465b..4f1dd8d834 100644 --- a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanExecuteTests.java +++ b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanExecuteTests.java @@ -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 collectionQueueIdList = new ArrayList<>(); for (String executeQueue : EXECUTE_QUEUE_PREFIX) { Set 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)) {