feat(测试跟踪): 新建测试计划批量执行功能

新建测试计划批量执行功能
--user=郭雨琦
This commit is contained in:
guoyuqi 2022-04-01 16:06:55 +08:00 committed by fit2-zhao
parent e22a021b17
commit 078f768a1a
18 changed files with 1124 additions and 38 deletions

View File

@ -59,6 +59,7 @@ public class ApiExecutionQueueService {
@Resource
private ApiScenarioReportResultMapper apiScenarioReportResultMapper;
@Transactional(propagation = Propagation.REQUIRES_NEW)
public DBTestQueue add(Object runObj, String poolId, String type, String reportId, String reportType, String runMode, RunModeConfigDTO config) {
ApiExecutionQueue executionQueue = new ApiExecutionQueue();

View File

@ -0,0 +1,19 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class TestPlanExecutionQueue implements Serializable {
private String id;
private String reportId;
private String runMode;
private Long createTime;
private String testPlanId;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,540 @@
package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class TestPlanExecutionQueueExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public TestPlanExecutionQueueExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andReportIdIsNull() {
addCriterion("report_id is null");
return (Criteria) this;
}
public Criteria andReportIdIsNotNull() {
addCriterion("report_id is not null");
return (Criteria) this;
}
public Criteria andReportIdEqualTo(String value) {
addCriterion("report_id =", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotEqualTo(String value) {
addCriterion("report_id <>", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdGreaterThan(String value) {
addCriterion("report_id >", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdGreaterThanOrEqualTo(String value) {
addCriterion("report_id >=", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLessThan(String value) {
addCriterion("report_id <", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLessThanOrEqualTo(String value) {
addCriterion("report_id <=", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLike(String value) {
addCriterion("report_id like", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotLike(String value) {
addCriterion("report_id not like", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdIn(List<String> values) {
addCriterion("report_id in", values, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotIn(List<String> values) {
addCriterion("report_id not in", values, "reportId");
return (Criteria) this;
}
public Criteria andReportIdBetween(String value1, String value2) {
addCriterion("report_id between", value1, value2, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotBetween(String value1, String value2) {
addCriterion("report_id not between", value1, value2, "reportId");
return (Criteria) this;
}
public Criteria andRunModeIsNull() {
addCriterion("run_mode is null");
return (Criteria) this;
}
public Criteria andRunModeIsNotNull() {
addCriterion("run_mode is not null");
return (Criteria) this;
}
public Criteria andRunModeEqualTo(String value) {
addCriterion("run_mode =", value, "runMode");
return (Criteria) this;
}
public Criteria andRunModeNotEqualTo(String value) {
addCriterion("run_mode <>", value, "runMode");
return (Criteria) this;
}
public Criteria andRunModeGreaterThan(String value) {
addCriterion("run_mode >", value, "runMode");
return (Criteria) this;
}
public Criteria andRunModeGreaterThanOrEqualTo(String value) {
addCriterion("run_mode >=", value, "runMode");
return (Criteria) this;
}
public Criteria andRunModeLessThan(String value) {
addCriterion("run_mode <", value, "runMode");
return (Criteria) this;
}
public Criteria andRunModeLessThanOrEqualTo(String value) {
addCriterion("run_mode <=", value, "runMode");
return (Criteria) this;
}
public Criteria andRunModeLike(String value) {
addCriterion("run_mode like", value, "runMode");
return (Criteria) this;
}
public Criteria andRunModeNotLike(String value) {
addCriterion("run_mode not like", value, "runMode");
return (Criteria) this;
}
public Criteria andRunModeIn(List<String> values) {
addCriterion("run_mode in", values, "runMode");
return (Criteria) this;
}
public Criteria andRunModeNotIn(List<String> values) {
addCriterion("run_mode not in", values, "runMode");
return (Criteria) this;
}
public Criteria andRunModeBetween(String value1, String value2) {
addCriterion("run_mode between", value1, value2, "runMode");
return (Criteria) this;
}
public Criteria andRunModeNotBetween(String value1, String value2) {
addCriterion("run_mode not between", value1, value2, "runMode");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Long value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Long value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Long value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Long value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Long value1, Long value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andTestPlanIdIsNull() {
addCriterion("test_plan_id is null");
return (Criteria) this;
}
public Criteria andTestPlanIdIsNotNull() {
addCriterion("test_plan_id is not null");
return (Criteria) this;
}
public Criteria andTestPlanIdEqualTo(String value) {
addCriterion("test_plan_id =", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotEqualTo(String value) {
addCriterion("test_plan_id <>", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdGreaterThan(String value) {
addCriterion("test_plan_id >", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdGreaterThanOrEqualTo(String value) {
addCriterion("test_plan_id >=", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLessThan(String value) {
addCriterion("test_plan_id <", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLessThanOrEqualTo(String value) {
addCriterion("test_plan_id <=", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdLike(String value) {
addCriterion("test_plan_id like", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotLike(String value) {
addCriterion("test_plan_id not like", value, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdIn(List<String> values) {
addCriterion("test_plan_id in", values, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotIn(List<String> values) {
addCriterion("test_plan_id not in", values, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdBetween(String value1, String value2) {
addCriterion("test_plan_id between", value1, value2, "testPlanId");
return (Criteria) this;
}
public Criteria andTestPlanIdNotBetween(String value1, String value2) {
addCriterion("test_plan_id not between", value1, value2, "testPlanId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -15,5 +15,7 @@ public class TestPlanWithBLOBs extends TestPlan implements Serializable {
private String reportConfig;
private String request;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,30 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.TestPlanExecutionQueue;
import io.metersphere.base.domain.TestPlanExecutionQueueExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TestPlanExecutionQueueMapper {
long countByExample(TestPlanExecutionQueueExample example);
int deleteByExample(TestPlanExecutionQueueExample example);
int deleteByPrimaryKey(String id);
int insert(TestPlanExecutionQueue record);
int insertSelective(TestPlanExecutionQueue record);
List<TestPlanExecutionQueue> selectByExample(TestPlanExecutionQueueExample example);
TestPlanExecutionQueue selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") TestPlanExecutionQueue record, @Param("example") TestPlanExecutionQueueExample example);
int updateByExample(@Param("record") TestPlanExecutionQueue record, @Param("example") TestPlanExecutionQueueExample example);
int updateByPrimaryKeySelective(TestPlanExecutionQueue record);
int updateByPrimaryKey(TestPlanExecutionQueue record);
}

View File

@ -0,0 +1,211 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.TestPlanExecutionQueueMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.TestPlanExecutionQueue">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="report_id" jdbcType="VARCHAR" property="reportId" />
<result column="run_mode" jdbcType="VARCHAR" property="runMode" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="test_plan_id" jdbcType="VARCHAR" property="testPlanId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, report_id, run_mode, create_time, test_plan_id
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestPlanExecutionQueueExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from test_plan_execution_queue
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from test_plan_execution_queue
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from test_plan_execution_queue
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.TestPlanExecutionQueueExample">
delete from test_plan_execution_queue
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestPlanExecutionQueue">
insert into test_plan_execution_queue (id, report_id, run_mode,
create_time, test_plan_id)
values (#{id,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, #{runMode,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{testPlanId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanExecutionQueue">
insert into test_plan_execution_queue
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="reportId != null">
report_id,
</if>
<if test="runMode != null">
run_mode,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="testPlanId != null">
test_plan_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="reportId != null">
#{reportId,jdbcType=VARCHAR},
</if>
<if test="runMode != null">
#{runMode,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="testPlanId != null">
#{testPlanId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanExecutionQueueExample" resultType="java.lang.Long">
select count(*) from test_plan_execution_queue
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update test_plan_execution_queue
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.reportId != null">
report_id = #{record.reportId,jdbcType=VARCHAR},
</if>
<if test="record.runMode != null">
run_mode = #{record.runMode,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.testPlanId != null">
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update test_plan_execution_queue
set id = #{record.id,jdbcType=VARCHAR},
report_id = #{record.reportId,jdbcType=VARCHAR},
run_mode = #{record.runMode,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.TestPlanExecutionQueue">
update test_plan_execution_queue
<set>
<if test="reportId != null">
report_id = #{reportId,jdbcType=VARCHAR},
</if>
<if test="runMode != null">
run_mode = #{runMode,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="testPlanId != null">
test_plan_id = #{testPlanId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestPlanExecutionQueue">
update test_plan_execution_queue
set report_id = #{reportId,jdbcType=VARCHAR},
run_mode = #{runMode,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
test_plan_id = #{testPlanId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -27,6 +27,7 @@
<result column="tags" jdbcType="LONGVARCHAR" property="tags" />
<result column="report_summary" jdbcType="LONGVARCHAR" property="reportSummary" />
<result column="report_config" jdbcType="LONGVARCHAR" property="reportConfig" />
<result column="request" jdbcType="LONGVARCHAR" property="request" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -93,7 +94,7 @@
repeat_case
</sql>
<sql id="Blob_Column_List">
tags, report_summary, report_config
tags, report_summary, report_config, request
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.TestPlanExample" resultMap="ResultMapWithBLOBs">
select
@ -151,7 +152,8 @@
planned_end_time, actual_start_time, actual_end_time,
creator, project_id, execution_times,
automatic_status_update, repeat_case, tags,
report_summary, report_config)
report_summary, report_config, request
)
values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{stage,jdbcType=VARCHAR}, #{testCaseMatchRule,jdbcType=VARCHAR}, #{executorMatchRule,jdbcType=VARCHAR},
@ -159,7 +161,8 @@
#{plannedEndTime,jdbcType=BIGINT}, #{actualStartTime,jdbcType=BIGINT}, #{actualEndTime,jdbcType=BIGINT},
#{creator,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{executionTimes,jdbcType=INTEGER},
#{automaticStatusUpdate,jdbcType=BIT}, #{repeatCase,jdbcType=BIT}, #{tags,jdbcType=LONGVARCHAR},
#{reportSummary,jdbcType=LONGVARCHAR}, #{reportConfig,jdbcType=LONGVARCHAR})
#{reportSummary,jdbcType=LONGVARCHAR}, #{reportConfig,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanWithBLOBs">
insert into test_plan
@ -233,6 +236,9 @@
<if test="reportConfig != null">
report_config,
</if>
<if test="request != null">
request,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -304,6 +310,9 @@
<if test="reportConfig != null">
#{reportConfig,jdbcType=LONGVARCHAR},
</if>
<if test="request != null">
#{request,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanExample" resultType="java.lang.Long">
@ -384,6 +393,9 @@
<if test="record.reportConfig != null">
report_config = #{record.reportConfig,jdbcType=LONGVARCHAR},
</if>
<if test="record.request != null">
request = #{record.request,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -413,7 +425,8 @@
repeat_case = #{record.repeatCase,jdbcType=BIT},
tags = #{record.tags,jdbcType=LONGVARCHAR},
report_summary = #{record.reportSummary,jdbcType=LONGVARCHAR},
report_config = #{record.reportConfig,jdbcType=LONGVARCHAR}
report_config = #{record.reportConfig,jdbcType=LONGVARCHAR},
request = #{record.request,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -513,6 +526,9 @@
<if test="reportConfig != null">
report_config = #{reportConfig,jdbcType=LONGVARCHAR},
</if>
<if test="request != null">
request = #{request,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -539,7 +555,8 @@
repeat_case = #{repeatCase,jdbcType=BIT},
tags = #{tags,jdbcType=LONGVARCHAR},
report_summary = #{reportSummary,jdbcType=LONGVARCHAR},
report_config = #{reportConfig,jdbcType=LONGVARCHAR}
report_config = #{reportConfig,jdbcType=LONGVARCHAR},
request = #{request,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestPlan">

View File

@ -0,0 +1,12 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.TestPlanExecutionQueue;
import org.apache.ibatis.annotations.InsertProvider;
import java.util.List;
public interface ExtTestPlanExecutionQueueMapper {
@InsertProvider(type = ExtTestPlanExecutionQueueProvider.class, method = "insertListSql")
void sqlInsert(List<TestPlanExecutionQueue> list);
}

View File

@ -0,0 +1,30 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.TestPlanExecutionQueue;
import java.util.List;
public class ExtTestPlanExecutionQueueProvider {
public String insertListSql(List<TestPlanExecutionQueue> list) {
StringBuffer sqlList = new StringBuffer();
sqlList.append("insert into test_plan_execution_queue (id,report_id, run_mode, create_time) values ");
for (int i = 0; i < list.size(); i++) {
TestPlanExecutionQueue result = list.get(i);
sqlList.append(" (")
.append("'")
.append(result.getId())
.append("','")
.append(result.getReportId())
.append("','")
.append(result.getRunMode())
.append("','")
.append(result.getCreateTime())
.append("'")
.append(")");
if (i < list.size() - 1) {
sqlList.append(",");
}
}
return sqlList.toString();
}
}

View File

@ -1,7 +1,9 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.TestPlanReport;
import io.metersphere.track.dto.TestPlanReportDTO;
import io.metersphere.track.request.report.QueryTestPlanReportRequest;
import org.apache.ibatis.annotations.InsertProvider;
import org.springframework.data.repository.query.Param;
import java.util.List;

View File

@ -56,7 +56,7 @@ public class TestPlanTestJob extends MsScheduleJob {
@Override
public void run() {
LogUtil.info("Start test_plan_scehdule. test_plan_id:" + runResourceId);
testPlanService.run(runResourceId, runProjectId, runUserId, ReportTriggerMode.SCHEDULE.name(),config);
testPlanService.run(runResourceId, runProjectId, runUserId, ReportTriggerMode.SCHEDULE.name(),null,config);
}
});
thread.start();

View File

@ -7,12 +7,10 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.datacount.request.ScheduleInfoRequest;
import io.metersphere.api.service.ApiAutomationService;
import io.metersphere.base.domain.*;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.constants.*;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.service.CheckPermissionService;
@ -194,7 +192,7 @@ public class TestPlanController {
api.setOnSampleError(false);
api.setReportType("iddReport");
String apiRunConfig = JSONObject.toJSONString(api);
return testPlanService.run(testplanRunRequest.getTestPlanId(), testplanRunRequest.getProjectId(), testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(), apiRunConfig);
return testPlanService.run(testplanRunRequest.getTestPlanId(), testplanRunRequest.getProjectId(), testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(),null, apiRunConfig);
}
@PostMapping("/copy/{id}")
@ -223,6 +221,13 @@ public class TestPlanController {
return testPlanService.runPlan(testplanRunRequest);
}
@PostMapping(value = "/run/batch")
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanService.class)
public List<MsExecResponseDTO> runBatch(@RequestBody TestplanRunRequest request) {
request.setTriggerMode(TriggerMode.BATCH.name());
return testPlanService.runBatch(request);
}
@GetMapping("/report/export/{planId}")
public void exportHtmlReport(@PathVariable String planId, HttpServletResponse response) throws UnsupportedEncodingException {
testPlanService.exportPlanReport(planId, response);
@ -299,4 +304,5 @@ public class TestPlanController {
public ScheduleDTO updateTestPlanBySchedule(@RequestBody ScheduleInfoRequest request) {
return testPlanService.updateTestPlanBySchedule(request);
}
}

View File

@ -1,8 +1,11 @@
package io.metersphere.track.request.testplan;
import io.metersphere.track.dto.TestPlanScheduleReportInfoDTO;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
@Getter
@ -20,5 +23,8 @@ public class TestplanRunRequest {
private Map<String, String> envMap;
private String environmentType;
private String environmentGroupId;
private List<String> testPlanIds;
private Boolean isAll;
private TestPlanScheduleReportInfoDTO planScheduleReportInfoDTO;
}

View File

@ -29,6 +29,7 @@ import io.metersphere.track.request.report.QueryTestPlanReportRequest;
import io.metersphere.track.request.report.TestPlanReportSaveRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.request.testplan.LoadCaseRequest;
import io.metersphere.track.request.testplan.TestplanRunRequest;
import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
@ -37,8 +38,6 @@ import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -100,6 +99,8 @@ public class TestPlanReportService {
private ApiDefinitionExecResultService apiDefinitionExecResultService;
@Resource
private ApiScenarioReportService apiScenarioReportService;
@Resource
private TestPlanExecutionQueueMapper testPlanExecutionQueueMapper;
public List<TestPlanReportDTO> list(QueryTestPlanReportRequest request) {
List<TestPlanReportDTO> list = new ArrayList<>();
@ -218,7 +219,7 @@ public class TestPlanReportService {
}
}
public TestPlanScheduleReportInfoDTO genTestPlanReportBySchedule(String projectID, String planId, String userId, String triggerMode) {
public TestPlanScheduleReportInfoDTO genTestPlanReportBySchedule(String projectID, String planReportId, String planId, String userId, String triggerMode) {
Map<String, String> planScenarioIdMap = new LinkedHashMap<>();
Map<String, String> planTestCaseIdMap = new LinkedHashMap<>();
Map<String, String> performanceIdMap = new LinkedHashMap<>();
@ -236,7 +237,7 @@ public class TestPlanReportService {
for (TestPlanLoadCaseDTO dto : testPlanLoadCaseDTOList) {
performanceIdMap.put(dto.getId(), dto.getLoadCaseId());
}
String planReportId = UUID.randomUUID().toString();
Map<String, String> apiCaseInfoMap = new HashMap<>();
for (String id : planTestCaseIdMap.keySet()) {
@ -250,10 +251,21 @@ public class TestPlanReportService {
for (String id : performanceIdMap.values()) {
performanceInfoMap.put(id, TestPlanApiExecuteStatus.PREPARE.name());
}
if(StringUtils.isBlank(planReportId)){
planReportId = UUID.randomUUID().toString();
}
TestPlanReportSaveRequest saveRequest = new TestPlanReportSaveRequest(planReportId, planId, userId, triggerMode,
planTestCaseIdMap.size() > 0, planScenarioIdMap.size() > 0, performanceIdMap.size() > 0,
apiCaseInfoMap, scenarioInfoMap, performanceInfoMap);
TestPlanScheduleReportInfoDTO returnDTO = this.genTestPlanReport(saveRequest);
TestPlanScheduleReportInfoDTO returnDTO = new TestPlanScheduleReportInfoDTO();
TestPlanReport testPlanReport = this.getTestPlanReport(planReportId);
if(testPlanReport==null){
returnDTO = this.genTestPlanReport(saveRequest);
}else{
returnDTO.setTestPlanReport(testPlanReport);
}
returnDTO.setPlanScenarioIdMap(planScenarioIdMap);
returnDTO.setApiTestCaseDataMap(planTestCaseIdMap);
returnDTO.setPerformanceIdMap(performanceIdMap);
@ -446,7 +458,6 @@ public class TestPlanReportService {
testPlanReport.setUpdateTime(endTime);
}
TestPlanReportContentExample contentExample = new TestPlanReportContentExample();
contentExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReportId);
List<TestPlanReportContentWithBLOBs> contents = testPlanReportContentMapper.selectByExampleWithBLOBs(contentExample);
@ -527,6 +538,26 @@ public class TestPlanReportService {
testPlanReport.setIsScenarioExecuting(false);
testPlanReport.setIsPerformanceExecuting(false);
testPlanReport = this.update(testPlanReport);
TestPlanExecutionQueueExample testPlanExecutionQueueExample = new TestPlanExecutionQueueExample();
testPlanExecutionQueueExample.createCriteria().andReportIdEqualTo(testPlanReportId);
List<TestPlanExecutionQueue> planExecutionQueues = testPlanExecutionQueueMapper.selectByExample(testPlanExecutionQueueExample);
String runMode=null;
if(planExecutionQueues!=null&&planExecutionQueues.size()>0){
runMode = planExecutionQueues.get(0).getRunMode();
testPlanExecutionQueueMapper.deleteByExample(testPlanExecutionQueueExample);
}
if(runMode!=null&&StringUtils.equalsIgnoreCase(runMode,"serial")){
TestPlanExecutionQueueExample queueExample = new TestPlanExecutionQueueExample();
queueExample.createCriteria().andReportIdIsNotNull();
List<TestPlanExecutionQueue> planExecutionQueueList = testPlanExecutionQueueMapper.selectByExample(testPlanExecutionQueueExample);
TestPlanExecutionQueue testPlanExecutionQueue = planExecutionQueueList.get(0);
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanExecutionQueue.getTestPlanId());
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRequest());
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject,TestplanRunRequest.class);
TestPlanScheduleReportInfoDTO testPlanScheduleReportInfoDTO = this.genTestPlanReportBySchedule(null, testPlanExecutionQueue.getReportId(), testPlanExecutionQueue.getTestPlanId(), runRequest.getUserId(), runRequest.getTriggerMode());
runRequest.setPlanScheduleReportInfoDTO(testPlanScheduleReportInfoDTO);
testPlanService.runPlan(runRequest);
}
}
return testPlanReport;
}

View File

@ -43,10 +43,7 @@ import io.metersphere.track.domain.ReportComponent;
import io.metersphere.track.dto.*;
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.request.testplan.AddTestPlanRequest;
import io.metersphere.track.request.testplan.LoadCaseReportRequest;
import io.metersphere.track.request.testplan.LoadCaseRequest;
import io.metersphere.track.request.testplan.TestplanRunRequest;
import io.metersphere.track.request.testplan.*;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
import io.metersphere.utils.LoggerUtil;
import org.apache.commons.beanutils.BeanMap;
@ -179,6 +176,11 @@ public class TestPlanService {
private LoadTestMapper loadTestMapper;
@Resource
private ProjectService projectService;
@Resource
private ExtTestPlanExecutionQueueMapper extTestPlanExecutionQueueMapper;
public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) {
if (getTestPlanByName(testPlan.getName()).size() > 0) {
@ -1008,11 +1010,11 @@ public class TestPlanService {
@Transactional(propagation = Propagation.NOT_SUPPORTED)
TestPlanScheduleReportInfoDTO genTestPlanReport(String projectID, String planId, String userId, String triggerMode) {
TestPlanScheduleReportInfoDTO reportInfoDTO = testPlanReportService.genTestPlanReportBySchedule(projectID, planId, userId, triggerMode);
TestPlanScheduleReportInfoDTO reportInfoDTO = testPlanReportService.genTestPlanReportBySchedule(projectID,null, planId, userId, triggerMode);
return reportInfoDTO;
}
public String run(String testPlanID, String projectID, String userId, String triggerMode, String apiRunConfig) {
public String run(String testPlanID, String projectID, String userId, String triggerMode, TestPlanScheduleReportInfoDTO reportInfoDTO,String apiRunConfig) {
RunModeConfigDTO runModeConfig = null;
try {
runModeConfig = JSONObject.parseObject(apiRunConfig, RunModeConfigDTO.class);
@ -1030,10 +1032,10 @@ public class TestPlanService {
runModeConfig.setEnvMap(new HashMap<>());
}
}
//创建测试报告然后返回的ID重新赋值为resourceID作为后续的参数
TestPlanScheduleReportInfoDTO reportInfoDTO = this.genTestPlanReport(projectID, testPlanID, userId, triggerMode);
if(reportInfoDTO==null){
reportInfoDTO = this.genTestPlanReport(projectID, testPlanID, userId, triggerMode);
}
//测试计划准备执行取消测试计划的实际结束时间
extTestPlanMapper.updateActualEndTimeIsNullById(testPlanID);
@ -1913,12 +1915,13 @@ public class TestPlanService {
String environmentGroupId = testplanRunRequest.getEnvironmentGroupId();
RunModeConfigDTO runModeConfig = new RunModeConfigDTO();
runModeConfig.setEnvironmentType(testplanRunRequest.getEnvironmentType());
String testPlanId = testplanRunRequest.getTestPlanId();
if (StringUtils.equals(envType, EnvironmentType.JSON.name()) && !envMap.isEmpty()) {
runModeConfig.setEnvMap(testplanRunRequest.getEnvMap());
this.setPlanCaseEnv(testplanRunRequest.getTestPlanId(), runModeConfig);
this.setPlanCaseEnv(testPlanId, runModeConfig);
} else if (StringUtils.equals(envType, EnvironmentType.GROUP.name()) && StringUtils.isNotBlank(environmentGroupId)) {
runModeConfig.setEnvironmentGroupId(testplanRunRequest.getEnvironmentGroupId());
this.setPlanCaseEnv(testplanRunRequest.getTestPlanId(), runModeConfig);
this.setPlanCaseEnv(testPlanId, runModeConfig);
}
runModeConfig.setMode(testplanRunRequest.getMode());
@ -1930,8 +1933,18 @@ public class TestPlanService {
runModeConfig.setReportType(testplanRunRequest.getReportType());
}
String apiRunConfig = JSONObject.toJSONString(runModeConfig);
return this.run(testplanRunRequest.getTestPlanId(), testplanRunRequest.getProjectId(),
testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(), apiRunConfig);
String request = JSON.toJSONString(testplanRunRequest);
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanId);
testPlanWithBLOBs.setRequest(request);
testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlanWithBLOBs);
if(testplanRunRequest.getPlanScheduleReportInfoDTO()!=null){
return this.run(testPlanId, testplanRunRequest.getProjectId(),
testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(),testplanRunRequest.getPlanScheduleReportInfoDTO(), apiRunConfig);
}else{
return this.run(testPlanId, testplanRunRequest.getProjectId(),
testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(),null, apiRunConfig);
}
}
public void setPlanCaseEnv(String planId, RunModeConfigDTO runModeConfig) {
@ -2099,4 +2112,100 @@ public class TestPlanService {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
return extTestPlanMapper.list(request);
}
public List<MsExecResponseDTO> runBatch(TestplanRunRequest request) {
List<String> ids = request.getTestPlanIds();
if (CollectionUtils.isEmpty(ids)&&!request.getIsAll()) {
return new LinkedList<>();
}
LoggerUtil.debug("开始查询测试计划");
List<TestPlanWithBLOBs> planList = getTestPlanWithBLOBs(request, ids);
Map<String, TestPlanWithBLOBs> testPlanMap = planList.stream().collect(Collectors.toMap(TestPlan::getId, a -> a,(k1,k2)->k1));
Map<String, TestPlanReport> executeQueue = new LinkedHashMap<>();
List<MsExecResponseDTO> responseDTOS = new LinkedList<>();
Map<String, TestPlanScheduleReportInfoDTO> planScheduleReportInfoDTOMap = new LinkedHashMap<>();
for (TestPlanWithBLOBs testPlan : planList) {
if(StringUtils.isBlank(testPlan.getRequest())){
MSException.throwException("请保存["+testPlan.getName()+"]的运行配置");
}
//创建测试报告然后返回的ID重新赋值为resourceID作为后续的参数
TestPlanScheduleReportInfoDTO reportInfoDTO = this.genTestPlanReport(testPlan.getProjectId(), testPlan.getId(), request.getUserId(), request.getTriggerMode());
//测试计划准备执行取消测试计划的实际结束时间
extTestPlanMapper.updateActualEndTimeIsNullById(testPlan.getId());
String planReportId = reportInfoDTO.getTestPlanReport().getId();
testPlanLog.info("ReportId[" + planReportId + "] created. TestPlanID:[" + testPlan.getId() + "] ");
executeQueue.put(testPlan.getId(), reportInfoDTO.getTestPlanReport());
responseDTOS.add(new MsExecResponseDTO(testPlan.getId(), reportInfoDTO.getTestPlanReport().getId(), request.getTriggerMode()));
planScheduleReportInfoDTOMap.put(testPlan.getId(),reportInfoDTO);
}
LoggerUtil.debug("开始生成测试计划队列");
List<TestPlanExecutionQueue> planExecutionQueues = getTestPlanExecutionQueues(request, executeQueue);
if (CollectionUtils.isNotEmpty(planExecutionQueues)) {
extTestPlanExecutionQueueMapper.sqlInsert(planExecutionQueues);
}
// 开始选择执行模式
runByMode(request, testPlanMap, planScheduleReportInfoDTOMap, planExecutionQueues);
return responseDTOS;
}
private List<TestPlanExecutionQueue> getTestPlanExecutionQueues(TestplanRunRequest request, Map<String, TestPlanReport> executeQueue) {
List<TestPlanExecutionQueue>planExecutionQueues = new ArrayList<>();
executeQueue.forEach((k, v)->{
TestPlanExecutionQueue executionQueue = new TestPlanExecutionQueue();
executionQueue.setId(UUID.randomUUID().toString());
executionQueue.setCreateTime(System.currentTimeMillis());
executionQueue.setReportId(v.getId());
executionQueue.setTestPlanId(k);
executionQueue.setRunMode(request.getMode());
planExecutionQueues.add(executionQueue);
});
return planExecutionQueues;
}
private void runByMode(TestplanRunRequest request, Map<String, TestPlanWithBLOBs> testPlanMap, Map<String, TestPlanScheduleReportInfoDTO> planScheduleReportInfoDTOMap, List<TestPlanExecutionQueue> planExecutionQueues) {
if (planExecutionQueues != null&& planExecutionQueues.size()>0) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
Thread.currentThread().setName("TEST_PLAN_BATCH" + System.currentTimeMillis());
if(StringUtils.equalsIgnoreCase(request.getMode(),"serial")){
TestPlanExecutionQueue planExecutionQueue = planExecutionQueues.get(0);
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRequest());
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject,TestplanRunRequest.class);
runRequest.setPlanScheduleReportInfoDTO(planScheduleReportInfoDTOMap.get(planExecutionQueue.getTestPlanId()));
runPlan(runRequest);
}else {
for (TestPlanExecutionQueue planExecutionQueue : planExecutionQueues) {
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRequest());
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject,TestplanRunRequest.class);
runRequest.setPlanScheduleReportInfoDTO(planScheduleReportInfoDTOMap.get(planExecutionQueue.getTestPlanId()));
runPlan(runRequest);
}
}
}
});
thread.start();
}
}
private List<TestPlanWithBLOBs> getTestPlanWithBLOBs(TestplanRunRequest request, List<String> ids) {
TestPlanExample example = new TestPlanExample();
if(CollectionUtils.isNotEmpty(ids)){
example.createCriteria().andIdIn(ids);
}
example.createCriteria().andProjectIdEqualTo(request.getProjectId());
List<TestPlanWithBLOBs> planList = testPlanMapper.selectByExampleWithBLOBs(example);
return planList;
}
}

View File

@ -123,6 +123,8 @@ END//
DELIMITER ;
CALL schema_change();
ALTER TABLE `test_plan` ADD COLUMN `request` LONGTEXT COMMENT 'request (JSON format)';
--
INSERT INTO user_group_permission (id, group_id, permission_id, module_id)
VALUES (UUID(), 'project_admin', 'PROJECT_UI_SCENARIO:READ+DEBUG', 'PROJECT_UI_SCENARIO');
@ -165,3 +167,16 @@ CREATE INDEX test_case_node_project_id_index
CREATE INDEX test_case_node_id_index
ON test_case(node_id);
CREATE TABLE IF NOT EXISTS `test_plan_execution_queue`
(
`id` varchar(50) NOT NULL COMMENT 'ID',
`report_id` varchar(100) COMMENT '测试计划报告',
`run_mode` varchar(100) COMMENT '执行模式/scenario/api/test_paln_api/test_pan_scenario',
create_time bigint(13) NULL COMMENT '创建时间',
`test_plan_id` varchar(100) COMMENT 'testPlanId',
PRIMARY KEY (`id`),
KEY `report_id_idx` (`report_id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;

View File

@ -86,7 +86,7 @@
<!-- <ignoreColumn column="clean_load_report_expr"/>-->
<!-- <ignoreColumn column="repeatable"/>-->
<!-- </table>-->
<table tableName="api_definition_exec_result"/>
<table tableName="test_plan"/>
<!--<table tableName="enterprise_test_report_send_record"/>-->
<!--<table tableName="test_case_review_api_case"/>
<table tableName="test_case_review_load"/>

View File

@ -317,6 +317,23 @@
:plan-id="currentPlanId"/>
<test-plan-report-review ref="testCaseReportView"/>
<ms-task-center ref="taskCenter" :show-menu="false"/>
<el-dialog
:visible.sync="showExecute"
destroy-on-close
:title="$t('load_test.runtime_config')"
width="550px"
@close="closeExecute">
<div>
<el-radio-group v-model="batchExecuteType">
<el-radio label="serial">{{ $t("run_mode.serial") }}</el-radio>
<el-radio label="parallel">{{ $t("run_mode.parallel") }}</el-radio>
</el-radio-group>
</div><br/>
<span>运行模式仅对测试计划间有效</span>
<template v-slot:footer>
<ms-dialog-footer @cancel="closeExecute" @confirm="handleRunBatch"/>
</template>
</el-dialog>
</el-card>
</template>
@ -383,6 +400,7 @@ export default {
result: {},
cardResult: {},
enableDeleteTip: false,
showExecute:false,
queryPath: "/test/plan/list",
deletePath: "/test/plan/delete",
condition: {
@ -423,6 +441,11 @@ export default {
name: this.$t('test_track.plan.test_plan_batch_switch'),
handleClick: this.handleBatchSwitch,
permissions: ['PROJECT_TRACK_PLAN:READ+SCHEDULE']
},
{
name: this.$t('api_test.automation.batch_execute'),
handleClick: this.handleBatchExecute,
permissions: ['PROJECT_TRACK_PLAN:READ+SCHEDULE']
}
],
simpleOperators: [
@ -444,7 +467,8 @@ export default {
exec: this.openReport,
permission: ['PROJECT_TRACK_PLAN:READ+EDIT']
},
]
],
batchExecuteType:"serial"
};
},
watch: {
@ -593,6 +617,37 @@ export default {
this.$refs.scheduleBatchSwitch.open(param, size, this.condition.selectAll, this.condition);
}
},
handleBatchExecute(){
this.showExecute = true;
},
handleRunBatch(){
this.showExecute = false;
let mode = this.batchExecuteType;
let param = {mode};
const ids = [];
if (this.condition.selectAll) {
param.isAll = true;
}
else {
this.$refs.testPlanLitTable.selectRows.forEach((item) => {
ids.push(item.id)
});
}
param.testPlanId = this.currentPlanId;
param.projectId = getCurrentProjectID();
param.userId = getCurrentUserId();
param.requestOriginator = "TEST_PLAN";
param.testPlanIds = ids;
this.$refs.taskCenter.open();
this.result = this.$post('/test/plan/run/batch/', param, () => {
this.$success(this.$t('commons.run_success'));
}, error => {
// this.$error(error.message);
});
},
closeExecute(){
this.showExecute = false;
},
statusChange(data) {
if (!hasPermission('PROJECT_TRACK_PLAN:READ+EDIT')) {
return;