From 1acdbd2e45730c814981db8d61a3c41ad599e703 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 16 Feb 2022 14:05:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=A4=9A=E4=B8=AA=E8=8A=82=E7=82=B9=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E6=AD=BB=E9=94=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/request/MsScenario.java | 14 ++++++++------ .../api/jmeter/APISingleResultListener.java | 8 -------- .../track/service/TestPlanReportService.java | 5 +++-- .../db/migration/V107__v1.17.2_release.sql | 1 + 4 files changed, 12 insertions(+), 16 deletions(-) create mode 100644 backend/src/main/resources/db/migration/V107__v1.17.2_release.sql diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index 995b9bd8b4..5b11277e78 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -159,12 +159,14 @@ public class MsScenario extends MsTestElement { if (CollectionUtils.isNotEmpty(hashTree)) { for (MsTestElement el : hashTree) { - el.setParent(this); - el.setMockEnvironment(this.isMockEnvironment()); - if (this.isEnvironmentEnable()) { - el.toHashTree(scenarioTree, el.getHashTree(), newConfig); - } else { - el.toHashTree(scenarioTree, el.getHashTree(), config); + if (el != null) { + el.setParent(this); + el.setMockEnvironment(this.isMockEnvironment()); + if (this.isEnvironmentEnable()) { + el.toHashTree(scenarioTree, el.getHashTree(), newConfig); + } else { + el.toHashTree(scenarioTree, el.getHashTree(), config); + } } } } diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APISingleResultListener.java b/backend/src/main/java/io/metersphere/api/jmeter/APISingleResultListener.java index 2eecc28022..dd56200b95 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APISingleResultListener.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APISingleResultListener.java @@ -4,7 +4,6 @@ package io.metersphere.api.jmeter; import io.metersphere.api.exec.queue.PoolExecBlockingQueueUtil; import io.metersphere.api.service.ApiExecutionQueueService; import io.metersphere.api.service.TestResultService; -import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.dto.ResultDTO; import io.metersphere.jmeter.MsExecListener; @@ -22,13 +21,6 @@ public class APISingleResultListener extends MsExecListener { LoggerUtil.info("处理单条执行结果报告【" + dto.getReportId() + " 】,资源【 " + dto.getTestId() + " 】"); dto.setConsole(FixedCapacityUtils.getJmeterLogger(dto.getReportId())); CommonBeanFactory.getBean(TestResultService.class).saveResults(dto); - - // 更新报告最后接收到请求的时间 - if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCENARIO.name(), - ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), - ApiRunMode.SCHEDULE_SCENARIO.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) { - CommonBeanFactory.getBean(TestResultService.class).editReportTime(dto); - } } @Override diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index 3b767b6284..61f33e2c7f 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -610,8 +610,9 @@ public class TestPlanReportService { try { //更新TestPlan状态为完成 TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(report.getTestPlanId()); - if (testPlan != null) { - testPlanService.checkStatus(testPlan); + if (testPlan != null && !StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) { + testPlan.setStatus(TestPlanStatus.Completed.name()); + testPlanService.editTestPlan(testPlan); } if (testPlan != null && StringUtils.equalsAny(report.getTriggerMode(), ReportTriggerMode.MANUAL.name(), diff --git a/backend/src/main/resources/db/migration/V107__v1.17.2_release.sql b/backend/src/main/resources/db/migration/V107__v1.17.2_release.sql new file mode 100644 index 0000000000..33ae82e919 --- /dev/null +++ b/backend/src/main/resources/db/migration/V107__v1.17.2_release.sql @@ -0,0 +1 @@ +alter table api_execution_queue_detail add index queue_id_test_id_index(queue_id,test_id); \ No newline at end of file