feat(测试跟踪): 测试计划操作列执行生成的报告与接口测试报告隔离

--story=1009179 --user=宋天阳 【测试跟踪】测试计划操作列执行生成的报告与接口测试报告隔离
https://www.tapd.cn/55049933/s/1221405
This commit is contained in:
song-tianyang 2022-08-10 10:50:43 +08:00 committed by jianxing
parent 2bd2ce9283
commit c46b4ed566
31 changed files with 479 additions and 108 deletions

View File

@ -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;
}

View File

@ -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());
}

View File

@ -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;

View File

@ -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() + " 】结束");
}

View File

@ -537,4 +537,12 @@ public class ApiDefinitionExecResultService {
return new ArrayList<>();
}
}
public void deleteByRelevanceTestPlanReportIds(List<String> testPlanReportIdList) {
if (CollectionUtils.isNotEmpty(testPlanReportIdList)) {
ApiDefinitionExecResultExample apiDefinitionExecResultExample = new ApiDefinitionExecResultExample();
apiDefinitionExecResultExample.createCriteria().andRelevanceTestPlanReportIdIn(testPlanReportIdList);
apiDefinitionExecResultMapper.deleteByExample(apiDefinitionExecResultExample);
}
}
}

View File

@ -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<String> testPlanReportIdList) {
if (CollectionUtils.isNotEmpty(testPlanReportIdList)) {
ApiScenarioReportExample apiScenarioReportExample = new ApiScenarioReportExample();
apiScenarioReportExample.createCriteria().andRelevanceTestPlanReportIdIn(testPlanReportIdList);
apiScenarioReportMapper.deleteByExample(apiScenarioReportExample);
}
}
}

View File

@ -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;
}

View File

@ -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<String> values) {
addCriterion("relevance_test_plan_report_id in", values, "relevanceTestPlanReportId");
return (Criteria) this;
}
public Criteria andRelevanceTestPlanReportIdNotIn(List<String> 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 {

View File

@ -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)

View File

@ -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;
}

View File

@ -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<String> values) {
addCriterion("relevance_test_plan_report_id in", values, "relevanceTestPlanReportId");
return (Criteria) this;
}
public Criteria andRelevanceTestPlanReportIdNotIn(List<String> 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 {

View File

@ -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)

View File

@ -43,5 +43,7 @@ public class LoadTestReport implements Serializable {
private String versionId;
private String relevanceTestPlanReportId;
private static final long serialVersionUID = 1L;
}

View File

@ -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<String> values) {
addCriterion("relevance_test_plan_report_id in", values, "relevanceTestPlanReportId");
return (Criteria) this;
}
public Criteria andRelevanceTestPlanReportIdNotIn(List<String> 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 {

View File

@ -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);

View File

@ -18,6 +18,7 @@
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
<result column="integrated_report_id" jdbcType="VARCHAR" property="integratedReportId" />
<result column="report_type" jdbcType="VARCHAR" property="reportType" />
<result column="relevance_test_plan_report_id" jdbcType="VARCHAR" property="relevanceTestPlanReportId" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs">
<result column="content" jdbcType="LONGVARCHAR" property="content" />
@ -84,7 +85,7 @@
<sql id="Base_Column_List">
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
</sql>
<sql id="Blob_Column_List">
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>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs">
insert into api_definition_exec_result
@ -204,6 +205,9 @@
<if test="reportType != null">
report_type,
</if>
<if test="relevanceTestPlanReportId != null">
relevance_test_plan_report_id,
</if>
<if test="content != null">
content,
</if>
@ -260,6 +264,9 @@
<if test="reportType != null">
#{reportType,jdbcType=VARCHAR},
</if>
<if test="relevanceTestPlanReportId != null">
#{relevanceTestPlanReportId,jdbcType=VARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
@ -325,6 +332,9 @@
<if test="record.reportType != null">
report_type = #{record.reportType,jdbcType=VARCHAR},
</if>
<if test="record.relevanceTestPlanReportId != null">
relevance_test_plan_report_id = #{record.relevanceTestPlanReportId,jdbcType=VARCHAR},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
@ -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}
<if test="_parameter != null">
@ -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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -430,6 +442,9 @@
<if test="reportType != null">
report_type = #{reportType,jdbcType=VARCHAR},
</if>
<if test="relevanceTestPlanReportId != null">
relevance_test_plan_report_id = #{relevanceTestPlanReportId,jdbcType=VARCHAR},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARCHAR},
</if>
@ -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}
</update>
</mapper>

View File

@ -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);

View File

@ -19,6 +19,7 @@
<result column="report_version" jdbcType="INTEGER" property="reportVersion" />
<result column="version_id" jdbcType="VARCHAR" property="versionId" />
<result column="report_type" jdbcType="VARCHAR" property="reportType" />
<result column="relevance_test_plan_report_id" jdbcType="VARCHAR" property="relevanceTestPlanReportId" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiScenarioReportWithBLOBs">
<result column="description" jdbcType="LONGVARCHAR" property="description" />
@ -85,7 +86,7 @@
<sql id="Base_Column_List">
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
</sql>
<sql id="Blob_Column_List">
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>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioReportWithBLOBs">
insert into api_scenario_report
@ -208,6 +209,9 @@
<if test="reportType != null">
report_type,
</if>
<if test="relevanceTestPlanReportId != null">
relevance_test_plan_report_id,
</if>
<if test="description != null">
description,
</if>
@ -267,6 +271,9 @@
<if test="reportType != null">
#{reportType,jdbcType=VARCHAR},
</if>
<if test="relevanceTestPlanReportId != null">
#{relevanceTestPlanReportId,jdbcType=VARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=LONGVARCHAR},
</if>
@ -335,6 +342,9 @@
<if test="record.reportType != null">
report_type = #{record.reportType,jdbcType=VARCHAR},
</if>
<if test="record.relevanceTestPlanReportId != null">
relevance_test_plan_report_id = #{record.relevanceTestPlanReportId,jdbcType=VARCHAR},
</if>
<if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR},
</if>
@ -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}
<if test="_parameter != null">
@ -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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -445,6 +457,9 @@
<if test="reportType != null">
report_type = #{reportType,jdbcType=VARCHAR},
</if>
<if test="relevanceTestPlanReportId != null">
relevance_test_plan_report_id = #{relevanceTestPlanReportId,jdbcType=VARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=LONGVARCHAR},
</if>
@ -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}
</update>
</mapper>

View File

@ -21,6 +21,7 @@
<result column="test_end_time" jdbcType="BIGINT" property="testEndTime" />
<result column="test_duration" jdbcType="BIGINT" property="testDuration" />
<result column="version_id" jdbcType="VARCHAR" property="versionId" />
<result column="relevance_test_plan_report_id" jdbcType="VARCHAR" property="relevanceTestPlanReportId" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.LoadTestReportWithBLOBs">
<result column="description" jdbcType="LONGVARCHAR" property="description" />
@ -90,7 +91,7 @@
<sql id="Base_Column_List">
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
</sql>
<sql id="Blob_Column_List">
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>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.LoadTestReportWithBLOBs">
insert into load_test_report
@ -223,6 +224,9 @@
<if test="versionId != null">
version_id,
</if>
<if test="relevanceTestPlanReportId != null">
relevance_test_plan_report_id,
</if>
<if test="description != null">
description,
</if>
@ -297,6 +301,9 @@
<if test="versionId != null">
#{versionId,jdbcType=VARCHAR},
</if>
<if test="relevanceTestPlanReportId != null">
#{relevanceTestPlanReportId,jdbcType=VARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=LONGVARCHAR},
</if>
@ -380,6 +387,9 @@
<if test="record.versionId != null">
version_id = #{record.versionId,jdbcType=VARCHAR},
</if>
<if test="record.relevanceTestPlanReportId != null">
relevance_test_plan_report_id = #{record.relevanceTestPlanReportId,jdbcType=VARCHAR},
</if>
<if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR},
</if>
@ -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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -512,6 +524,9 @@
<if test="versionId != null">
version_id = #{versionId,jdbcType=VARCHAR},
</if>
<if test="relevanceTestPlanReportId != null">
relevance_test_plan_report_id = #{relevanceTestPlanReportId,jdbcType=VARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=LONGVARCHAR},
</if>
@ -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}
</update>
</mapper>

View File

@ -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')
<if test="request.combine != null">
<include refid="listCombine">
<property name="condition" value="request.combine"/>
@ -425,6 +426,7 @@
from api_definition_exec_result
where project_id = #{projectId}
and create_time &lt; #{time}
and relevance_test_plan_report_id IS NULL
</select>
<update id="updateAllStatus">

View File

@ -8,7 +8,7 @@ public class ExtApiDefinitionExecResultProvider {
public String insertListSql(List<ApiDefinitionExecResultWithBLOBs> 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) {

View File

@ -230,6 +230,7 @@
</foreach>
</if>
AND s_r.execute_type = 'Saved'
AND s_r.relevance_test_plan_report_id IS NULL
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
@ -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
</if>
<if test="request.caseType == 'API'">
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')
</if>
) r
<where>
@ -480,6 +483,7 @@
from api_scenario_report
where create_time &lt; #{time}
and project_id = #{projectId}
and relevance_test_plan_report_id IS NULL
</select>
<update id="updateAllStatus">

View File

@ -8,7 +8,7 @@ public class ExtApiScenarioReportProvider {
public String insertListSql(List<APIScenarioReportResult> 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) {

View File

@ -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
<where>
ltr.relevance_test_plan_report_id IS NULL
<if test="reportRequest.combine != null">
<include refid="combine">
<property name="condition" value="reportRequest.combine"/>

View File

@ -11,6 +11,7 @@ public enum ReportTriggerMode {
CASE,
TEST_PLAN_SCHEDULE,
TEST_PLAN_API,
TEST_PLAN_MANUAL,
API_PLAN,
BATCH
}

View File

@ -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
}

View File

@ -24,4 +24,6 @@ public class RunTestPlanRequest extends TestPlanRequest {
* 测试计划中生成的报告ID
*/
private String reportId;
private String testPlanReportId;
}

View File

@ -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<LoadTestExportJmx> 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<LoadTestReport> loadTestReports = loadTestReportMapper.selectByExample(example);
List<String> ids = loadTestReports.stream().map(LoadTestReport::getId).collect(Collectors.toList());
DeleteReportRequest request = new DeleteReportRequest();

View File

@ -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<String> testPlanReportIdList) {
if (CollectionUtils.isNotEmpty(testPlanReportIdList)) {
LoadTestReportExample loadTestReportExample = new LoadTestReportExample();
loadTestReportExample.createCriteria().andRelevanceTestPlanReportIdIn(testPlanReportIdList);
loadTestReportMapper.deleteByExample(loadTestReportExample);
}
}
}

View File

@ -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<String> 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<String> 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 {

View File

@ -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());