diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanReport.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanReport.java index e5006dfce0..ca5b8cd85b 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanReport.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanReport.java @@ -37,6 +37,8 @@ public class TestPlanReport implements Serializable { private Boolean isNew; + private Boolean isUiScenarioExecuting; + private String runInfo; private static final long serialVersionUID = 1L; diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanReportExample.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanReportExample.java index 0c1db82e88..6bee74b257 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanReportExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanReportExample.java @@ -1143,6 +1143,66 @@ public class TestPlanReportExample { addCriterion("is_new not between", value1, value2, "isNew"); return (Criteria) this; } + + public Criteria andIsUiScenarioExecutingIsNull() { + addCriterion("is_ui_scenario_executing is null"); + return (Criteria) this; + } + + public Criteria andIsUiScenarioExecutingIsNotNull() { + addCriterion("is_ui_scenario_executing is not null"); + return (Criteria) this; + } + + public Criteria andIsUiScenarioExecutingEqualTo(Boolean value) { + addCriterion("is_ui_scenario_executing =", value, "isUiScenarioExecuting"); + return (Criteria) this; + } + + public Criteria andIsUiScenarioExecutingNotEqualTo(Boolean value) { + addCriterion("is_ui_scenario_executing <>", value, "isUiScenarioExecuting"); + return (Criteria) this; + } + + public Criteria andIsUiScenarioExecutingGreaterThan(Boolean value) { + addCriterion("is_ui_scenario_executing >", value, "isUiScenarioExecuting"); + return (Criteria) this; + } + + public Criteria andIsUiScenarioExecutingGreaterThanOrEqualTo(Boolean value) { + addCriterion("is_ui_scenario_executing >=", value, "isUiScenarioExecuting"); + return (Criteria) this; + } + + public Criteria andIsUiScenarioExecutingLessThan(Boolean value) { + addCriterion("is_ui_scenario_executing <", value, "isUiScenarioExecuting"); + return (Criteria) this; + } + + public Criteria andIsUiScenarioExecutingLessThanOrEqualTo(Boolean value) { + addCriterion("is_ui_scenario_executing <=", value, "isUiScenarioExecuting"); + return (Criteria) this; + } + + public Criteria andIsUiScenarioExecutingIn(List values) { + addCriterion("is_ui_scenario_executing in", values, "isUiScenarioExecuting"); + return (Criteria) this; + } + + public Criteria andIsUiScenarioExecutingNotIn(List values) { + addCriterion("is_ui_scenario_executing not in", values, "isUiScenarioExecuting"); + return (Criteria) this; + } + + public Criteria andIsUiScenarioExecutingBetween(Boolean value1, Boolean value2) { + addCriterion("is_ui_scenario_executing between", value1, value2, "isUiScenarioExecuting"); + return (Criteria) this; + } + + public Criteria andIsUiScenarioExecutingNotBetween(Boolean value1, Boolean value2) { + addCriterion("is_ui_scenario_executing not between", value1, value2, "isUiScenarioExecuting"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.xml index b84321155f..09731c2941 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.xml @@ -18,6 +18,7 @@ + @@ -83,7 +84,7 @@ id, test_plan_id, create_time, update_time, `name`, `status`, trigger_mode, creator, start_time, end_time, is_api_case_executing, is_scenario_executing, is_performance_executing, - principal, components, is_new + principal, components, is_new, is_ui_scenario_executing run_info @@ -142,13 +143,15 @@ trigger_mode, creator, start_time, end_time, is_api_case_executing, is_scenario_executing, is_performance_executing, principal, components, - is_new, run_info) + is_new, is_ui_scenario_executing, run_info + ) values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{creator,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}, #{isApiCaseExecuting,jdbcType=BIT}, #{isScenarioExecuting,jdbcType=BIT}, #{isPerformanceExecuting,jdbcType=BIT}, #{principal,jdbcType=VARCHAR}, #{components,jdbcType=VARCHAR}, - #{isNew,jdbcType=BIT}, #{runInfo,jdbcType=LONGVARCHAR}) + #{isNew,jdbcType=BIT}, #{isUiScenarioExecuting,jdbcType=BIT}, #{runInfo,jdbcType=LONGVARCHAR} + ) insert into test_plan_report @@ -201,6 +204,9 @@ is_new, + + is_ui_scenario_executing, + run_info, @@ -254,6 +260,9 @@ #{isNew,jdbcType=BIT}, + + #{isUiScenarioExecuting,jdbcType=BIT}, + #{runInfo,jdbcType=LONGVARCHAR}, @@ -316,6 +325,9 @@ is_new = #{record.isNew,jdbcType=BIT}, + + is_ui_scenario_executing = #{record.isUiScenarioExecuting,jdbcType=BIT}, + run_info = #{record.runInfo,jdbcType=LONGVARCHAR}, @@ -342,6 +354,7 @@ principal = #{record.principal,jdbcType=VARCHAR}, components = #{record.components,jdbcType=VARCHAR}, is_new = #{record.isNew,jdbcType=BIT}, + is_ui_scenario_executing = #{record.isUiScenarioExecuting,jdbcType=BIT}, run_info = #{record.runInfo,jdbcType=LONGVARCHAR} @@ -364,7 +377,8 @@ is_performance_executing = #{record.isPerformanceExecuting,jdbcType=BIT}, principal = #{record.principal,jdbcType=VARCHAR}, components = #{record.components,jdbcType=VARCHAR}, - is_new = #{record.isNew,jdbcType=BIT} + is_new = #{record.isNew,jdbcType=BIT}, + is_ui_scenario_executing = #{record.isUiScenarioExecuting,jdbcType=BIT} @@ -417,6 +431,9 @@ is_new = #{isNew,jdbcType=BIT}, + + is_ui_scenario_executing = #{isUiScenarioExecuting,jdbcType=BIT}, + run_info = #{runInfo,jdbcType=LONGVARCHAR}, @@ -440,6 +457,7 @@ principal = #{principal,jdbcType=VARCHAR}, components = #{components,jdbcType=VARCHAR}, is_new = #{isNew,jdbcType=BIT}, + is_ui_scenario_executing = #{isUiScenarioExecuting,jdbcType=BIT}, run_info = #{runInfo,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -459,7 +477,8 @@ is_performance_executing = #{isPerformanceExecuting,jdbcType=BIT}, principal = #{principal,jdbcType=VARCHAR}, components = #{components,jdbcType=VARCHAR}, - is_new = #{isNew,jdbcType=BIT} + is_new = #{isNew,jdbcType=BIT}, + is_ui_scenario_executing = #{isUiScenarioExecuting,jdbcType=BIT} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/request/report/TestPlanReportSaveRequest.java b/backend/src/main/java/io/metersphere/track/request/report/TestPlanReportSaveRequest.java index e322c34d67..8585fa4c94 100644 --- a/backend/src/main/java/io/metersphere/track/request/report/TestPlanReportSaveRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/report/TestPlanReportSaveRequest.java @@ -21,14 +21,13 @@ public class TestPlanReportSaveRequest { private boolean countResources; private boolean apiCaseIsExecuting; private boolean scenarioIsExecuting; + private boolean uiScenarioIsExecuting; private boolean performanceIsExecuting; -// private String apiCaseIdListJSON; -// private String scenarioIdListJSON; -// private String performanceIdListJSON; - Map apiCaseIdMap; - Map scenarioIdMap; - Map performanceIdMap; + Map apiCaseIdMap; + Map scenarioIdMap; + Map uiScenarioIdMap; + Map performanceIdMap; public TestPlanReportSaveRequest(String reportID, String planId, String userId, String triggerMode) { this.reportID = reportID; @@ -39,21 +38,106 @@ public class TestPlanReportSaveRequest { this.countResources = true; } - public TestPlanReportSaveRequest(String reportID, String planId, String userId, String triggerMode, boolean apiCaseIsExecuting, boolean scenarioIsExecuting, boolean performanceIsExecuting, - Map apiCaseIdMap, Map scenarioIdMap, Map performanceIdMap) { - this.reportID = reportID; - this.planId = planId; - this.userId = userId; - this.triggerMode = triggerMode; + public TestPlanReportSaveRequest(Builder builder) { + this.reportID = builder.reportID; + this.planId = builder.planId; + this.userId = builder.userId; + this.triggerMode = builder.triggerMode; + this.countResources = builder.countResources; + this.apiCaseIsExecuting = builder.apiCaseIsExecuting; + this.scenarioIsExecuting = builder.scenarioIsExecuting; + this.uiScenarioIsExecuting = builder.uiScenarioIsExecuting; + this.performanceIsExecuting = builder.performanceIsExecuting; + this.apiCaseIdMap = builder.apiCaseIdMap; + this.scenarioIdMap = builder.scenarioIdMap; + this.uiScenarioIdMap = builder.uiScenarioIdMap; + this.performanceIdMap = builder.performanceIdMap; + } - this.countResources = false; + public static class Builder { + private String reportID; + private String planId; + private String userId; + private String triggerMode; - this.apiCaseIsExecuting = apiCaseIsExecuting; - this.scenarioIsExecuting = scenarioIsExecuting; - this.performanceIsExecuting = performanceIsExecuting; + private boolean countResources; + private boolean apiCaseIsExecuting; + private boolean scenarioIsExecuting; + private boolean uiScenarioIsExecuting; + private boolean performanceIsExecuting; + Map apiCaseIdMap; + Map scenarioIdMap; + Map uiScenarioIdMap; + Map performanceIdMap; - this.apiCaseIdMap = apiCaseIdMap; - this.scenarioIdMap = scenarioIdMap; - this.performanceIdMap = performanceIdMap; + public Builder setReportID(String reportID) { + this.reportID = reportID; + return this; + } + + public Builder setPlanId(String planId) { + this.planId = planId; + return this; + } + + public Builder setUserId(String userId) { + this.userId = userId; + return this; + } + + public Builder setTriggerMode(String triggerMode) { + this.triggerMode = triggerMode; + return this; + } + + public Builder setCountResources(boolean countResources) { + this.countResources = countResources; + return this; + } + + public Builder setApiCaseIsExecuting(boolean apiCaseIsExecuting) { + this.apiCaseIsExecuting = apiCaseIsExecuting; + return this; + } + + public Builder setScenarioIsExecuting(boolean scenarioIsExecuting) { + this.scenarioIsExecuting = scenarioIsExecuting; + return this; + } + + public Builder setUiScenarioIsExecuting(boolean uiScenarioIsExecuting) { + this.uiScenarioIsExecuting = uiScenarioIsExecuting; + return this; + } + + public Builder setPerformanceIsExecuting(boolean performanceIsExecuting) { + this.performanceIsExecuting = performanceIsExecuting; + return this; + } + + public Builder setApiCaseIdMap(Map apiCaseIdMap) { + this.apiCaseIdMap = apiCaseIdMap; + return this; + } + + public Builder setScenarioIdMap(Map scenarioIdMap) { + this.scenarioIdMap = scenarioIdMap; + return this; + } + + + public Builder setPerformanceIdMap(Map performanceIdMap) { + this.performanceIdMap = performanceIdMap; + return this; + } + + public Builder setUiScenarioIdMap(Map uiScenarioIdMap) { + this.uiScenarioIdMap = uiScenarioIdMap; + return this; + } + + public TestPlanReportSaveRequest build() { + return new TestPlanReportSaveRequest(this); + } } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanMessageService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanMessageService.java index 65b030a817..3e95935824 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanMessageService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanMessageService.java @@ -58,7 +58,7 @@ public class TestPlanMessageService { if (testPlanReportContent != null) { report = testPlanReportService.checkTestPlanReportHasErrorCase(report, testPlanReportContent); } - if (!report.getIsApiCaseExecuting() && !report.getIsPerformanceExecuting() && !report.getIsScenarioExecuting()) { + if (!report.getIsApiCaseExecuting() && !report.getIsPerformanceExecuting() && !report.getIsScenarioExecuting() && !report.getIsUiScenarioExecuting()) { //更新TestPlan状态为完成 TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(report.getTestPlanId()); if (testPlan != null && !StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) { 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 0345d3dd0c..d176965b05 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -271,22 +271,21 @@ public class TestPlanReportService { uiScenarioIdMap.put(dto.getId(), dto.getUiScenarioId()); } - Map apiCaseInfoMap = new HashMap<>(); - for (String id : planTestCaseIdMap.keySet()) { - apiCaseInfoMap.put(id, TestPlanApiExecuteStatus.PREPARE.name()); - } - Map scenarioInfoMap = new HashMap<>(); - for (String id : planScenarioIdMap.keySet()) { - scenarioInfoMap.put(id, TestPlanApiExecuteStatus.PREPARE.name()); - } - Map performanceInfoMap = new HashMap<>(); - for (String id : performanceIdMap.values()) { - performanceInfoMap.put(id, TestPlanApiExecuteStatus.PREPARE.name()); - } - - TestPlanReportSaveRequest saveRequest = new TestPlanReportSaveRequest(planReportId, planId, userId, triggerMode, - planTestCaseIdMap.size() > 0, planScenarioIdMap.size() > 0, performanceIdMap.size() > 0, - apiCaseInfoMap, scenarioInfoMap, performanceInfoMap); + TestPlanReportSaveRequest saveRequest = new TestPlanReportSaveRequest.Builder() + .setReportID(planReportId) + .setPlanId(planId) + .setUserId(userId) + .setCountResources(false) + .setTriggerMode(triggerMode) + .setApiCaseIsExecuting(!planTestCaseIdMap.isEmpty()) + .setScenarioIsExecuting(!planScenarioIdMap.isEmpty()) + .setPerformanceIsExecuting(!performanceIdMap.isEmpty()) + .setUiScenarioIsExecuting(!uiScenarioIdMap.isEmpty()) + .setApiCaseIdMap(planTestCaseIdMap) + .setScenarioIdMap(planScenarioIdMap) + .setPerformanceIdMap(performanceIdMap) + .setUiScenarioIdMap(uiScenarioIdMap) + .build(); if (testPlanReport == null) { returnDTO = this.genTestPlanReport(saveRequest, runInfoDTO); @@ -383,6 +382,9 @@ public class TestPlanReportService { List scenarioIdList = testPlanApiScenarioList.stream().map(TestPlanApiScenarioInfoDTO::getApiScenarioId).collect(Collectors.toList()); testPlanReport.setIsScenarioExecuting(!scenarioIdList.isEmpty()); + List testPlanUiScenarioList = extTestPlanUiScenarioCaseMapper.selectLegalDataByTestPlanId(saveRequest.getPlanId()); + testPlanReport.setIsUiScenarioExecuting(!testPlanUiScenarioList.isEmpty()); + LoadCaseRequest loadCaseRequest = new LoadCaseRequest(); loadCaseRequest.setTestPlanId(saveRequest.getPlanId()); loadCaseRequest.setProjectId(testPlan.getProjectId()); @@ -393,9 +395,13 @@ public class TestPlanReportService { testPlanReport.setIsApiCaseExecuting(saveRequest.isApiCaseIsExecuting()); testPlanReport.setIsScenarioExecuting(saveRequest.isScenarioIsExecuting()); testPlanReport.setIsPerformanceExecuting(saveRequest.isPerformanceIsExecuting()); + testPlanReport.setIsUiScenarioExecuting(saveRequest.isUiScenarioIsExecuting()); } - if (testPlanReport.getIsScenarioExecuting() || testPlanReport.getIsApiCaseExecuting() || testPlanReport.getIsPerformanceExecuting()) { + if (testPlanReport.getIsScenarioExecuting() + || testPlanReport.getIsApiCaseExecuting() + || testPlanReport.getIsPerformanceExecuting() + || testPlanReport.getIsUiScenarioExecuting()) { testPlanReport.setStatus(TestPlanReportStatus.RUNNING.name()); } else { testPlanReport.setStatus(TestPlanReportStatus.COMPLETED.name()); @@ -572,6 +578,7 @@ public class TestPlanReportService { testPlanReport.setIsApiCaseExecuting(false); testPlanReport.setIsScenarioExecuting(false); testPlanReport.setIsPerformanceExecuting(false); + testPlanReport.setIsUiScenarioExecuting(false); TestPlanExecutionQueueExample testPlanExecutionQueueExample = new TestPlanExecutionQueueExample(); testPlanExecutionQueueExample.createCriteria().andReportIdEqualTo(testPlanReportId); @@ -1346,6 +1353,41 @@ public class TestPlanReportService { LogUtil.error("Parse test plan report cenario case error!", e); } } + + if (!hasErrorCase && StringUtils.isNotEmpty(content.getPlanUiScenarioReportStruct())) { + try { + List scenarioCases = JSONArray.parseArray(content.getPlanUiScenarioReportStruct(), TestPlanUiScenarioDTO.class); + List reportIdList = new ArrayList<>(); + scenarioCases.forEach(item -> { + if (StringUtils.isNotEmpty(item.getReportId())) { + reportIdList.add(item.getReportId()); + } + }); + String defaultStatus = "Fail"; + Map reportStatus = apiScenarioReportService.getReportStatusByReportIds(reportIdList); + + for (TestPlanUiScenarioDTO dto : scenarioCases) { + String reportId = dto.getReportId(); + if (StringUtils.isNotEmpty(reportId)) { + String execStatus = reportStatus.get(reportId); + if (execStatus == null) { + execStatus = defaultStatus; + } else { + if (StringUtils.equalsIgnoreCase(execStatus, "Error")) { + execStatus = "Fail"; + } + } + dto.setLastResult(execStatus); + dto.setStatus(execStatus); + if (!StringUtils.equalsAnyIgnoreCase(execStatus, "success")) { + hasErrorCase = true; + } + } + } + } catch (Exception e) { + LogUtil.error("Parse test plan report ui scenario case error!", e); + } + } } return hasErrorCase; }