From c46b4ed566ee78f7ba8ea1ba54a2c67488ab9103 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 10 Aug 2022 10:50:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=93=8D=E4=BD=9C=E5=88=97?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E7=94=9F=E6=88=90=E7=9A=84=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E4=B8=8E=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E9=9A=94=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1009179 --user=宋天阳 【测试跟踪】测试计划操作列执行生成的报告与接口测试报告隔离 https://www.tapd.cn/55049933/s/1221405 --- .../automation/ApiScenarioReportInitDTO.java | 23 ++++++ .../api/exec/perf/PerfExecService.java | 1 + .../utils/ApiDefinitionExecResultUtil.java | 1 + .../api/jmeter/APISingleResultListener.java | 3 +- .../ApiDefinitionExecResultService.java | 8 +++ .../api/service/ApiScenarioReportService.java | 68 ++++++++++-------- .../base/domain/ApiDefinitionExecResult.java | 5 +- .../ApiDefinitionExecResultExample.java | 70 ++++++++++++++++++ .../ApiDefinitionExecResultWithBLOBs.java | 3 +- .../base/domain/ApiScenarioReport.java | 5 +- .../base/domain/ApiScenarioReportExample.java | 70 ++++++++++++++++++ .../domain/ApiScenarioReportWithBLOBs.java | 3 +- .../base/domain/LoadTestReport.java | 2 + .../base/domain/LoadTestReportExample.java | 70 ++++++++++++++++++ .../mapper/ApiDefinitionExecResultMapper.java | 3 +- .../mapper/ApiDefinitionExecResultMapper.xml | 31 ++++++-- .../base/mapper/ApiScenarioReportMapper.java | 3 +- .../base/mapper/ApiScenarioReportMapper.xml | 31 ++++++-- .../base/mapper/LoadTestReportMapper.xml | 35 ++++++--- .../ext/ExtApiDefinitionExecResultMapper.xml | 4 +- .../ExtApiDefinitionExecResultProvider.java | 4 +- .../mapper/ext/ExtApiScenarioReportMapper.xml | 16 +++-- .../ext/ExtApiScenarioReportProvider.java | 4 +- .../mapper/ext/ExtLoadTestReportMapper.xml | 1 + .../commons/constants/ReportTriggerMode.java | 1 + .../constants/ReportTypeConstants.java | 5 +- .../request/RunTestPlanRequest.java | 2 + .../service/PerformanceReportService.java | 12 +--- .../service/PerformanceTestService.java | 11 ++- .../track/service/TestPlanReportService.java | 72 +++++++++++++------ .../track/service/TestPlanService.java | 20 +++++- 31 files changed, 479 insertions(+), 108 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/api/dto/automation/ApiScenarioReportInitDTO.java diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenarioReportInitDTO.java b/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenarioReportInitDTO.java new file mode 100644 index 0000000000..23c3ec1206 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenarioReportInitDTO.java @@ -0,0 +1,23 @@ +package io.metersphere.api.dto.automation; + +import io.metersphere.dto.RunModeConfigDTO; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class ApiScenarioReportInitDTO { + private String id; + private String scenarioId; + private String scenarioName; + private String triggerMode; + private String execType; + private String projectId; + private String userId; + private RunModeConfigDTO config; + private String relevanceTestPlanReportId; +} diff --git a/backend/src/main/java/io/metersphere/api/exec/perf/PerfExecService.java b/backend/src/main/java/io/metersphere/api/exec/perf/PerfExecService.java index c96d868229..925d10f74c 100644 --- a/backend/src/main/java/io/metersphere/api/exec/perf/PerfExecService.java +++ b/backend/src/main/java/io/metersphere/api/exec/perf/PerfExecService.java @@ -45,6 +45,7 @@ public class PerfExecService { request.setTestPlanLoadId(k); request.setReportId(reportId); request.setTriggerMode(triggerMode); + request.setTestPlanReportId(planReportId); if (StringUtils.isNotBlank(config.getResourcePoolId())) { request.setTestResourcePoolId(config.getResourcePoolId()); } diff --git a/backend/src/main/java/io/metersphere/api/exec/utils/ApiDefinitionExecResultUtil.java b/backend/src/main/java/io/metersphere/api/exec/utils/ApiDefinitionExecResultUtil.java index 7936003358..090a858588 100644 --- a/backend/src/main/java/io/metersphere/api/exec/utils/ApiDefinitionExecResultUtil.java +++ b/backend/src/main/java/io/metersphere/api/exec/utils/ApiDefinitionExecResultUtil.java @@ -75,6 +75,7 @@ public class ApiDefinitionExecResultUtil { apiResult.setType(ApiRunMode.API_PLAN.name()); apiResult.setStatus(status); apiResult.setContent(request.getPlanReportId()); + apiResult.setRelevanceTestPlanReportId(request.getPlanReportId()); apiResult.setEnvConfig(JSON.toJSONString(runModeConfigDTO)); return apiResult; diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APISingleResultListener.java b/backend/src/main/java/io/metersphere/api/jmeter/APISingleResultListener.java index 4d48d2d8fb..8702ad8989 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APISingleResultListener.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APISingleResultListener.java @@ -45,7 +45,8 @@ public class APISingleResultListener implements MsExecListener { queues = RetryResultUtil.clearLoops(queues); JMeterBase.resultFormatting(queues, dto); if (dto.isRetryEnable()) { - LoggerUtil.info("重试结果处理【" + dto.getReportId() + " 】开始"); + LoggerUtil.info("重试 " + + "结果处理【" + dto.getReportId() + " 】开始"); RetryResultUtil.mergeRetryResults(dto.getRequestResults()); LoggerUtil.info("重试结果处理【" + dto.getReportId() + " 】结束"); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java index 32c6ff5055..ae15987b19 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java @@ -537,4 +537,12 @@ public class ApiDefinitionExecResultService { return new ArrayList<>(); } } + + public void deleteByRelevanceTestPlanReportIds(List testPlanReportIdList) { + if (CollectionUtils.isNotEmpty(testPlanReportIdList)) { + ApiDefinitionExecResultExample apiDefinitionExecResultExample = new ApiDefinitionExecResultExample(); + apiDefinitionExecResultExample.createCriteria().andRelevanceTestPlanReportIdIn(testPlanReportIdList); + apiDefinitionExecResultMapper.deleteByExample(apiDefinitionExecResultExample); + } + } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 726f01ffcb..e2772bf15c 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.parser.Feature; import io.metersphere.api.dto.*; -import io.metersphere.api.dto.automation.APIScenarioReportResult; -import io.metersphere.api.dto.automation.ExecuteType; -import io.metersphere.api.dto.automation.RunScenarioRequest; -import io.metersphere.api.dto.automation.ScenarioStatus; +import io.metersphere.api.dto.automation.*; import io.metersphere.api.dto.datacount.ApiDataCountResult; import io.metersphere.api.dto.definition.RunDefinitionRequest; import io.metersphere.api.jmeter.FixedCapacityUtils; @@ -877,13 +874,17 @@ public class ApiScenarioReportService { return map; } - public APIScenarioReportResult init(String id, String scenarioId, String scenarioName, String triggerMode, String execType, String projectId, String userId, RunModeConfigDTO config) { - APIScenarioReportResult report = new APIScenarioReportResult(); - if (triggerMode.equals(ApiRunMode.SCENARIO.name()) || triggerMode.equals(ApiRunMode.DEFINITION.name())) { - triggerMode = ReportTriggerMode.MANUAL.name(); + public APIScenarioReportResult init(ApiScenarioReportInitDTO initModel) { + if (initModel == null) { + initModel = new ApiScenarioReportInitDTO(); } - report.setId(id); - report.setTestId(id); + APIScenarioReportResult report = new APIScenarioReportResult(); + if (StringUtils.equalsAny(initModel.getTriggerMode(), ApiRunMode.SCENARIO.name(), ApiRunMode.DEFINITION.name())) { + initModel.setTriggerMode(ReportTriggerMode.MANUAL.name()); + } + report.setId(initModel.getId()); + report.setTestId(initModel.getId()); + String scenarioName = initModel.getScenarioName(); if (StringUtils.isNotEmpty(scenarioName)) { scenarioName = scenarioName.length() >= 3000 ? scenarioName.substring(0, 2000) : scenarioName; report.setName(scenarioName); @@ -893,31 +894,32 @@ public class ApiScenarioReportService { report.setUpdateTime(System.currentTimeMillis()); report.setCreateTime(System.currentTimeMillis()); - String status = config != null && StringUtils.equals(config.getMode(), RunModeConstants.SERIAL.toString()) + String status = initModel.getConfig() != null && StringUtils.equals(initModel.getConfig().getMode(), RunModeConstants.SERIAL.toString()) ? APITestStatus.Waiting.name() : APITestStatus.Running.name(); report.setStatus(status); - if (StringUtils.isNotEmpty(userId)) { - report.setUserId(userId); - report.setCreateUser(userId); + if (StringUtils.isNotEmpty(initModel.getUserId())) { + report.setUserId(initModel.getUserId()); + report.setCreateUser(initModel.getUserId()); } else { report.setUserId(SessionUtils.getUserId()); report.setCreateUser(SessionUtils.getUserId()); } - if (config != null && StringUtils.isNotBlank(config.getResourcePoolId())) { - report.setActuator(config.getResourcePoolId()); + if (initModel.getConfig() != null && StringUtils.isNotBlank(initModel.getConfig().getResourcePoolId())) { + report.setActuator(initModel.getConfig().getResourcePoolId()); } else { report.setActuator("LOCAL"); } - report.setTriggerMode(triggerMode); + report.setTriggerMode(initModel.getTriggerMode()); report.setReportVersion(2); - report.setExecuteType(execType); - report.setProjectId(projectId); + report.setExecuteType(initModel.getExecType()); + report.setProjectId(initModel.getProjectId()); report.setScenarioName(scenarioName); - report.setScenarioId(scenarioId); - if (config != null) { - report.setEnvConfig(JSON.toJSONString(config)); + report.setScenarioId(initModel.getScenarioId()); + if (initModel.getConfig() != null) { + report.setEnvConfig(JSON.toJSONString(initModel.getConfig())); } - if (config instanceof UiRunModeConfigDTO) { + report.setRelevanceTestPlanReportId(initModel.getRelevanceTestPlanReportId()); + if (initModel.getConfig() instanceof UiRunModeConfigDTO) { report.setReportType(ReportTypeConstants.UI_INDEPENDENT.name()); } else { report.setReportType(ReportTypeConstants.SCENARIO_INDEPENDENT.name()); @@ -927,9 +929,9 @@ public class ApiScenarioReportService { public APIScenarioReportResult getApiScenarioReportResult(RunScenarioRequest request, String serialReportId, String scenarioNames, String reportScenarioIds) { - APIScenarioReportResult report = this.init(request.getConfig().getReportId(), reportScenarioIds, + APIScenarioReportResult report = this.init(new ApiScenarioReportInitDTO(request.getConfig().getReportId(), reportScenarioIds, scenarioNames, request.getTriggerMode(), ExecuteType.Saved.name(), request.getProjectId(), - request.getReportUserID(), request.getConfig()); + request.getReportUserID(), request.getConfig(), request.getTestPlanReportId())); report.setName(request.getConfig().getReportName()); report.setId(serialReportId); report.setReportType(ReportTypeConstants.SCENARIO_INTEGRATED.name()); @@ -1059,18 +1061,26 @@ public class ApiScenarioReportService { } public APIScenarioReportResult initResult(String reportId, String testPlanScenarioId, String name, RunScenarioRequest request) { - return this.init(reportId, testPlanScenarioId, name, request.getTriggerMode(), - request.getExecuteType(), request.getProjectId(), request.getReportUserID(), request.getConfig()); + return this.init(new ApiScenarioReportInitDTO(reportId, testPlanScenarioId, name, request.getTriggerMode(), + request.getExecuteType(), request.getProjectId(), request.getReportUserID(), request.getConfig(), request.getTestPlanReportId())); } public APIScenarioReportResult initDebugResult(RunDefinitionRequest request) { - return this.init(request.getId(), + return this.init(new ApiScenarioReportInitDTO(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(), SessionUtils.getUserId(), - request.getConfig()); + request.getConfig(), null)); + } + + public void deleteByRelevanceTestPlanReportIds(List testPlanReportIdList) { + if (CollectionUtils.isNotEmpty(testPlanReportIdList)) { + ApiScenarioReportExample apiScenarioReportExample = new ApiScenarioReportExample(); + apiScenarioReportExample.createCriteria().andRelevanceTestPlanReportIdIn(testPlanReportIdList); + apiScenarioReportMapper.deleteByExample(apiScenarioReportExample); + } } } diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExecResult.java b/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExecResult.java index 62f81775b3..1def7c9632 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExecResult.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExecResult.java @@ -1,8 +1,7 @@ package io.metersphere.base.domain; -import lombok.Data; - import java.io.Serializable; +import lombok.Data; @Data public class ApiDefinitionExecResult implements Serializable { @@ -38,5 +37,7 @@ public class ApiDefinitionExecResult implements Serializable { private String reportType; + private String relevanceTestPlanReportId; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExecResultExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExecResultExample.java index 46ff7cc848..336c789f49 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExecResultExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExecResultExample.java @@ -1193,6 +1193,76 @@ public class ApiDefinitionExecResultExample { addCriterion("report_type not between", value1, value2, "reportType"); return (Criteria) this; } + + public Criteria andRelevanceTestPlanReportIdIsNull() { + addCriterion("relevance_test_plan_report_id is null"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdIsNotNull() { + addCriterion("relevance_test_plan_report_id is not null"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdEqualTo(String value) { + addCriterion("relevance_test_plan_report_id =", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdNotEqualTo(String value) { + addCriterion("relevance_test_plan_report_id <>", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdGreaterThan(String value) { + addCriterion("relevance_test_plan_report_id >", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdGreaterThanOrEqualTo(String value) { + addCriterion("relevance_test_plan_report_id >=", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdLessThan(String value) { + addCriterion("relevance_test_plan_report_id <", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdLessThanOrEqualTo(String value) { + addCriterion("relevance_test_plan_report_id <=", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdLike(String value) { + addCriterion("relevance_test_plan_report_id like", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdNotLike(String value) { + addCriterion("relevance_test_plan_report_id not like", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdIn(List values) { + addCriterion("relevance_test_plan_report_id in", values, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdNotIn(List values) { + addCriterion("relevance_test_plan_report_id not in", values, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdBetween(String value1, String value2) { + addCriterion("relevance_test_plan_report_id between", value1, value2, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdNotBetween(String value1, String value2) { + addCriterion("relevance_test_plan_report_id not between", value1, value2, "relevanceTestPlanReportId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExecResultWithBLOBs.java b/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExecResultWithBLOBs.java index 1a084ab65f..8b47fcbb84 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExecResultWithBLOBs.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExecResultWithBLOBs.java @@ -1,11 +1,10 @@ package io.metersphere.base.domain; +import java.io.Serializable; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import java.io.Serializable; - @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReport.java b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReport.java index 48da6d947e..1d612e54b0 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReport.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReport.java @@ -1,8 +1,7 @@ package io.metersphere.base.domain; -import lombok.Data; - import java.io.Serializable; +import lombok.Data; @Data public class ApiScenarioReport implements Serializable { @@ -40,5 +39,7 @@ public class ApiScenarioReport implements Serializable { private String reportType; + private String relevanceTestPlanReportId; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportExample.java index 9c39cf7213..e4c9c681d7 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportExample.java @@ -1253,6 +1253,76 @@ public class ApiScenarioReportExample { addCriterion("report_type not between", value1, value2, "reportType"); return (Criteria) this; } + + public Criteria andRelevanceTestPlanReportIdIsNull() { + addCriterion("relevance_test_plan_report_id is null"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdIsNotNull() { + addCriterion("relevance_test_plan_report_id is not null"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdEqualTo(String value) { + addCriterion("relevance_test_plan_report_id =", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdNotEqualTo(String value) { + addCriterion("relevance_test_plan_report_id <>", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdGreaterThan(String value) { + addCriterion("relevance_test_plan_report_id >", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdGreaterThanOrEqualTo(String value) { + addCriterion("relevance_test_plan_report_id >=", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdLessThan(String value) { + addCriterion("relevance_test_plan_report_id <", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdLessThanOrEqualTo(String value) { + addCriterion("relevance_test_plan_report_id <=", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdLike(String value) { + addCriterion("relevance_test_plan_report_id like", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdNotLike(String value) { + addCriterion("relevance_test_plan_report_id not like", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdIn(List values) { + addCriterion("relevance_test_plan_report_id in", values, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdNotIn(List values) { + addCriterion("relevance_test_plan_report_id not in", values, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdBetween(String value1, String value2) { + addCriterion("relevance_test_plan_report_id between", value1, value2, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdNotBetween(String value1, String value2) { + addCriterion("relevance_test_plan_report_id not between", value1, value2, "relevanceTestPlanReportId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportWithBLOBs.java b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportWithBLOBs.java index 94ac76cfd5..5073458446 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportWithBLOBs.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportWithBLOBs.java @@ -1,11 +1,10 @@ package io.metersphere.base.domain; +import java.io.Serializable; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import java.io.Serializable; - @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/backend/src/main/java/io/metersphere/base/domain/LoadTestReport.java b/backend/src/main/java/io/metersphere/base/domain/LoadTestReport.java index 5be6bfffdd..74c7d99af7 100644 --- a/backend/src/main/java/io/metersphere/base/domain/LoadTestReport.java +++ b/backend/src/main/java/io/metersphere/base/domain/LoadTestReport.java @@ -43,5 +43,7 @@ public class LoadTestReport implements Serializable { private String versionId; + private String relevanceTestPlanReportId; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/LoadTestReportExample.java b/backend/src/main/java/io/metersphere/base/domain/LoadTestReportExample.java index ac32586af4..fdb3a81a08 100644 --- a/backend/src/main/java/io/metersphere/base/domain/LoadTestReportExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/LoadTestReportExample.java @@ -1383,6 +1383,76 @@ public class LoadTestReportExample { addCriterion("version_id not between", value1, value2, "versionId"); return (Criteria) this; } + + public Criteria andRelevanceTestPlanReportIdIsNull() { + addCriterion("relevance_test_plan_report_id is null"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdIsNotNull() { + addCriterion("relevance_test_plan_report_id is not null"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdEqualTo(String value) { + addCriterion("relevance_test_plan_report_id =", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdNotEqualTo(String value) { + addCriterion("relevance_test_plan_report_id <>", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdGreaterThan(String value) { + addCriterion("relevance_test_plan_report_id >", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdGreaterThanOrEqualTo(String value) { + addCriterion("relevance_test_plan_report_id >=", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdLessThan(String value) { + addCriterion("relevance_test_plan_report_id <", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdLessThanOrEqualTo(String value) { + addCriterion("relevance_test_plan_report_id <=", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdLike(String value) { + addCriterion("relevance_test_plan_report_id like", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdNotLike(String value) { + addCriterion("relevance_test_plan_report_id not like", value, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdIn(List values) { + addCriterion("relevance_test_plan_report_id in", values, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdNotIn(List values) { + addCriterion("relevance_test_plan_report_id not in", values, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdBetween(String value1, String value2) { + addCriterion("relevance_test_plan_report_id between", value1, value2, "relevanceTestPlanReportId"); + return (Criteria) this; + } + + public Criteria andRelevanceTestPlanReportIdNotBetween(String value1, String value2) { + addCriterion("relevance_test_plan_report_id not between", value1, value2, "relevanceTestPlanReportId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiDefinitionExecResultMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ApiDefinitionExecResultMapper.java index eaa00c6f5c..1eb9d013fe 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiDefinitionExecResultMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiDefinitionExecResultMapper.java @@ -3,9 +3,8 @@ package io.metersphere.base.mapper; import io.metersphere.base.domain.ApiDefinitionExecResult; import io.metersphere.base.domain.ApiDefinitionExecResultExample; import io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs; -import org.apache.ibatis.annotations.Param; - import java.util.List; +import org.apache.ibatis.annotations.Param; public interface ApiDefinitionExecResultMapper { long countByExample(ApiDefinitionExecResultExample example); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiDefinitionExecResultMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiDefinitionExecResultMapper.xml index 1f0a9a36c5..7bdcec77d0 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiDefinitionExecResultMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiDefinitionExecResultMapper.xml @@ -18,6 +18,7 @@ + @@ -84,7 +85,7 @@ id, `name`, resource_id, `status`, user_id, start_time, end_time, create_time, `type`, actuator, trigger_mode, error_code, version_id, project_id, integrated_report_id, - report_type + report_type, relevance_test_plan_report_id content, env_config @@ -143,15 +144,15 @@ end_time, create_time, `type`, actuator, trigger_mode, error_code, version_id, project_id, integrated_report_id, - report_type, content, env_config - ) + report_type, relevance_test_plan_report_id, + content, env_config) values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}, #{createTime,jdbcType=BIGINT}, #{type,jdbcType=VARCHAR}, #{actuator,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{errorCode,jdbcType=VARCHAR}, #{versionId,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{integratedReportId,jdbcType=VARCHAR}, - #{reportType,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR}, #{envConfig,jdbcType=LONGVARCHAR} - ) + #{reportType,jdbcType=VARCHAR}, #{relevanceTestPlanReportId,jdbcType=VARCHAR}, + #{content,jdbcType=LONGVARCHAR}, #{envConfig,jdbcType=LONGVARCHAR}) insert into api_definition_exec_result @@ -204,6 +205,9 @@ report_type, + + relevance_test_plan_report_id, + content, @@ -260,6 +264,9 @@ #{reportType,jdbcType=VARCHAR}, + + #{relevanceTestPlanReportId,jdbcType=VARCHAR}, + #{content,jdbcType=LONGVARCHAR}, @@ -325,6 +332,9 @@ report_type = #{record.reportType,jdbcType=VARCHAR}, + + relevance_test_plan_report_id = #{record.relevanceTestPlanReportId,jdbcType=VARCHAR}, + content = #{record.content,jdbcType=LONGVARCHAR}, @@ -354,6 +364,7 @@ project_id = #{record.projectId,jdbcType=VARCHAR}, integrated_report_id = #{record.integratedReportId,jdbcType=VARCHAR}, report_type = #{record.reportType,jdbcType=VARCHAR}, + relevance_test_plan_report_id = #{record.relevanceTestPlanReportId,jdbcType=VARCHAR}, content = #{record.content,jdbcType=LONGVARCHAR}, env_config = #{record.envConfig,jdbcType=LONGVARCHAR} @@ -377,7 +388,8 @@ version_id = #{record.versionId,jdbcType=VARCHAR}, project_id = #{record.projectId,jdbcType=VARCHAR}, integrated_report_id = #{record.integratedReportId,jdbcType=VARCHAR}, - report_type = #{record.reportType,jdbcType=VARCHAR} + report_type = #{record.reportType,jdbcType=VARCHAR}, + relevance_test_plan_report_id = #{record.relevanceTestPlanReportId,jdbcType=VARCHAR} @@ -430,6 +442,9 @@ report_type = #{reportType,jdbcType=VARCHAR}, + + relevance_test_plan_report_id = #{relevanceTestPlanReportId,jdbcType=VARCHAR}, + content = #{content,jdbcType=LONGVARCHAR}, @@ -456,6 +471,7 @@ project_id = #{projectId,jdbcType=VARCHAR}, integrated_report_id = #{integratedReportId,jdbcType=VARCHAR}, report_type = #{reportType,jdbcType=VARCHAR}, + relevance_test_plan_report_id = #{relevanceTestPlanReportId,jdbcType=VARCHAR}, content = #{content,jdbcType=LONGVARCHAR}, env_config = #{envConfig,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -476,7 +492,8 @@ version_id = #{versionId,jdbcType=VARCHAR}, project_id = #{projectId,jdbcType=VARCHAR}, integrated_report_id = #{integratedReportId,jdbcType=VARCHAR}, - report_type = #{reportType,jdbcType=VARCHAR} + report_type = #{reportType,jdbcType=VARCHAR}, + relevance_test_plan_report_id = #{relevanceTestPlanReportId,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportMapper.java index 1f946f5e0b..7adf9bf4d3 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportMapper.java @@ -3,9 +3,8 @@ package io.metersphere.base.mapper; import io.metersphere.base.domain.ApiScenarioReport; import io.metersphere.base.domain.ApiScenarioReportExample; import io.metersphere.base.domain.ApiScenarioReportWithBLOBs; -import org.apache.ibatis.annotations.Param; - import java.util.List; +import org.apache.ibatis.annotations.Param; public interface ApiScenarioReportMapper { long countByExample(ApiScenarioReportExample example); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportMapper.xml index af5af4da22..6bf25c98ad 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportMapper.xml @@ -19,6 +19,7 @@ + @@ -85,7 +86,7 @@ id, project_id, `name`, create_time, update_time, `status`, user_id, trigger_mode, execute_type, scenario_name, scenario_id, create_user, actuator, end_time, report_version, - version_id, report_type + version_id, report_type, relevance_test_plan_report_id description, env_config @@ -144,15 +145,15 @@ user_id, trigger_mode, execute_type, scenario_name, scenario_id, create_user, actuator, end_time, report_version, - version_id, report_type, description, - env_config) + version_id, report_type, relevance_test_plan_report_id, + description, env_config) values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{executeType,jdbcType=VARCHAR}, #{scenarioName,jdbcType=VARCHAR}, #{scenarioId,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{actuator,jdbcType=VARCHAR}, #{endTime,jdbcType=BIGINT}, #{reportVersion,jdbcType=INTEGER}, - #{versionId,jdbcType=VARCHAR}, #{reportType,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}, - #{envConfig,jdbcType=LONGVARCHAR}) + #{versionId,jdbcType=VARCHAR}, #{reportType,jdbcType=VARCHAR}, #{relevanceTestPlanReportId,jdbcType=VARCHAR}, + #{description,jdbcType=LONGVARCHAR}, #{envConfig,jdbcType=LONGVARCHAR}) insert into api_scenario_report @@ -208,6 +209,9 @@ report_type, + + relevance_test_plan_report_id, + description, @@ -267,6 +271,9 @@ #{reportType,jdbcType=VARCHAR}, + + #{relevanceTestPlanReportId,jdbcType=VARCHAR}, + #{description,jdbcType=LONGVARCHAR}, @@ -335,6 +342,9 @@ report_type = #{record.reportType,jdbcType=VARCHAR}, + + relevance_test_plan_report_id = #{record.relevanceTestPlanReportId,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=LONGVARCHAR}, @@ -365,6 +375,7 @@ report_version = #{record.reportVersion,jdbcType=INTEGER}, version_id = #{record.versionId,jdbcType=VARCHAR}, report_type = #{record.reportType,jdbcType=VARCHAR}, + relevance_test_plan_report_id = #{record.relevanceTestPlanReportId,jdbcType=VARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR}, env_config = #{record.envConfig,jdbcType=LONGVARCHAR} @@ -389,7 +400,8 @@ end_time = #{record.endTime,jdbcType=BIGINT}, report_version = #{record.reportVersion,jdbcType=INTEGER}, version_id = #{record.versionId,jdbcType=VARCHAR}, - report_type = #{record.reportType,jdbcType=VARCHAR} + report_type = #{record.reportType,jdbcType=VARCHAR}, + relevance_test_plan_report_id = #{record.relevanceTestPlanReportId,jdbcType=VARCHAR} @@ -445,6 +457,9 @@ report_type = #{reportType,jdbcType=VARCHAR}, + + relevance_test_plan_report_id = #{relevanceTestPlanReportId,jdbcType=VARCHAR}, + description = #{description,jdbcType=LONGVARCHAR}, @@ -472,6 +487,7 @@ report_version = #{reportVersion,jdbcType=INTEGER}, version_id = #{versionId,jdbcType=VARCHAR}, report_type = #{reportType,jdbcType=VARCHAR}, + relevance_test_plan_report_id = #{relevanceTestPlanReportId,jdbcType=VARCHAR}, description = #{description,jdbcType=LONGVARCHAR}, env_config = #{envConfig,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -493,7 +509,8 @@ end_time = #{endTime,jdbcType=BIGINT}, report_version = #{reportVersion,jdbcType=INTEGER}, version_id = #{versionId,jdbcType=VARCHAR}, - report_type = #{reportType,jdbcType=VARCHAR} + report_type = #{reportType,jdbcType=VARCHAR}, + relevance_test_plan_report_id = #{relevanceTestPlanReportId,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.xml index d1eefa91fc..0e918244e0 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.xml @@ -21,6 +21,7 @@ + @@ -90,7 +91,7 @@ id, test_id, `name`, create_time, update_time, `status`, user_id, trigger_mode, file_id, max_users, avg_response_time, tps, project_id, test_name, test_resource_pool_id, - test_start_time, test_end_time, test_duration, version_id + test_start_time, test_end_time, test_duration, version_id, relevance_test_plan_report_id description, load_configuration, jmx_content, advanced_configuration, env_info @@ -150,18 +151,18 @@ max_users, avg_response_time, tps, project_id, test_name, test_resource_pool_id, test_start_time, test_end_time, test_duration, - version_id, description, load_configuration, - jmx_content, advanced_configuration, - env_info) + version_id, relevance_test_plan_report_id, description, + load_configuration, jmx_content, + advanced_configuration, env_info) values (#{id,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{fileId,jdbcType=VARCHAR}, #{maxUsers,jdbcType=VARCHAR}, #{avgResponseTime,jdbcType=VARCHAR}, #{tps,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{testName,jdbcType=VARCHAR}, #{testResourcePoolId,jdbcType=VARCHAR}, #{testStartTime,jdbcType=BIGINT}, #{testEndTime,jdbcType=BIGINT}, #{testDuration,jdbcType=BIGINT}, - #{versionId,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}, #{loadConfiguration,jdbcType=LONGVARCHAR}, - #{jmxContent,jdbcType=LONGVARCHAR}, #{advancedConfiguration,jdbcType=LONGVARCHAR}, - #{envInfo,jdbcType=LONGVARCHAR}) + #{versionId,jdbcType=VARCHAR}, #{relevanceTestPlanReportId,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}, + #{loadConfiguration,jdbcType=LONGVARCHAR}, #{jmxContent,jdbcType=LONGVARCHAR}, + #{advancedConfiguration,jdbcType=LONGVARCHAR}, #{envInfo,jdbcType=LONGVARCHAR}) insert into load_test_report @@ -223,6 +224,9 @@ version_id, + + relevance_test_plan_report_id, + description, @@ -297,6 +301,9 @@ #{versionId,jdbcType=VARCHAR}, + + #{relevanceTestPlanReportId,jdbcType=VARCHAR}, + #{description,jdbcType=LONGVARCHAR}, @@ -380,6 +387,9 @@ version_id = #{record.versionId,jdbcType=VARCHAR}, + + relevance_test_plan_report_id = #{record.relevanceTestPlanReportId,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=LONGVARCHAR}, @@ -421,6 +431,7 @@ test_end_time = #{record.testEndTime,jdbcType=BIGINT}, test_duration = #{record.testDuration,jdbcType=BIGINT}, version_id = #{record.versionId,jdbcType=VARCHAR}, + relevance_test_plan_report_id = #{record.relevanceTestPlanReportId,jdbcType=VARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR}, load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR}, jmx_content = #{record.jmxContent,jdbcType=LONGVARCHAR}, @@ -450,7 +461,8 @@ test_start_time = #{record.testStartTime,jdbcType=BIGINT}, test_end_time = #{record.testEndTime,jdbcType=BIGINT}, test_duration = #{record.testDuration,jdbcType=BIGINT}, - version_id = #{record.versionId,jdbcType=VARCHAR} + version_id = #{record.versionId,jdbcType=VARCHAR}, + relevance_test_plan_report_id = #{record.relevanceTestPlanReportId,jdbcType=VARCHAR} @@ -512,6 +524,9 @@ version_id = #{versionId,jdbcType=VARCHAR}, + + relevance_test_plan_report_id = #{relevanceTestPlanReportId,jdbcType=VARCHAR}, + description = #{description,jdbcType=LONGVARCHAR}, @@ -550,6 +565,7 @@ test_end_time = #{testEndTime,jdbcType=BIGINT}, test_duration = #{testDuration,jdbcType=BIGINT}, version_id = #{versionId,jdbcType=VARCHAR}, + relevance_test_plan_report_id = #{relevanceTestPlanReportId,jdbcType=VARCHAR}, description = #{description,jdbcType=LONGVARCHAR}, load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR}, jmx_content = #{jmxContent,jdbcType=LONGVARCHAR}, @@ -576,7 +592,8 @@ test_start_time = #{testStartTime,jdbcType=BIGINT}, test_end_time = #{testEndTime,jdbcType=BIGINT}, test_duration = #{testDuration,jdbcType=BIGINT}, - version_id = #{versionId,jdbcType=VARCHAR} + version_id = #{versionId,jdbcType=VARCHAR}, + relevance_test_plan_report_id = #{relevanceTestPlanReportId,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml index b0967e56f9..f1d701b646 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml @@ -216,7 +216,8 @@ a_r.report_type, 'Saved' as execute_type from api_definition_exec_result a_r - where (a_r.integrated_report_id is null or a_r.integrated_report_id = 'null') + where a_r.relevance_test_plan_report_id IS NULL AND (a_r.integrated_report_id is null or + a_r.integrated_report_id = 'null') @@ -425,6 +426,7 @@ from api_definition_exec_result where project_id = #{projectId} and create_time < #{time} + and relevance_test_plan_report_id IS NULL diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultProvider.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultProvider.java index be463bd065..5edae2b8a8 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultProvider.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultProvider.java @@ -8,7 +8,7 @@ public class ExtApiDefinitionExecResultProvider { public String insertListSql(List list) { StringBuffer sqlList = new StringBuffer(); sqlList.append("insert into api_definition_exec_result (id, `name`, resource_id, `status`, user_id, start_time, end_time," + - " create_time, `type`, actuator, trigger_mode, version_id, error_code,project_id,integrated_report_id,report_type, content,env_config) values "); + " create_time, `type`, actuator, trigger_mode, version_id, error_code,project_id,integrated_report_id,report_type, content,env_config,relevance_test_plan_report_id) values "); for (int i = 0; i < list.size(); i++) { ApiDefinitionExecResultWithBLOBs result = list.get(i); sqlList.append(" (") @@ -48,6 +48,8 @@ public class ExtApiDefinitionExecResultProvider { .append(result.getContent()) .append("','") .append(result.getEnvConfig()) + .append("','") + .append(result.getRelevanceTestPlanReportId()) .append("'") .append(")"); if (i < list.size() - 1) { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml index d18a372baa..e5371b7eb5 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml @@ -230,6 +230,7 @@ AND s_r.execute_type = 'Saved' + AND s_r.relevance_test_plan_report_id IS NULL order by @@ -255,22 +256,24 @@ s_r.execute_type, s_r.report_type FROM api_scenario_report s_r + WHERE s_r.relevance_test_plan_report_id IS NULL - select a_r.name as test_name, + SELECT a_r.name AS test_name, a_r.end_time, a_r.user_id, a_r.name, a_r.id, a_r.project_id, a_r.create_time, - a_r.create_time as update_time, + a_r.create_time AS update_time, a_r.status, a_r.trigger_mode, - 'Saved' as execute_type, - 'API_INDEPENDENT' as report_type - from api_definition_exec_result a_r - where a_r.integrated_report_id is null or a_r.integrated_report_id = 'null' + 'Saved' AS execute_type, + 'API_INDEPENDENT' AS report_type + FROM api_definition_exec_result a_r + WHERE a_r.relevance_test_plan_report_id IS NULL + AND (a_r.integrated_report_id is null or a_r.integrated_report_id = 'null') ) r @@ -480,6 +483,7 @@ from api_scenario_report where create_time < #{time} and project_id = #{projectId} + and relevance_test_plan_report_id IS NULL diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportProvider.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportProvider.java index d192920516..5e3aa21ccf 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportProvider.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportProvider.java @@ -8,7 +8,7 @@ public class ExtApiScenarioReportProvider { public String insertListSql(List list) { StringBuffer sqlList = new StringBuffer(); sqlList.append("INSERT INTO api_scenario_report (id, project_id, `name`, create_time, update_time, `status`, user_id, trigger_mode," + - " execute_type, scenario_name, scenario_id, create_user, actuator, end_time, report_version, version_id, description,report_type,env_config) VALUES "); + " execute_type, scenario_name, scenario_id, create_user, actuator, end_time, report_version, version_id, description,report_type,env_config,relevance_test_plan_report_id) VALUES "); for (int i = 0; i < list.size(); i++) { APIScenarioReportResult result = list.get(i); sqlList.append(" (") @@ -50,6 +50,8 @@ public class ExtApiScenarioReportProvider { .append(result.getReportType()) .append("','") .append(result.getEnvConfig()) + .append("','") + .append(result.getRelevanceTestPlanReportId()) .append("'") .append(")"); if (i < list.size() - 1) { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.xml index 5e21959990..a4b4fc707f 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.xml @@ -79,6 +79,7 @@ join project on project.id = ltr.project_id JOIN project_version on project.id = project_version.project_id AND ltr.version_id = project_version.id + ltr.relevance_test_plan_report_id IS NULL diff --git a/backend/src/main/java/io/metersphere/commons/constants/ReportTriggerMode.java b/backend/src/main/java/io/metersphere/commons/constants/ReportTriggerMode.java index f0e591a216..e2edfe234e 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/ReportTriggerMode.java +++ b/backend/src/main/java/io/metersphere/commons/constants/ReportTriggerMode.java @@ -11,6 +11,7 @@ public enum ReportTriggerMode { CASE, TEST_PLAN_SCHEDULE, TEST_PLAN_API, + TEST_PLAN_MANUAL, API_PLAN, BATCH } diff --git a/backend/src/main/java/io/metersphere/commons/constants/ReportTypeConstants.java b/backend/src/main/java/io/metersphere/commons/constants/ReportTypeConstants.java index 529b057694..f349ffaaf6 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/ReportTypeConstants.java +++ b/backend/src/main/java/io/metersphere/commons/constants/ReportTypeConstants.java @@ -15,5 +15,8 @@ public enum ReportTypeConstants { API_INDEPENDENT, UI_INTEGRATED, UI_INDEPENDENT, - TEST_PLAN + TEST_PLAN, + TEST_PLAN_API, + TEST_PLAN_SCENARIO, + TEST_PLAN_UI } diff --git a/backend/src/main/java/io/metersphere/performance/request/RunTestPlanRequest.java b/backend/src/main/java/io/metersphere/performance/request/RunTestPlanRequest.java index 0a05d20cd5..fe1fb2b0cc 100644 --- a/backend/src/main/java/io/metersphere/performance/request/RunTestPlanRequest.java +++ b/backend/src/main/java/io/metersphere/performance/request/RunTestPlanRequest.java @@ -24,4 +24,6 @@ public class RunTestPlanRequest extends TestPlanRequest { * 测试计划中生成的报告ID */ private String reportId; + + private String testPlanReportId; } diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java index 0b330fc8c2..10d7ddfb12 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java @@ -479,16 +479,6 @@ public class PerformanceReportService { } } - public String getPoolTypeByReportId(String reportId) { - LoadTestReportWithBLOBs report = getReport(reportId); - String poolId = report.getTestResourcePoolId(); - TestResourcePool testResourcePool = testResourcePoolMapper.selectByPrimaryKey(poolId); - if (testResourcePool != null) { - return testResourcePool.getType(); - } - return ""; - } - public List getJmxContent(String reportId) { LoadTestReportWithBLOBs loadTestReportWithBLOBs = loadTestReportMapper.selectByPrimaryKey(reportId); if (loadTestReportWithBLOBs == null) { @@ -566,7 +556,7 @@ public class PerformanceReportService { public void cleanUpReport(long time, String projectId) { LoadTestReportExample example = new LoadTestReportExample(); - example.createCriteria().andCreateTimeLessThan(time).andProjectIdEqualTo(projectId); + example.createCriteria().andCreateTimeLessThan(time).andProjectIdEqualTo(projectId).andRelevanceTestPlanReportIdIsNull(); List loadTestReports = loadTestReportMapper.selectByExample(example); List ids = loadTestReports.stream().map(LoadTestReport::getId).collect(Collectors.toList()); DeleteReportRequest request = new DeleteReportRequest(); diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index b356d8e397..6bda4631a9 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -48,6 +48,7 @@ import io.metersphere.track.request.testplan.LoadCaseRequest; import io.metersphere.track.service.TestCaseService; import io.metersphere.track.service.TestPlanLoadCaseService; import io.metersphere.track.service.TestPlanProjectService; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -61,7 +62,6 @@ import org.redisson.api.RedissonClient; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; @@ -456,6 +456,7 @@ public class PerformanceTestService { testReport.setName(loadTest.getName()); testReport.setTriggerMode(request.getTriggerMode()); testReport.setVersionId(loadTest.getVersionId()); + testReport.setRelevanceTestPlanReportId(request.getTestPlanReportId()); if (SessionUtils.getUser() == null) { testReport.setUserId(loadTest.getUserId()); } else { @@ -1170,4 +1171,12 @@ public class PerformanceTestService { request2.setFilters(param); return this.list(request2); } + + public void deleteByRelevanceTestPlanReportIds(List testPlanReportIdList) { + if (CollectionUtils.isNotEmpty(testPlanReportIdList)) { + LoadTestReportExample loadTestReportExample = new LoadTestReportExample(); + loadTestReportExample.createCriteria().andRelevanceTestPlanReportIdIn(testPlanReportIdList); + loadTestReportMapper.deleteByExample(loadTestReportExample); + } + } } 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 6e8d7dd5d0..0345d3dd0c 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -19,6 +19,7 @@ import io.metersphere.dto.TestPlanExecuteReportDTO; import io.metersphere.dto.TestPlanUiScenarioDTO; import io.metersphere.i18n.Translator; import io.metersphere.log.vo.OperatingLogDetails; +import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.service.EnvironmentGroupProjectService; import io.metersphere.service.EnvironmentGroupService; import io.metersphere.service.ProjectService; @@ -82,6 +83,8 @@ public class TestPlanReportService { @Resource ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper; @Resource + private PerformanceTestService performanceTestService; + @Resource private ExtLoadTestReportMapper extLoadTestReportMapper; @Resource private ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper; @@ -778,14 +781,22 @@ public class TestPlanReportService { } public void delete(List testPlanReportIdList) { - for (String testPlanReportId : testPlanReportIdList) { - testPlanReportMapper.deleteByPrimaryKey(testPlanReportId); - TestPlanReportDataExample example = new TestPlanReportDataExample(); - example.createCriteria().andTestPlanReportIdEqualTo(testPlanReportId); - testPlanReportDataMapper.deleteByExample(example); + if (CollectionUtils.isNotEmpty(testPlanReportIdList)) { + TestPlanReportExample example = new TestPlanReportExample(); + example.createCriteria().andIdIn(testPlanReportIdList); + testPlanReportMapper.deleteByExample(example); + TestPlanReportDataExample testPlanReportDataExample = new TestPlanReportDataExample(); + testPlanReportDataExample.createCriteria().andTestPlanReportIdIn(testPlanReportIdList); + testPlanReportDataMapper.deleteByExample(testPlanReportDataExample); TestPlanReportContentExample contentExample = new TestPlanReportContentExample(); - contentExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReportId); + contentExample.createCriteria().andTestPlanReportIdIn(testPlanReportIdList); testPlanReportContentMapper.deleteByExample(contentExample); + + //删除关联资源对应的报告ID + apiDefinitionExecResultService.deleteByRelevanceTestPlanReportIds(testPlanReportIdList); + apiScenarioReportService.deleteByRelevanceTestPlanReportIds(testPlanReportIdList); + performanceTestService.deleteByRelevanceTestPlanReportIds(testPlanReportIdList); + } } @@ -800,20 +811,7 @@ public class TestPlanReportService { if (request.isSelectAllDate()) { deleteReportIds = this.getAllApiIdsByFrontedSelect(request.getFilters(), request.getName(), request.getProjectId(), request.getUnSelectIds(), request.getCombine()); } - if (CollectionUtils.isNotEmpty(deleteReportIds)) { - TestPlanReportExample deleteReportExample = new TestPlanReportExample(); - deleteReportExample.createCriteria().andIdIn(deleteReportIds); - testPlanReportMapper.deleteByExample(deleteReportExample); - - - TestPlanReportDataExample example = new TestPlanReportDataExample(); - example.createCriteria().andTestPlanReportIdIn(deleteReportIds); - testPlanReportDataMapper.deleteByExample(example); - - TestPlanReportContentExample contentExample = new TestPlanReportContentExample(); - contentExample.createCriteria().andTestPlanReportIdIn(deleteReportIds); - testPlanReportContentMapper.deleteByExample(contentExample); - } + this.delete(deleteReportIds); } private void deleteReportBatch(List reportIds) { @@ -825,6 +823,10 @@ public class TestPlanReportService { TestPlanReportDataMapper planReportDataMapper = sqlSession.getMapper(TestPlanReportDataMapper.class); TestPlanReportContentMapper planReportContentMapper = sqlSession.getMapper(TestPlanReportContentMapper.class); + ApiDefinitionExecResultMapper batchDefinitionExecResultMapper = sqlSession.getMapper(ApiDefinitionExecResultMapper.class); + ApiScenarioReportMapper batchScenarioReportMapper = sqlSession.getMapper(ApiScenarioReportMapper.class); + LoadTestReportMapper batchLoadTestReportMapper = sqlSession.getMapper(LoadTestReportMapper.class); + try { while (reportIds.size() > handleCount) { handleIdList = new ArrayList<>(handleCount); @@ -849,6 +851,21 @@ public class TestPlanReportService { contentExample.createCriteria().andTestPlanReportIdIn(handleIdList); planReportContentMapper.deleteByExample(contentExample); + //删除关联的接口用例报告 + ApiDefinitionExecResultExample apiDefinitionExecResultExample = new ApiDefinitionExecResultExample(); + apiDefinitionExecResultExample.createCriteria().andRelevanceTestPlanReportIdIn(handleIdList); + batchDefinitionExecResultMapper.deleteByExample(apiDefinitionExecResultExample); + + //删除关联的场景和ui用例报告 + ApiScenarioReportExample apiScenarioReportExample = new ApiScenarioReportExample(); + apiScenarioReportExample.createCriteria().andRelevanceTestPlanReportIdIn(handleIdList); + batchScenarioReportMapper.deleteByExample(apiScenarioReportExample); + + //删除关联的性能测试用例报告 + LoadTestReportExample loadTestReportExample = new LoadTestReportExample(); + loadTestReportExample.createCriteria().andRelevanceTestPlanReportIdIn(handleIdList); + batchLoadTestReportMapper.deleteByExample(loadTestReportExample); + sqlSession.flushStatements(); reportIds = otherIdList; @@ -868,6 +885,21 @@ public class TestPlanReportService { contentExample.createCriteria().andTestPlanReportIdIn(reportIds); planReportContentMapper.deleteByExample(contentExample); + //删除关联的接口用例报告 + ApiDefinitionExecResultExample apiDefinitionExecResultExample = new ApiDefinitionExecResultExample(); + apiDefinitionExecResultExample.createCriteria().andRelevanceTestPlanReportIdIn(reportIds); + batchDefinitionExecResultMapper.deleteByExample(apiDefinitionExecResultExample); + + //删除关联的场景和ui用例报告 + ApiScenarioReportExample apiScenarioReportExample = new ApiScenarioReportExample(); + apiScenarioReportExample.createCriteria().andRelevanceTestPlanReportIdIn(reportIds); + batchScenarioReportMapper.deleteByExample(apiScenarioReportExample); + + //删除关联的性能测试用例报告 + LoadTestReportExample loadTestReportExample = new LoadTestReportExample(); + loadTestReportExample.createCriteria().andRelevanceTestPlanReportIdIn(reportIds); + batchLoadTestReportMapper.deleteByExample(loadTestReportExample); + sqlSession.flushStatements(); } } finally { 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 ebd760d0a4..78c6a4418c 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -1027,7 +1027,7 @@ public class TestPlanService { if (reportInfoDTO.getPerformanceIdMap() != null) { //执行性能测试任务 LoggerUtil.info("开始执行测试计划性能用例 " + planReportId); - loadCaseReportMap = perfExecService.run(planReportId, runModeConfig, triggerMode, reportInfoDTO.getPerformanceIdMap()); + loadCaseReportMap = perfExecService.run(planReportId, runModeConfig, transformationPerfTriggerMode(triggerMode), reportInfoDTO.getPerformanceIdMap()); } if (reportInfoDTO.getUiScenarioIdMap() != null) { @@ -1043,6 +1043,24 @@ public class TestPlanService { return planReportId; } + /** + * 将测试计划运行时的triggerMode转化为性能测试中辨别更明确的值 + * + * @param triggerMode + * @return + */ + private String transformationPerfTriggerMode(String triggerMode) { + if (StringUtils.equalsIgnoreCase(triggerMode, ReportTriggerMode.SCHEDULE.name())) { + return ReportTriggerMode.TEST_PLAN_SCHEDULE.name(); + } else if (StringUtils.equalsIgnoreCase(triggerMode, ReportTriggerMode.MANUAL.name())) { + return ReportTriggerMode.TEST_PLAN_MANUAL.name(); + } else if (StringUtils.equalsIgnoreCase(triggerMode, ReportTriggerMode.API.name())) { + return ReportTriggerMode.TEST_PLAN_API.name(); + } else { + return triggerMode; + } + } + private RunModeConfigDTO buildRunModeConfigDTO() { RunModeConfigDTO runModeConfig = new RunModeConfigDTO(); runModeConfig.setMode(RunModeConstants.SERIAL.name());