From 6015fce556c62023fc737dad0dca9cb9172fadbf Mon Sep 17 00:00:00 2001 From: metersphere-bot <78466014+metersphere-bot@users.noreply.github.com> Date: Wed, 25 Aug 2021 22:07:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20#1?= =?UTF-8?q?005967=20=20#1006056=20=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=EF=BC=8C=E6=89=A7=E8=A1=8C=E5=9C=BA=E6=99=AF=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E6=9C=89=E4=B8=80=E4=B8=AA=E7=94=A8=E4=BE=8B=E6=80=BB=E6=98=AF?= =?UTF-8?q?=E4=B8=8D=E5=9C=A8=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=20=E3=80=90github#5497=E3=80=91=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=B7=9F=E8=B8=AA-=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92-?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E4=BB=85=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E5=85=B3=E8=81=94=E7=9A=84=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=9C=BA=E6=99=AF=E7=94=A8=E4=BE=8B=20(#5694)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【测试计划,执行场景用例有一个用例总是不在任务中心显示】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001005967;--bug=1006056 --user=宋天阳 【github#5497】测试跟踪-测试计划-定时任务仅执行第一次关联的测试场景用例 https://www.tapd.cn/55049933/s/1040247; Co-authored-by: song-tianyang --- .../api/service/ApiAutomationService.java | 18 ++++++++++++++---- .../ext/ExtTestPlanScenarioCaseMapper.java | 2 ++ .../ext/ExtTestPlanScenarioCaseMapper.xml | 6 ++++++ .../track/service/TestPlanReportService.java | 10 +++++----- .../service/TestPlanScenarioCaseService.java | 4 ++++ .../track/service/TestPlanService.java | 1 + 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index bb9e5ad15b..0fb69691d7 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1026,13 +1026,17 @@ public class ApiAutomationService { planEnvMap = JSON.parseObject(environment, Map.class); } } + String projectId = testPlanScenarioCaseService.getProjectIdById(testPlanScenarioId); + if(StringUtils.isEmpty(projectId)){ + projectId = item.getProjectId(); + } if (request.isTestPlanScheduleJob()) { String savedScenarioId = testPlanScenarioId + ":" + request.getTestPlanReportId(); report = createScenarioReport(reportId, savedScenarioId, item.getName(), request.getTriggerMode(), - request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig(),item.getId()); + request.getExecuteType(), projectId, request.getReportUserID(), request.getConfig(),item.getId()); } else { report = createScenarioReport(reportId, testPlanScenarioId, item.getName(), request.getTriggerMode(), - request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig(),item.getId()); + request.getExecuteType(), projectId, request.getReportUserID(), request.getConfig(),item.getId()); } } else { report = createScenarioReport(reportId, ExecuteType.Marge.name().equals(request.getExecuteType()) ? serialReportId : item.getId(), item.getName(), request.getTriggerMode(), @@ -1251,13 +1255,19 @@ public class ApiAutomationService { scenario.setEnvironmentMap(JSON.parseObject(environment, Map.class)); } } + + String projectId = testPlanScenarioCaseService.getProjectIdById(testPlanScenarioId); + if(StringUtils.isEmpty(projectId)){ + projectId = item.getProjectId(); + } + if (request.isTestPlanScheduleJob()) { String savedScenarioId = testPlanScenarioId + ":" + request.getTestPlanReportId(); report = createScenarioReport(group.getName(), savedScenarioId, item.getName(), request.getTriggerMode(), - request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig(),item.getId()); + request.getExecuteType(), projectId, request.getReportUserID(), request.getConfig(),item.getId()); } else { report = createScenarioReport(group.getName(), testPlanScenarioId, item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(), - request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig(),item.getId()); + request.getExecuteType(), projectId, request.getReportUserID(), request.getConfig(),item.getId()); } } else { report = createScenarioReport(group.getName(), item.getId(), item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(), diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanScenarioCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanScenarioCaseMapper.java index 9b5c973742..83a75c6f4b 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanScenarioCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanScenarioCaseMapper.java @@ -34,4 +34,6 @@ public interface ExtTestPlanScenarioCaseMapper { List getFailureListByIds(@Param("ids") Collection ids, @Param("planId") String planId, @Param("status") String status); List getUnderwaySteps(@Param("ids") List underwayIds); + + String getProjectIdById(String testPlanScenarioId); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanScenarioCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanScenarioCaseMapper.xml index d8996827d0..b7271c9211 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanScenarioCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanScenarioCaseMapper.xml @@ -247,4 +247,10 @@ + + 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 2034105527..7995a92d43 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -685,9 +685,9 @@ public class TestPlanReportService { status = TestPlanReportStatus.SUCCESS.name(); try { if (CollectionUtils.isNotEmpty(reportDTO.getFunctionFailureCases()) - && CollectionUtils.isNotEmpty(reportDTO.getApiFailureCases()) - && CollectionUtils.isNotEmpty(reportDTO.getScenarioFailureCases()) - && CollectionUtils.isNotEmpty(reportDTO.getLoadFailureCases())) { + || CollectionUtils.isNotEmpty(reportDTO.getApiFailureCases()) + || CollectionUtils.isNotEmpty(reportDTO.getScenarioFailureCases()) + || CollectionUtils.isNotEmpty(reportDTO.getLoadFailureCases())) { status = TestPlanReportStatus.FAILED.name(); return status; } @@ -751,7 +751,7 @@ public class TestPlanReportService { //更新TestPlan状态为完成 TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(report.getTestPlanId()); if (testPlan != null) { - testPlan.setStatus(TestPlanStatus.Completed.name()); +// testPlan.setStatus(TestPlanStatus.Completed.name()); testPlanMapper.updateByPrimaryKeySelective(testPlan); } if (StringUtils.equalsAny(report.getTriggerMode(), ReportTriggerMode.API.name(), ReportTriggerMode.SCHEDULE.name())) { @@ -813,7 +813,7 @@ public class TestPlanReportService { } NoticeModel noticeModel = NoticeModel.builder() - .operator(SessionUtils.getUserId()) + .operator("MeterSphere") .successContext(successContext) .successMailTemplate(successfulMailTemplate) .failedContext(failedContext) diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java index 283b808112..1b02876765 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java @@ -468,4 +468,8 @@ public class TestPlanScenarioCaseService { } return null; } + + public String getProjectIdById(String testPlanScenarioId) { + return extTestPlanScenarioCaseMapper.getProjectIdById(testPlanScenarioId); + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index e4673922a0..8286425c79 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -990,6 +990,7 @@ public class TestPlanService { @Transactional(propagation = Propagation.NOT_SUPPORTED) public String run(String testPlanID, String projectID, String userId, String triggerMode, String apiRunConfig) { + triggerMode = ReportTriggerMode.SCHEDULE.name(); //创建测试报告,然后返回的ID重新赋值为resourceID,作为后续的参数 TestPlanScheduleReportInfoDTO reportInfoDTO = testPlanReportService.genTestPlanReportBySchedule(projectID, testPlanID, userId, triggerMode);