From b8100c50984e9dfecc0857b92d5ff56900e0f101 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Thu, 13 Jan 2022 18:34:50 +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=E8=B6=85=E6=97=B6=E7=8A=B6=E6=80=81=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复测试计划执行超时状态判断错误的问题 --- .../api/service/ApiExecutionQueueService.java | 16 +++++++++------- .../component/ApiScenarioFailureResult.vue | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java b/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java index a7fe1d721f..dbdba9e4e7 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiExecutionQueueService.java @@ -73,7 +73,7 @@ public class ApiExecutionQueueService { SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); ApiExecutionQueueDetailMapper batchMapper = sqlSession.getMapper(ApiExecutionQueueDetailMapper.class); - if (StringUtils.equalsAny(type, ApiRunMode.DEFINITION.name(), ApiRunMode.API_PLAN.name())) { + if (StringUtils.equalsAnyIgnoreCase(type, ApiRunMode.DEFINITION.name(), ApiRunMode.API_PLAN.name())) { final int[] sort = {0}; Map runMap = (Map) runObj; if (envMap == null) { @@ -163,7 +163,7 @@ public class ApiExecutionQueueService { if (executionQueue.getFailure()) { LoggerUtil.info("进入失败停止处理:" + executionQueue.getId()); boolean isError = false; - if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCENARIO.name(), + if (StringUtils.equalsAnyIgnoreCase(dto.getRunMode(), ApiRunMode.SCENARIO.name(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) { ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(executionQueue.getNowReportId()); @@ -232,12 +232,11 @@ public class ApiExecutionQueueService { if (CollectionUtils.isNotEmpty(queueDetails)) { queueDetails.forEach(item -> { - if (StringUtils.equalsAny(item.getType(), ApiRunMode.SCENARIO.name(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) { + if (StringUtils.equalsAnyIgnoreCase(item.getType(), ApiRunMode.SCENARIO.name(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) { ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(item.getReportId()); - if (report != null && StringUtils.equalsAny(report.getStatus(), TestPlanReportStatus.RUNNING.name()) && (System.currentTimeMillis() - report.getUpdateTime()) < now) { + if (report != null && StringUtils.equalsAnyIgnoreCase(report.getStatus(), TestPlanReportStatus.RUNNING.name()) && (System.currentTimeMillis() - report.getUpdateTime()) < now) { report.setStatus(ScenarioStatus.Timeout.name()); apiScenarioReportMapper.updateByPrimaryKeySelective(report); - executionQueueDetailMapper.deleteByPrimaryKey(item.getId()); ResultDTO dto = new ResultDTO(); dto.setQueueId(item.getQueueId()); @@ -247,13 +246,16 @@ public class ApiExecutionQueueService { dto.setTestPlanReportId(executionQueue.getReportId()); dto.setReportId(executionQueue.getReportId()); dto.setRunMode(executionQueue.getRunMode()); + dto.setRunType(RunModeConstants.SERIAL.toString()); dto.setReportType(executionQueue.getReportType()); queueNext(dto); + }else { + executionQueueDetailMapper.deleteByPrimaryKey(item.getId()); } } } else { ApiDefinitionExecResult result = apiDefinitionExecResultMapper.selectByPrimaryKey(item.getReportId()); - if (result != null && StringUtils.equalsAny(result.getStatus(), TestPlanReportStatus.RUNNING.name())) { + if (result != null && StringUtils.equalsAnyIgnoreCase(result.getStatus(), TestPlanReportStatus.RUNNING.name())) { result.setStatus(ScenarioStatus.Timeout.name()); apiDefinitionExecResultMapper.updateByPrimaryKeySelective(result); executionQueueDetailMapper.deleteByPrimaryKey(item.getId()); @@ -268,7 +270,7 @@ public class ApiExecutionQueueService { if (CollectionUtils.isNotEmpty(executionQueues)) { executionQueues.forEach(item -> { ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(item.getReportId()); - if (report != null && StringUtils.equalsAny(report.getStatus(), TestPlanReportStatus.RUNNING.name()) && report.getUpdateTime() < now) { + if (report != null && StringUtils.equalsAnyIgnoreCase(report.getStatus(), TestPlanReportStatus.RUNNING.name()) && (System.currentTimeMillis() - report.getUpdateTime()) < now) { report.setStatus(ScenarioStatus.Timeout.name()); apiScenarioReportMapper.updateByPrimaryKeySelective(report); } diff --git a/frontend/src/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioFailureResult.vue b/frontend/src/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioFailureResult.vue index be775ac7b9..277eac5f5e 100644 --- a/frontend/src/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioFailureResult.vue +++ b/frontend/src/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioFailureResult.vue @@ -46,6 +46,7 @@ +