From 4dcdbce306ccd48091d854fa3c4ad76fe8694e6f Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 15 Dec 2021 23:51:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=89=A7=E8=A1=8C):=20=E4=BC=98=E5=8C=96=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E6=89=A7=E8=A1=8C=E6=97=B6=E7=9A=84=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化测试计划执行时的监听方法,输出更多日志 --- .../api/cache/TestPlanExecuteInfo.java | 20 +++++++++++-------- .../track/service/TestPlanReportService.java | 3 +++ 2 files changed, 15 insertions(+), 8 deletions(-) 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 82031428dd..0c3c30ca9e 100644 --- a/backend/src/main/java/io/metersphere/api/cache/TestPlanExecuteInfo.java +++ b/backend/src/main/java/io/metersphere/api/cache/TestPlanExecuteInfo.java @@ -243,10 +243,12 @@ public class TestPlanExecuteInfo { public Map getRunningApiCaseReportMap() { //key: reportId, value: testPlanApiCaseId Map returnMap = new HashMap<>(); - for (String result : apiCaseExecInfo.keySet()) { - if (StringUtils.equalsIgnoreCase(result, TestPlanApiExecuteStatus.RUNNING.name())) { - if (apiCaseExecuteThreadMap.containsKey(result)) { - returnMap.put(apiCaseExecuteThreadMap.get(result), result); + for (Map.Entry entry : apiCaseExecInfo.entrySet()) { + String planCaseId = entry.getKey(); + String status = entry.getValue(); + if (StringUtils.equalsIgnoreCase(status, TestPlanApiExecuteStatus.RUNNING.name())) { + if (apiCaseExecuteThreadMap.containsKey(planCaseId)) { + returnMap.put(apiCaseExecuteThreadMap.get(planCaseId), planCaseId); } } } @@ -256,10 +258,12 @@ public class TestPlanExecuteInfo { public Map getRunningScenarioReportMap() { //key: reportId, value: testPlanApiScenarioId Map returnMap = new HashMap<>(); - for (String result : apiScenarioCaseExecInfo.keySet()) { - if (StringUtils.equalsIgnoreCase(result, TestPlanApiExecuteStatus.RUNNING.name())) { - if (apiScenarioThreadMap.containsKey(result)) { - returnMap.put(apiScenarioThreadMap.get(result), result); + for (Map.Entry entry : apiScenarioCaseExecInfo.entrySet()) { + String planScenarioId = entry.getKey(); + String status = entry.getValue(); + if (StringUtils.equalsIgnoreCase(status, TestPlanApiExecuteStatus.RUNNING.name())) { + if (apiScenarioThreadMap.containsKey(planScenarioId)) { + returnMap.put(apiScenarioThreadMap.get(planScenarioId), planScenarioId); } } } 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 849edc5eb2..bca89377e3 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -1312,7 +1312,10 @@ public class TestPlanReportService { } } } + testPlanLog.info("ReportID:"+planReportId+" 本次数据库同步,案例ID:"+JSON.toJSONString(apiCaseReportMap.keySet())+";场景ID:"+JSON.toJSONString(scenarioReportMap.keySet())+"; 同步结果,案例:"+JSON.toJSONString(updateCaseStatusMap)+";场景:"+JSON.toJSONString(updateScenarioStatusMap)); TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(planReportId, updateCaseStatusMap, updateScenarioStatusMap, null); + }else { + testPlanLog.info("同步数据库查询执行信息失败! 报告ID在缓存中未找到!"+planReportId); } }