From a4291470d045045afb31396a51c6ae02e2bd0d29 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Tue, 22 Aug 2023 17:39:07 +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=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=AF=BC=E5=85=A5=E7=9A=84=E6=9C=AA=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E7=9A=84=E5=9C=BA=E6=99=AF=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91=E5=88=A4=E6=96=AD=E5=87=BA?= =?UTF-8?q?=E9=94=99=E6=9C=80=E7=BB=88=E5=AF=BC=E8=87=B4=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E7=BB=93=E6=9D=9F=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1029266 --user=宋天阳 【测试跟踪】执行计划-报告列表查看-状态仍显示为Running https://www.tapd.cn/55049933/s/1407134 --- .../service/ApiJMeterFileService.java | 4 ++-- .../scenario/ApiScenarioReportService.java | 4 ++-- .../execute/TestPlanExecuteService.java | 20 +++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/ApiJMeterFileService.java b/api-test/backend/src/main/java/io/metersphere/service/ApiJMeterFileService.java index 13b73948ad..dc3ea677a1 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/ApiJMeterFileService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/ApiJMeterFileService.java @@ -112,9 +112,9 @@ public class ApiJMeterFileService { private Map extractScenarioEnv(String envType, String envJson, String envGroupId) { Map scenarioEnv = new LinkedHashMap<>(); - if (envType.equals(EnvironmentType.JSON.name()) && !envJson.isBlank()) { + if (envType.equals(EnvironmentType.JSON.name()) && StringUtils.isNotBlank(envJson)) { scenarioEnv = JSON.parseObject(envJson, Map.class); - } else if (envType.equals(EnvironmentType.GROUP.name()) && !envGroupId.isBlank()) { + } else if (envType.equals(EnvironmentType.GROUP.name()) && StringUtils.isNotBlank(envGroupId)) { scenarioEnv = environmentGroupProjectService.getEnvMap(envGroupId); } return scenarioEnv; diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java index 41f9bbc1de..4b326a788c 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java @@ -861,9 +861,9 @@ public class ApiScenarioReportService { private Map extractScenarioEnv(String envType, String envJson, String envGroupId) { Map scenarioEnv = new LinkedHashMap<>(); - if (envType.equals(EnvironmentType.JSON.name()) && !envJson.isBlank()) { + if (envType.equals(EnvironmentType.JSON.name()) && StringUtils.isNotBlank(envJson)) { scenarioEnv = JSON.parseObject(envJson, Map.class); - } else if (envType.equals(EnvironmentType.GROUP.name()) && !envGroupId.isBlank()) { + } else if (envType.equals(EnvironmentType.GROUP.name()) && StringUtils.isNotBlank(envGroupId)) { scenarioEnv = environmentGroupProjectService.getEnvMap(envGroupId); } return scenarioEnv; diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/execute/TestPlanExecuteService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/execute/TestPlanExecuteService.java index fbadc32001..7a0eb3dd6e 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/execute/TestPlanExecuteService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/execute/TestPlanExecuteService.java @@ -175,10 +175,15 @@ public class TestPlanExecuteService { for (TestPlanApiDTO dto : apiTestCases) { dto.setReportId(apiCaseReportMap.get(dto.getId())); } + } else { + redisTemplateService.unlock(testPlanReportId, TestPlanExecuteCaseType.API_CASE.name(), testPlanReportId); + executing = false; + apiTestCases.clear(); } } catch (Exception e) { redisTemplateService.unlock(testPlanReportId, TestPlanExecuteCaseType.API_CASE.name(), testPlanReportId); apiTestCases = null; + executing = false; LoggerUtil.info("测试报告" + testPlanReportId + "本次执行测试计划接口用例失败! ", e); } } @@ -217,10 +222,16 @@ public class TestPlanExecuteService { if (CollectionUtils.isNotEmpty(removeDTO)) { scenarioCases.removeAll(removeDTO); } + } else { + //如果没有执行的用例,解锁数据,并设置执行数据为空 + redisTemplateService.unlock(testPlanReportId, TestPlanExecuteCaseType.SCENARIO.name(), testPlanReportId); + executing = false; + scenarioCases.clear(); } } catch (Exception e) { redisTemplateService.unlock(testPlanReportId, TestPlanExecuteCaseType.SCENARIO.name(), testPlanReportId); scenarioCases = null; + executing = false; LoggerUtil.info("测试报告" + testPlanReportId + "本次执行测试计划场景用例失败! ", e); } } @@ -249,10 +260,15 @@ public class TestPlanExecuteService { for (TestPlanUiScenarioDTO dto : uiScenarios) { dto.setReportId(uiScenarioReportMap.get(dto.getId())); } + } else { + redisTemplateService.unlock(testPlanReportId, TestPlanExecuteCaseType.UI_SCENARIO.name(), testPlanReportId); + uiScenarios.clear(); + executing = false; } } catch (Exception e) { redisTemplateService.unlock(testPlanReportId, TestPlanExecuteCaseType.UI_SCENARIO.name(), testPlanReportId); uiScenarios = null; + executing = false; LoggerUtil.info("测试报告" + testPlanReportId + "本次执行测试计划 UI 用例失败! ", e); } } @@ -273,8 +289,12 @@ public class TestPlanExecuteService { loadCaseReportMap = perfExecService.executeLoadCase(testPlanReportId, runModeConfig, testPlanService.transformationPerfTriggerMode(triggerMode), executeCase); if (MapUtils.isNotEmpty(loadCaseReportMap)) { executing = true; + } else { + redisTemplateService.unlock(testPlanReportId, TestPlanExecuteCaseType.LOAD_CASE.name(), testPlanReportId); + executing = false; } } catch (Exception e) { + executing = false; redisTemplateService.unlock(testPlanReportId, TestPlanExecuteCaseType.LOAD_CASE.name(), testPlanReportId); LoggerUtil.info("测试报告" + testPlanReportId + "本次执行测试计划性能用例失败! ", e); }