From aedaddd2d5dfe5b58dce0651ce67fcb365612a14 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 5 Nov 2021 17:28:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E8=B6=85=E6=97=B6=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E6=97=B6=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E7=9A=84=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 测试计划超时关闭时修改测试报告的状态 --- .../api/cache/TestPlanExecuteInfo.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backend/src/main/java/io/metersphere/api/cache/TestPlanExecuteInfo.java b/backend/src/main/java/io/metersphere/api/cache/TestPlanExecuteInfo.java index 232a70c5d3..88b615e639 100644 --- a/backend/src/main/java/io/metersphere/api/cache/TestPlanExecuteInfo.java +++ b/backend/src/main/java/io/metersphere/api/cache/TestPlanExecuteInfo.java @@ -3,14 +3,21 @@ package io.metersphere.api.cache; import io.metersphere.api.jmeter.JmeterThreadUtils; import io.metersphere.api.jmeter.MessageCache; +import io.metersphere.base.domain.ApiScenarioReport; +import io.metersphere.base.domain.ApiScenarioReportExample; +import io.metersphere.base.mapper.ApiScenarioReportMapper; import io.metersphere.commons.constants.TestPlanApiExecuteStatus; import io.metersphere.commons.constants.TestPlanResourceType; +import io.metersphere.commons.utils.CommonBeanFactory; import lombok.Getter; import lombok.Setter; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -173,11 +180,14 @@ public class TestPlanExecuteInfo { MessageCache.executionQueue.remove(apiCaseExecuteReportMap.get(resourceId)); } } + + List updateScenarioReportList = new ArrayList<>(); for (Map.Entry entry : apiScenarioCaseExecInfo.entrySet()) { String resourceId = entry.getKey(); String executeResult = entry.getValue(); if (StringUtils.equalsIgnoreCase(executeResult, TestPlanApiExecuteStatus.RUNNING.name())) { apiScenarioCaseExecInfo.put(resourceId, TestPlanApiExecuteStatus.FAILD.name()); + updateScenarioReportList.add(apiScenarioReportReportMap.get(resourceId)); if (StringUtils.isNotEmpty(apiScenarioReportReportMap.get(resourceId))) { JmeterThreadUtils.stop(apiScenarioReportReportMap.get(resourceId)); } @@ -187,6 +197,15 @@ public class TestPlanExecuteInfo { MessageCache.executionQueue.remove(apiScenarioReportReportMap.get(resourceId)); } } + if(CollectionUtils.isNotEmpty(updateScenarioReportList)){ + ApiScenarioReportMapper apiScenarioReportMapper = CommonBeanFactory.getBean(ApiScenarioReportMapper.class); + ApiScenarioReportExample example = new ApiScenarioReportExample(); + example.createCriteria().andIdIn(updateScenarioReportList).andStatusEqualTo("Running"); + ApiScenarioReport report = new ApiScenarioReport(); + report.setStatus("Error"); + apiScenarioReportMapper.updateByExampleSelective(report,example); + } + for (Map.Entry entry : loadCaseExecInfo.entrySet()) { String resourceId = entry.getKey(); String executeResult = entry.getValue();