From 98a9fc662bed8e19c1b524a8d364c1ab30268d36 Mon Sep 17 00:00:00 2001 From: Jianguo-Genius Date: Mon, 24 Jun 2024 21:22:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E6=B5=8B=E8=AF=95=E9=9B=86=E5=B9=B6=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E4=BC=9A=E5=87=BA=E7=8E=B0=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E5=AE=8C=E6=97=A0=E6=B3=95=E8=BF=9B=E8=A1=8C=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/PlanRunTestPlanApiCaseService.java | 3 ++- .../PlanRunTestPlanApiScenarioService.java | 3 ++- .../plan/service/TestPlanExecuteService.java | 17 +++++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiCaseService.java index 8f5fdc41c7..bad09c974a 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiCaseService.java @@ -28,6 +28,7 @@ import io.metersphere.sdk.dto.queue.TestPlanExecutionQueue; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.LogUtils; import io.metersphere.sdk.util.SubListUtils; +import io.metersphere.system.uid.IDGenerator; import jakarta.annotation.Resource; import jodd.util.StringUtil; import org.apache.commons.collections.CollectionUtils; @@ -106,7 +107,7 @@ public class PlanRunTestPlanApiCaseService { * @return 是否执行完毕 */ public boolean parallelExecute(TestPlanExecutionQueue testPlanExecutionQueue) { - String parentQueueId = testPlanExecutionQueue.getQueueId(); + String parentQueueId = testPlanExecutionQueue.getQueueId() + "_" + IDGenerator.nextStr(); String testPlanReportId = testPlanExecutionQueue.getPrepareReportId(); String userId = testPlanExecutionQueue.getCreateUser(); TestPlanCollection collection = JSON.parseObject(testPlanExecutionQueue.getTestPlanCollectionJson(), TestPlanCollection.class); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiScenarioService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiScenarioService.java index 7c963e8006..d0b84ebd24 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiScenarioService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiScenarioService.java @@ -27,6 +27,7 @@ import io.metersphere.sdk.dto.queue.TestPlanExecutionQueue; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.LogUtils; import io.metersphere.sdk.util.SubListUtils; +import io.metersphere.system.uid.IDGenerator; import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; import org.springframework.stereotype.Service; @@ -100,7 +101,7 @@ public class PlanRunTestPlanApiScenarioService { * @return 是否执行完毕 */ public boolean parallelExecute(TestPlanExecutionQueue testPlanExecutionQueue) { - String parentQueueId = testPlanExecutionQueue.getQueueId(); + String parentQueueId = testPlanExecutionQueue.getQueueId() + "_" + IDGenerator.nextStr(); String testPlanReportId = testPlanExecutionQueue.getPrepareReportId(); String userId = testPlanExecutionQueue.getCreateUser(); TestPlanCollection collection = JSON.parseObject(testPlanExecutionQueue.getTestPlanCollectionJson(), TestPlanCollection.class); 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 f71b329e2c..575514a843 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 @@ -365,7 +365,7 @@ public class TestPlanExecuteService { }} ); } - LogUtils.info("测试计划不同用例类型的执行节点 --- 队列ID[{}],队列类型[{}],父队列ID[{}],父队列类型[{}],执行模式[{}]", queueId, queueType, executionQueue.getParentQueueId(), executionQueue.getParentQueueType(), executionQueue.getRunMode()); + LogUtils.info("测试计划不同用例类型的执行节点 --- 队列ID[{}],队列类型[{}],父队列ID[{}],父队列类型[{}],执行模式[{}]", executionQueue.getQueueId(), executionQueue.getQueueType(), executionQueue.getParentQueueId(), executionQueue.getParentQueueType(), executionQueue.getRunMode()); if (CollectionUtils.isEmpty(childrenQueue)) { //本次的测试集执行完成 this.caseTypeExecuteQueueFinish(executionQueue.getQueueId(), executionQueue.getQueueType()); @@ -393,7 +393,9 @@ public class TestPlanExecuteService { */ private void executeCase(TestPlanExecutionQueue testPlanExecutionQueue) { String queueId = testPlanExecutionQueue.getQueueId(); - LogUtils.info("测试集执行节点 --- 队列ID[{}],队列类型[{}],父队列ID[{}],父队列类型[{}],执行模式[{}]", queueId, testPlanExecutionQueue.getQueueType(), testPlanExecutionQueue.getParentQueueId(), testPlanExecutionQueue.getParentQueueType(), testPlanExecutionQueue.getRunMode()); + LogUtils.info("测试集执行节点 --- 队列ID[{}],队列类型[{}],父队列ID[{}],父队列类型[{}],执行模式[{},资源ID[{}]", + queueId, testPlanExecutionQueue.getQueueType(), testPlanExecutionQueue.getParentQueueId(), testPlanExecutionQueue.getParentQueueType(), + testPlanExecutionQueue.getRunMode(), testPlanExecutionQueue.getSourceID()); boolean execOver = false; try { TestPlanCollection collection = JSON.parseObject(testPlanExecutionQueue.getTestPlanCollectionJson(), TestPlanCollection.class); @@ -428,10 +430,17 @@ public class TestPlanExecuteService { } //测试集执行完成 - public void collectionExecuteQueueFinish(String queueID) { + public void collectionExecuteQueueFinish(String paramQueueId) { + LogUtils.info("收到测试集执行完成的信息: [{}]", paramQueueId); + String queueID = paramQueueId; + String[] queueIdArr = queueID.split("_"); + if (queueIdArr.length > 2) { + queueID = queueIdArr[0] + "_" + queueIdArr[1]; + } String queueType = QUEUE_PREFIX_TEST_PLAN_COLLECTION; - LogUtils.info("收到测试集执行完成的信息: 队列ID[{}],队列类型[{}],下一个节点的执行工作准备中...", queueID, queueType); TestPlanExecutionQueue nextQueue = testPlanExecuteSupportService.getNextQueue(queueID, queueType); + LogUtils.info("获取执行节点完成: 队列ID[{}],队列类型[{},串并行:[{}]执行是否结束[{}],是否是最后一个[{}],当前查出节点的资源ID[{}]],下一个节点的执行工作准备中...", + queueID, queueType, nextQueue.getRunMode(), nextQueue.isExecuteFinish(), nextQueue.isLastOne(), nextQueue.getSourceID()); if (StringUtils.equalsIgnoreCase(nextQueue.getRunMode(), ApiBatchRunMode.SERIAL.name())) { //串行时,由于是先拿出节点再判断执行,所以要判断节点的isExecuteFinish if (!nextQueue.isExecuteFinish()) {