refactor(测试计划): 移除失败重试相关配置&&补充报告功能用例执行详情

This commit is contained in:
song-cc-rock 2024-06-17 11:31:38 +08:00 committed by Craftsman
parent 09d8a97398
commit 1b6938e013
8 changed files with 24 additions and 127 deletions

View File

@ -66,17 +66,10 @@ public class TestPlanCollection implements Serializable {
@NotNull(message = "{test_plan_collection.retry_on_fail.not_blank}", groups = {Created.class})
private Boolean retryOnFail;
@Schema(description = "失败重试类型(步骤/场景)", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{test_plan_collection.retry_type.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{test_plan_collection.retry_type.length_range}", groups = {Created.class, Updated.class})
private String retryType;
@Schema(description = "失败重试次数", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "{test_plan_collection.retry_times.not_blank}", groups = {Created.class})
@Schema(description = "失败重试次数")
private Integer retryTimes;
@Schema(description = "失败重试间隔(单位: ms)", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "{test_plan_collection.retry_interval.not_blank}", groups = {Created.class})
@Schema(description = "失败重试间隔(单位: ms)")
private Integer retryInterval;
@Schema(description = "是否失败停止", requiredMode = Schema.RequiredMode.REQUIRED)
@ -107,7 +100,6 @@ public class TestPlanCollection implements Serializable {
environmentId("environment_id", "environmentId", "VARCHAR", false),
testResourcePoolId("test_resource_pool_id", "testResourcePoolId", "VARCHAR", false),
retryOnFail("retry_on_fail", "retryOnFail", "BIT", false),
retryType("retry_type", "retryType", "VARCHAR", false),
retryTimes("retry_times", "retryTimes", "INTEGER", false),
retryInterval("retry_interval", "retryInterval", "INTEGER", false),
stopOnFail("stop_on_fail", "stopOnFail", "BIT", false),

View File

@ -844,76 +844,6 @@ public class TestPlanCollectionExample {
return (Criteria) this;
}
public Criteria andRetryTypeIsNull() {
addCriterion("retry_type is null");
return (Criteria) this;
}
public Criteria andRetryTypeIsNotNull() {
addCriterion("retry_type is not null");
return (Criteria) this;
}
public Criteria andRetryTypeEqualTo(String value) {
addCriterion("retry_type =", value, "retryType");
return (Criteria) this;
}
public Criteria andRetryTypeNotEqualTo(String value) {
addCriterion("retry_type <>", value, "retryType");
return (Criteria) this;
}
public Criteria andRetryTypeGreaterThan(String value) {
addCriterion("retry_type >", value, "retryType");
return (Criteria) this;
}
public Criteria andRetryTypeGreaterThanOrEqualTo(String value) {
addCriterion("retry_type >=", value, "retryType");
return (Criteria) this;
}
public Criteria andRetryTypeLessThan(String value) {
addCriterion("retry_type <", value, "retryType");
return (Criteria) this;
}
public Criteria andRetryTypeLessThanOrEqualTo(String value) {
addCriterion("retry_type <=", value, "retryType");
return (Criteria) this;
}
public Criteria andRetryTypeLike(String value) {
addCriterion("retry_type like", value, "retryType");
return (Criteria) this;
}
public Criteria andRetryTypeNotLike(String value) {
addCriterion("retry_type not like", value, "retryType");
return (Criteria) this;
}
public Criteria andRetryTypeIn(List<String> values) {
addCriterion("retry_type in", values, "retryType");
return (Criteria) this;
}
public Criteria andRetryTypeNotIn(List<String> values) {
addCriterion("retry_type not in", values, "retryType");
return (Criteria) this;
}
public Criteria andRetryTypeBetween(String value1, String value2) {
addCriterion("retry_type between", value1, value2, "retryType");
return (Criteria) this;
}
public Criteria andRetryTypeNotBetween(String value1, String value2) {
addCriterion("retry_type not between", value1, value2, "retryType");
return (Criteria) this;
}
public Criteria andRetryTimesIsNull() {
addCriterion("retry_times is null");
return (Criteria) this;

View File

@ -13,7 +13,6 @@
<result column="environment_id" jdbcType="VARCHAR" property="environmentId" />
<result column="test_resource_pool_id" jdbcType="VARCHAR" property="testResourcePoolId" />
<result column="retry_on_fail" jdbcType="BIT" property="retryOnFail" />
<result column="retry_type" jdbcType="VARCHAR" property="retryType" />
<result column="retry_times" jdbcType="INTEGER" property="retryTimes" />
<result column="retry_interval" jdbcType="INTEGER" property="retryInterval" />
<result column="stop_on_fail" jdbcType="BIT" property="stopOnFail" />
@ -81,7 +80,7 @@
</sql>
<sql id="Base_Column_List">
id, test_plan_id, parent_id, `name`, `type`, execute_method, extended, grouped, environment_id,
test_resource_pool_id, retry_on_fail, retry_type, retry_times, retry_interval, stop_on_fail,
test_resource_pool_id, retry_on_fail, retry_times, retry_interval, stop_on_fail,
create_user, create_time, pos
</sql>
<select id="selectByExample" parameterType="io.metersphere.plan.domain.TestPlanCollectionExample" resultMap="BaseResultMap">
@ -118,17 +117,15 @@
insert into test_plan_collection (id, test_plan_id, parent_id,
`name`, `type`, execute_method,
extended, grouped, environment_id,
test_resource_pool_id, retry_on_fail, retry_type,
retry_times, retry_interval, stop_on_fail,
create_user, create_time, pos
)
test_resource_pool_id, retry_on_fail, retry_times,
retry_interval, stop_on_fail, create_user,
create_time, pos)
values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{executeMethod,jdbcType=VARCHAR},
#{extended,jdbcType=BIT}, #{grouped,jdbcType=BIT}, #{environmentId,jdbcType=VARCHAR},
#{testResourcePoolId,jdbcType=VARCHAR}, #{retryOnFail,jdbcType=BIT}, #{retryType,jdbcType=VARCHAR},
#{retryTimes,jdbcType=INTEGER}, #{retryInterval,jdbcType=INTEGER}, #{stopOnFail,jdbcType=BIT},
#{createUser,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{pos,jdbcType=BIGINT}
)
#{testResourcePoolId,jdbcType=VARCHAR}, #{retryOnFail,jdbcType=BIT}, #{retryTimes,jdbcType=INTEGER},
#{retryInterval,jdbcType=INTEGER}, #{stopOnFail,jdbcType=BIT}, #{createUser,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{pos,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.plan.domain.TestPlanCollection">
insert into test_plan_collection
@ -166,9 +163,6 @@
<if test="retryOnFail != null">
retry_on_fail,
</if>
<if test="retryType != null">
retry_type,
</if>
<if test="retryTimes != null">
retry_times,
</if>
@ -222,9 +216,6 @@
<if test="retryOnFail != null">
#{retryOnFail,jdbcType=BIT},
</if>
<if test="retryType != null">
#{retryType,jdbcType=VARCHAR},
</if>
<if test="retryTimes != null">
#{retryTimes,jdbcType=INTEGER},
</if>
@ -287,9 +278,6 @@
<if test="record.retryOnFail != null">
retry_on_fail = #{record.retryOnFail,jdbcType=BIT},
</if>
<if test="record.retryType != null">
retry_type = #{record.retryType,jdbcType=VARCHAR},
</if>
<if test="record.retryTimes != null">
retry_times = #{record.retryTimes,jdbcType=INTEGER},
</if>
@ -326,7 +314,6 @@
environment_id = #{record.environmentId,jdbcType=VARCHAR},
test_resource_pool_id = #{record.testResourcePoolId,jdbcType=VARCHAR},
retry_on_fail = #{record.retryOnFail,jdbcType=BIT},
retry_type = #{record.retryType,jdbcType=VARCHAR},
retry_times = #{record.retryTimes,jdbcType=INTEGER},
retry_interval = #{record.retryInterval,jdbcType=INTEGER},
stop_on_fail = #{record.stopOnFail,jdbcType=BIT},
@ -370,9 +357,6 @@
<if test="retryOnFail != null">
retry_on_fail = #{retryOnFail,jdbcType=BIT},
</if>
<if test="retryType != null">
retry_type = #{retryType,jdbcType=VARCHAR},
</if>
<if test="retryTimes != null">
retry_times = #{retryTimes,jdbcType=INTEGER},
</if>
@ -406,7 +390,6 @@
environment_id = #{environmentId,jdbcType=VARCHAR},
test_resource_pool_id = #{testResourcePoolId,jdbcType=VARCHAR},
retry_on_fail = #{retryOnFail,jdbcType=BIT},
retry_type = #{retryType,jdbcType=VARCHAR},
retry_times = #{retryTimes,jdbcType=INTEGER},
retry_interval = #{retryInterval,jdbcType=INTEGER},
stop_on_fail = #{stopOnFail,jdbcType=BIT},
@ -418,17 +401,17 @@
<insert id="batchInsert" parameterType="map">
insert into test_plan_collection
(id, test_plan_id, parent_id, `name`, `type`, execute_method, extended, grouped,
environment_id, test_resource_pool_id, retry_on_fail, retry_type, retry_times,
retry_interval, stop_on_fail, create_user, create_time, pos)
environment_id, test_resource_pool_id, retry_on_fail, retry_times, retry_interval,
stop_on_fail, create_user, create_time, pos)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.testPlanId,jdbcType=VARCHAR}, #{item.parentId,jdbcType=VARCHAR},
#{item.name,jdbcType=VARCHAR}, #{item.type,jdbcType=VARCHAR}, #{item.executeMethod,jdbcType=VARCHAR},
#{item.extended,jdbcType=BIT}, #{item.grouped,jdbcType=BIT}, #{item.environmentId,jdbcType=VARCHAR},
#{item.testResourcePoolId,jdbcType=VARCHAR}, #{item.retryOnFail,jdbcType=BIT},
#{item.retryType,jdbcType=VARCHAR}, #{item.retryTimes,jdbcType=INTEGER}, #{item.retryInterval,jdbcType=INTEGER},
#{item.stopOnFail,jdbcType=BIT}, #{item.createUser,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT},
#{item.pos,jdbcType=BIGINT})
#{item.retryTimes,jdbcType=INTEGER}, #{item.retryInterval,jdbcType=INTEGER}, #{item.stopOnFail,jdbcType=BIT},
#{item.createUser,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.pos,jdbcType=BIGINT}
)
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
@ -474,9 +457,6 @@
<if test="'retry_on_fail'.toString() == column.value">
#{item.retryOnFail,jdbcType=BIT}
</if>
<if test="'retry_type'.toString() == column.value">
#{item.retryType,jdbcType=VARCHAR}
</if>
<if test="'retry_times'.toString() == column.value">
#{item.retryTimes,jdbcType=INTEGER}
</if>

View File

@ -98,9 +98,8 @@ CREATE TABLE IF NOT EXISTS test_plan_collection(
`environment_id` VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '环境ID/环境组ID' ,
`test_resource_pool_id` VARCHAR(50) NOT NULL COMMENT '测试资源池ID' ,
`retry_on_fail` BIT NOT NULL DEFAULT 0 COMMENT '是否失败重试' ,
`retry_type` VARCHAR(50) NOT NULL DEFAULT 'STEP' COMMENT '失败重试类型(步骤/场景)' ,
`retry_times` INT NOT NULL DEFAULT 1 COMMENT '失败重试次数' ,
`retry_interval` INT NOT NULL DEFAULT 1000 COMMENT '失败重试间隔(单位: ms)' ,
`retry_times` INT DEFAULT 1 COMMENT '失败重试次数' ,
`retry_interval` INT DEFAULT 1000 COMMENT '失败重试间隔(单位: ms)' ,
`stop_on_fail` BIT NOT NULL DEFAULT 0 COMMENT '是否失败停止' ,
`create_user` VARCHAR(50) NOT NULL COMMENT '创建人' ,
`create_time` BIGINT NOT NULL COMMENT '创建时间' ,

View File

@ -7,7 +7,7 @@
tpc.id, tpc.test_plan_id, tpc.parent_id,
tpc.`name`, tpc.`type`, tpc.execute_method,
tpc.extended, tpc.grouped, tpc.environment_id,
tpc.test_resource_pool_id, tpc.retry_on_fail, tpc.retry_type,
tpc.test_resource_pool_id, tpc.retry_on_fail,
tpc.retry_times, tpc.retry_interval, tpc.stop_on_fail,
tpc.create_user, tpc.create_time, tpc.pos,
trp.name as poolName,

View File

@ -62,7 +62,7 @@
select distinct tprfc.function_case_id as id, tprfc.function_case_num as num, tprfc.function_case_name as name,
tprfc.function_case_module as moduleName, tprfc.function_case_priority as priority,
tprfc.function_case_execute_result as executeResult, tprfc.function_case_execute_user as executeUser,
ifnull(tprfc.function_case_bug_count, 0) as bugCount
ifnull(tprfc.function_case_bug_count, 0) as bugCount, tprfc.function_case_execute_report_id reportId
from test_plan_report_function_case tprfc
where tprfc.test_plan_report_id = #{request.reportId}
<include refid="filter"/>

View File

@ -216,8 +216,8 @@ public class TestPlanReportService {
* @param request 请求参数
* @param currentUser 当前用户
*/
public Map<String, String> genReportByManual(TestPlanReportGenRequest request, String currentUser) {
return genReport(IDGenerator.nextStr(),request, true, currentUser, "/test-plan/report/gen");
public void genReportByManual(TestPlanReportGenRequest request, String currentUser) {
genReport(IDGenerator.nextStr(),request, true, currentUser, "/test-plan/report/gen");
}
/**
@ -254,8 +254,8 @@ public class TestPlanReportService {
TestPlanReportGenPreParam genPreParam = buildReportGenParam(request, plan, prepareReportId);
genPreParam.setUseManual(manual);
//如果是测试计划的独立报告使用参数中的预生成的报告id否则只有测试计划组报告使用该id
String prepareItemReportId = isGroupReports?IDGenerator.nextStr() : prepareReportId;
TestPlanReport preReport = preGenReport(prepareItemReportId,genPreParam, currentUser, logPath, moduleParam, childPlanIds);
String prepareItemReportId = isGroupReports ? IDGenerator.nextStr() : prepareReportId;
TestPlanReport preReport = preGenReport(prepareItemReportId, genPreParam, currentUser, logPath, moduleParam, childPlanIds);
if (manual) {
// 汇总
if (genPreParam.getIntegrated()) {
@ -359,7 +359,7 @@ public class TestPlanReportService {
List<TestPlanCaseExecuteHistory> hisList = functionalExecMap.get(reportFunctionalCase.getTestPlanFunctionCaseId());
if (CollectionUtils.isNotEmpty(hisList)) {
Optional<String> lastExecuteHisOpt = hisList.stream().sorted(Comparator.comparing(TestPlanCaseExecuteHistory::getCreateTime).reversed()).map(TestPlanCaseExecuteHistory::getId).findFirst();
reportFunctionalCase.setFunctionCaseExecuteReportId(lastExecuteHisOpt.get());
reportFunctionalCase.setFunctionCaseExecuteReportId(lastExecuteHisOpt.orElse(null));
} else {
reportFunctionalCase.setFunctionCaseExecuteReportId(null);
}
@ -612,7 +612,7 @@ public class TestPlanReportService {
/**
* 汇总生成的计划组报告
* @param reportId
* @param reportId 报告ID
*/
public void summaryGroupReport(String reportId) {
TestPlanReportSummaryExample summaryExample = new TestPlanReportSummaryExample();

View File

@ -7,7 +7,6 @@ import io.metersphere.plan.dto.request.*;
import io.metersphere.plan.dto.response.TestPlanDetailResponse;
import io.metersphere.plan.dto.response.TestPlanOperationResponse;
import io.metersphere.plan.enums.ExecuteMethod;
import io.metersphere.plan.enums.RetryType;
import io.metersphere.plan.job.TestPlanScheduleJob;
import io.metersphere.plan.mapper.*;
import io.metersphere.project.request.ProjectApplicationRequest;
@ -919,9 +918,6 @@ public class TestPlanService extends TestPlanBaseUtilsService {
defaultCollection.setEnvironmentId("NONE");
defaultCollection.setTestResourcePoolId(configMap.getOrDefault(ProjectApplicationType.API.API_RESOURCE_POOL_ID.name(), StringUtils.EMPTY).toString());
defaultCollection.setRetryOnFail(false);
defaultCollection.setRetryType(RetryType.STEP.name());
defaultCollection.setRetryTimes(10);
defaultCollection.setRetryInterval(1);
defaultCollection.setStopOnFail(false);
defaultCollection.setCreateUser(currentUser);
defaultCollection.setCreateTime(System.currentTimeMillis());