feat(接口测试): 测试计划整体执行,重跑逻辑

--task=1016918 --user=陈建星 失败重跑 https://www.tapd.cn/55049933/s/1609836
This commit is contained in:
AgAngle 2024-11-15 22:33:13 +08:00 committed by Craftsman
parent 87eabd9129
commit fa013cfe97
32 changed files with 643 additions and 283 deletions

View File

@ -1,11 +1,8 @@
package io.metersphere.system.domain; package io.metersphere.system.domain;
import io.metersphere.validation.groups.Created; import io.metersphere.validation.groups.*;
import io.metersphere.validation.groups.Updated;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -80,6 +77,10 @@ public class ExecTask implements Serializable {
@NotNull(message = "{exec_task.deleted.not_blank}", groups = {Created.class}) @NotNull(message = "{exec_task.deleted.not_blank}", groups = {Created.class})
private Boolean deleted; private Boolean deleted;
@Schema(description = "是否是并行执行", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "{exec_task.parallel.not_blank}", groups = {Created.class})
private Boolean parallel;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public enum Column { public enum Column {
@ -94,12 +95,13 @@ public class ExecTask implements Serializable {
triggerMode("trigger_mode", "triggerMode", "VARCHAR", false), triggerMode("trigger_mode", "triggerMode", "VARCHAR", false),
projectId("project_id", "projectId", "VARCHAR", false), projectId("project_id", "projectId", "VARCHAR", false),
organizationId("organization_id", "organizationId", "VARCHAR", false), organizationId("organization_id", "organizationId", "VARCHAR", false),
integrated("integrated", "integrated", "BIT", false),
createTime("create_time", "createTime", "BIGINT", false), createTime("create_time", "createTime", "BIGINT", false),
createUser("create_user", "createUser", "VARCHAR", false), createUser("create_user", "createUser", "VARCHAR", false),
startTime("start_time", "startTime", "BIGINT", false), startTime("start_time", "startTime", "BIGINT", false),
endTime("end_time", "endTime", "BIGINT", false), endTime("end_time", "endTime", "BIGINT", false),
integrated("integrated", "integrated", "BIT", false), deleted("deleted", "deleted", "BIT", false),
deleted("deleted", "deleted", "BIT", false); parallel("parallel", "parallel", "BIT", false);
private static final String BEGINNING_DELIMITER = "`"; private static final String BEGINNING_DELIMITER = "`";

View File

@ -574,6 +574,76 @@ public class ExecTaskExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andResourceIdIsNull() {
addCriterion("resource_id is null");
return (Criteria) this;
}
public Criteria andResourceIdIsNotNull() {
addCriterion("resource_id is not null");
return (Criteria) this;
}
public Criteria andResourceIdEqualTo(String value) {
addCriterion("resource_id =", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotEqualTo(String value) {
addCriterion("resource_id <>", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdGreaterThan(String value) {
addCriterion("resource_id >", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdGreaterThanOrEqualTo(String value) {
addCriterion("resource_id >=", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdLessThan(String value) {
addCriterion("resource_id <", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdLessThanOrEqualTo(String value) {
addCriterion("resource_id <=", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdLike(String value) {
addCriterion("resource_id like", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotLike(String value) {
addCriterion("resource_id not like", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdIn(List<String> values) {
addCriterion("resource_id in", values, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotIn(List<String> values) {
addCriterion("resource_id not in", values, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdBetween(String value1, String value2) {
addCriterion("resource_id between", value1, value2, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotBetween(String value1, String value2) {
addCriterion("resource_id not between", value1, value2, "resourceId");
return (Criteria) this;
}
public Criteria andTriggerModeIsNull() { public Criteria andTriggerModeIsNull() {
addCriterion("trigger_mode is null"); addCriterion("trigger_mode is null");
return (Criteria) this; return (Criteria) this;
@ -784,6 +854,66 @@ public class ExecTaskExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIntegratedIsNull() {
addCriterion("integrated is null");
return (Criteria) this;
}
public Criteria andIntegratedIsNotNull() {
addCriterion("integrated is not null");
return (Criteria) this;
}
public Criteria andIntegratedEqualTo(Boolean value) {
addCriterion("integrated =", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedNotEqualTo(Boolean value) {
addCriterion("integrated <>", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedGreaterThan(Boolean value) {
addCriterion("integrated >", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedGreaterThanOrEqualTo(Boolean value) {
addCriterion("integrated >=", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedLessThan(Boolean value) {
addCriterion("integrated <", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedLessThanOrEqualTo(Boolean value) {
addCriterion("integrated <=", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedIn(List<Boolean> values) {
addCriterion("integrated in", values, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedNotIn(List<Boolean> values) {
addCriterion("integrated not in", values, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedBetween(Boolean value1, Boolean value2) {
addCriterion("integrated between", value1, value2, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedNotBetween(Boolean value1, Boolean value2) {
addCriterion("integrated not between", value1, value2, "integrated");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() { public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null"); addCriterion("create_time is null");
return (Criteria) this; return (Criteria) this;
@ -1034,136 +1164,6 @@ public class ExecTaskExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIntegratedIsNull() {
addCriterion("integrated is null");
return (Criteria) this;
}
public Criteria andIntegratedIsNotNull() {
addCriterion("integrated is not null");
return (Criteria) this;
}
public Criteria andIntegratedEqualTo(Boolean value) {
addCriterion("integrated =", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedNotEqualTo(Boolean value) {
addCriterion("integrated <>", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedGreaterThan(Boolean value) {
addCriterion("integrated >", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedGreaterThanOrEqualTo(Boolean value) {
addCriterion("integrated >=", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedLessThan(Boolean value) {
addCriterion("integrated <", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedLessThanOrEqualTo(Boolean value) {
addCriterion("integrated <=", value, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedIn(List<Boolean> values) {
addCriterion("integrated in", values, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedNotIn(List<Boolean> values) {
addCriterion("integrated not in", values, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedBetween(Boolean value1, Boolean value2) {
addCriterion("integrated between", value1, value2, "integrated");
return (Criteria) this;
}
public Criteria andIntegratedNotBetween(Boolean value1, Boolean value2) {
addCriterion("integrated not between", value1, value2, "integrated");
return (Criteria) this;
}
public Criteria andResourceIdIsNull() {
addCriterion("resource_id is null");
return (Criteria) this;
}
public Criteria andResourceIdIsNotNull() {
addCriterion("resource_id is not null");
return (Criteria) this;
}
public Criteria andResourceIdEqualTo(String value) {
addCriterion("resource_id =", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotEqualTo(String value) {
addCriterion("resource_id <>", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdGreaterThan(String value) {
addCriterion("resource_id >", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdGreaterThanOrEqualTo(String value) {
addCriterion("resource_id >=", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdLessThan(String value) {
addCriterion("resource_id <", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdLessThanOrEqualTo(String value) {
addCriterion("resource_id <=", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdLike(String value) {
addCriterion("resource_id like", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotLike(String value) {
addCriterion("resource_id not like", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdIn(List<String> values) {
addCriterion("resource_id in", values, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotIn(List<String> values) {
addCriterion("resource_id not in", values, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdBetween(String value1, String value2) {
addCriterion("resource_id between", value1, value2, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotBetween(String value1, String value2) {
addCriterion("resource_id not between", value1, value2, "resourceId");
return (Criteria) this;
}
public Criteria andDeletedIsNull() { public Criteria andDeletedIsNull() {
addCriterion("deleted is null"); addCriterion("deleted is null");
return (Criteria) this; return (Criteria) this;
@ -1223,6 +1223,66 @@ public class ExecTaskExample {
addCriterion("deleted not between", value1, value2, "deleted"); addCriterion("deleted not between", value1, value2, "deleted");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andParallelIsNull() {
addCriterion("parallel is null");
return (Criteria) this;
}
public Criteria andParallelIsNotNull() {
addCriterion("parallel is not null");
return (Criteria) this;
}
public Criteria andParallelEqualTo(Boolean value) {
addCriterion("parallel =", value, "parallel");
return (Criteria) this;
}
public Criteria andParallelNotEqualTo(Boolean value) {
addCriterion("parallel <>", value, "parallel");
return (Criteria) this;
}
public Criteria andParallelGreaterThan(Boolean value) {
addCriterion("parallel >", value, "parallel");
return (Criteria) this;
}
public Criteria andParallelGreaterThanOrEqualTo(Boolean value) {
addCriterion("parallel >=", value, "parallel");
return (Criteria) this;
}
public Criteria andParallelLessThan(Boolean value) {
addCriterion("parallel <", value, "parallel");
return (Criteria) this;
}
public Criteria andParallelLessThanOrEqualTo(Boolean value) {
addCriterion("parallel <=", value, "parallel");
return (Criteria) this;
}
public Criteria andParallelIn(List<Boolean> values) {
addCriterion("parallel in", values, "parallel");
return (Criteria) this;
}
public Criteria andParallelNotIn(List<Boolean> values) {
addCriterion("parallel not in", values, "parallel");
return (Criteria) this;
}
public Criteria andParallelBetween(Boolean value1, Boolean value2) {
addCriterion("parallel between", value1, value2, "parallel");
return (Criteria) this;
}
public Criteria andParallelNotBetween(Boolean value1, Boolean value2) {
addCriterion("parallel not between", value1, value2, "parallel");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -91,6 +91,9 @@ public class ExecTaskItem implements Serializable {
@Schema(description = "异常信息") @Schema(description = "异常信息")
private String errorMessage; private String errorMessage;
@Schema(description = "是否是重跑任务项")
private Boolean rerun;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public enum Column { public enum Column {
@ -113,7 +116,8 @@ public class ExecTaskItem implements Serializable {
collectionId("collection_id", "collectionId", "VARCHAR", false), collectionId("collection_id", "collectionId", "VARCHAR", false),
deleted("deleted", "deleted", "BIT", false), deleted("deleted", "deleted", "BIT", false),
caseId("case_id", "caseId", "VARCHAR", false), caseId("case_id", "caseId", "VARCHAR", false),
errorMessage("error_message", "errorMessage", "VARCHAR", false); errorMessage("error_message", "errorMessage", "VARCHAR", false),
rerun("rerun", "rerun", "BIT", false);
private static final String BEGINNING_DELIMITER = "`"; private static final String BEGINNING_DELIMITER = "`";

View File

@ -1473,6 +1473,66 @@ public class ExecTaskItemExample {
addCriterion("error_message not between", value1, value2, "errorMessage"); addCriterion("error_message not between", value1, value2, "errorMessage");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRerunIsNull() {
addCriterion("rerun is null");
return (Criteria) this;
}
public Criteria andRerunIsNotNull() {
addCriterion("rerun is not null");
return (Criteria) this;
}
public Criteria andRerunEqualTo(Boolean value) {
addCriterion("rerun =", value, "rerun");
return (Criteria) this;
}
public Criteria andRerunNotEqualTo(Boolean value) {
addCriterion("rerun <>", value, "rerun");
return (Criteria) this;
}
public Criteria andRerunGreaterThan(Boolean value) {
addCriterion("rerun >", value, "rerun");
return (Criteria) this;
}
public Criteria andRerunGreaterThanOrEqualTo(Boolean value) {
addCriterion("rerun >=", value, "rerun");
return (Criteria) this;
}
public Criteria andRerunLessThan(Boolean value) {
addCriterion("rerun <", value, "rerun");
return (Criteria) this;
}
public Criteria andRerunLessThanOrEqualTo(Boolean value) {
addCriterion("rerun <=", value, "rerun");
return (Criteria) this;
}
public Criteria andRerunIn(List<Boolean> values) {
addCriterion("rerun in", values, "rerun");
return (Criteria) this;
}
public Criteria andRerunNotIn(List<Boolean> values) {
addCriterion("rerun not in", values, "rerun");
return (Criteria) this;
}
public Criteria andRerunBetween(Boolean value1, Boolean value2) {
addCriterion("rerun between", value1, value2, "rerun");
return (Criteria) this;
}
public Criteria andRerunNotBetween(Boolean value1, Boolean value2) {
addCriterion("rerun not between", value1, value2, "rerun");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -22,6 +22,7 @@
<result column="deleted" jdbcType="BIT" property="deleted" /> <result column="deleted" jdbcType="BIT" property="deleted" />
<result column="case_id" jdbcType="VARCHAR" property="caseId" /> <result column="case_id" jdbcType="VARCHAR" property="caseId" />
<result column="error_message" jdbcType="VARCHAR" property="errorMessage" /> <result column="error_message" jdbcType="VARCHAR" property="errorMessage" />
<result column="rerun" jdbcType="BIT" property="rerun" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -84,7 +85,7 @@
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, task_id, resource_id, resource_name, task_origin, `status`, `result`, resource_pool_id, id, task_id, resource_id, resource_name, task_origin, `status`, `result`, resource_pool_id,
resource_pool_node, resource_type, project_id, organization_id, thread_id, start_time, resource_pool_node, resource_type, project_id, organization_id, thread_id, start_time,
end_time, executor, collection_id, deleted, case_id, error_message end_time, executor, collection_id, deleted, case_id, error_message, rerun
</sql> </sql>
<select id="selectByExample" parameterType="io.metersphere.system.domain.ExecTaskItemExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="io.metersphere.system.domain.ExecTaskItemExample" resultMap="BaseResultMap">
select select
@ -123,14 +124,16 @@
resource_type, project_id, organization_id, resource_type, project_id, organization_id,
thread_id, start_time, end_time, thread_id, start_time, end_time,
executor, collection_id, deleted, executor, collection_id, deleted,
case_id, error_message) case_id, error_message, rerun
)
values (#{id,jdbcType=VARCHAR}, #{taskId,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{taskId,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR},
#{resourceName,jdbcType=VARCHAR}, #{taskOrigin,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{resourceName,jdbcType=VARCHAR}, #{taskOrigin,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{result,jdbcType=VARCHAR}, #{resourcePoolId,jdbcType=VARCHAR}, #{resourcePoolNode,jdbcType=VARCHAR}, #{result,jdbcType=VARCHAR}, #{resourcePoolId,jdbcType=VARCHAR}, #{resourcePoolNode,jdbcType=VARCHAR},
#{resourceType,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR}, #{resourceType,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR},
#{threadId,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}, #{threadId,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT},
#{executor,jdbcType=VARCHAR}, #{collectionId,jdbcType=VARCHAR}, #{deleted,jdbcType=BIT}, #{executor,jdbcType=VARCHAR}, #{collectionId,jdbcType=VARCHAR}, #{deleted,jdbcType=BIT},
#{caseId,jdbcType=VARCHAR}, #{errorMessage,jdbcType=VARCHAR}) #{caseId,jdbcType=VARCHAR}, #{errorMessage,jdbcType=VARCHAR}, #{rerun,jdbcType=BIT}
)
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.system.domain.ExecTaskItem"> <insert id="insertSelective" parameterType="io.metersphere.system.domain.ExecTaskItem">
insert into exec_task_item insert into exec_task_item
@ -195,6 +198,9 @@
<if test="errorMessage != null"> <if test="errorMessage != null">
error_message, error_message,
</if> </if>
<if test="rerun != null">
rerun,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -257,6 +263,9 @@
<if test="errorMessage != null"> <if test="errorMessage != null">
#{errorMessage,jdbcType=VARCHAR}, #{errorMessage,jdbcType=VARCHAR},
</if> </if>
<if test="rerun != null">
#{rerun,jdbcType=BIT},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="io.metersphere.system.domain.ExecTaskItemExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="io.metersphere.system.domain.ExecTaskItemExample" resultType="java.lang.Long">
@ -328,6 +337,9 @@
<if test="record.errorMessage != null"> <if test="record.errorMessage != null">
error_message = #{record.errorMessage,jdbcType=VARCHAR}, error_message = #{record.errorMessage,jdbcType=VARCHAR},
</if> </if>
<if test="record.rerun != null">
rerun = #{record.rerun,jdbcType=BIT},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -354,7 +366,8 @@
collection_id = #{record.collectionId,jdbcType=VARCHAR}, collection_id = #{record.collectionId,jdbcType=VARCHAR},
deleted = #{record.deleted,jdbcType=BIT}, deleted = #{record.deleted,jdbcType=BIT},
case_id = #{record.caseId,jdbcType=VARCHAR}, case_id = #{record.caseId,jdbcType=VARCHAR},
error_message = #{record.errorMessage,jdbcType=VARCHAR} error_message = #{record.errorMessage,jdbcType=VARCHAR},
rerun = #{record.rerun,jdbcType=BIT}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -419,6 +432,9 @@
<if test="errorMessage != null"> <if test="errorMessage != null">
error_message = #{errorMessage,jdbcType=VARCHAR}, error_message = #{errorMessage,jdbcType=VARCHAR},
</if> </if>
<if test="rerun != null">
rerun = #{rerun,jdbcType=BIT},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -442,14 +458,15 @@
collection_id = #{collectionId,jdbcType=VARCHAR}, collection_id = #{collectionId,jdbcType=VARCHAR},
deleted = #{deleted,jdbcType=BIT}, deleted = #{deleted,jdbcType=BIT},
case_id = #{caseId,jdbcType=VARCHAR}, case_id = #{caseId,jdbcType=VARCHAR},
error_message = #{errorMessage,jdbcType=VARCHAR} error_message = #{errorMessage,jdbcType=VARCHAR},
rerun = #{rerun,jdbcType=BIT}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
<insert id="batchInsert" parameterType="map"> <insert id="batchInsert" parameterType="map">
insert into exec_task_item insert into exec_task_item
(id, task_id, resource_id, resource_name, task_origin, `status`, `result`, resource_pool_id, (id, task_id, resource_id, resource_name, task_origin, `status`, `result`, resource_pool_id,
resource_pool_node, resource_type, project_id, organization_id, thread_id, start_time, resource_pool_node, resource_type, project_id, organization_id, thread_id, start_time,
end_time, executor, collection_id, deleted, case_id, error_message) end_time, executor, collection_id, deleted, case_id, error_message, rerun)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.taskId,jdbcType=VARCHAR}, #{item.resourceId,jdbcType=VARCHAR}, (#{item.id,jdbcType=VARCHAR}, #{item.taskId,jdbcType=VARCHAR}, #{item.resourceId,jdbcType=VARCHAR},
@ -458,7 +475,8 @@
#{item.resourceType,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR}, #{item.organizationId,jdbcType=VARCHAR}, #{item.resourceType,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR}, #{item.organizationId,jdbcType=VARCHAR},
#{item.threadId,jdbcType=VARCHAR}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT}, #{item.threadId,jdbcType=VARCHAR}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT},
#{item.executor,jdbcType=VARCHAR}, #{item.collectionId,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT}, #{item.executor,jdbcType=VARCHAR}, #{item.collectionId,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT},
#{item.caseId,jdbcType=VARCHAR}, #{item.errorMessage,jdbcType=VARCHAR}) #{item.caseId,jdbcType=VARCHAR}, #{item.errorMessage,jdbcType=VARCHAR}, #{item.rerun,jdbcType=BIT}
)
</foreach> </foreach>
</insert> </insert>
<insert id="batchInsertSelective" parameterType="map"> <insert id="batchInsertSelective" parameterType="map">
@ -531,6 +549,9 @@
<if test="'error_message'.toString() == column.value"> <if test="'error_message'.toString() == column.value">
#{item.errorMessage,jdbcType=VARCHAR} #{item.errorMessage,jdbcType=VARCHAR}
</if> </if>
<if test="'rerun'.toString() == column.value">
#{item.rerun,jdbcType=BIT}
</if>
</foreach> </foreach>
) )
</foreach> </foreach>

View File

@ -9,16 +9,17 @@
<result column="case_count" jdbcType="BIGINT" property="caseCount" /> <result column="case_count" jdbcType="BIGINT" property="caseCount" />
<result column="result" jdbcType="VARCHAR" property="result" /> <result column="result" jdbcType="VARCHAR" property="result" />
<result column="task_type" jdbcType="VARCHAR" property="taskType" /> <result column="task_type" jdbcType="VARCHAR" property="taskType" />
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
<result column="trigger_mode" jdbcType="VARCHAR" property="triggerMode" /> <result column="trigger_mode" jdbcType="VARCHAR" property="triggerMode" />
<result column="project_id" jdbcType="VARCHAR" property="projectId" /> <result column="project_id" jdbcType="VARCHAR" property="projectId" />
<result column="organization_id" jdbcType="VARCHAR" property="organizationId" /> <result column="organization_id" jdbcType="VARCHAR" property="organizationId" />
<result column="integrated" jdbcType="BIT" property="integrated" />
<result column="create_time" jdbcType="BIGINT" property="createTime" /> <result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" /> <result column="create_user" jdbcType="VARCHAR" property="createUser" />
<result column="start_time" jdbcType="BIGINT" property="startTime" /> <result column="start_time" jdbcType="BIGINT" property="startTime" />
<result column="end_time" jdbcType="BIGINT" property="endTime" /> <result column="end_time" jdbcType="BIGINT" property="endTime" />
<result column="integrated" jdbcType="BIT" property="integrated" />
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
<result column="deleted" jdbcType="BIT" property="deleted" /> <result column="deleted" jdbcType="BIT" property="deleted" />
<result column="parallel" jdbcType="BIT" property="parallel" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -79,9 +80,9 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, num, task_name, `status`, case_count, `result`, task_type, trigger_mode, project_id, id, num, task_name, `status`, case_count, `result`, task_type, resource_id, trigger_mode,
organization_id, create_time, create_user, start_time, end_time, integrated, resource_id, project_id, organization_id, integrated, create_time, create_user, start_time, end_time,
deleted deleted, parallel
</sql> </sql>
<select id="selectByExample" parameterType="io.metersphere.system.domain.ExecTaskExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="io.metersphere.system.domain.ExecTaskExample" resultMap="BaseResultMap">
select select
@ -116,16 +117,16 @@
<insert id="insert" parameterType="io.metersphere.system.domain.ExecTask"> <insert id="insert" parameterType="io.metersphere.system.domain.ExecTask">
insert into exec_task (id, num, task_name, insert into exec_task (id, num, task_name,
`status`, case_count, `result`, `status`, case_count, `result`,
task_type, trigger_mode, project_id, task_type, resource_id, trigger_mode,
organization_id, create_time, create_user, project_id, organization_id, integrated,
start_time, end_time, integrated, create_time, create_user, start_time,
resource_id, deleted) end_time, deleted, parallel)
values (#{id,jdbcType=VARCHAR}, #{num,jdbcType=BIGINT}, #{taskName,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{num,jdbcType=BIGINT}, #{taskName,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{caseCount,jdbcType=BIGINT}, #{result,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{caseCount,jdbcType=BIGINT}, #{result,jdbcType=VARCHAR},
#{taskType,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR},
#{organizationId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR}, #{integrated,jdbcType=BIT},
#{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}, #{integrated,jdbcType=BIT}, #{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT},
#{resourceId,jdbcType=VARCHAR}, #{deleted,jdbcType=BIT}) #{endTime,jdbcType=BIGINT}, #{deleted,jdbcType=BIT}, #{parallel,jdbcType=BIT})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.system.domain.ExecTask"> <insert id="insertSelective" parameterType="io.metersphere.system.domain.ExecTask">
insert into exec_task insert into exec_task
@ -151,6 +152,9 @@
<if test="taskType != null"> <if test="taskType != null">
task_type, task_type,
</if> </if>
<if test="resourceId != null">
resource_id,
</if>
<if test="triggerMode != null"> <if test="triggerMode != null">
trigger_mode, trigger_mode,
</if> </if>
@ -160,6 +164,9 @@
<if test="organizationId != null"> <if test="organizationId != null">
organization_id, organization_id,
</if> </if>
<if test="integrated != null">
integrated,
</if>
<if test="createTime != null"> <if test="createTime != null">
create_time, create_time,
</if> </if>
@ -172,15 +179,12 @@
<if test="endTime != null"> <if test="endTime != null">
end_time, end_time,
</if> </if>
<if test="integrated != null">
integrated,
</if>
<if test="resourceId != null">
resource_id,
</if>
<if test="deleted != null"> <if test="deleted != null">
deleted, deleted,
</if> </if>
<if test="parallel != null">
parallel,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -204,6 +208,9 @@
<if test="taskType != null"> <if test="taskType != null">
#{taskType,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR},
</if> </if>
<if test="resourceId != null">
#{resourceId,jdbcType=VARCHAR},
</if>
<if test="triggerMode != null"> <if test="triggerMode != null">
#{triggerMode,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR},
</if> </if>
@ -213,6 +220,9 @@
<if test="organizationId != null"> <if test="organizationId != null">
#{organizationId,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR},
</if> </if>
<if test="integrated != null">
#{integrated,jdbcType=BIT},
</if>
<if test="createTime != null"> <if test="createTime != null">
#{createTime,jdbcType=BIGINT}, #{createTime,jdbcType=BIGINT},
</if> </if>
@ -225,15 +235,12 @@
<if test="endTime != null"> <if test="endTime != null">
#{endTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT},
</if> </if>
<if test="integrated != null">
#{integrated,jdbcType=BIT},
</if>
<if test="resourceId != null">
#{resourceId,jdbcType=VARCHAR},
</if>
<if test="deleted != null"> <if test="deleted != null">
#{deleted,jdbcType=BIT}, #{deleted,jdbcType=BIT},
</if> </if>
<if test="parallel != null">
#{parallel,jdbcType=BIT},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="io.metersphere.system.domain.ExecTaskExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="io.metersphere.system.domain.ExecTaskExample" resultType="java.lang.Long">
@ -266,6 +273,9 @@
<if test="record.taskType != null"> <if test="record.taskType != null">
task_type = #{record.taskType,jdbcType=VARCHAR}, task_type = #{record.taskType,jdbcType=VARCHAR},
</if> </if>
<if test="record.resourceId != null">
resource_id = #{record.resourceId,jdbcType=VARCHAR},
</if>
<if test="record.triggerMode != null"> <if test="record.triggerMode != null">
trigger_mode = #{record.triggerMode,jdbcType=VARCHAR}, trigger_mode = #{record.triggerMode,jdbcType=VARCHAR},
</if> </if>
@ -275,6 +285,9 @@
<if test="record.organizationId != null"> <if test="record.organizationId != null">
organization_id = #{record.organizationId,jdbcType=VARCHAR}, organization_id = #{record.organizationId,jdbcType=VARCHAR},
</if> </if>
<if test="record.integrated != null">
integrated = #{record.integrated,jdbcType=BIT},
</if>
<if test="record.createTime != null"> <if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
</if> </if>
@ -287,15 +300,12 @@
<if test="record.endTime != null"> <if test="record.endTime != null">
end_time = #{record.endTime,jdbcType=BIGINT}, end_time = #{record.endTime,jdbcType=BIGINT},
</if> </if>
<if test="record.integrated != null">
integrated = #{record.integrated,jdbcType=BIT},
</if>
<if test="record.resourceId != null">
resource_id = #{record.resourceId,jdbcType=VARCHAR},
</if>
<if test="record.deleted != null"> <if test="record.deleted != null">
deleted = #{record.deleted,jdbcType=BIT}, deleted = #{record.deleted,jdbcType=BIT},
</if> </if>
<if test="record.parallel != null">
parallel = #{record.parallel,jdbcType=BIT},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -310,16 +320,17 @@
case_count = #{record.caseCount,jdbcType=BIGINT}, case_count = #{record.caseCount,jdbcType=BIGINT},
`result` = #{record.result,jdbcType=VARCHAR}, `result` = #{record.result,jdbcType=VARCHAR},
task_type = #{record.taskType,jdbcType=VARCHAR}, task_type = #{record.taskType,jdbcType=VARCHAR},
resource_id = #{record.resourceId,jdbcType=VARCHAR},
trigger_mode = #{record.triggerMode,jdbcType=VARCHAR}, trigger_mode = #{record.triggerMode,jdbcType=VARCHAR},
project_id = #{record.projectId,jdbcType=VARCHAR}, project_id = #{record.projectId,jdbcType=VARCHAR},
organization_id = #{record.organizationId,jdbcType=VARCHAR}, organization_id = #{record.organizationId,jdbcType=VARCHAR},
integrated = #{record.integrated,jdbcType=BIT},
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
create_user = #{record.createUser,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR},
start_time = #{record.startTime,jdbcType=BIGINT}, start_time = #{record.startTime,jdbcType=BIGINT},
end_time = #{record.endTime,jdbcType=BIGINT}, end_time = #{record.endTime,jdbcType=BIGINT},
integrated = #{record.integrated,jdbcType=BIT}, deleted = #{record.deleted,jdbcType=BIT},
resource_id = #{record.resourceId,jdbcType=VARCHAR}, parallel = #{record.parallel,jdbcType=BIT}
deleted = #{record.deleted,jdbcType=BIT}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -345,6 +356,9 @@
<if test="taskType != null"> <if test="taskType != null">
task_type = #{taskType,jdbcType=VARCHAR}, task_type = #{taskType,jdbcType=VARCHAR},
</if> </if>
<if test="resourceId != null">
resource_id = #{resourceId,jdbcType=VARCHAR},
</if>
<if test="triggerMode != null"> <if test="triggerMode != null">
trigger_mode = #{triggerMode,jdbcType=VARCHAR}, trigger_mode = #{triggerMode,jdbcType=VARCHAR},
</if> </if>
@ -354,6 +368,9 @@
<if test="organizationId != null"> <if test="organizationId != null">
organization_id = #{organizationId,jdbcType=VARCHAR}, organization_id = #{organizationId,jdbcType=VARCHAR},
</if> </if>
<if test="integrated != null">
integrated = #{integrated,jdbcType=BIT},
</if>
<if test="createTime != null"> <if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
</if> </if>
@ -366,15 +383,12 @@
<if test="endTime != null"> <if test="endTime != null">
end_time = #{endTime,jdbcType=BIGINT}, end_time = #{endTime,jdbcType=BIGINT},
</if> </if>
<if test="integrated != null">
integrated = #{integrated,jdbcType=BIT},
</if>
<if test="resourceId != null">
resource_id = #{resourceId,jdbcType=VARCHAR},
</if>
<if test="deleted != null"> <if test="deleted != null">
deleted = #{deleted,jdbcType=BIT}, deleted = #{deleted,jdbcType=BIT},
</if> </if>
<if test="parallel != null">
parallel = #{parallel,jdbcType=BIT},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -386,31 +400,33 @@
case_count = #{caseCount,jdbcType=BIGINT}, case_count = #{caseCount,jdbcType=BIGINT},
`result` = #{result,jdbcType=VARCHAR}, `result` = #{result,jdbcType=VARCHAR},
task_type = #{taskType,jdbcType=VARCHAR}, task_type = #{taskType,jdbcType=VARCHAR},
resource_id = #{resourceId,jdbcType=VARCHAR},
trigger_mode = #{triggerMode,jdbcType=VARCHAR}, trigger_mode = #{triggerMode,jdbcType=VARCHAR},
project_id = #{projectId,jdbcType=VARCHAR}, project_id = #{projectId,jdbcType=VARCHAR},
organization_id = #{organizationId,jdbcType=VARCHAR}, organization_id = #{organizationId,jdbcType=VARCHAR},
integrated = #{integrated,jdbcType=BIT},
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
create_user = #{createUser,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR},
start_time = #{startTime,jdbcType=BIGINT}, start_time = #{startTime,jdbcType=BIGINT},
end_time = #{endTime,jdbcType=BIGINT}, end_time = #{endTime,jdbcType=BIGINT},
integrated = #{integrated,jdbcType=BIT}, deleted = #{deleted,jdbcType=BIT},
resource_id = #{resourceId,jdbcType=VARCHAR}, parallel = #{parallel,jdbcType=BIT}
deleted = #{deleted,jdbcType=BIT}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
<insert id="batchInsert" parameterType="map"> <insert id="batchInsert" parameterType="map">
insert into exec_task insert into exec_task
(id, num, task_name, `status`, case_count, `result`, task_type, trigger_mode, project_id, (id, num, task_name, `status`, case_count, `result`, task_type, resource_id, trigger_mode,
organization_id, create_time, create_user, start_time, end_time, integrated, resource_id, project_id, organization_id, integrated, create_time, create_user, start_time,
deleted) end_time, deleted, parallel)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.taskName,jdbcType=VARCHAR}, (#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.taskName,jdbcType=VARCHAR},
#{item.status,jdbcType=VARCHAR}, #{item.caseCount,jdbcType=BIGINT}, #{item.result,jdbcType=VARCHAR}, #{item.status,jdbcType=VARCHAR}, #{item.caseCount,jdbcType=BIGINT}, #{item.result,jdbcType=VARCHAR},
#{item.taskType,jdbcType=VARCHAR}, #{item.triggerMode,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR}, #{item.taskType,jdbcType=VARCHAR}, #{item.resourceId,jdbcType=VARCHAR}, #{item.triggerMode,jdbcType=VARCHAR},
#{item.organizationId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR}, #{item.organizationId,jdbcType=VARCHAR}, #{item.integrated,jdbcType=BIT},
#{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT}, #{item.integrated,jdbcType=BIT}, #{item.createTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}, #{item.startTime,jdbcType=BIGINT},
#{item.resourceId,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT}) #{item.endTime,jdbcType=BIGINT}, #{item.deleted,jdbcType=BIT}, #{item.parallel,jdbcType=BIT}
)
</foreach> </foreach>
</insert> </insert>
<insert id="batchInsertSelective" parameterType="map"> <insert id="batchInsertSelective" parameterType="map">
@ -444,6 +460,9 @@
<if test="'task_type'.toString() == column.value"> <if test="'task_type'.toString() == column.value">
#{item.taskType,jdbcType=VARCHAR} #{item.taskType,jdbcType=VARCHAR}
</if> </if>
<if test="'resource_id'.toString() == column.value">
#{item.resourceId,jdbcType=VARCHAR}
</if>
<if test="'trigger_mode'.toString() == column.value"> <if test="'trigger_mode'.toString() == column.value">
#{item.triggerMode,jdbcType=VARCHAR} #{item.triggerMode,jdbcType=VARCHAR}
</if> </if>
@ -453,6 +472,9 @@
<if test="'organization_id'.toString() == column.value"> <if test="'organization_id'.toString() == column.value">
#{item.organizationId,jdbcType=VARCHAR} #{item.organizationId,jdbcType=VARCHAR}
</if> </if>
<if test="'integrated'.toString() == column.value">
#{item.integrated,jdbcType=BIT}
</if>
<if test="'create_time'.toString() == column.value"> <if test="'create_time'.toString() == column.value">
#{item.createTime,jdbcType=BIGINT} #{item.createTime,jdbcType=BIGINT}
</if> </if>
@ -465,15 +487,12 @@
<if test="'end_time'.toString() == column.value"> <if test="'end_time'.toString() == column.value">
#{item.endTime,jdbcType=BIGINT} #{item.endTime,jdbcType=BIGINT}
</if> </if>
<if test="'integrated'.toString() == column.value">
#{item.integrated,jdbcType=BIT}
</if>
<if test="'resource_id'.toString() == column.value">
#{item.resourceId,jdbcType=VARCHAR}
</if>
<if test="'deleted'.toString() == column.value"> <if test="'deleted'.toString() == column.value">
#{item.deleted,jdbcType=BIT} #{item.deleted,jdbcType=BIT}
</if> </if>
<if test="'parallel'.toString() == column.value">
#{item.parallel,jdbcType=BIT}
</if>
</foreach> </foreach>
) )
</foreach> </foreach>

View File

@ -83,6 +83,10 @@ CREATE INDEX idx_case_id ON exec_task_item(case_id);
ALTER TABLE exec_task_item ADD collection_id varchar(50) NULL COMMENT '测试集ID'; ALTER TABLE exec_task_item ADD collection_id varchar(50) NULL COMMENT '测试集ID';
-- 任务项添加异常信息字段 -- 任务项添加异常信息字段
ALTER TABLE exec_task_item ADD error_message varchar(50) NULL COMMENT '异常信息'; ALTER TABLE exec_task_item ADD error_message varchar(50) NULL COMMENT '异常信息';
-- 任务项添加重跑字段
ALTER TABLE exec_task_item ADD rerun bit(1) DEFAULT 0 NULL COMMENT '是否是重跑任务项';
-- 任务添加串并行字段
ALTER TABLE exec_task ADD parallel bit(1) DEFAULT 1 NOT NULL COMMENT '是否是并行执行';
-- set innodb lock wait timeout to default -- set innodb lock wait timeout to default
SET SESSION innodb_lock_wait_timeout = DEFAULT; SET SESSION innodb_lock_wait_timeout = DEFAULT;

View File

@ -71,5 +71,5 @@ public class GetRunScriptRequest implements Serializable {
/** /**
* 是否是任务失败重跑 * 是否是任务失败重跑
*/ */
private Boolean rerun; private Boolean rerun = false;
} }

View File

@ -127,5 +127,5 @@ public class TaskInfo implements Serializable {
/** /**
* 是否是任务失败重跑 * 是否是任务失败重跑
*/ */
private Boolean rerun; private Boolean rerun = false;
} }

View File

@ -44,6 +44,10 @@ public class ExecutionQueue implements Serializable {
* {@link io.metersphere.sdk.constants.ApiExecuteResourceType} * {@link io.metersphere.sdk.constants.ApiExecuteResourceType}
*/ */
private String resourceType; private String resourceType;
/**
* 是否是重跑
*/
private Boolean rerun = false;
/** /**
* 运行模式配置 * 运行模式配置

View File

@ -39,9 +39,11 @@ public class TestPlanExecutionQueue {
private boolean isLastOne = false; private boolean isLastOne = false;
// 是否执行完毕 // 是否执行完毕
private boolean executeFinish = false; private boolean executeFinish = false;
// 是否是重新执行
private boolean rerun = false;
public TestPlanExecutionQueue(long pos, String createUser, long createTime, String queueId, String queueType, String parentQueueId, String parentQueueType, String sourceID, String runMode, public TestPlanExecutionQueue(long pos, String createUser, long createTime, String queueId, String queueType, String parentQueueId, String parentQueueType, String sourceID, String runMode,
String executionSource, String prepareReportId, String taskId) { String executionSource, String prepareReportId, String taskId, boolean rerun) {
this.pos = pos; this.pos = pos;
this.createUser = createUser; this.createUser = createUser;
this.createTime = createTime; this.createTime = createTime;
@ -54,5 +56,6 @@ public class TestPlanExecutionQueue {
this.executionSource = executionSource; this.executionSource = executionSource;
this.prepareReportId = prepareReportId; this.prepareReportId = prepareReportId;
this.taskId = taskId; this.taskId = taskId;
this.rerun = rerun;
} }
} }

View File

@ -267,8 +267,8 @@ public class ApiBatchRunBaseService {
} }
} }
public List<ExecTaskItem> getExecTaskItemByTaskIdAndCollectionId(String taskId, String collectionId) { public List<ExecTaskItem> getExecTaskItemByTaskIdAndCollectionId(String taskId, String collectionId, boolean rerun) {
List<ExecTaskItem> execTaskItems = extExecTaskItemMapper.selectExecInfoByTaskIdAndCollectionId(taskId, collectionId) List<ExecTaskItem> execTaskItems = extExecTaskItemMapper.selectExecInfoByTaskIdAndCollectionId(taskId, collectionId, rerun)
.stream().sorted(Comparator.comparing(ExecTaskItem::getId)).toList(); .stream().sorted(Comparator.comparing(ExecTaskItem::getId)).toList();
return execTaskItems; return execTaskItems;
} }

View File

@ -35,12 +35,14 @@ import io.metersphere.sdk.constants.TaskItemErrorMessage;
import io.metersphere.sdk.dto.api.task.GetRunScriptRequest; import io.metersphere.sdk.dto.api.task.GetRunScriptRequest;
import io.metersphere.sdk.dto.api.task.TaskBatchRequestDTO; import io.metersphere.sdk.dto.api.task.TaskBatchRequestDTO;
import io.metersphere.sdk.dto.api.task.TaskItem; import io.metersphere.sdk.dto.api.task.TaskItem;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.CommonBeanFactory; import io.metersphere.sdk.util.CommonBeanFactory;
import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.LogUtils; import io.metersphere.sdk.util.LogUtils;
import io.metersphere.system.domain.ExecTask; import io.metersphere.system.domain.ExecTask;
import io.metersphere.system.domain.ExecTaskItem; import io.metersphere.system.domain.ExecTaskItem;
import io.metersphere.system.domain.ExecTaskItemExample;
import io.metersphere.system.mapper.ExecTaskItemMapper; import io.metersphere.system.mapper.ExecTaskItemMapper;
import io.metersphere.system.mapper.ExecTaskMapper; import io.metersphere.system.mapper.ExecTaskMapper;
import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.uid.IDGenerator;
@ -578,4 +580,15 @@ public class ApiCommonService {
execTaskItem.setThreadId(request.getThreadId()); execTaskItem.setThreadId(request.getThreadId());
execTaskItemMapper.updateByPrimaryKeySelective(execTaskItem); execTaskItemMapper.updateByPrimaryKeySelective(execTaskItem);
} }
public ExecTaskItem getRerunTaskItem(String id) {
ExecTaskItemExample example = new ExecTaskItemExample();
example.createCriteria().andTaskIdEqualTo(id).andRerunEqualTo(true);
List<ExecTaskItem> execTaskItems = execTaskItemMapper.selectByExample(example);
if (org.apache.commons.collections4.CollectionUtils.isEmpty(execTaskItems)) {
throw new MSException("No test cases to rerun");
}
ExecTaskItem execTaskItem = execTaskItems.getFirst();
return execTaskItem;
}
} }

View File

@ -1,18 +1,16 @@
package io.metersphere.api.service.rerun; package io.metersphere.api.service.rerun;
import io.metersphere.api.service.ApiCommonService;
import io.metersphere.api.service.definition.ApiTestCaseRunService; import io.metersphere.api.service.definition.ApiTestCaseRunService;
import io.metersphere.sdk.constants.ExecTaskType; import io.metersphere.sdk.constants.ExecTaskType;
import io.metersphere.system.domain.ExecTask; import io.metersphere.system.domain.ExecTask;
import io.metersphere.system.domain.ExecTaskItem; import io.metersphere.system.domain.ExecTaskItem;
import io.metersphere.system.invoker.TaskRerunServiceInvoker; import io.metersphere.system.invoker.TaskRerunServiceInvoker;
import io.metersphere.system.mapper.ExecTaskItemMapper;
import io.metersphere.system.service.TaskRerunService; import io.metersphere.system.service.TaskRerunService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* @Author: jianxing * @Author: jianxing
* @CreateTime: 2024-02-06 20:47 * @CreateTime: 2024-02-06 20:47
@ -23,15 +21,15 @@ public class ApiCaseRerunService implements TaskRerunService {
@Resource @Resource
private ApiTestCaseRunService apiTestCaseRunService; private ApiTestCaseRunService apiTestCaseRunService;
@Resource @Resource
private ExecTaskItemMapper execTaskItemMapper; private ApiCommonService apiCommonService;
public ApiCaseRerunService() { public ApiCaseRerunService() {
TaskRerunServiceInvoker.register(ExecTaskType.API_CASE, this); TaskRerunServiceInvoker.register(ExecTaskType.API_CASE, this);
} }
@Override @Override
public void rerun(ExecTask execTask, List<String> taskItemIds, String userId) { public void rerun(ExecTask execTask, String userId) {
ExecTaskItem execTaskItem = execTaskItemMapper.selectByPrimaryKey(taskItemIds.getFirst()); ExecTaskItem execTaskItem = apiCommonService.getRerunTaskItem(execTask.getId());
apiTestCaseRunService.runRun(execTask, execTaskItem, userId); apiTestCaseRunService.runRun(execTask, execTaskItem, userId);
} }
} }

View File

@ -1,11 +1,11 @@
package io.metersphere.api.service.rerun; package io.metersphere.api.service.rerun;
import io.metersphere.api.service.ApiCommonService;
import io.metersphere.api.service.scenario.ApiScenarioRunService; import io.metersphere.api.service.scenario.ApiScenarioRunService;
import io.metersphere.sdk.constants.ExecTaskType; import io.metersphere.sdk.constants.ExecTaskType;
import io.metersphere.system.domain.ExecTask; import io.metersphere.system.domain.ExecTask;
import io.metersphere.system.domain.ExecTaskItem; import io.metersphere.system.domain.ExecTaskItem;
import io.metersphere.system.invoker.TaskRerunServiceInvoker; import io.metersphere.system.invoker.TaskRerunServiceInvoker;
import io.metersphere.system.mapper.ExecTaskItemMapper;
import io.metersphere.system.service.TaskRerunService; import io.metersphere.system.service.TaskRerunService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -23,15 +23,15 @@ public class ApiScenarioRerunService implements TaskRerunService {
@Resource @Resource
private ApiScenarioRunService apiScenarioRunService; private ApiScenarioRunService apiScenarioRunService;
@Resource @Resource
private ExecTaskItemMapper execTaskItemMapper; private ApiCommonService apiCommonService;
public ApiScenarioRerunService() { public ApiScenarioRerunService() {
TaskRerunServiceInvoker.register(ExecTaskType.API_SCENARIO, this); TaskRerunServiceInvoker.register(ExecTaskType.API_SCENARIO, this);
} }
@Override @Override
public void rerun(ExecTask execTask, List<String> taskItemIds, String userId) { public void rerun(ExecTask execTask, String userId) {
ExecTaskItem execTaskItem = execTaskItemMapper.selectByPrimaryKey(taskItemIds.getFirst()); ExecTaskItem execTaskItem = apiCommonService.getRerunTaskItem(execTask.getId());
apiScenarioRunService.runRun(execTask, execTaskItem, userId); apiScenarioRunService.runRun(execTask, execTaskItem, userId);
} }
} }

View File

@ -6,7 +6,6 @@ import io.metersphere.system.domain.ExecTask;
import io.metersphere.system.service.TaskRerunService; import io.metersphere.system.service.TaskRerunService;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -29,7 +28,10 @@ public class TaskRerunServiceInvoker {
return EnumValidator.validateEnum(ExecTaskType.class, execTaskType); return EnumValidator.validateEnum(ExecTaskType.class, execTaskType);
} }
public static void rerun(ExecTask execTask, List<String> taskItemIds, String userId) { public static void rerun(ExecTask execTask, String userId) {
getTaskRerunService(getExecTaskType(execTask.getTaskType())).rerun(execTask, taskItemIds, userId); TaskRerunService taskRerunService = getTaskRerunService(getExecTaskType(execTask.getTaskType()));
if (taskRerunService != null) {
taskRerunService.rerun(execTask, userId);
}
} }
} }

View File

@ -37,7 +37,7 @@ public interface ExtExecTaskItemMapper {
List<ExecTaskItem> selectExecInfoByTaskIdAndResourceIds(@Param("taskId") String taskId, @Param("resourceIds") List<String> resourceIds); List<ExecTaskItem> selectExecInfoByTaskIdAndResourceIds(@Param("taskId") String taskId, @Param("resourceIds") List<String> resourceIds);
List<ExecTaskItem> selectExecInfoByTaskIdAndCollectionId(@Param("taskId") String taskId, @Param("collectionId") String collectionId); List<ExecTaskItem> selectExecInfoByTaskIdAndCollectionId(@Param("taskId") String taskId, @Param("collectionId") String collectionId, @Param("rerun") boolean rerun);
Boolean hasErrorItem(@Param("taskId") String taskId); Boolean hasErrorItem(@Param("taskId") String taskId);
@ -64,8 +64,6 @@ public interface ExtExecTaskItemMapper {
long getUnDeleteScenarioExecCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("resourceTypes") List<String> resourceTypes); long getUnDeleteScenarioExecCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("resourceTypes") List<String> resourceTypes);
List<String> selectRerunIds(@Param("taskId") String taskId);
void resetRerunTaskItem(@Param("taskId") String taskId, @Param("userId") String userId); void resetRerunTaskItem(@Param("taskId") String taskId, @Param("userId") String userId);
void deleteRerunTaskItemReportRelation(@Param("taskId") String taskId); void deleteRerunTaskItemReportRelation(@Param("taskId") String taskId);

View File

@ -33,6 +33,9 @@
SELECT id, resource_id SELECT id, resource_id
FROM exec_task_item FROM exec_task_item
WHERE task_id = #{taskId} and collection_id = #{collectionId} WHERE task_id = #{taskId} and collection_id = #{collectionId}
<if test="rerun != null and rerun == true">
and rerun = true
</if>
</select> </select>
<select id="selectItemByTaskIds" resultType="io.metersphere.system.domain.ExecTaskItem"> <select id="selectItemByTaskIds" resultType="io.metersphere.system.domain.ExecTaskItem">
@ -320,10 +323,6 @@
</if> </if>
</select> </select>
<select id="selectRerunIds" resultType="java.lang.String">
select id from exec_task_item where task_id = #{taskId} and `result` = 'ERROR' and deleted = false
</select>
<update id="resetRerunTaskItem"> <update id="resetRerunTaskItem">
UPDATE exec_task_item UPDATE exec_task_item
SET `status` = 'PENDING', SET `status` = 'PENDING',
@ -333,9 +332,9 @@
thread_id = null, thread_id = null,
start_time = null, start_time = null,
end_time = null, end_time = null,
collection_id = null,
error_message = null, error_message = null,
executor = #{userId} executor = #{userId},
rerun = true
WHERE WHERE
deleted = false deleted = false
and task_id = #{taskId} and task_id = #{taskId}

View File

@ -528,6 +528,7 @@ public class BaseTaskHubService {
List<ExecTaskItem> items = extExecTaskItemMapper.selectPoolNodeByIds(ids); List<ExecTaskItem> items = extExecTaskItemMapper.selectPoolNodeByIds(ids);
return items.stream() return items.stream()
.filter(item -> StringUtils.isNotBlank(item.getResourcePoolNode()))
.collect(Collectors.groupingBy(ExecTaskItem::getResourcePoolNode)) .collect(Collectors.groupingBy(ExecTaskItem::getResourcePoolNode))
.entrySet() .entrySet()
.stream() .stream()
@ -599,13 +600,6 @@ public class BaseTaskHubService {
throw new MSException(Translator.get("no_permission_to_resource")); throw new MSException(Translator.get("no_permission_to_resource"));
} }
// 查询待执行的任务项
List<String> taskItemIds = extExecTaskItemMapper.selectRerunIds(execTask.getId());
if (CollectionUtils.isEmpty(taskItemIds)) {
return;
}
// 更新任务状态 // 更新任务状态
execTask.setStatus(ExecStatus.RERUNNING.name()); execTask.setStatus(ExecStatus.RERUNNING.name());
execTask.setCreateUser(userId); execTask.setCreateUser(userId);
@ -626,7 +620,7 @@ public class BaseTaskHubService {
// 更新任务项状态等 // 更新任务项状态等
extExecTaskItemMapper.resetRerunTaskItem(execTask.getId(), userId); extExecTaskItemMapper.resetRerunTaskItem(execTask.getId(), userId);
TaskRerunServiceInvoker.rerun(execTask, taskItemIds, userId); TaskRerunServiceInvoker.rerun(execTask, userId);
} }
private void handleStopTaskAsync(List<String> ids) { private void handleStopTaskAsync(List<String> ids) {

View File

@ -1,16 +1,18 @@
package io.metersphere.system.service; package io.metersphere.system.service;
import io.metersphere.system.domain.ExecTask; import io.metersphere.system.domain.ExecTask;
import org.springframework.stereotype.Service;
import java.util.List; import org.springframework.transaction.annotation.Transactional;
/** /**
* @Author: jianxing * @Author: jianxing
* @CreateTime: 2024-02-06 20:47 * @CreateTime: 2024-02-06 20:47
*/ */
@Service
@Transactional(rollbackFor = Exception.class)
public interface TaskRerunService { public interface TaskRerunService {
/** /**
* 任务重跑 * 任务重跑
*/ */
void rerun(ExecTask execTask, List<String> taskItemIds, String userId); void rerun(ExecTask execTask, String userId);
} }

View File

@ -73,4 +73,6 @@ public interface ExtTestPlanReportMapper {
void deleteGroupReport(@Param("id") String id); void deleteGroupReport(@Param("id") String id);
List<TestPlanReport> getChildrenReport(@Param("reportId") String reportId); List<TestPlanReport> getChildrenReport(@Param("reportId") String reportId);
void resetRerunReport(@Param("reportId") String reportId);
} }

View File

@ -552,4 +552,8 @@
<select id="getChildrenReport" resultType="io.metersphere.plan.domain.TestPlanReport"> <select id="getChildrenReport" resultType="io.metersphere.plan.domain.TestPlanReport">
select id from test_plan_report where parent_id = #{reportId} and id != #{reportId} select id from test_plan_report where parent_id = #{reportId} and id != #{reportId}
</select> </select>
<update id="resetRerunReport">
update test_plan_report set exec_status = 'RUNNING', end_time = null where id = #{reportId} or parent_id = #{reportId}
</update>
</mapper> </mapper>

View File

@ -76,7 +76,7 @@ public class PlanRunTestPlanApiCaseService {
String collectionId = collection.getId(); String collectionId = collection.getId();
String execQueueId = taskId + "_" + collectionId; String execQueueId = taskId + "_" + collectionId;
List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(taskId, collectionId); List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(taskId, collectionId, testPlanExecutionQueue.isRerun());
if (CollectionUtils.isEmpty(execTaskItems)) { if (CollectionUtils.isEmpty(execTaskItems)) {
return true; return true;
} }
@ -85,6 +85,7 @@ public class PlanRunTestPlanApiCaseService {
ExecutionQueue queue = apiBatchRunBaseService.getExecutionQueue(runModeConfig, ApiExecuteResourceType.PLAN_RUN_API_CASE.name(), ExecutionQueue queue = apiBatchRunBaseService.getExecutionQueue(runModeConfig, ApiExecuteResourceType.PLAN_RUN_API_CASE.name(),
testPlanExecutionQueue.getTaskId(), userId); testPlanExecutionQueue.getTaskId(), userId);
queue.setQueueId(execQueueId); queue.setQueueId(execQueueId);
queue.setRerun(testPlanExecutionQueue.isRerun());
queue.setParentQueueId(testPlanExecutionQueue.getQueueId()); queue.setParentQueueId(testPlanExecutionQueue.getQueueId());
apiExecutionQueueService.insertQueue(queue); apiExecutionQueueService.insertQueue(queue);
@ -114,13 +115,15 @@ public class PlanRunTestPlanApiCaseService {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(testPlanId); TestPlan testPlan = testPlanMapper.selectByPrimaryKey(testPlanId);
TaskBatchRequestDTO taskRequest = apiTestCaseBatchRunService.getTaskBatchRequestDTO(testPlan.getProjectId(), runModeConfig); TaskBatchRequestDTO taskRequest = apiTestCaseBatchRunService.getTaskBatchRequestDTO(testPlan.getProjectId(), runModeConfig);
taskRequest.getTaskInfo().setTaskId(testPlanExecutionQueue.getTaskId()); taskRequest.getTaskInfo().setTaskId(taskId);
taskRequest.getTaskInfo().setParentQueueId(testPlanExecutionQueue.getQueueId()); taskRequest.getTaskInfo().setParentQueueId(testPlanExecutionQueue.getQueueId());
taskRequest.getTaskInfo().setSetId(execSetId); taskRequest.getTaskInfo().setSetId(execSetId);
taskRequest.getTaskInfo().setRerun(testPlanExecutionQueue.isRerun());
taskRequest.getTaskInfo().setUserId(userId); taskRequest.getTaskInfo().setUserId(userId);
taskRequest.getTaskInfo().setResourceType(ApiExecuteResourceType.PLAN_RUN_API_CASE.name()); taskRequest.getTaskInfo().setResourceType(ApiExecuteResourceType.PLAN_RUN_API_CASE.name());
List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(testPlanExecutionQueue.getTaskId(), collection.getId()); List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(testPlanExecutionQueue.getTaskId(),
collection.getId(), testPlanExecutionQueue.isRerun());
SubListUtils.dealForSubList(execTaskItems, ApiBatchRunBaseService.BATCH_TASK_ITEM_SIZE, subExecTaskItems -> { SubListUtils.dealForSubList(execTaskItems, ApiBatchRunBaseService.BATCH_TASK_ITEM_SIZE, subExecTaskItems -> {
List<TaskItem> taskItems = subExecTaskItems List<TaskItem> taskItems = subExecTaskItems
.stream() .stream()
@ -166,6 +169,7 @@ public class PlanRunTestPlanApiCaseService {
taskRequest.getTaskInfo().setResourceType(ApiExecuteResourceType.PLAN_RUN_API_CASE.name()); taskRequest.getTaskInfo().setResourceType(ApiExecuteResourceType.PLAN_RUN_API_CASE.name());
taskRequest.getTaskInfo().setQueueId(queue.getQueueId()); taskRequest.getTaskInfo().setQueueId(queue.getQueueId());
taskRequest.getTaskInfo().setUserId(queue.getUserId()); taskRequest.getTaskInfo().setUserId(queue.getUserId());
taskRequest.getTaskInfo().setRerun(queue.getRerun());
taskRequest.getTaskInfo().setParentQueueId(queue.getParentQueueId()); taskRequest.getTaskInfo().setParentQueueId(queue.getParentQueueId());
taskRequest.getTaskItem().setRequestCount(1L); taskRequest.getTaskItem().setRequestCount(1L);
taskRequest.getTaskItem().setId(queueDetail.getTaskItemId()); taskRequest.getTaskItem().setId(queueDetail.getTaskItemId());
@ -183,8 +187,6 @@ public class PlanRunTestPlanApiCaseService {
ApiReport apiReport = apiTestCaseRunService.getApiReport(apiTestCase, request); ApiReport apiReport = apiTestCaseRunService.getApiReport(apiTestCase, request);
apiReport.setEnvironmentId(apiBatchRunBaseService.getEnvId(request.getRunModeConfig(), testPlanReportApiCase.getEnvironmentId())); apiReport.setEnvironmentId(apiBatchRunBaseService.getEnvId(request.getRunModeConfig(), testPlanReportApiCase.getEnvironmentId()));
apiReport.setTestPlanCaseId(testPlanReportApiCase.getTestPlanApiCaseId()); apiReport.setTestPlanCaseId(testPlanReportApiCase.getTestPlanApiCaseId());
// 报告ID预生成
apiReport.setId(testPlanReportApiCase.getApiCaseExecuteReportId());
// 标记是测试计划整体执行 // 标记是测试计划整体执行
apiReport.setPlan(true); apiReport.setPlan(true);
apiReportService.insertApiReport(apiReport); apiReportService.insertApiReport(apiReport);

View File

@ -72,7 +72,7 @@ public class PlanRunTestPlanApiScenarioService {
String collectionId = collection.getId(); String collectionId = collection.getId();
String execQueueId = taskId + "_" + collectionId; String execQueueId = taskId + "_" + collectionId;
List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(taskId, collectionId); List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(taskId, collectionId, testPlanExecutionQueue.isRerun());
if (CollectionUtils.isEmpty(execTaskItems)) { if (CollectionUtils.isEmpty(execTaskItems)) {
return true; return true;
} }
@ -81,6 +81,7 @@ public class PlanRunTestPlanApiScenarioService {
ExecutionQueue queue = apiBatchRunBaseService.getExecutionQueue(runModeConfig, ApiExecuteResourceType.PLAN_RUN_API_SCENARIO.name(), ExecutionQueue queue = apiBatchRunBaseService.getExecutionQueue(runModeConfig, ApiExecuteResourceType.PLAN_RUN_API_SCENARIO.name(),
testPlanExecutionQueue.getTaskId(), userId); testPlanExecutionQueue.getTaskId(), userId);
queue.setQueueId(execQueueId); queue.setQueueId(execQueueId);
queue.setRerun(testPlanExecutionQueue.isRerun());
queue.setParentQueueId(testPlanExecutionQueue.getQueueId()); queue.setParentQueueId(testPlanExecutionQueue.getQueueId());
apiExecutionQueueService.insertQueue(queue); apiExecutionQueueService.insertQueue(queue);
@ -113,9 +114,11 @@ public class PlanRunTestPlanApiScenarioService {
taskRequest.getTaskInfo().setParentQueueId(testPlanExecutionQueue.getQueueId()); taskRequest.getTaskInfo().setParentQueueId(testPlanExecutionQueue.getQueueId());
taskRequest.getTaskInfo().setSetId(execSetId); taskRequest.getTaskInfo().setSetId(execSetId);
taskRequest.getTaskInfo().setUserId(userId); taskRequest.getTaskInfo().setUserId(userId);
taskRequest.getTaskInfo().setRerun(testPlanExecutionQueue.isRerun());
taskRequest.getTaskInfo().setResourceType(ApiExecuteResourceType.PLAN_RUN_API_SCENARIO.name()); taskRequest.getTaskInfo().setResourceType(ApiExecuteResourceType.PLAN_RUN_API_SCENARIO.name());
List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(testPlanExecutionQueue.getTaskId(), collection.getId()); List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(testPlanExecutionQueue.getTaskId(),
collection.getId(), testPlanExecutionQueue.isRerun());
SubListUtils.dealForSubList(execTaskItems, ApiBatchRunBaseService.BATCH_TASK_ITEM_SIZE, subExecTaskItems -> { SubListUtils.dealForSubList(execTaskItems, ApiBatchRunBaseService.BATCH_TASK_ITEM_SIZE, subExecTaskItems -> {
List<TaskItem> taskItems = subExecTaskItems List<TaskItem> taskItems = subExecTaskItems
.stream() .stream()
@ -141,16 +144,13 @@ public class PlanRunTestPlanApiScenarioService {
// 初始化报告 // 初始化报告
ApiScenarioReport apiScenarioReport = apiScenarioRunService.getScenarioReport(apiScenario, request); ApiScenarioReport apiScenarioReport = apiScenarioRunService.getScenarioReport(apiScenario, request);
apiScenarioReport.setName(testPlanReportApiScenario.getApiScenarioName() + "_" + DateUtils.getTimeString(System.currentTimeMillis())); apiScenarioReport.setName(testPlanReportApiScenario.getApiScenarioName() + "_" + DateUtils.getTimeString(System.currentTimeMillis()));
apiScenarioReport.setTestPlanScenarioId(testPlanReportApiScenario.getTestPlanApiScenarioId());
// 报告预生成方便停止测试计划时直接更新报告状态
apiScenarioReport.setId(testPlanReportApiScenario.getApiScenarioExecuteReportId());
apiScenarioReport.setEnvironmentId(apiBatchRunBaseService.getEnvId(request.getRunModeConfig(), testPlanReportApiScenario.getEnvironmentId())); apiScenarioReport.setEnvironmentId(apiBatchRunBaseService.getEnvId(request.getRunModeConfig(), testPlanReportApiScenario.getEnvironmentId()));
apiScenarioReport.setPlan(true); apiScenarioReport.setPlan(true);
apiScenarioReport.setTestPlanScenarioId(testPlanReportApiScenario.getTestPlanApiScenarioId());
apiScenarioReportService.insertApiScenarioReport(apiScenarioReport); apiScenarioReportService.insertApiScenarioReport(apiScenarioReport);
return apiScenarioRunService.initApiScenarioReportDetail(request.getTaskItem().getId(), apiScenario.getId(), apiScenarioReport.getId()); return apiScenarioRunService.initApiScenarioReportDetail(request.getTaskItem().getId(), apiScenario.getId(), apiScenarioReport.getId());
} }
/** /**
* 执行串行的下一个任务 * 执行串行的下一个任务
* *
@ -176,6 +176,7 @@ public class PlanRunTestPlanApiScenarioService {
taskRequest.getTaskInfo().setTaskId(queue.getTaskId()); taskRequest.getTaskInfo().setTaskId(queue.getTaskId());
taskRequest.getTaskInfo().setQueueId(queue.getQueueId()); taskRequest.getTaskInfo().setQueueId(queue.getQueueId());
taskRequest.getTaskInfo().setUserId(queue.getUserId()); taskRequest.getTaskInfo().setUserId(queue.getUserId());
taskRequest.getTaskInfo().setRerun(queue.getRerun());
taskRequest.getTaskInfo().setParentQueueId(queue.getParentQueueId()); taskRequest.getTaskInfo().setParentQueueId(queue.getParentQueueId());
taskRequest.getTaskInfo().setResourceType(ApiExecuteResourceType.PLAN_RUN_API_SCENARIO.name()); taskRequest.getTaskInfo().setResourceType(ApiExecuteResourceType.PLAN_RUN_API_SCENARIO.name());

View File

@ -30,7 +30,6 @@ import io.metersphere.sdk.util.SubListUtils;
import io.metersphere.sdk.util.Translator; import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.ExecTask; import io.metersphere.system.domain.ExecTask;
import io.metersphere.system.domain.ExecTaskItem; import io.metersphere.system.domain.ExecTaskItem;
import io.metersphere.system.mapper.ExtExecTaskItemMapper;
import io.metersphere.system.service.BaseTaskHubService; import io.metersphere.system.service.BaseTaskHubService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
@ -74,8 +73,6 @@ public class TestPlanApiCaseBatchRunService {
@Resource @Resource
private BaseTaskHubService baseTaskHubService; private BaseTaskHubService baseTaskHubService;
@Resource @Resource
private ExtExecTaskItemMapper extExecTaskItemMapper;
@Resource
private TestPlanService testPlanService; private TestPlanService testPlanService;
/** /**
@ -197,7 +194,7 @@ public class TestPlanApiCaseBatchRunService {
// 初始化执行队列 // 初始化执行队列
ExecutionQueue queue = apiBatchRunBaseService.initExecutionQueue(taskId, taskId + '_' + collectionId, runModeConfig, ApiExecuteResourceType.TEST_PLAN_API_CASE.name(), parentQueueId, parentSetId, userId); ExecutionQueue queue = apiBatchRunBaseService.initExecutionQueue(taskId, taskId + '_' + collectionId, runModeConfig, ApiExecuteResourceType.TEST_PLAN_API_CASE.name(), parentQueueId, parentSetId, userId);
List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(taskId, collectionId); List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(taskId, collectionId, false);
apiBatchRunBaseService.initQueueDetail(queue, execTaskItems); apiBatchRunBaseService.initQueueDetail(queue, execTaskItems);
@ -232,7 +229,7 @@ public class TestPlanApiCaseBatchRunService {
taskRequest.getTaskInfo().setParentSetId(parentSetId); taskRequest.getTaskInfo().setParentSetId(parentSetId);
} }
List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(taskId, collectionId); List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(taskId, collectionId, false);
SubListUtils.dealForSubList(execTaskItems, ApiBatchRunBaseService.BATCH_TASK_ITEM_SIZE, subExecTaskItems -> { SubListUtils.dealForSubList(execTaskItems, ApiBatchRunBaseService.BATCH_TASK_ITEM_SIZE, subExecTaskItems -> {
List<TaskItem> taskItems = subExecTaskItems List<TaskItem> taskItems = subExecTaskItems

View File

@ -205,7 +205,7 @@ public class TestPlanApiScenarioBatchRunService {
// 初始化执行队列 // 初始化执行队列
ExecutionQueue queue = apiBatchRunBaseService.initExecutionQueue(taskId, taskId + '_' + collectionId, runModeConfig, ApiExecuteResourceType.TEST_PLAN_API_SCENARIO.name(), parentQueueId, parentSetId, userId); ExecutionQueue queue = apiBatchRunBaseService.initExecutionQueue(taskId, taskId + '_' + collectionId, runModeConfig, ApiExecuteResourceType.TEST_PLAN_API_SCENARIO.name(), parentQueueId, parentSetId, userId);
List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(taskId, collectionId); List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(taskId, collectionId, false);
apiBatchRunBaseService.initQueueDetail(queue, execTaskItems); apiBatchRunBaseService.initQueueDetail(queue, execTaskItems);
@ -239,7 +239,7 @@ public class TestPlanApiScenarioBatchRunService {
taskRequest.getTaskInfo().setParentSetId(parentSetId); taskRequest.getTaskInfo().setParentSetId(parentSetId);
} }
List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(taskId, collectionId); List<ExecTaskItem> execTaskItems = apiBatchRunBaseService.getExecTaskItemByTaskIdAndCollectionId(taskId, collectionId, false);
SubListUtils.dealForSubList(execTaskItems, ApiBatchRunBaseService.BATCH_TASK_ITEM_SIZE, subExecTaskItems -> { SubListUtils.dealForSubList(execTaskItems, ApiBatchRunBaseService.BATCH_TASK_ITEM_SIZE, subExecTaskItems -> {
List<TaskItem> taskItems = subExecTaskItems List<TaskItem> taskItems = subExecTaskItems
.stream() .stream()

View File

@ -2,6 +2,7 @@ package io.metersphere.plan.service;
import com.esotericsoftware.minlog.Log; import com.esotericsoftware.minlog.Log;
import io.metersphere.api.domain.ApiReportRelateTask; import io.metersphere.api.domain.ApiReportRelateTask;
import io.metersphere.api.domain.ApiReportRelateTaskExample;
import io.metersphere.api.mapper.ApiReportRelateTaskMapper; import io.metersphere.api.mapper.ApiReportRelateTaskMapper;
import io.metersphere.api.service.ApiBatchRunBaseService; import io.metersphere.api.service.ApiBatchRunBaseService;
import io.metersphere.api.service.ApiCommonService; import io.metersphere.api.service.ApiCommonService;
@ -23,6 +24,7 @@ import io.metersphere.system.service.BaseTaskHubService;
import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
@ -32,6 +34,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import static io.metersphere.plan.service.TestPlanExecuteSupportService.*; import static io.metersphere.plan.service.TestPlanExecuteSupportService.*;
@ -80,6 +83,8 @@ public class TestPlanExecuteService {
private ApiBatchRunBaseService apiBatchRunBaseService; private ApiBatchRunBaseService apiBatchRunBaseService;
@Resource @Resource
private ApiReportRelateTaskMapper apiReportRelateTaskMapper; private ApiReportRelateTaskMapper apiReportRelateTaskMapper;
@Resource
private ExtTestPlanReportMapper extTestPlanReportMapper;
// 停止测试计划的执行 // 停止测试计划的执行
public void stopTestPlanRunning(String testPlanReportId) { public void stopTestPlanRunning(String testPlanReportId) {
@ -168,7 +173,8 @@ public class TestPlanExecuteService {
request.getRunMode(), request.getRunMode(),
request.getExecutionSource(), request.getExecutionSource(),
reportId, reportId,
IDGenerator.nextStr() IDGenerator.nextStr(),
false
); );
testPlanExecuteSupportService.setRedisForList( testPlanExecuteSupportService.setRedisForList(
@ -210,7 +216,8 @@ public class TestPlanExecuteService {
runMode, runMode,
TaskTriggerMode.BATCH.name(), TaskTriggerMode.BATCH.name(),
IDGenerator.nextStr(), IDGenerator.nextStr(),
IDGenerator.nextStr() IDGenerator.nextStr(),
false
) )
); );
} }
@ -253,7 +260,7 @@ public class TestPlanExecuteService {
extTestPlanApiScenarioMapper.countByPlanIds(childPlanIds); extTestPlanApiScenarioMapper.countByPlanIds(childPlanIds);
} }
// 初始化任务 // 初始化任务
ExecTask execTask = initExecTask(executionQueue.getTaskId(), caseTotal, testPlan, project, executionQueue.getCreateUser(), executionQueue.getExecutionSource(), executionQueue.getPrepareReportId()); ExecTask execTask = initExecTask(executionQueue, caseTotal, testPlan, project);
// 预生成计划组报告 // 预生成计划组报告
Map<String, String> reportMap = testPlanReportService.genReportByExecution(executionQueue.getPrepareReportId(), execTask.getId(), genReportRequest, executionQueue.getCreateUser()); Map<String, String> reportMap = testPlanReportService.genReportByExecution(executionQueue.getPrepareReportId(), execTask.getId(), genReportRequest, executionQueue.getCreateUser());
@ -276,7 +283,8 @@ public class TestPlanExecuteService {
executionQueue.getRunMode(), executionQueue.getRunMode(),
executionQueue.getExecutionSource(), executionQueue.getExecutionSource(),
reportMap.get(child.getId()), reportMap.get(child.getId()),
executionQueue.getTaskId() executionQueue.getTaskId(),
executionQueue.isRerun()
) )
); );
} }
@ -309,7 +317,7 @@ public class TestPlanExecuteService {
Integer caseTotal = extTestPlanApiCaseMapper.countByPlanIds(List.of(testPlan.getId())) + Integer caseTotal = extTestPlanApiCaseMapper.countByPlanIds(List.of(testPlan.getId())) +
extTestPlanApiScenarioMapper.countByPlanIds(List.of(testPlan.getId())); extTestPlanApiScenarioMapper.countByPlanIds(List.of(testPlan.getId()));
// 初始化任务 // 初始化任务
ExecTask execTask = initExecTask(executionQueue.getTaskId(), caseTotal, testPlan, project, executionQueue.getCreateUser(), executionQueue.getExecutionSource(), executionQueue.getPrepareReportId()); ExecTask execTask = initExecTask(executionQueue, caseTotal, testPlan, project);
Map<String, String> reportMap = testPlanReportService.genReportByExecution(executionQueue.getPrepareReportId(), execTask.getId(), genReportRequest, executionQueue.getCreateUser()); Map<String, String> reportMap = testPlanReportService.genReportByExecution(executionQueue.getPrepareReportId(), execTask.getId(), genReportRequest, executionQueue.getCreateUser());
executionQueue.setPrepareReportId(reportMap.get(executionQueue.getSourceID())); executionQueue.setPrepareReportId(reportMap.get(executionQueue.getSourceID()));
@ -319,21 +327,22 @@ public class TestPlanExecuteService {
} }
} }
private ExecTask initExecTask(String taskId, int caseSize, TestPlan testPlan, Project project, String userId, String triggerMode, String reportId) { private ExecTask initExecTask(TestPlanExecutionQueue executionQueue, int caseSize, TestPlan testPlan, Project project) {
ExecTask execTask = apiCommonService.newExecTask(project.getId(), userId); ExecTask execTask = apiCommonService.newExecTask(project.getId(), executionQueue.getCreateUser());
execTask.setId(taskId); execTask.setId(executionQueue.getTaskId());
execTask.setCaseCount(Long.valueOf(caseSize)); execTask.setCaseCount(Long.valueOf(caseSize));
execTask.setTaskName(testPlan.getName()); execTask.setTaskName(testPlan.getName());
execTask.setOrganizationId(project.getOrganizationId()); execTask.setOrganizationId(project.getOrganizationId());
execTask.setTriggerMode(triggerMode); execTask.setTriggerMode(executionQueue.getExecutionSource());
execTask.setParallel(StringUtils.equals(executionQueue.getRunMode(), ApiBatchRunMode.PARALLEL.name()));
execTask.setTaskType(StringUtils.equalsIgnoreCase(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_PLAN) ? ExecTaskType.TEST_PLAN.name() : ExecTaskType.TEST_PLAN_GROUP.name()); execTask.setTaskType(StringUtils.equalsIgnoreCase(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_PLAN) ? ExecTaskType.TEST_PLAN.name() : ExecTaskType.TEST_PLAN_GROUP.name());
execTask.setResourceId(testPlan.getId()); execTask.setResourceId(testPlan.getId());
baseTaskHubService.insertExecTask(execTask); baseTaskHubService.insertExecTask(execTask);
// 创建报告和任务的关联关系 // 创建报告和任务的关联关系
ApiReportRelateTask apiReportRelateTask = new ApiReportRelateTask(); ApiReportRelateTask apiReportRelateTask = new ApiReportRelateTask();
apiReportRelateTask.setReportId(reportId); apiReportRelateTask.setReportId(executionQueue.getPrepareReportId());
apiReportRelateTask.setTaskResourceId(taskId); apiReportRelateTask.setTaskResourceId(execTask.getId());
apiReportRelateTaskMapper.insertSelective(apiReportRelateTask); apiReportRelateTaskMapper.insertSelective(apiReportRelateTask);
return execTask; return execTask;
} }
@ -376,7 +385,8 @@ public class TestPlanExecuteService {
runMode, runMode,
executionQueue.getExecutionSource(), executionQueue.getExecutionSource(),
executionQueue.getPrepareReportId(), executionQueue.getPrepareReportId(),
executionQueue.getTaskId()) executionQueue.getTaskId(),
executionQueue.isRerun())
); );
} }
LogUtils.info("测试计划执行节点 --- 队列ID[{}],队列类型[{}],父队列ID[{}],父队列类型[{}],执行模式[{}]", queueId, queueType, executionQueue.getParentQueueId(), executionQueue.getParentQueueType(), runMode); LogUtils.info("测试计划执行节点 --- 队列ID[{}],队列类型[{}],父队列ID[{}],父队列类型[{}],执行模式[{}]", queueId, queueType, executionQueue.getParentQueueId(), executionQueue.getParentQueueType(), runMode);
@ -401,6 +411,110 @@ public class TestPlanExecuteService {
} }
} }
public String testPlanOrGroupRerun(ExecTask execTask, String userId) {
String taskId = execTask.getId();
ApiReportRelateTaskExample example = new ApiReportRelateTaskExample();
example.createCriteria().andTaskResourceIdEqualTo(taskId);
List<ApiReportRelateTask> apiReportRelateTasks = apiReportRelateTaskMapper.selectByExample(example);
String reportId;
if (CollectionUtils.isNotEmpty(apiReportRelateTasks)) {
reportId = apiReportRelateTasks.getFirst().getReportId();
} else {
// 报告被删除生成虚拟ID
reportId = IDGenerator.nextStr();
}
String queueId = IDGenerator.nextStr();
TestPlanExecutionQueue singleExecuteRootQueue = new TestPlanExecutionQueue(
0,
userId,
System.currentTimeMillis(),
queueId,
QUEUE_PREFIX_TEST_PLAN_BATCH_EXECUTE,
null,
null,
execTask.getResourceId(),
BooleanUtils.isTrue(execTask.getParallel()) ? ApiBatchRunMode.PARALLEL.name() : ApiBatchRunMode.SERIAL.name(),
TaskTriggerMode.MANUAL.name(),
reportId,
taskId,
true
);
testPlanExecuteSupportService.setRedisForList(
testPlanExecuteSupportService.genQueueKey(queueId, QUEUE_PREFIX_TEST_PLAN_BATCH_EXECUTE), List.of(JSON.toJSONString(singleExecuteRootQueue)));
TestPlanExecutionQueue nextQueue = testPlanExecuteSupportService.getNextQueue(queueId, QUEUE_PREFIX_TEST_PLAN_BATCH_EXECUTE);
LogUtils.info("测试计划(组)重跑!计划报告[{}] , 资源ID[{}]", singleExecuteRootQueue.getPrepareReportId(), singleExecuteRootQueue.getSourceID());
doTestPlanOrGroupRerun(nextQueue);
return reportId;
}
private String doTestPlanOrGroupRerun(TestPlanExecutionQueue executionQueue) {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(executionQueue.getSourceID());
if (testPlan == null || StringUtils.equalsIgnoreCase(testPlan.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) {
throw new MSException("test_plan.error");
}
String prepareReportId = executionQueue.getPrepareReportId();
// 更新计划组以及子计划的状态为 RUNNING
extTestPlanReportMapper.resetRerunReport(prepareReportId);
if (StringUtils.equalsIgnoreCase(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_GROUP)) {
List<TestPlan> children = testPlanService.selectNotArchivedChildren(testPlan.getId());
long pos = 0;
List<TestPlanExecutionQueue> childrenQueue = new ArrayList<>();
String queueType = QUEUE_PREFIX_TEST_PLAN_GROUP_EXECUTE;
String queueId = prepareReportId;
TestPlanReportExample example = new TestPlanReportExample();
example.createCriteria().andParentIdEqualTo(prepareReportId);
Map<String, String> planReportMap = testPlanReportMapper.selectByExample(example).stream().
collect(Collectors.toMap(TestPlanReport::getTestPlanId, TestPlanReport::getId));
for (TestPlan child : children) {
childrenQueue.add(
new TestPlanExecutionQueue(
pos++,
executionQueue.getCreateUser(),
System.currentTimeMillis(),
queueId,
queueType,
executionQueue.getQueueId(),
executionQueue.getQueueType(),
child.getId(),
executionQueue.getRunMode(),
executionQueue.getExecutionSource(),
planReportMap.get(child.getId()) == null ? IDGenerator.nextStr() : planReportMap.get(child.getId()),
executionQueue.getTaskId(),
executionQueue.isRerun()
)
);
}
LogUtils.info("计划组重跑 --- 队列ID[{}],队列类型[{}]", queueId, queueType);
if (CollectionUtils.isEmpty(childrenQueue)) {
//本次的测试计划组执行完成
this.testPlanGroupQueueFinish(queueId, queueType);
} else {
testPlanExecuteSupportService.setRedisForList(testPlanExecuteSupportService.genQueueKey(queueId, queueType), childrenQueue.stream().map(JSON::toJSONString).toList());
if (StringUtils.equalsIgnoreCase(executionQueue.getRunMode(), ApiBatchRunMode.SERIAL.name())) {
//串行
TestPlanExecutionQueue nextQueue = testPlanExecuteSupportService.getNextQueue(queueId, queueType);
executeTestPlan(nextQueue);
} else {
//并行
childrenQueue.forEach(childQueue -> executeTestPlan(childQueue));
}
}
} else {
this.executeTestPlan(executionQueue);
}
return prepareReportId;
}
//执行测试集 -- 回调collectionExecuteQueueFinish //执行测试集 -- 回调collectionExecuteQueueFinish
private void executeByTestPlanCollection(TestPlanExecutionQueue executionQueue) { private void executeByTestPlanCollection(TestPlanExecutionQueue executionQueue) {
TestPlanCollection parentCollection = testPlanCollectionMapper.selectByPrimaryKey(executionQueue.getSourceID()); TestPlanCollection parentCollection = testPlanCollectionMapper.selectByPrimaryKey(executionQueue.getSourceID());
@ -429,7 +543,8 @@ public class TestPlanExecuteService {
runMode, runMode,
executionQueue.getExecutionSource(), executionQueue.getExecutionSource(),
executionQueue.getPrepareReportId(), executionQueue.getPrepareReportId(),
executionQueue.getTaskId()) {{ executionQueue.getTaskId(),
executionQueue.isRerun()) {{
this.setTestPlanCollectionJson(JSON.toJSONString(collection)); this.setTestPlanCollectionJson(JSON.toJSONString(collection));
}} }}
); );

View File

@ -550,7 +550,6 @@ public class TestPlanReportService {
// 接口执行时才更新结果 // 接口执行时才更新结果
reportApiCase.setApiCaseExecuteResult(null); reportApiCase.setApiCaseExecuteResult(null);
reportApiCase.setApiCaseExecuteUser(null); reportApiCase.setApiCaseExecuteUser(null);
reportApiCase.setApiCaseExecuteReportId(IDGenerator.nextStr());
} }
reportApiCase.setApiCaseBugCount(bugCountMap.containsKey(reportApiCase.getTestPlanApiCaseId()) ? bugCountMap.get(reportApiCase.getTestPlanApiCaseId()) : 0); reportApiCase.setApiCaseBugCount(bugCountMap.containsKey(reportApiCase.getTestPlanApiCaseId()) ? bugCountMap.get(reportApiCase.getTestPlanApiCaseId()) : 0);
} }
@ -593,7 +592,6 @@ public class TestPlanReportService {
// 接口执行时才更新结果 // 接口执行时才更新结果
reportApiScenario.setApiScenarioExecuteResult(null); reportApiScenario.setApiScenarioExecuteResult(null);
reportApiScenario.setApiScenarioExecuteUser(null); reportApiScenario.setApiScenarioExecuteUser(null);
reportApiScenario.setApiScenarioExecuteReportId(IDGenerator.nextStr());
} }
reportApiScenario.setApiScenarioBugCount(bugCountMap.containsKey(reportApiScenario.getTestPlanApiScenarioId()) ? bugCountMap.get(reportApiScenario.getTestPlanApiScenarioId()) : 0); reportApiScenario.setApiScenarioBugCount(bugCountMap.containsKey(reportApiScenario.getTestPlanApiScenarioId()) ? bugCountMap.get(reportApiScenario.getTestPlanApiScenarioId()) : 0);
} }

View File

@ -1,17 +1,16 @@
package io.metersphere.plan.service.rerun; package io.metersphere.plan.service.rerun;
import io.metersphere.api.service.ApiCommonService;
import io.metersphere.plan.service.TestPlanApiCaseService; import io.metersphere.plan.service.TestPlanApiCaseService;
import io.metersphere.sdk.constants.ExecTaskType; import io.metersphere.sdk.constants.ExecTaskType;
import io.metersphere.system.domain.ExecTask; import io.metersphere.system.domain.ExecTask;
import io.metersphere.system.domain.ExecTaskItem; import io.metersphere.system.domain.ExecTaskItem;
import io.metersphere.system.invoker.TaskRerunServiceInvoker; import io.metersphere.system.invoker.TaskRerunServiceInvoker;
import io.metersphere.system.mapper.ExecTaskItemMapper;
import io.metersphere.system.service.TaskRerunService; import io.metersphere.system.service.TaskRerunService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* @Author: jianxing * @Author: jianxing
@ -23,15 +22,15 @@ public class TestPlanApiCaseRerunService implements TaskRerunService {
@Resource @Resource
private TestPlanApiCaseService testPlanApiCaseService; private TestPlanApiCaseService testPlanApiCaseService;
@Resource @Resource
private ExecTaskItemMapper execTaskItemMapper; private ApiCommonService apiCommonService;
public TestPlanApiCaseRerunService() { public TestPlanApiCaseRerunService() {
TaskRerunServiceInvoker.register(ExecTaskType.TEST_PLAN_API_CASE, this); TaskRerunServiceInvoker.register(ExecTaskType.TEST_PLAN_API_CASE, this);
} }
@Override @Override
public void rerun(ExecTask execTask, List<String> taskItemIds, String userId) { public void rerun(ExecTask execTask, String userId) {
ExecTaskItem execTaskItem = execTaskItemMapper.selectByPrimaryKey(taskItemIds.getFirst()); ExecTaskItem execTaskItem = apiCommonService.getRerunTaskItem(execTask.getId());
testPlanApiCaseService.runRun(execTask, execTaskItem, userId); testPlanApiCaseService.runRun(execTask, execTaskItem, userId);
} }
} }

View File

@ -1,18 +1,16 @@
package io.metersphere.plan.service.rerun; package io.metersphere.plan.service.rerun;
import io.metersphere.api.service.ApiCommonService;
import io.metersphere.plan.service.TestPlanApiScenarioService; import io.metersphere.plan.service.TestPlanApiScenarioService;
import io.metersphere.sdk.constants.ExecTaskType; import io.metersphere.sdk.constants.ExecTaskType;
import io.metersphere.system.domain.ExecTask; import io.metersphere.system.domain.ExecTask;
import io.metersphere.system.domain.ExecTaskItem; import io.metersphere.system.domain.ExecTaskItem;
import io.metersphere.system.invoker.TaskRerunServiceInvoker; import io.metersphere.system.invoker.TaskRerunServiceInvoker;
import io.metersphere.system.mapper.ExecTaskItemMapper;
import io.metersphere.system.service.TaskRerunService; import io.metersphere.system.service.TaskRerunService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* @Author: jianxing * @Author: jianxing
* @CreateTime: 2024-02-06 20:47 * @CreateTime: 2024-02-06 20:47
@ -23,15 +21,16 @@ public class TestPlanApiScenarioRerunService implements TaskRerunService {
@Resource @Resource
private TestPlanApiScenarioService testPlanApiScenarioService; private TestPlanApiScenarioService testPlanApiScenarioService;
@Resource @Resource
private ExecTaskItemMapper execTaskItemMapper; private ApiCommonService apiCommonService;
public TestPlanApiScenarioRerunService() { public TestPlanApiScenarioRerunService() {
TaskRerunServiceInvoker.register(ExecTaskType.TEST_PLAN_API_SCENARIO, this); TaskRerunServiceInvoker.register(ExecTaskType.TEST_PLAN_API_SCENARIO, this);
} }
@Override @Override
public void rerun(ExecTask execTask, List<String> taskItemIds, String userId) { public void rerun(ExecTask execTask, String userId) {
ExecTaskItem execTaskItem = execTaskItemMapper.selectByPrimaryKey(taskItemIds.getFirst()); ExecTaskItem execTaskItem = apiCommonService.getRerunTaskItem(execTask.getId());
testPlanApiScenarioService.runRun(execTask, execTaskItem, userId); testPlanApiScenarioService.runRun(execTask, execTaskItem, userId);
} }
} }

View File

@ -0,0 +1,30 @@
package io.metersphere.plan.service.rerun;
import io.metersphere.plan.service.TestPlanExecuteService;
import io.metersphere.sdk.constants.ExecTaskType;
import io.metersphere.system.domain.ExecTask;
import io.metersphere.system.invoker.TaskRerunServiceInvoker;
import io.metersphere.system.service.TaskRerunService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @Author: jianxing
* @CreateTime: 2024-02-06 20:47
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class TestPlanGroupRerunService implements TaskRerunService {
@Resource
private TestPlanExecuteService testPlanExecuteService;
public TestPlanGroupRerunService() {
TaskRerunServiceInvoker.register(ExecTaskType.TEST_PLAN_GROUP, this);
}
@Override
public void rerun(ExecTask execTask, String userId) {
Thread.startVirtualThread(() -> testPlanExecuteService.testPlanOrGroupRerun(execTask, userId));
}
}

View File

@ -0,0 +1,30 @@
package io.metersphere.plan.service.rerun;
import io.metersphere.plan.service.TestPlanExecuteService;
import io.metersphere.sdk.constants.ExecTaskType;
import io.metersphere.system.domain.ExecTask;
import io.metersphere.system.invoker.TaskRerunServiceInvoker;
import io.metersphere.system.service.TaskRerunService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @Author: jianxing
* @CreateTime: 2024-02-06 20:47
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class TestPlanRerunService implements TaskRerunService {
@Resource
private TestPlanExecuteService testPlanExecuteService;
public TestPlanRerunService() {
TaskRerunServiceInvoker.register(ExecTaskType.TEST_PLAN, this);
}
@Override
public void rerun(ExecTask execTask, String userId) {
Thread.startVirtualThread(() -> testPlanExecuteService.testPlanOrGroupRerun(execTask, userId));
}
}