fix(测试跟踪): 批量执行测试计划重构,解决重复键问题
--user=郭雨琦 批量执行测试计划重构,解决重复键问题,增加批次,排序属性
This commit is contained in:
parent
777afe6bc5
commit
5efce8644a
|
@ -15,5 +15,9 @@ public class TestPlanExecutionQueue implements Serializable {
|
||||||
|
|
||||||
private String testPlanId;
|
private String testPlanId;
|
||||||
|
|
||||||
|
private String resourceId;
|
||||||
|
|
||||||
|
private Integer num;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
|
@ -443,6 +443,136 @@ public class TestPlanExecutionQueueExample {
|
||||||
addCriterion("test_plan_id not between", value1, value2, "testPlanId");
|
addCriterion("test_plan_id not between", value1, value2, "testPlanId");
|
||||||
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 andNumIsNull() {
|
||||||
|
addCriterion("num is null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumIsNotNull() {
|
||||||
|
addCriterion("num is not null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumEqualTo(Integer value) {
|
||||||
|
addCriterion("num =", value, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumNotEqualTo(Integer value) {
|
||||||
|
addCriterion("num <>", value, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumGreaterThan(Integer value) {
|
||||||
|
addCriterion("num >", value, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumGreaterThanOrEqualTo(Integer value) {
|
||||||
|
addCriterion("num >=", value, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumLessThan(Integer value) {
|
||||||
|
addCriterion("num <", value, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumLessThanOrEqualTo(Integer value) {
|
||||||
|
addCriterion("num <=", value, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumIn(List<Integer> values) {
|
||||||
|
addCriterion("num in", values, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumNotIn(List<Integer> values) {
|
||||||
|
addCriterion("num not in", values, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumBetween(Integer value1, Integer value2) {
|
||||||
|
addCriterion("num between", value1, value2, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andNumNotBetween(Integer value1, Integer value2) {
|
||||||
|
addCriterion("num not between", value1, value2, "num");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Criteria extends GeneratedCriteria {
|
public static class Criteria extends GeneratedCriteria {
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
<result column="run_mode" jdbcType="VARCHAR" property="runMode" />
|
<result column="run_mode" jdbcType="VARCHAR" property="runMode" />
|
||||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||||
<result column="test_plan_id" jdbcType="VARCHAR" property="testPlanId" />
|
<result column="test_plan_id" jdbcType="VARCHAR" property="testPlanId" />
|
||||||
|
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
|
||||||
|
<result column="num" jdbcType="INTEGER" property="num" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Example_Where_Clause">
|
<sql id="Example_Where_Clause">
|
||||||
<where>
|
<where>
|
||||||
|
@ -67,7 +69,7 @@
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, report_id, run_mode, create_time, test_plan_id
|
id, report_id, run_mode, create_time, test_plan_id, resource_id, num
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestPlanExecutionQueueExample" resultMap="BaseResultMap">
|
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestPlanExecutionQueueExample" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
|
@ -101,9 +103,11 @@
|
||||||
</delete>
|
</delete>
|
||||||
<insert id="insert" parameterType="io.metersphere.base.domain.TestPlanExecutionQueue">
|
<insert id="insert" parameterType="io.metersphere.base.domain.TestPlanExecutionQueue">
|
||||||
insert into test_plan_execution_queue (id, report_id, run_mode,
|
insert into test_plan_execution_queue (id, report_id, run_mode,
|
||||||
create_time, test_plan_id)
|
create_time, test_plan_id, resource_id,
|
||||||
|
num)
|
||||||
values (#{id,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, #{runMode,jdbcType=VARCHAR},
|
values (#{id,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, #{runMode,jdbcType=VARCHAR},
|
||||||
#{createTime,jdbcType=BIGINT}, #{testPlanId,jdbcType=VARCHAR})
|
#{createTime,jdbcType=BIGINT}, #{testPlanId,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR},
|
||||||
|
#{num,jdbcType=INTEGER})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanExecutionQueue">
|
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanExecutionQueue">
|
||||||
insert into test_plan_execution_queue
|
insert into test_plan_execution_queue
|
||||||
|
@ -123,6 +127,12 @@
|
||||||
<if test="testPlanId != null">
|
<if test="testPlanId != null">
|
||||||
test_plan_id,
|
test_plan_id,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="resourceId != null">
|
||||||
|
resource_id,
|
||||||
|
</if>
|
||||||
|
<if test="num != null">
|
||||||
|
num,
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
|
@ -140,6 +150,12 @@
|
||||||
<if test="testPlanId != null">
|
<if test="testPlanId != null">
|
||||||
#{testPlanId,jdbcType=VARCHAR},
|
#{testPlanId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="resourceId != null">
|
||||||
|
#{resourceId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="num != null">
|
||||||
|
#{num,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanExecutionQueueExample" resultType="java.lang.Long">
|
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanExecutionQueueExample" resultType="java.lang.Long">
|
||||||
|
@ -166,6 +182,12 @@
|
||||||
<if test="record.testPlanId != null">
|
<if test="record.testPlanId != null">
|
||||||
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
|
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="record.resourceId != null">
|
||||||
|
resource_id = #{record.resourceId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="record.num != null">
|
||||||
|
num = #{record.num,jdbcType=INTEGER},
|
||||||
|
</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" />
|
||||||
|
@ -177,7 +199,9 @@
|
||||||
report_id = #{record.reportId,jdbcType=VARCHAR},
|
report_id = #{record.reportId,jdbcType=VARCHAR},
|
||||||
run_mode = #{record.runMode,jdbcType=VARCHAR},
|
run_mode = #{record.runMode,jdbcType=VARCHAR},
|
||||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||||
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}
|
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
|
||||||
|
resource_id = #{record.resourceId,jdbcType=VARCHAR},
|
||||||
|
num = #{record.num,jdbcType=INTEGER}
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Update_By_Example_Where_Clause" />
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
</if>
|
</if>
|
||||||
|
@ -197,6 +221,12 @@
|
||||||
<if test="testPlanId != null">
|
<if test="testPlanId != null">
|
||||||
test_plan_id = #{testPlanId,jdbcType=VARCHAR},
|
test_plan_id = #{testPlanId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="resourceId != null">
|
||||||
|
resource_id = #{resourceId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="num != null">
|
||||||
|
num = #{num,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
</set>
|
</set>
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
|
@ -205,7 +235,9 @@
|
||||||
set report_id = #{reportId,jdbcType=VARCHAR},
|
set report_id = #{reportId,jdbcType=VARCHAR},
|
||||||
run_mode = #{runMode,jdbcType=VARCHAR},
|
run_mode = #{runMode,jdbcType=VARCHAR},
|
||||||
create_time = #{createTime,jdbcType=BIGINT},
|
create_time = #{createTime,jdbcType=BIGINT},
|
||||||
test_plan_id = #{testPlanId,jdbcType=VARCHAR}
|
test_plan_id = #{testPlanId,jdbcType=VARCHAR},
|
||||||
|
resource_id = #{resourceId,jdbcType=VARCHAR},
|
||||||
|
num = #{num,jdbcType=INTEGER}
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
|
@ -1,7 +1,9 @@
|
||||||
package io.metersphere.base.mapper.ext;
|
package io.metersphere.base.mapper.ext;
|
||||||
|
|
||||||
|
import io.metersphere.base.domain.ApiDefinition;
|
||||||
import io.metersphere.base.domain.TestPlanExecutionQueue;
|
import io.metersphere.base.domain.TestPlanExecutionQueue;
|
||||||
import org.apache.ibatis.annotations.InsertProvider;
|
import org.apache.ibatis.annotations.InsertProvider;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -9,4 +11,6 @@ public interface ExtTestPlanExecutionQueueMapper {
|
||||||
|
|
||||||
@InsertProvider(type = ExtTestPlanExecutionQueueProvider.class, method = "insertListSql")
|
@InsertProvider(type = ExtTestPlanExecutionQueueProvider.class, method = "insertListSql")
|
||||||
void sqlInsert(List<TestPlanExecutionQueue> list);
|
void sqlInsert(List<TestPlanExecutionQueue> list);
|
||||||
|
|
||||||
|
TestPlanExecutionQueue getNextNum(@Param("resourceId") String resourceId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?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.ext.ExtTestPlanExecutionQueueMapper">
|
||||||
|
<select id="getNextNum" resultType="io.metersphere.base.domain.TestPlanExecutionQueue">
|
||||||
|
SELECT * FROM test_plan_execution_queue WHERE test_plan_execution_queue.resource_id = #{resourceId} ORDER BY num DESC LIMIT 1;
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -7,7 +7,7 @@ import java.util.List;
|
||||||
public class ExtTestPlanExecutionQueueProvider {
|
public class ExtTestPlanExecutionQueueProvider {
|
||||||
public String insertListSql(List<TestPlanExecutionQueue> list) {
|
public String insertListSql(List<TestPlanExecutionQueue> list) {
|
||||||
StringBuffer sqlList = new StringBuffer();
|
StringBuffer sqlList = new StringBuffer();
|
||||||
sqlList.append("insert into test_plan_execution_queue (id,report_id, run_mode, create_time, test_plan_id) values ");
|
sqlList.append("insert into test_plan_execution_queue (id,report_id, run_mode, create_time, test_plan_id, resource_id, num) values ");
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
TestPlanExecutionQueue result = list.get(i);
|
TestPlanExecutionQueue result = list.get(i);
|
||||||
sqlList.append(" (")
|
sqlList.append(" (")
|
||||||
|
@ -21,7 +21,10 @@ public class ExtTestPlanExecutionQueueProvider {
|
||||||
.append(result.getCreateTime())
|
.append(result.getCreateTime())
|
||||||
.append("','")
|
.append("','")
|
||||||
.append(result.getTestPlanId())
|
.append(result.getTestPlanId())
|
||||||
.append("'")
|
.append("','")
|
||||||
|
.append(result.getResourceId())
|
||||||
|
.append("',")
|
||||||
|
.append(result.getNum())
|
||||||
.append(")");
|
.append(")");
|
||||||
if (i < list.size() - 1) {
|
if (i < list.size() - 1) {
|
||||||
sqlList.append(",");
|
sqlList.append(",");
|
||||||
|
|
|
@ -10,7 +10,6 @@ import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.commons.constants.*;
|
import io.metersphere.commons.constants.*;
|
||||||
import io.metersphere.commons.utils.PageUtils;
|
import io.metersphere.commons.utils.PageUtils;
|
||||||
import io.metersphere.commons.utils.Pager;
|
import io.metersphere.commons.utils.Pager;
|
||||||
import io.metersphere.dto.MsExecResponseDTO;
|
|
||||||
import io.metersphere.log.annotation.MsAuditLog;
|
import io.metersphere.log.annotation.MsAuditLog;
|
||||||
import io.metersphere.notice.annotation.SendNotice;
|
import io.metersphere.notice.annotation.SendNotice;
|
||||||
import io.metersphere.service.CheckPermissionService;
|
import io.metersphere.service.CheckPermissionService;
|
||||||
|
@ -229,9 +228,9 @@ public class TestPlanController {
|
||||||
|
|
||||||
@PostMapping(value = "/run/batch")
|
@PostMapping(value = "/run/batch")
|
||||||
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanService.class)
|
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanService.class)
|
||||||
public List<MsExecResponseDTO> runBatch(@RequestBody TestplanRunRequest request) {
|
public void runBatch(@RequestBody TestplanRunRequest request) {
|
||||||
request.setTriggerMode(TriggerMode.BATCH.name());
|
request.setTriggerMode(TriggerMode.BATCH.name());
|
||||||
return testPlanService.runBatch(request);
|
testPlanService.runBatch(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/report/export/{planId}")
|
@GetMapping("/report/export/{planId}")
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package io.metersphere.track.dto;
|
package io.metersphere.track.dto;
|
||||||
|
|
||||||
import io.metersphere.base.domain.TestPlanReport;
|
import io.metersphere.base.domain.TestPlanReport;
|
||||||
import io.metersphere.base.domain.TestPlanReportContent;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +14,7 @@ import java.util.Map;
|
||||||
@Setter
|
@Setter
|
||||||
public class TestPlanScheduleReportInfoDTO {
|
public class TestPlanScheduleReportInfoDTO {
|
||||||
private TestPlanReport testPlanReport;
|
private TestPlanReport testPlanReport;
|
||||||
private Map<String, String> planScenarioIdMap = new LinkedHashMap<>();
|
private Map<String, String> planScenarioIdMap;
|
||||||
private Map<String, String> apiTestCaseDataMap = new LinkedHashMap<>();
|
private Map<String, String> apiTestCaseDataMap;
|
||||||
private Map<String, String> performanceIdMap = new LinkedHashMap<>();
|
private Map<String, String> performanceIdMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package io.metersphere.track.request.testplan;
|
package io.metersphere.track.request.testplan;
|
||||||
|
|
||||||
|
|
||||||
import io.metersphere.track.dto.TestPlanScheduleReportInfoDTO;
|
|
||||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
@ -26,7 +24,7 @@ public class TestplanRunRequest {
|
||||||
private String environmentGroupId;
|
private String environmentGroupId;
|
||||||
private List<String> testPlanIds;
|
private List<String> testPlanIds;
|
||||||
private Boolean isAll;
|
private Boolean isAll;
|
||||||
private TestPlanScheduleReportInfoDTO planScheduleReportInfoDTO;
|
private String reportId;
|
||||||
private QueryTestPlanRequest queryTestPlanRequest;
|
private QueryTestPlanRequest queryTestPlanRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package io.metersphere.track.service;
|
||||||
|
|
||||||
|
import io.metersphere.base.domain.TestPlanExecutionQueue;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtTestPlanExecutionQueueMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TestPlanExecutionQueueService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ExtTestPlanExecutionQueueMapper extTestPlanExecutionQueueMapper;
|
||||||
|
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||||
|
public void batchSave(List<TestPlanExecutionQueue> planExecutionQueues) {
|
||||||
|
if (!planExecutionQueues.isEmpty()) {
|
||||||
|
extTestPlanExecutionQueueMapper.sqlInsert(planExecutionQueues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNextNum(String resourceId) {
|
||||||
|
TestPlanExecutionQueue testPlanExecutionQueue = extTestPlanExecutionQueueMapper.getNextNum(resourceId);
|
||||||
|
if (testPlanExecutionQueue == null || testPlanExecutionQueue.getNum() == null) {
|
||||||
|
return 100001;
|
||||||
|
} else {
|
||||||
|
return Optional.of(testPlanExecutionQueue.getNum() + 1).orElse(100001);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -221,6 +221,12 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestPlanScheduleReportInfoDTO genTestPlanReportBySchedule(String planReportId, String planId, String userId, String triggerMode) {
|
public TestPlanScheduleReportInfoDTO genTestPlanReportBySchedule(String planReportId, String planId, String userId, String triggerMode) {
|
||||||
|
TestPlanReport testPlanReport = this.getTestPlanReport(planReportId);
|
||||||
|
TestPlanScheduleReportInfoDTO returnDTO = new TestPlanScheduleReportInfoDTO();
|
||||||
|
if (testPlanReport != null) {
|
||||||
|
returnDTO.setTestPlanReport(testPlanReport);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, String> planScenarioIdMap = new LinkedHashMap<>();
|
Map<String, String> planScenarioIdMap = new LinkedHashMap<>();
|
||||||
Map<String, String> planTestCaseIdMap = new LinkedHashMap<>();
|
Map<String, String> planTestCaseIdMap = new LinkedHashMap<>();
|
||||||
Map<String, String> performanceIdMap = new LinkedHashMap<>();
|
Map<String, String> performanceIdMap = new LinkedHashMap<>();
|
||||||
|
@ -239,7 +245,6 @@ public class TestPlanReportService {
|
||||||
performanceIdMap.put(dto.getId(), dto.getLoadCaseId());
|
performanceIdMap.put(dto.getId(), dto.getLoadCaseId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Map<String, String> apiCaseInfoMap = new HashMap<>();
|
Map<String, String> apiCaseInfoMap = new HashMap<>();
|
||||||
for (String id : planTestCaseIdMap.keySet()) {
|
for (String id : planTestCaseIdMap.keySet()) {
|
||||||
apiCaseInfoMap.put(id, TestPlanApiExecuteStatus.PREPARE.name());
|
apiCaseInfoMap.put(id, TestPlanApiExecuteStatus.PREPARE.name());
|
||||||
|
@ -253,26 +258,17 @@ public class TestPlanReportService {
|
||||||
performanceInfoMap.put(id, TestPlanApiExecuteStatus.PREPARE.name());
|
performanceInfoMap.put(id, TestPlanApiExecuteStatus.PREPARE.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
TestPlanScheduleReportInfoDTO returnDTO = new TestPlanScheduleReportInfoDTO();
|
|
||||||
TestPlanReport testPlanReport;
|
|
||||||
if(StringUtils.isBlank(planReportId)){
|
|
||||||
planReportId = UUID.randomUUID().toString();
|
|
||||||
testPlanReport = null;
|
|
||||||
}else{
|
|
||||||
testPlanReport= this.getTestPlanReport(planReportId);
|
|
||||||
returnDTO.setTestPlanReport(testPlanReport);
|
|
||||||
}
|
|
||||||
|
|
||||||
TestPlanReportSaveRequest saveRequest = new TestPlanReportSaveRequest(planReportId, planId, userId, triggerMode,
|
TestPlanReportSaveRequest saveRequest = new TestPlanReportSaveRequest(planReportId, planId, userId, triggerMode,
|
||||||
planTestCaseIdMap.size() > 0, planScenarioIdMap.size() > 0, performanceIdMap.size() > 0,
|
planTestCaseIdMap.size() > 0, planScenarioIdMap.size() > 0, performanceIdMap.size() > 0,
|
||||||
apiCaseInfoMap, scenarioInfoMap, performanceInfoMap);
|
apiCaseInfoMap, scenarioInfoMap, performanceInfoMap);
|
||||||
|
|
||||||
if(testPlanReport==null){
|
if (testPlanReport == null) {
|
||||||
returnDTO = this.genTestPlanReport(saveRequest);
|
returnDTO = this.genTestPlanReport(saveRequest);
|
||||||
}
|
}
|
||||||
returnDTO.setPlanScenarioIdMap(planScenarioIdMap);
|
returnDTO.setPlanScenarioIdMap(planScenarioIdMap);
|
||||||
returnDTO.setApiTestCaseDataMap(planTestCaseIdMap);
|
returnDTO.setApiTestCaseDataMap(planTestCaseIdMap);
|
||||||
returnDTO.setPerformanceIdMap(performanceIdMap);
|
returnDTO.setPerformanceIdMap(performanceIdMap);
|
||||||
|
|
||||||
return returnDTO;
|
return returnDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +460,7 @@ public class TestPlanReportService {
|
||||||
contentExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReportId);
|
contentExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReportId);
|
||||||
List<TestPlanReportContentWithBLOBs> contents = testPlanReportContentMapper.selectByExampleWithBLOBs(contentExample);
|
List<TestPlanReportContentWithBLOBs> contents = testPlanReportContentMapper.selectByExampleWithBLOBs(contentExample);
|
||||||
TestPlanReportContentWithBLOBs content = null;
|
TestPlanReportContentWithBLOBs content = null;
|
||||||
if(CollectionUtils.isNotEmpty(contents)){
|
if (CollectionUtils.isNotEmpty(contents)) {
|
||||||
content = contents.get(0);
|
content = contents.get(0);
|
||||||
}
|
}
|
||||||
boolean hasErrorCase = false;
|
boolean hasErrorCase = false;
|
||||||
|
@ -497,16 +493,16 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
content.setPlanApiCaseReportStruct(JSONObject.toJSONString(apiTestCases));
|
content.setPlanApiCaseReportStruct(JSONObject.toJSONString(apiTestCases));
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
LogUtil.error("update test plan api error! "+e.getMessage());
|
LogUtil.error("update test plan api error! " , e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(StringUtils.isNotEmpty(content.getPlanScenarioReportStruct())){
|
if (StringUtils.isNotEmpty(content.getPlanScenarioReportStruct())) {
|
||||||
try {
|
try {
|
||||||
List<TestPlanFailureScenarioDTO> scenarioCases = JSONArray.parseArray(content.getPlanScenarioReportStruct(),TestPlanFailureScenarioDTO.class);
|
List<TestPlanFailureScenarioDTO> scenarioCases = JSONArray.parseArray(content.getPlanScenarioReportStruct(), TestPlanFailureScenarioDTO.class);
|
||||||
List<String> reportIdList = new ArrayList<>();
|
List<String> reportIdList = new ArrayList<>();
|
||||||
scenarioCases.forEach( item -> {
|
scenarioCases.forEach(item -> {
|
||||||
if(StringUtils.isNotEmpty(item.getReportId())){
|
if (StringUtils.isNotEmpty(item.getReportId())) {
|
||||||
reportIdList.add(item.getReportId());
|
reportIdList.add(item.getReportId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -532,8 +528,8 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
content.setPlanScenarioReportStruct(JSONObject.toJSONString(scenarioCases));
|
content.setPlanScenarioReportStruct(JSONObject.toJSONString(scenarioCases));
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
LogUtil.error("update test plan api error! "+e.getMessage());
|
LogUtil.error("update test plan api error! " , e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//更新content表对结束日期
|
//更新content表对结束日期
|
||||||
|
@ -559,24 +555,26 @@ public class TestPlanReportService {
|
||||||
TestPlanExecutionQueueExample testPlanExecutionQueueExample = new TestPlanExecutionQueueExample();
|
TestPlanExecutionQueueExample testPlanExecutionQueueExample = new TestPlanExecutionQueueExample();
|
||||||
testPlanExecutionQueueExample.createCriteria().andReportIdEqualTo(testPlanReportId);
|
testPlanExecutionQueueExample.createCriteria().andReportIdEqualTo(testPlanReportId);
|
||||||
List<TestPlanExecutionQueue> planExecutionQueues = testPlanExecutionQueueMapper.selectByExample(testPlanExecutionQueueExample);
|
List<TestPlanExecutionQueue> planExecutionQueues = testPlanExecutionQueueMapper.selectByExample(testPlanExecutionQueueExample);
|
||||||
String runMode=null;
|
String runMode = null;
|
||||||
if(CollectionUtils.isNotEmpty(planExecutionQueues)){
|
String resourceId = null;
|
||||||
|
if (CollectionUtils.isNotEmpty(planExecutionQueues)) {
|
||||||
runMode = planExecutionQueues.get(0).getRunMode();
|
runMode = planExecutionQueues.get(0).getRunMode();
|
||||||
|
resourceId = planExecutionQueues.get(0).getResourceId();
|
||||||
testPlanExecutionQueueMapper.deleteByExample(testPlanExecutionQueueExample);
|
testPlanExecutionQueueMapper.deleteByExample(testPlanExecutionQueueExample);
|
||||||
}
|
}
|
||||||
if(runMode!=null&&StringUtils.equalsIgnoreCase(runMode, RunModeConstants.SERIAL.name())){
|
if (runMode != null && StringUtils.equalsIgnoreCase(runMode, RunModeConstants.SERIAL.name()) && resourceId != null) {
|
||||||
TestPlanExecutionQueueExample queueExample = new TestPlanExecutionQueueExample();
|
TestPlanExecutionQueueExample queueExample = new TestPlanExecutionQueueExample();
|
||||||
queueExample.createCriteria().andReportIdIsNotNull();
|
queueExample.createCriteria().andReportIdIsNotNull().andResourceIdEqualTo(resourceId);
|
||||||
|
queueExample.setOrderByClause("`num` ASC");
|
||||||
List<TestPlanExecutionQueue> planExecutionQueueList = testPlanExecutionQueueMapper.selectByExample(queueExample);
|
List<TestPlanExecutionQueue> planExecutionQueueList = testPlanExecutionQueueMapper.selectByExample(queueExample);
|
||||||
if(CollectionUtils.isEmpty(planExecutionQueueList)){
|
if (CollectionUtils.isEmpty(planExecutionQueueList)) {
|
||||||
return testPlanReport;
|
return testPlanReport;
|
||||||
}
|
}
|
||||||
TestPlanExecutionQueue testPlanExecutionQueue = planExecutionQueueList.get(0);
|
TestPlanExecutionQueue testPlanExecutionQueue = planExecutionQueueList.get(0);
|
||||||
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanExecutionQueue.getTestPlanId());
|
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanExecutionQueue.getTestPlanId());
|
||||||
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
|
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
|
||||||
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject,TestplanRunRequest.class);
|
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestplanRunRequest.class);
|
||||||
TestPlanScheduleReportInfoDTO testPlanScheduleReportInfoDTO = this.genTestPlanReportBySchedule( testPlanExecutionQueue.getReportId(), testPlanExecutionQueue.getTestPlanId(), runRequest.getUserId(), runRequest.getTriggerMode());
|
runRequest.setReportId(testPlanExecutionQueue.getReportId());
|
||||||
runRequest.setPlanScheduleReportInfoDTO(testPlanScheduleReportInfoDTO);
|
|
||||||
testPlanService.runPlan(runRequest);
|
testPlanService.runPlan(runRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -689,10 +687,10 @@ public class TestPlanReportService {
|
||||||
if (reportDTO.getErrorReportScenarios() != null) {
|
if (reportDTO.getErrorReportScenarios() != null) {
|
||||||
testPlanReportContentWithBLOBs.setErrorReportScenarios(JSONObject.toJSONString(reportDTO.getErrorReportScenarios()));
|
testPlanReportContentWithBLOBs.setErrorReportScenarios(JSONObject.toJSONString(reportDTO.getErrorReportScenarios()));
|
||||||
}
|
}
|
||||||
if(reportDTO.getUnExecuteCases() != null){
|
if (reportDTO.getUnExecuteCases() != null) {
|
||||||
testPlanReportContentWithBLOBs.setUnExecuteCases(JSONObject.toJSONString(reportDTO.getUnExecuteCases()));
|
testPlanReportContentWithBLOBs.setUnExecuteCases(JSONObject.toJSONString(reportDTO.getUnExecuteCases()));
|
||||||
}
|
}
|
||||||
if(reportDTO.getUnExecuteScenarios() != null){
|
if (reportDTO.getUnExecuteScenarios() != null) {
|
||||||
testPlanReportContentWithBLOBs.setUnExecuteScenarios(JSONObject.toJSONString(reportDTO.getUnExecuteScenarios()));
|
testPlanReportContentWithBLOBs.setUnExecuteScenarios(JSONObject.toJSONString(reportDTO.getUnExecuteScenarios()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1007,9 +1005,9 @@ public class TestPlanReportService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (this.isDynamicallyGenerateReports(testPlanReportContent)) {
|
if (this.isDynamicallyGenerateReports(testPlanReportContent)) {
|
||||||
Log.info("----> GenerateReports: "+ JSONObject.toJSONString(testPlanReportContent));
|
LogUtil.info("----> GenerateReports: " + JSONObject.toJSONString(testPlanReportContent));
|
||||||
testPlanReportContent = this.dynamicallyGenerateReports(testPlanReportContent);
|
testPlanReportContent = this.dynamicallyGenerateReports(testPlanReportContent);
|
||||||
Log.info("----> GenerateReports OVER: "+ JSONObject.toJSONString(testPlanReportContent));
|
LogUtil.info("----> GenerateReports OVER: " + JSONObject.toJSONString(testPlanReportContent));
|
||||||
}
|
}
|
||||||
TestPlanSimpleReportDTO testPlanReportDTO = new TestPlanSimpleReportDTO();
|
TestPlanSimpleReportDTO testPlanReportDTO = new TestPlanSimpleReportDTO();
|
||||||
BeanUtils.copyBean(testPlanReportDTO, testPlanReportContent);
|
BeanUtils.copyBean(testPlanReportDTO, testPlanReportContent);
|
||||||
|
@ -1084,7 +1082,7 @@ public class TestPlanReportService {
|
||||||
content.setTestPlanReportId(testPlanReportID);
|
content.setTestPlanReportId(testPlanReportID);
|
||||||
|
|
||||||
if (MapUtils.isNotEmpty(apiCaseReportMap)) {
|
if (MapUtils.isNotEmpty(apiCaseReportMap)) {
|
||||||
List<TestPlanFailureApiDTO> apiTestCases = extTestPlanApiCaseMapper.getFailureListByIds(apiCaseReportMap.keySet(),null);
|
List<TestPlanFailureApiDTO> apiTestCases = extTestPlanApiCaseMapper.getFailureListByIds(apiCaseReportMap.keySet(), null);
|
||||||
for (TestPlanFailureApiDTO dto : apiTestCases) {
|
for (TestPlanFailureApiDTO dto : apiTestCases) {
|
||||||
dto.setReportId(apiCaseReportMap.get(dto.getId()));
|
dto.setReportId(apiCaseReportMap.get(dto.getId()));
|
||||||
}
|
}
|
||||||
|
@ -1114,30 +1112,35 @@ public class TestPlanReportService {
|
||||||
if (StringUtils.isNotEmpty(testPlanReportContentWithBLOBs.getPlanApiCaseReportStruct())) {
|
if (StringUtils.isNotEmpty(testPlanReportContentWithBLOBs.getPlanApiCaseReportStruct())) {
|
||||||
try {
|
try {
|
||||||
apiCaseInfoDTOList = JSONArray.parseArray(testPlanReportContentWithBLOBs.getPlanApiCaseReportStruct(), TestPlanFailureApiDTO.class);
|
apiCaseInfoDTOList = JSONArray.parseArray(testPlanReportContentWithBLOBs.getPlanApiCaseReportStruct(), TestPlanFailureApiDTO.class);
|
||||||
}catch (Exception ignore){}
|
} catch (Exception e) {
|
||||||
if(apiCaseInfoDTOList == null){
|
LogUtil.error(e);
|
||||||
|
}
|
||||||
|
if (apiCaseInfoDTOList == null) {
|
||||||
try {
|
try {
|
||||||
testPlanApiCaseIdAndReportIdMap = JSONObject.parseObject(testPlanReportContentWithBLOBs.getPlanApiCaseReportStruct(), Map.class);
|
testPlanApiCaseIdAndReportIdMap = JSONObject.parseObject(testPlanReportContentWithBLOBs.getPlanApiCaseReportStruct(), Map.class);
|
||||||
} catch (Exception ignore) {
|
} catch (Exception e) {
|
||||||
|
LogUtil.error(e);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
for (TestPlanFailureApiDTO item : apiCaseInfoDTOList) {
|
for (TestPlanFailureApiDTO item : apiCaseInfoDTOList) {
|
||||||
testPlanApiCaseIdAndReportIdMap.put(item.getId(),item.getReportId());
|
testPlanApiCaseIdAndReportIdMap.put(item.getId(), item.getReportId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(testPlanReportContentWithBLOBs.getPlanScenarioReportStruct())) {
|
if (StringUtils.isNotEmpty(testPlanReportContentWithBLOBs.getPlanScenarioReportStruct())) {
|
||||||
try {
|
try {
|
||||||
scenarioInfoDTOList = JSONArray.parseArray(testPlanReportContentWithBLOBs.getPlanScenarioReportStruct(), TestPlanFailureScenarioDTO.class);
|
scenarioInfoDTOList = JSONArray.parseArray(testPlanReportContentWithBLOBs.getPlanScenarioReportStruct(), TestPlanFailureScenarioDTO.class);
|
||||||
}catch (Exception ignore){}
|
} catch (Exception e) {
|
||||||
if(scenarioInfoDTOList == null){
|
LogUtil.error(e);
|
||||||
|
}
|
||||||
|
if (scenarioInfoDTOList == null) {
|
||||||
try {
|
try {
|
||||||
testPlanScenarioIdAndReportIdMap = JSONObject.parseObject(testPlanReportContentWithBLOBs.getPlanScenarioReportStruct(), Map.class);
|
testPlanScenarioIdAndReportIdMap = JSONObject.parseObject(testPlanReportContentWithBLOBs.getPlanScenarioReportStruct(), Map.class);
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
for (TestPlanFailureScenarioDTO item : scenarioInfoDTOList) {
|
for (TestPlanFailureScenarioDTO item : scenarioInfoDTOList) {
|
||||||
testPlanScenarioIdAndReportIdMap.put(item.getId(),item.getReportId());
|
testPlanScenarioIdAndReportIdMap.put(item.getId(), item.getReportId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1148,7 +1151,7 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TestPlanExecuteReportDTO returnDTO = new TestPlanExecuteReportDTO(testPlanApiCaseIdAndReportIdMap, testPlanScenarioIdAndReportIdMap, testPlanLoadCaseIdAndReportIdMap,apiCaseInfoDTOList,scenarioInfoDTOList);
|
TestPlanExecuteReportDTO returnDTO = new TestPlanExecuteReportDTO(testPlanApiCaseIdAndReportIdMap, testPlanScenarioIdAndReportIdMap, testPlanLoadCaseIdAndReportIdMap, apiCaseInfoDTOList, scenarioInfoDTOList);
|
||||||
return returnDTO;
|
return returnDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,8 +176,7 @@ public class TestPlanService {
|
||||||
@Resource
|
@Resource
|
||||||
private ProjectService projectService;
|
private ProjectService projectService;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtTestPlanExecutionQueueMapper extTestPlanExecutionQueueMapper;
|
private TestPlanExecutionQueueService testPlanExecutionQueueService;
|
||||||
|
|
||||||
|
|
||||||
public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) {
|
public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) {
|
||||||
if (getTestPlanByName(testPlan.getName()).size() > 0) {
|
if (getTestPlanByName(testPlan.getName()).size() > 0) {
|
||||||
|
@ -937,12 +936,12 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||||
TestPlanScheduleReportInfoDTO genTestPlanReport(String projectID, String planId, String userId, String triggerMode) {
|
TestPlanScheduleReportInfoDTO genTestPlanReport(String planReportId, String planId, String userId, String triggerMode) {
|
||||||
TestPlanScheduleReportInfoDTO reportInfoDTO = testPlanReportService.genTestPlanReportBySchedule(null, planId, userId, triggerMode);
|
TestPlanScheduleReportInfoDTO reportInfoDTO = testPlanReportService.genTestPlanReportBySchedule(planReportId, planId, userId, triggerMode);
|
||||||
return reportInfoDTO;
|
return reportInfoDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String run(String testPlanID, String projectID, String userId, String triggerMode, TestPlanScheduleReportInfoDTO reportInfoDTO, String apiRunConfig) {
|
public String run(String testPlanID, String projectID, String userId, String triggerMode, String planReportId, String apiRunConfig) {
|
||||||
RunModeConfigDTO runModeConfig = null;
|
RunModeConfigDTO runModeConfig = null;
|
||||||
try {
|
try {
|
||||||
runModeConfig = JSONObject.parseObject(apiRunConfig, RunModeConfigDTO.class);
|
runModeConfig = JSONObject.parseObject(apiRunConfig, RunModeConfigDTO.class);
|
||||||
|
@ -960,28 +959,41 @@ public class TestPlanService {
|
||||||
runModeConfig.setEnvMap(new HashMap<>());
|
runModeConfig.setEnvMap(new HashMap<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//创建测试报告,然后返回的ID重新赋值为resourceID,作为后续的参数
|
if (planReportId == null) {
|
||||||
if (reportInfoDTO == null) {
|
planReportId = UUID.randomUUID().toString();
|
||||||
reportInfoDTO = this.genTestPlanReport(projectID, testPlanID, userId, triggerMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//创建测试报告,然后返回的ID重新赋值为resourceID,作为后续的参数
|
||||||
|
TestPlanScheduleReportInfoDTO reportInfoDTO = this.genTestPlanReport(planReportId, testPlanID, userId, triggerMode);
|
||||||
//测试计划准备执行,取消测试计划的实际结束时间
|
//测试计划准备执行,取消测试计划的实际结束时间
|
||||||
extTestPlanMapper.updateActualEndTimeIsNullById(testPlanID);
|
extTestPlanMapper.updateActualEndTimeIsNullById(testPlanID);
|
||||||
|
|
||||||
String planReportId = reportInfoDTO.getTestPlanReport().getId();
|
|
||||||
testPlanLog.info("ReportId[" + planReportId + "] created. TestPlanID:[" + testPlanID + "]. " + "API Run Config:【" + apiRunConfig + "】");
|
testPlanLog.info("ReportId[" + planReportId + "] created. TestPlanID:[" + testPlanID + "]. " + "API Run Config:【" + apiRunConfig + "】");
|
||||||
|
|
||||||
|
Map<String, String> apiCaseReportMap = null;
|
||||||
|
Map<String, String> scenarioReportMap = null;
|
||||||
|
Map<String, String> loadCaseReportMap = null;
|
||||||
|
if(reportInfoDTO.getApiTestCaseDataMap()!=null){
|
||||||
|
//执行接口案例任务
|
||||||
|
LoggerUtil.info("开始执行测试计划接口用例 " + planReportId);
|
||||||
|
apiCaseReportMap = this.executeApiTestCase(triggerMode, planReportId, userId, new ArrayList<>(reportInfoDTO.getApiTestCaseDataMap().keySet()), runModeConfig);
|
||||||
|
}
|
||||||
|
if(reportInfoDTO.getPlanScenarioIdMap()!=null){
|
||||||
|
//执行场景执行任务
|
||||||
|
LoggerUtil.info("开始执行测试计划场景用例 " + planReportId);
|
||||||
|
scenarioReportMap = this.executeScenarioCase(planReportId, testPlanID, projectID, runModeConfig, triggerMode, userId, reportInfoDTO.getPlanScenarioIdMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(reportInfoDTO.getPerformanceIdMap()!=null){
|
||||||
|
//执行性能测试任务
|
||||||
|
LoggerUtil.info("开始执行测试计划性能用例 " + planReportId);
|
||||||
|
loadCaseReportMap = this.executeLoadCaseTask(planReportId,runModeConfig, triggerMode, reportInfoDTO.getPerformanceIdMap());
|
||||||
|
}
|
||||||
|
if(apiCaseReportMap!=null&&scenarioReportMap!=null&&loadCaseReportMap!=null){
|
||||||
|
LoggerUtil.info("开始生成测试计划报告 " + planReportId);
|
||||||
|
testPlanReportService.createTestPlanReportContentReportIds(planReportId, apiCaseReportMap, scenarioReportMap, loadCaseReportMap);
|
||||||
|
}
|
||||||
|
|
||||||
//执行接口案例任务
|
|
||||||
LoggerUtil.info("开始执行测试计划接口用例 " + planReportId);
|
|
||||||
Map<String, String> apiCaseReportMap = this.executeApiTestCase(triggerMode, planReportId, userId, new ArrayList<>(reportInfoDTO.getApiTestCaseDataMap().keySet()), runModeConfig);
|
|
||||||
//执行场景执行任务
|
|
||||||
LoggerUtil.info("开始执行测试计划场景用例 " + planReportId);
|
|
||||||
Map<String, String> scenarioReportMap = this.executeScenarioCase(planReportId, testPlanID, projectID, runModeConfig, triggerMode, userId, reportInfoDTO.getPlanScenarioIdMap());
|
|
||||||
//执行性能测试任务
|
|
||||||
LoggerUtil.info("开始执行测试计划性能用例 " + planReportId);
|
|
||||||
Map<String, String> loadCaseReportMap = this.executeLoadCaseTask(planReportId, runModeConfig, triggerMode, reportInfoDTO.getPerformanceIdMap());
|
|
||||||
LoggerUtil.info("开始生成测试计划报告 " + planReportId);
|
|
||||||
testPlanReportService.createTestPlanReportContentReportIds(planReportId, apiCaseReportMap, scenarioReportMap, loadCaseReportMap);
|
|
||||||
return planReportId;
|
return planReportId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1852,7 +1864,7 @@ public class TestPlanService {
|
||||||
String apiRunConfig = JSONObject.toJSONString(runModeConfig);
|
String apiRunConfig = JSONObject.toJSONString(runModeConfig);
|
||||||
updatePlan(testplanRunRequest, testPlanId);
|
updatePlan(testplanRunRequest, testPlanId);
|
||||||
return this.run(testPlanId, testplanRunRequest.getProjectId(),
|
return this.run(testPlanId, testplanRunRequest.getProjectId(),
|
||||||
testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(), testplanRunRequest.getPlanScheduleReportInfoDTO() != null ? testplanRunRequest.getPlanScheduleReportInfoDTO() : null, apiRunConfig);
|
testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(), testplanRunRequest.getReportId(), apiRunConfig);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2052,10 +2064,10 @@ public class TestPlanService {
|
||||||
return extTestPlanMapper.list(request);
|
return extTestPlanMapper.list(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MsExecResponseDTO> runBatch(TestplanRunRequest request) {
|
public void runBatch(TestplanRunRequest request) {
|
||||||
List<String> ids = request.getTestPlanIds();
|
List<String> ids = request.getTestPlanIds();
|
||||||
if (CollectionUtils.isEmpty(ids) && !request.getIsAll()) {
|
if (CollectionUtils.isEmpty(ids) && !request.getIsAll()) {
|
||||||
return new LinkedList<>();
|
return;
|
||||||
}
|
}
|
||||||
LoggerUtil.info("开始查询测试计划");
|
LoggerUtil.info("开始查询测试计划");
|
||||||
List<TestPlanWithBLOBs> planList = new ArrayList<>();
|
List<TestPlanWithBLOBs> planList = new ArrayList<>();
|
||||||
|
@ -2070,25 +2082,31 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, TestPlanWithBLOBs> testPlanMap = planList.stream().collect(Collectors.toMap(TestPlan::getId, a -> a, (k1, k2) -> k1));
|
Map<String, TestPlanWithBLOBs> testPlanMap = planList.stream().collect(Collectors.toMap(TestPlan::getId, a -> a, (k1, k2) -> k1));
|
||||||
Map<String, TestPlanReport> executeQueue = new LinkedHashMap<>();
|
Map<String, String> executeQueue = new LinkedHashMap<>();
|
||||||
List<MsExecResponseDTO> responseDTOS = new LinkedList<>();
|
|
||||||
Map<String, TestPlanScheduleReportInfoDTO> planScheduleReportInfoDTOMap = new LinkedHashMap<>();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
boolean startThread = true;
|
for (int i = 0; i < planList.size(); i++) {
|
||||||
|
if (StringUtils.isBlank(planList.get(i).getRunModeConfig())) {
|
||||||
|
StringBuilder append = stringBuilder.append("请保存[").append(planList.get(i).getName()).append("]的运行配置");
|
||||||
|
if (i <= planList.size() - 2) {
|
||||||
|
append.append("/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(stringBuilder)) {
|
||||||
|
MSException.throwException(stringBuilder.toString());
|
||||||
|
}
|
||||||
|
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
TestPlanWithBLOBs testPlan = testPlanMap.get(id);
|
TestPlanWithBLOBs testPlan = testPlanMap.get(id);
|
||||||
if (StringUtils.isBlank(testPlan.getRunModeConfig())) {
|
String planReportId = UUID.randomUUID().toString();
|
||||||
startThread = false;
|
//创建测试报告
|
||||||
MSException.throwException("请保存[" + testPlan.getName() + "]的运行配置");
|
this.genTestPlanReport(planReportId, testPlan.getId(), request.getUserId(), request.getTriggerMode());
|
||||||
}
|
|
||||||
//创建测试报告,然后返回的ID重新赋值为resourceID,作为后续的参数
|
|
||||||
TestPlanScheduleReportInfoDTO reportInfoDTO = this.genTestPlanReport(testPlan.getProjectId(), testPlan.getId(), request.getUserId(), request.getTriggerMode());
|
|
||||||
|
|
||||||
//测试计划准备执行,取消测试计划的实际结束时间
|
//测试计划准备执行,取消测试计划的实际结束时间
|
||||||
extTestPlanMapper.updateActualEndTimeIsNullById(testPlan.getId());
|
extTestPlanMapper.updateActualEndTimeIsNullById(testPlan.getId());
|
||||||
|
executeQueue.put(testPlan.getId(), planReportId);
|
||||||
|
|
||||||
executeQueue.put(testPlan.getId(), reportInfoDTO.getTestPlanReport());
|
|
||||||
responseDTOS.add(new MsExecResponseDTO(testPlan.getId(), reportInfoDTO.getTestPlanReport().getId(), request.getTriggerMode()));
|
|
||||||
planScheduleReportInfoDTOMap.put(testPlan.getId(), reportInfoDTO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LoggerUtil.info("开始生成测试计划队列");
|
LoggerUtil.info("开始生成测试计划队列");
|
||||||
|
@ -2096,29 +2114,34 @@ public class TestPlanService {
|
||||||
List<TestPlanExecutionQueue> planExecutionQueues = getTestPlanExecutionQueues(request, executeQueue);
|
List<TestPlanExecutionQueue> planExecutionQueues = getTestPlanExecutionQueues(request, executeQueue);
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(planExecutionQueues)) {
|
if (CollectionUtils.isNotEmpty(planExecutionQueues)) {
|
||||||
extTestPlanExecutionQueueMapper.sqlInsert(planExecutionQueues);
|
testPlanExecutionQueueService.batchSave(planExecutionQueues);
|
||||||
}
|
}
|
||||||
// 开始选择执行模式
|
// 开始选择执行模式
|
||||||
runByMode(startThread, request, testPlanMap, planScheduleReportInfoDTOMap, planExecutionQueues);
|
runByMode(request, testPlanMap, planExecutionQueues);
|
||||||
|
|
||||||
return responseDTOS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TestPlanExecutionQueue> getTestPlanExecutionQueues(TestplanRunRequest request, Map<String, TestPlanReport> executeQueue) {
|
|
||||||
List<TestPlanExecutionQueue> planExecutionQueues = new ArrayList<>();
|
private List<TestPlanExecutionQueue> getTestPlanExecutionQueues(TestplanRunRequest request, Map<String, String> executeQueue) {
|
||||||
executeQueue.forEach((k, v) -> {
|
List<TestPlanExecutionQueue>planExecutionQueues = new ArrayList<>();
|
||||||
|
String resourceId = UUID.randomUUID().toString();
|
||||||
|
final int[] nextNum = {testPlanExecutionQueueService.getNextNum(resourceId)};
|
||||||
|
executeQueue.forEach((k, v)->{
|
||||||
TestPlanExecutionQueue executionQueue = new TestPlanExecutionQueue();
|
TestPlanExecutionQueue executionQueue = new TestPlanExecutionQueue();
|
||||||
executionQueue.setId(UUID.randomUUID().toString());
|
executionQueue.setId(UUID.randomUUID().toString());
|
||||||
executionQueue.setCreateTime(System.currentTimeMillis());
|
executionQueue.setCreateTime(System.currentTimeMillis());
|
||||||
executionQueue.setReportId(v.getId());
|
executionQueue.setReportId(v);
|
||||||
executionQueue.setTestPlanId(k);
|
executionQueue.setTestPlanId(k);
|
||||||
executionQueue.setRunMode(request.getMode());
|
executionQueue.setRunMode(request.getMode());
|
||||||
|
executionQueue.setResourceId(resourceId);
|
||||||
|
executionQueue.setNum(nextNum[0]);
|
||||||
|
nextNum[0]++;
|
||||||
planExecutionQueues.add(executionQueue);
|
planExecutionQueues.add(executionQueue);
|
||||||
});
|
});
|
||||||
return planExecutionQueues;
|
return planExecutionQueues;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runByMode(boolean startThread, TestplanRunRequest request, Map<String, TestPlanWithBLOBs> testPlanMap, Map<String, TestPlanScheduleReportInfoDTO> planScheduleReportInfoDTOMap, List<TestPlanExecutionQueue> planExecutionQueues) {
|
private void runByMode(TestplanRunRequest request, Map<String, TestPlanWithBLOBs> testPlanMap, List<TestPlanExecutionQueue> planExecutionQueues) {
|
||||||
if (CollectionUtils.isNotEmpty(planExecutionQueues)) {
|
if (CollectionUtils.isNotEmpty(planExecutionQueues)) {
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -2128,23 +2151,21 @@ public class TestPlanService {
|
||||||
TestPlanExecutionQueue planExecutionQueue = planExecutionQueues.get(0);
|
TestPlanExecutionQueue planExecutionQueue = planExecutionQueues.get(0);
|
||||||
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
|
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
|
||||||
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
|
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
|
||||||
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestplanRunRequest.class);
|
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject,TestplanRunRequest.class);
|
||||||
runRequest.setPlanScheduleReportInfoDTO(planScheduleReportInfoDTOMap.get(planExecutionQueue.getTestPlanId()));
|
runRequest.setReportId(planExecutionQueue.getReportId());
|
||||||
runPlan(runRequest);
|
runPlan(runRequest);
|
||||||
} else {
|
}else {
|
||||||
for (TestPlanExecutionQueue planExecutionQueue : planExecutionQueues) {
|
for (TestPlanExecutionQueue planExecutionQueue : planExecutionQueues) {
|
||||||
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
|
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
|
||||||
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
|
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
|
||||||
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestplanRunRequest.class);
|
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject,TestplanRunRequest.class);
|
||||||
runRequest.setPlanScheduleReportInfoDTO(planScheduleReportInfoDTOMap.get(planExecutionQueue.getTestPlanId()));
|
runRequest.setReportId(planExecutionQueue.getReportId());
|
||||||
runPlan(runRequest);
|
runPlan(runRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (startThread) {
|
thread.start();
|
||||||
thread.start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,16 +181,18 @@ CREATE TABLE IF NOT EXISTS `test_plan_execution_queue`
|
||||||
`run_mode` varchar(100) COMMENT '执行模式/scenario/api/test_paln_api/test_pan_scenario',
|
`run_mode` varchar(100) COMMENT '执行模式/scenario/api/test_paln_api/test_pan_scenario',
|
||||||
create_time bigint(13) NULL COMMENT '创建时间',
|
create_time bigint(13) NULL COMMENT '创建时间',
|
||||||
`test_plan_id` varchar(100) COMMENT 'testPlanId',
|
`test_plan_id` varchar(100) COMMENT 'testPlanId',
|
||||||
|
`resource_id` varchar(100) COMMENT 'resourceId/批次id',
|
||||||
|
`num` int null comment 'order',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `report_id_idx` (`report_id`)
|
KEY `report_id_idx` (`report_id`),
|
||||||
|
KEY `resource_id_index` (`resource_id`),
|
||||||
|
KEY `num_index` (`num`)
|
||||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;
|
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;
|
||||||
|
|
||||||
-- 场景步骤结果增加简要信息
|
-- 场景步骤结果增加简要信息
|
||||||
ALTER TABLE api_scenario_report_result ADD `base_info` LONGTEXT NULL;
|
ALTER TABLE api_scenario_report_result ADD `base_info` LONGTEXT NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- quota
|
-- quota
|
||||||
-- 处理移除组织时遗留的脏数据
|
-- 处理移除组织时遗留的脏数据
|
||||||
delete
|
delete
|
||||||
|
|
|
@ -86,7 +86,7 @@
|
||||||
<!-- <ignoreColumn column="clean_load_report_expr"/>-->
|
<!-- <ignoreColumn column="clean_load_report_expr"/>-->
|
||||||
<!-- <ignoreColumn column="repeatable"/>-->
|
<!-- <ignoreColumn column="repeatable"/>-->
|
||||||
<!-- </table>-->
|
<!-- </table>-->
|
||||||
<table tableName="test_plan"/>
|
<table tableName="test_plan_execution_queue"/>
|
||||||
<!--<table tableName="enterprise_test_report_send_record"/>-->
|
<!--<table tableName="enterprise_test_report_send_record"/>-->
|
||||||
<!--<table tableName="test_case_review_api_case"/>
|
<!--<table tableName="test_case_review_api_case"/>
|
||||||
<table tableName="test_case_review_load"/>
|
<table tableName="test_case_review_load"/>
|
||||||
|
|
Loading…
Reference in New Issue