# Conflicts:
#	backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java
This commit is contained in:
fit2-zhao 2021-01-18 18:15:31 +08:00
commit 7fdf8b4154
36 changed files with 465 additions and 253 deletions

View File

@ -182,7 +182,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
apiDefinitionExecResultService.saveApiResultByScheduleTask(testResult, ApiRunMode.SCHEDULE_API_PLAN.name()); apiDefinitionExecResultService.saveApiResultByScheduleTask(testResult, ApiRunMode.SCHEDULE_API_PLAN.name());
List<String> testPlanReportIdList = new ArrayList<>(); List<String> testPlanReportIdList = new ArrayList<>();
testPlanReportIdList.add(debugReportId); testPlanReportIdList.add(debugReportId);
testPlanReportService.updateReport(testPlanReportIdList,ApiRunMode.SCHEDULE_API_PLAN.name()); testPlanReportService.updateReport(testPlanReportIdList,ApiRunMode.SCHEDULE_API_PLAN.name(),ReportTriggerMode.SCHEDULE.name());
}else { }else {
apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.API_PLAN.name()); apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.API_PLAN.name());
} }

View File

@ -190,7 +190,7 @@ public class ApiDefinitionService {
.andProtocolEqualTo(request.getProtocol()).andPathEqualTo(request.getPath()) .andProtocolEqualTo(request.getProtocol()).andPathEqualTo(request.getPath())
.andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId()); .andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId());
Project project = projectMapper.selectByPrimaryKey(request.getProjectId()); Project project = projectMapper.selectByPrimaryKey(request.getProjectId());
if (apiDefinitionMapper.countByExample(example) > 0 && !project.getRepeatable()) { if (apiDefinitionMapper.countByExample(example) > 0 && (project.getRepeatable() == null || !project.getRepeatable())) {
MSException.throwException(Translator.get("api_definition_url_not_repeating")); MSException.throwException(Translator.get("api_definition_url_not_repeating"));
} }
} else { } else {

View File

@ -16,6 +16,7 @@ import io.metersphere.base.mapper.ApiScenarioReportMapper;
import io.metersphere.base.mapper.TestPlanApiScenarioMapper; import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper;
import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.DateUtils; import io.metersphere.commons.utils.DateUtils;
@ -211,6 +212,7 @@ public class ApiScenarioReportService {
TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class); TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class);
testPlanReportService.updateReport(testPlanReportIdList, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name()); testPlanReportService.updateReport(testPlanReportIdList, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name());
testPlanReportService.updateReport(testPlanReportIdList,ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ReportTriggerMode.SCHEDULE.name());
return lastReport; return lastReport;
} }

View File

@ -19,6 +19,8 @@ public class TestCaseReview implements Serializable {
private Long endTime; private Long endTime;
private String projectId;
private String description; private String description;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -563,6 +563,76 @@ public class TestCaseReviewExample {
addCriterion("end_time not between", value1, value2, "endTime"); addCriterion("end_time not between", value1, value2, "endTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProjectIdIsNull() {
addCriterion("project_id is null");
return (Criteria) this;
}
public Criteria andProjectIdIsNotNull() {
addCriterion("project_id is not null");
return (Criteria) this;
}
public Criteria andProjectIdEqualTo(String value) {
addCriterion("project_id =", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdNotEqualTo(String value) {
addCriterion("project_id <>", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdGreaterThan(String value) {
addCriterion("project_id >", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdGreaterThanOrEqualTo(String value) {
addCriterion("project_id >=", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdLessThan(String value) {
addCriterion("project_id <", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdLessThanOrEqualTo(String value) {
addCriterion("project_id <=", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdLike(String value) {
addCriterion("project_id like", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdNotLike(String value) {
addCriterion("project_id not like", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdIn(List<String> values) {
addCriterion("project_id in", values, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdNotIn(List<String> values) {
addCriterion("project_id not in", values, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdBetween(String value1, String value2) {
addCriterion("project_id between", value1, value2, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdNotBetween(String value1, String value2) {
addCriterion("project_id not between", value1, value2, "projectId");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -9,6 +9,7 @@
<result column="create_time" jdbcType="BIGINT" property="createTime" /> <result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" /> <result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="end_time" jdbcType="BIGINT" property="endTime" /> <result column="end_time" jdbcType="BIGINT" property="endTime" />
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestCaseReview"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestCaseReview">
<result column="description" jdbcType="LONGVARCHAR" property="description" /> <result column="description" jdbcType="LONGVARCHAR" property="description" />
@ -72,7 +73,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, `name`, creator, `status`, create_time, update_time, end_time id, `name`, creator, `status`, create_time, update_time, end_time, project_id
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
description description
@ -128,10 +129,12 @@
<insert id="insert" parameterType="io.metersphere.base.domain.TestCaseReview"> <insert id="insert" parameterType="io.metersphere.base.domain.TestCaseReview">
insert into test_case_review (id, `name`, creator, insert into test_case_review (id, `name`, creator,
`status`, create_time, update_time, `status`, create_time, update_time,
end_time, description) end_time, project_id, description
)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{creator,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{creator,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{endTime,jdbcType=BIGINT}, #{description,jdbcType=LONGVARCHAR}) #{endTime,jdbcType=BIGINT}, #{projectId,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}
)
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseReview"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseReview">
insert into test_case_review insert into test_case_review
@ -157,6 +160,9 @@
<if test="endTime != null"> <if test="endTime != null">
end_time, end_time,
</if> </if>
<if test="projectId != null">
project_id,
</if>
<if test="description != null"> <if test="description != null">
description, description,
</if> </if>
@ -183,6 +189,9 @@
<if test="endTime != null"> <if test="endTime != null">
#{endTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT},
</if> </if>
<if test="projectId != null">
#{projectId,jdbcType=VARCHAR},
</if>
<if test="description != null"> <if test="description != null">
#{description,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR},
</if> </if>
@ -218,6 +227,9 @@
<if test="record.endTime != null"> <if test="record.endTime != null">
end_time = #{record.endTime,jdbcType=BIGINT}, end_time = #{record.endTime,jdbcType=BIGINT},
</if> </if>
<if test="record.projectId != null">
project_id = #{record.projectId,jdbcType=VARCHAR},
</if>
<if test="record.description != null"> <if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR},
</if> </if>
@ -235,6 +247,7 @@
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT},
end_time = #{record.endTime,jdbcType=BIGINT}, end_time = #{record.endTime,jdbcType=BIGINT},
project_id = #{record.projectId,jdbcType=VARCHAR},
description = #{record.description,jdbcType=LONGVARCHAR} description = #{record.description,jdbcType=LONGVARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -248,7 +261,8 @@
`status` = #{record.status,jdbcType=VARCHAR}, `status` = #{record.status,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT},
end_time = #{record.endTime,jdbcType=BIGINT} end_time = #{record.endTime,jdbcType=BIGINT},
project_id = #{record.projectId,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -274,6 +288,9 @@
<if test="endTime != null"> <if test="endTime != null">
end_time = #{endTime,jdbcType=BIGINT}, end_time = #{endTime,jdbcType=BIGINT},
</if> </if>
<if test="projectId != null">
project_id = #{projectId,jdbcType=VARCHAR},
</if>
<if test="description != null"> <if test="description != null">
description = #{description,jdbcType=LONGVARCHAR}, description = #{description,jdbcType=LONGVARCHAR},
</if> </if>
@ -288,6 +305,7 @@
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT},
end_time = #{endTime,jdbcType=BIGINT}, end_time = #{endTime,jdbcType=BIGINT},
project_id = #{projectId,jdbcType=VARCHAR},
description = #{description,jdbcType=LONGVARCHAR} description = #{description,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -298,7 +316,8 @@
`status` = #{status,jdbcType=VARCHAR}, `status` = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT},
end_time = #{endTime,jdbcType=BIGINT} end_time = #{endTime,jdbcType=BIGINT},
project_id = #{projectId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -6,17 +6,16 @@
parameterType="io.metersphere.track.request.testreview.QueryCaseReviewRequest"> parameterType="io.metersphere.track.request.testreview.QueryCaseReviewRequest">
select distinct test_case_review.id, test_case_review.name, test_case_review.creator, test_case_review.status, select distinct test_case_review.id, test_case_review.name, test_case_review.creator, test_case_review.status,
test_case_review.create_time, test_case_review.update_time, test_case_review.end_time, test_case_review.create_time, test_case_review.update_time, test_case_review.end_time,
test_case_review.description, user.name as creatorName test_case_review.description, user.name as creatorName, project.name as projectName, test_case_review.project_id
from test_case_review join test_case_review_project on test_case_review.id = test_case_review_project.review_id from test_case_review
join project on test_case_review_project.project_id = project.id join project on project.id = test_case_review.project_id
left join user on test_case_review.creator = user.id left join user on test_case_review.creator = user.id
<where> <where>
<if test="request.name != null"> <if test="request.name != null">
and test_case_review.name like CONCAT('%', #{request.name},'%') and test_case_review.name like CONCAT('%', #{request.name},'%')
</if> </if>
and project.workspace_id = #{request.workspaceId}
<if test="request.projectId != null"> <if test="request.projectId != null">
and test_case_review_project.project_id = #{request.projectId} and test_case_review.project_id = #{request.projectId}
</if> </if>
</where> </where>
<if test="request.orders != null and request.orders.size() > 0"> <if test="request.orders != null and request.orders.size() > 0">
@ -30,13 +29,10 @@
<select id="listByWorkspaceId" resultType="io.metersphere.track.dto.TestCaseReviewDTO" <select id="listByWorkspaceId" resultType="io.metersphere.track.dto.TestCaseReviewDTO"
parameterType="io.metersphere.track.request.testreview.QueryCaseReviewRequest"> parameterType="io.metersphere.track.request.testreview.QueryCaseReviewRequest">
select distinct test_case_review.* select distinct test_case_review.*
from test_case_review, project, test_case_review_project, test_case_review_users from test_case_review, test_case_review_users
<where> <where>
test_case_review.id = test_case_review_project.review_id
and test_case_review_project.project_id = project.id
and project.workspace_id = #{workspaceId}
<if test="projectId != null"> <if test="projectId != null">
and test_case_review_project.project_id = #{projectId} and test_case_review.project_id = #{projectId}
</if> </if>
and ( and (
(test_case_review_users.review_id = test_case_review.id (test_case_review_users.review_id = test_case_review.id
@ -48,9 +44,8 @@
</select> </select>
<select id="listRelate" resultType="io.metersphere.track.dto.TestReviewDTOWithMetric"> <select id="listRelate" resultType="io.metersphere.track.dto.TestReviewDTOWithMetric">
select distinct test_case_review.* from test_case_review select distinct test_case_review.*, project.name as projectName from test_case_review
inner join test_case_review_project on test_case_review.id = test_case_review_project.review_id inner join project on project.id = test_case_review.project_id
inner join project on project.id = test_case_review_project.project_id
inner join test_case_review_users on test_case_review_users.review_id = test_case_review.id inner join test_case_review_users on test_case_review_users.review_id = test_case_review.id
<where> <where>
project.workspace_id = #{request.workspaceId} project.workspace_id = #{request.workspaceId}
@ -58,7 +53,7 @@
and test_case_review_users.user_id = #{request.reviewerId} and test_case_review_users.user_id = #{request.reviewerId}
</if> </if>
<if test="request.projectId != null"> <if test="request.projectId != null">
and test_case_review_project.project_id = #{request.projectId} and test_case_review.project_id = #{request.projectId}
</if> </if>
<if test="request.creator != null"> <if test="request.creator != null">
and (test_case_review.creator = #{request.creator} and (test_case_review.creator = #{request.creator}
@ -75,15 +70,24 @@
order by test_case_review.update_time desc order by test_case_review.update_time desc
</select> </select>
<select id="checkIsHave" resultType="int"> <select id="checkIsHave" resultType="int">
SELECT COUNT(1) select sum(c) from (
SELECT COUNT(1) as c
FROM project, test_case_review_project FROM project, test_case_review_project
WHERE project.id = test_case_review_project.project_id WHERE project.id = test_case_review_project.project_id AND test_case_review_project.review_id = #{reviewId}
<if test="workspaceIds != null and workspaceIds.size() > 0"> <if test="workspaceIds != null and workspaceIds.size() > 0">
AND project.workspace_id IN AND project.workspace_id IN
<foreach collection="workspaceIds" item="id" separator="," open="(" close=")"> <foreach collection="workspaceIds" item="id" separator="," open="(" close=")">
#{id} #{id}
</foreach> </foreach>
</if> </if>
AND test_case_review_project.review_id = #{reviewId} union
select count(1) as c from test_case_review, project
WHERE project_id = project.id AND test_case_review.id = #{reviewId}
<if test="workspaceIds != null and workspaceIds.size() > 0">
AND project.workspace_id IN
<foreach collection="workspaceIds" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</if>) as temp
</select> </select>
</mapper> </mapper>

View File

@ -98,8 +98,9 @@
<select id="list" resultType="io.metersphere.track.dto.TestPlanDTOWithMetric" <select id="list" resultType="io.metersphere.track.dto.TestPlanDTOWithMetric"
parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest"> parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
select DISTINCT test_plan.*, user.name as user_name, project.name as projectName from test_plan select DISTINCT test_plan.*, user.name as user_name, project.name as projectName,schedule.id as scheduleId from test_plan
LEFT JOIN user ON user.id = test_plan.principal LEFT JOIN user ON user.id = test_plan.principal
LEFT JOIN schedule ON schedule.resource_id = test_plan.id
JOIN project on project.id = test_plan.project_id JOIN project on project.id = test_plan.project_id
<where> <where>
<if test="request.combine != null"> <if test="request.combine != null">

View File

@ -7,7 +7,6 @@
SELECT tpr.id AS id, tpr.`name` AS `name`, tp.`name` AS testPlanName, tpr.creator AS creator, tpr.create_time AS createTime,tpr.trigger_Mode AS triggerMode SELECT tpr.id AS id, tpr.`name` AS `name`, tp.`name` AS testPlanName, tpr.creator AS creator, tpr.create_time AS createTime,tpr.trigger_Mode AS triggerMode
FROM test_plan tp FROM test_plan tp
INNER JOIN test_plan_report tpr on tp.id = tpr.test_plan_id INNER JOIN test_plan_report tpr on tp.id = tpr.test_plan_id
-- INNER JOIN
<where> <where>
<if test="name != null"> <if test="name != null">
and tpr.name like CONCAT('%', #{name},'%') and tpr.name like CONCAT('%', #{name},'%')
@ -26,7 +25,12 @@
<if test="orders != null and orders.size() > 0"> <if test="orders != null and orders.size() > 0">
order by order by
<foreach collection="orders" separator="," item="order"> <foreach collection="orders" separator="," item="order">
tpr.${order.name} ${order.type} <if test="order.name == 'test_plan_name'">
tp.name ${order.type}
</if>
<if test="order.name != 'test_plan_name'">
tpr.${order.name} ${order.type}
</if>
</foreach> </foreach>
</if> </if>
</select> </select>

View File

@ -202,11 +202,10 @@
<select id="findRelateTestReviewId" resultType="java.lang.String"> <select id="findRelateTestReviewId" resultType="java.lang.String">
select distinct test_case_review_test_case.review_id from test_case_review_test_case select distinct test_case_review_test_case.review_id from test_case_review_test_case
inner join test_case_review on test_case_review_test_case.review_id = test_case_review.id inner join test_case_review on test_case_review_test_case.review_id = test_case_review.id
inner join test_case_review_project on test_case_review_project.review_id = test_case_review.id inner join project on project.id = test_case_review.project_id
inner join project on project.id = test_case_review_project.project_id
where test_case_review_test_case.review_id = #{userId} where test_case_review_test_case.review_id = #{userId}
and project.workspace_id = #{workspaceId} and project.workspace_id = #{workspaceId}
and test_case_review_project.project_id = #{projectId} and test_case_review.project_id = #{projectId}
</select> </select>
<select id="listTestCaseByProjectIds" resultType="io.metersphere.track.dto.TestReviewCaseDTO"> <select id="listTestCaseByProjectIds" resultType="io.metersphere.track.dto.TestReviewCaseDTO">
select distinct * from test_case_review_test_case, test_case select distinct * from test_case_review_test_case, test_case

View File

@ -5,6 +5,7 @@ import io.metersphere.Application;
import io.metersphere.base.domain.LoadTestReport; import io.metersphere.base.domain.LoadTestReport;
import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.config.KafkaProperties;
import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.reflections8.Reflections; import org.reflections8.Reflections;
import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.annotation.KafkaListener;
@ -21,6 +22,8 @@ public class LoadTestConsumer {
LoadTestReport loadTestReport = JSON.parseObject(record.value(), LoadTestReport.class); LoadTestReport loadTestReport = JSON.parseObject(record.value(), LoadTestReport.class);
Reflections reflections = new Reflections(Application.class); Reflections reflections = new Reflections(Application.class);
Set<Class<? extends LoadTestFinishEvent>> subTypes = reflections.getSubTypesOf(LoadTestFinishEvent.class); Set<Class<? extends LoadTestFinishEvent>> subTypes = reflections.getSubTypesOf(LoadTestFinishEvent.class);
LogUtil.info("Execute Over: LoadTestConsumer");
System.out.println("Execute Over: LoadTestConsumer");
subTypes.forEach(s -> { subTypes.forEach(s -> {
try { try {
CommonBeanFactory.getBean(s).execute(loadTestReport); CommonBeanFactory.getBean(s).execute(loadTestReport);

View File

@ -12,7 +12,6 @@ import io.metersphere.base.domain.*;
import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.constants.ScheduleGroup; import io.metersphere.commons.constants.ScheduleGroup;
import io.metersphere.commons.consumer.LoadTestFinishEvent;
import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.performance.service.PerformanceTestService;
@ -25,6 +24,8 @@ import org.quartz.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/** /**
* 情景测试Job * 情景测试Job
@ -102,7 +103,7 @@ public class TestPlanTestJob extends MsScheduleJob {
void businessExecute(JobExecutionContext context) { void businessExecute(JobExecutionContext context) {
LogUtil.info("-------------- start testplan schedule ----------"); LogUtil.info("-------------- start testplan schedule ----------");
//首先创建testPlanReport然后返回的ID重新赋值为resourceID作为后续的参数 //首先创建testPlanReport然后返回的ID重新赋值为resourceID作为后续的参数
TestPlanReport testPlanReport = testPlanReportService.genTestPlanReport(this.resourceId,this.userId); TestPlanReport testPlanReport = testPlanReportService.genTestPlanReport(this.resourceId,this.userId,ReportTriggerMode.SCHEDULE.name());
//执行接口案例任务 //执行接口案例任务
for (Map.Entry<String,String> entry: this.apiTestCaseIdMap.entrySet()) { for (Map.Entry<String,String> entry: this.apiTestCaseIdMap.entrySet()) {
String apiCaseID = entry.getKey(); String apiCaseID = entry.getKey();
@ -127,39 +128,38 @@ public class TestPlanTestJob extends MsScheduleJob {
scenarioRequest.setTestPlanID(this.resourceId); scenarioRequest.setTestPlanID(this.resourceId);
scenarioRequest.setRunMode(ApiRunMode.SCHEDULE_SCENARIO_PLAN.name()); scenarioRequest.setRunMode(ApiRunMode.SCHEDULE_SCENARIO_PLAN.name());
scenarioRequest.setTestPlanReportId(testPlanReport.getId()); scenarioRequest.setTestPlanReportId(testPlanReport.getId());
String reportID = apiAutomationService.run(scenarioRequest); apiAutomationService.run(scenarioRequest);
LogUtil.info("-------------- testplan schedule ---------- scenario case over -----------------"); LogUtil.info("-------------- testplan schedule ---------- scenario case over -----------------");
//执行性能测试任务 //执行性能测试任务
boolean havePerformanceTask = false;
List<String> performaneReportIDList = new ArrayList<>(); List<String> performaneReportIDList = new ArrayList<>();
for (Map.Entry<String,String> entry: this.performanceIdMap.entrySet()) { for (Map.Entry<String,String> entry: this.performanceIdMap.entrySet()) {
String id = entry.getKey(); String id = entry.getKey();
String caseID = entry.getValue(); String caseID = entry.getValue();
RunTestPlanRequest performanceRequest = new RunTestPlanRequest(); RunTestPlanRequest performanceRequest = new RunTestPlanRequest();
performanceRequest.setId(id); performanceRequest.setId(caseID);
performanceRequest.setTestPlanLoadId(caseID); performanceRequest.setTestPlanLoadId(caseID);
performanceRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); performanceRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
String reportId = null; String reportId = null;
havePerformanceTask = true;
try { try {
reportId = performanceTestService.run(performanceRequest); reportId = performanceTestService.run(performanceRequest);
if(reportId!=null){
performaneReportIDList.add(reportId);
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId());
testPlanLoadCase.setLoadReportId(reportId);
testPlanLoadCaseService.update(testPlanLoadCase);
}
}catch (Exception e){ }catch (Exception e){
} e.printStackTrace();
if(reportID!=null){
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId());
testPlanLoadCase.setLoadReportId(reportId);
testPlanLoadCaseService.update(testPlanLoadCase);
performaneReportIDList.add(reportID);
} }
} }
if(!performaneReportIDList.isEmpty()){ if(!performaneReportIDList.isEmpty()){
//性能测试时保存性能测试报告ID在结果返回时用于捕捉并进行 //性能测试时保存性能测试报告ID在结果返回时用于捕捉并进行
testPlanReportService.updatePerformanceInfo(testPlanReport,performaneReportIDList); testPlanReportService.updatePerformanceInfo(testPlanReport,performaneReportIDList,ReportTriggerMode.SCHEDULE.name());
} }
} }

View File

@ -5,6 +5,7 @@ import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.PerformanceTestStatus; import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.consumer.LoadTestFinishEvent; import io.metersphere.commons.consumer.LoadTestFinishEvent;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.dto.BaseSystemConfigDTO;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.sender.NoticeModel;
@ -70,6 +71,7 @@ public class PerformanceNoticeEvent implements LoadTestFinishEvent {
@Override @Override
public void execute(LoadTestReport loadTestReport) { public void execute(LoadTestReport loadTestReport) {
LogUtil.info("PerformanceNoticeEvent OVER:" + loadTestReport.getTriggerMode()+";"+loadTestReport.getStatus());
if (StringUtils.equals(ReportTriggerMode.API.name(), loadTestReport.getTriggerMode()) if (StringUtils.equals(ReportTriggerMode.API.name(), loadTestReport.getTriggerMode())
|| StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), loadTestReport.getTriggerMode())) { || StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), loadTestReport.getTriggerMode())) {
if (StringUtils.equalsAny(loadTestReport.getStatus(), if (StringUtils.equalsAny(loadTestReport.getStatus(),

View File

@ -91,14 +91,14 @@ public class TestCaseReviewController {
@PostMapping("/projects") @PostMapping("/projects")
public List<Project> getProjectByReviewId(@RequestBody TestReviewRelevanceRequest request) { public List<Project> getProjectByReviewId(@RequestBody TestReviewRelevanceRequest request) {
List<String> projectIds = testReviewProjectService.getProjectIdsByPlanId(request.getReviewId()); List<String> projectIds = testReviewProjectService.getProjectIdsByReviewId(request.getReviewId());
request.setProjectIds(projectIds); request.setProjectIds(projectIds);
return testReviewProjectService.getProject(request); return testReviewProjectService.getProject(request);
} }
@PostMapping("/project/{goPage}/{pageSize}") @PostMapping("/project/{goPage}/{pageSize}")
public Pager<List<Project>> getProjectByReviewId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestReviewRelevanceRequest request) { public Pager<List<Project>> getProjectByReviewId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestReviewRelevanceRequest request) {
List<String> projectIds = testReviewProjectService.getProjectIdsByPlanId(request.getReviewId()); List<String> projectIds = testReviewProjectService.getProjectIdsByReviewId(request.getReviewId());
request.setProjectIds(projectIds); request.setProjectIds(projectIds);
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testReviewProjectService.getProject(request)); return PageUtils.setPageInfo(page, testReviewProjectService.getProject(request));

View File

@ -4,6 +4,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.TestCaseReport; import io.metersphere.base.domain.TestCaseReport;
import io.metersphere.base.domain.TestPlanReport; import io.metersphere.base.domain.TestPlanReport;
import io.metersphere.commons.constants.ReportTriggerMode;
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.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
@ -52,4 +53,10 @@ public class TestPlanReportController {
public void delete(@RequestBody List<String> testPlanReportIdList) { public void delete(@RequestBody List<String> testPlanReportIdList) {
testPlanReportService.delete(testPlanReportIdList); testPlanReportService.delete(testPlanReportIdList);
} }
@GetMapping("/apiExecuteFinish/{planId}/{userId}")
public void apiExecuteFinish(@PathVariable String planId,@PathVariable String userId) {
TestPlanReport report = testPlanReportService.genTestPlanReport(planId,userId,ReportTriggerMode.API.name());
testPlanReportService.countReportByTestPlanReportId(report.getId(),null, ReportTriggerMode.API.name());
}
} }

View File

@ -12,4 +12,5 @@ public class TestPlanDTO extends TestPlan {
private String projectName; private String projectName;
private String userName; private String userName;
private List<String> projectIds; private List<String> projectIds;
private String scheduleId;
} }

View File

@ -18,7 +18,7 @@ public class TestPlanReportDTO {
private String name; private String name;
private String testPlanName; private String testPlanName;
private String creator; private String creator;
private String createTime; private long createTime;
private String triggerMode; private String triggerMode;
private TestCaseReportAdvanceStatusResultDTO executeResult; private TestCaseReportAdvanceStatusResultDTO executeResult;

View File

@ -37,4 +37,6 @@ public class QueryCaseReviewRequest extends TestCaseReviewTestCase {
private Map<String, Object> combine; private Map<String, Object> combine;
private String projectId; private String projectId;
private String projectName;
} }

View File

@ -83,12 +83,17 @@ public class TestCaseReviewService {
String reviewId = UUID.randomUUID().toString(); String reviewId = UUID.randomUUID().toString();
List<String> projectIds = reviewRequest.getProjectIds(); List<String> projectIds = reviewRequest.getProjectIds();
List<String> userIds = reviewRequest.getUserIds();//执行人 List<String> userIds = reviewRequest.getUserIds();//执行人
projectIds.forEach(projectId -> { if (!CollectionUtils.isEmpty(projectIds)) {
TestCaseReviewProject testCaseReviewProject = new TestCaseReviewProject(); List<String> ids = projectIds.stream().distinct().collect(Collectors.toList());
testCaseReviewProject.setProjectId(projectId); // 如果关联项目id中包含当前项目id进行移除
testCaseReviewProject.setReviewId(reviewId); ids.remove(SessionUtils.getCurrentProjectId());
testCaseReviewProjectMapper.insertSelective(testCaseReviewProject); ids.forEach(projectId -> {
}); TestCaseReviewProject testCaseReviewProject = new TestCaseReviewProject();
testCaseReviewProject.setProjectId(projectId);
testCaseReviewProject.setReviewId(reviewId);
testCaseReviewProjectMapper.insertSelective(testCaseReviewProject);
});
}
userIds.forEach(userId -> { userIds.forEach(userId -> {
TestCaseReviewUsers testCaseReviewUsers = new TestCaseReviewUsers(); TestCaseReviewUsers testCaseReviewUsers = new TestCaseReviewUsers();
@ -102,6 +107,7 @@ public class TestCaseReviewService {
reviewRequest.setUpdateTime(System.currentTimeMillis()); reviewRequest.setUpdateTime(System.currentTimeMillis());
reviewRequest.setCreator(SessionUtils.getUser().getId());//创建人 reviewRequest.setCreator(SessionUtils.getUser().getId());//创建人
reviewRequest.setStatus(TestCaseReviewStatus.Prepare.name()); reviewRequest.setStatus(TestCaseReviewStatus.Prepare.name());
reviewRequest.setProjectId(SessionUtils.getCurrentProjectId());
testCaseReviewMapper.insert(reviewRequest); testCaseReviewMapper.insert(reviewRequest);
// 发送通知 // 发送通知
String context = getReviewContext(reviewRequest, NoticeConstants.Event.CREATE); String context = getReviewContext(reviewRequest, NoticeConstants.Event.CREATE);
@ -156,7 +162,10 @@ public class TestCaseReviewService {
public List<TestCaseReviewDTO> listCaseReview(QueryCaseReviewRequest request) { public List<TestCaseReviewDTO> listCaseReview(QueryCaseReviewRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
request.setProjectId(SessionUtils.getCurrentProjectId()); String projectId = request.getProjectId();
if (StringUtils.isBlank(projectId)) {
return new ArrayList<>();
}
return extTestCaseReviewMapper.list(request); return extTestCaseReviewMapper.list(request);
} }
@ -172,6 +181,9 @@ public class TestCaseReviewService {
.map(TestCaseReviewProject::getProjectId) .map(TestCaseReviewProject::getProjectId)
.collect(Collectors.toList()); .collect(Collectors.toList());
TestCaseReview testCaseReview = testCaseReviewMapper.selectByPrimaryKey(reviewId);
String projectId = testCaseReview.getProjectId();
projectIds.add(projectId);
ProjectExample projectExample = new ProjectExample(); ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andIdIn(projectIds); projectExample.createCriteria().andIdIn(projectIds);
return projectMapper.selectByExample(projectExample); return projectMapper.selectByExample(projectExample);
@ -249,8 +261,11 @@ public class TestCaseReviewService {
private void editCaseReviewProject(SaveTestCaseReviewRequest testCaseReview) { private void editCaseReviewProject(SaveTestCaseReviewRequest testCaseReview) {
List<String> projectIds = testCaseReview.getProjectIds(); List<String> projectIds = testCaseReview.getProjectIds();
String id = testCaseReview.getId();
if (!CollectionUtils.isEmpty(projectIds)) { if (!CollectionUtils.isEmpty(projectIds)) {
projectIds.remove(testCaseReview.getProjectId());
}
String id = testCaseReview.getId();
if (StringUtils.isNotBlank(testCaseReview.getProjectId())) {
TestCaseReviewProjectExample testCaseReviewProjectExample = new TestCaseReviewProjectExample(); TestCaseReviewProjectExample testCaseReviewProjectExample = new TestCaseReviewProjectExample();
testCaseReviewProjectExample.createCriteria().andReviewIdEqualTo(id); testCaseReviewProjectExample.createCriteria().andReviewIdEqualTo(id);
List<TestCaseReviewProject> testCaseReviewProjects = testCaseReviewProjectMapper.selectByExample(testCaseReviewProjectExample); List<TestCaseReviewProject> testCaseReviewProjects = testCaseReviewProjectMapper.selectByExample(testCaseReviewProjectExample);
@ -265,15 +280,24 @@ public class TestCaseReviewService {
}); });
TestCaseReviewProjectExample example = new TestCaseReviewProjectExample(); TestCaseReviewProjectExample example = new TestCaseReviewProjectExample();
example.createCriteria().andReviewIdEqualTo(id).andProjectIdNotIn(projectIds); TestCaseReviewProjectExample.Criteria criteria1 = example.createCriteria().andReviewIdEqualTo(id);
if (!CollectionUtils.isEmpty(projectIds)) {
criteria1.andProjectIdNotIn(projectIds);
}
testCaseReviewProjectMapper.deleteByExample(example); testCaseReviewProjectMapper.deleteByExample(example);
// 关联的项目下的用例idList // 关联的项目下的用例idList
TestCaseExample testCaseExample = new TestCaseExample(); List<String> caseIds = null;
testCaseExample.createCriteria().andProjectIdIn(projectIds); // 测试计划所属项目下的用例不解除关联
List<TestCase> caseList = testCaseMapper.selectByExample(testCaseExample); projectIds.add(testCaseReview.getProjectId());
List<String> caseIds = caseList.stream().map(TestCase::getId).collect(Collectors.toList()); // 关联的项目下的用例idList
if (!CollectionUtils.isEmpty(projectIds)) {
TestCaseExample testCaseExample = new TestCaseExample();
testCaseExample.createCriteria().andProjectIdIn(projectIds);
List<TestCase> caseList = testCaseMapper.selectByExample(testCaseExample);
caseIds = caseList.stream().map(TestCase::getId).collect(Collectors.toList());
}
TestCaseReviewTestCaseExample testCaseReviewTestCaseExample = new TestCaseReviewTestCaseExample(); TestCaseReviewTestCaseExample testCaseReviewTestCaseExample = new TestCaseReviewTestCaseExample();
TestCaseReviewTestCaseExample.Criteria criteria = testCaseReviewTestCaseExample.createCriteria().andReviewIdEqualTo(id); TestCaseReviewTestCaseExample.Criteria criteria = testCaseReviewTestCaseExample.createCriteria().andReviewIdEqualTo(id);
@ -282,6 +306,7 @@ public class TestCaseReviewService {
} }
testCaseReviewTestCaseMapper.deleteByExample(testCaseReviewTestCaseExample); testCaseReviewTestCaseMapper.deleteByExample(testCaseReviewTestCaseExample);
} }
} }
private void checkCaseReviewExist(TestCaseReview testCaseReview) { private void checkCaseReviewExist(TestCaseReview testCaseReview) {
@ -348,19 +373,11 @@ public class TestCaseReviewService {
} }
public List<TestCaseReview> listCaseReviewAll() { public List<TestCaseReview> listCaseReviewAll() {
TestCaseReviewProjectExample reviewProjectExample = new TestCaseReviewProjectExample();
TestCaseReviewProjectExample.Criteria criteria = reviewProjectExample.createCriteria();
if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) { if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) {
criteria.andProjectIdEqualTo(SessionUtils.getCurrentProjectId()); TestCaseReviewExample testCaseReviewExample = new TestCaseReviewExample();
List<TestCaseReviewProject> testCaseReviewProjects = testCaseReviewProjectMapper.selectByExample(reviewProjectExample); testCaseReviewExample.createCriteria().andProjectIdEqualTo(SessionUtils.getCurrentProjectId());
if (!CollectionUtils.isEmpty(testCaseReviewProjects)) { return testCaseReviewMapper.selectByExample(testCaseReviewExample);
List<String> caseReviewIds = testCaseReviewProjects.stream().map(TestCaseReviewProject::getReviewId).collect(Collectors.toList());
TestCaseReviewExample testCaseReviewExample = new TestCaseReviewExample();
testCaseReviewExample.createCriteria().andIdIn(caseReviewIds);
return testCaseReviewMapper.selectByExample(testCaseReviewExample);
}
} }
return new ArrayList<>(); return new ArrayList<>();
} }

View File

@ -4,7 +4,9 @@ import io.metersphere.base.domain.LoadTestReport;
import io.metersphere.base.domain.TestPlanReport; import io.metersphere.base.domain.TestPlanReport;
import io.metersphere.commons.constants.NoticeConstants; import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.PerformanceTestStatus; import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.consumer.LoadTestFinishEvent; import io.metersphere.commons.consumer.LoadTestFinishEvent;
import io.metersphere.commons.utils.LogUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -22,10 +24,11 @@ public class TestPlanLoadCaseEvent implements LoadTestFinishEvent {
@Override @Override
public void execute(LoadTestReport loadTestReport) { public void execute(LoadTestReport loadTestReport) {
LogUtil.info("PerformanceNoticeEvent OVER:" + loadTestReport.getTriggerMode()+";"+loadTestReport.getStatus());
if (StringUtils.equals(NoticeConstants.Mode.SCHEDULE, loadTestReport.getTriggerMode()) ) { if (StringUtils.equals(NoticeConstants.Mode.SCHEDULE, loadTestReport.getTriggerMode()) ) {
if (StringUtils.equalsAny(loadTestReport.getStatus(), if (StringUtils.equalsAny(loadTestReport.getStatus(),
PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) { PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
testPlanReportService.updatePerformanceTestStatus(loadTestReport.getId()); testPlanReportService.updatePerformanceTestStatus(loadTestReport.getId(), ReportTriggerMode.SCHEDULE.name());
} }
} }
} }

View File

@ -8,10 +8,7 @@ import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanMapper; import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanReportMapper; import io.metersphere.base.mapper.ext.ExtTestPlanReportMapper;
import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.*;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.constants.TestPlanStatus;
import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.DateUtils; import io.metersphere.commons.utils.DateUtils;
import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.ServiceUtils;
@ -33,6 +30,8 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -62,9 +61,12 @@ public class TestPlanReportService {
ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper; ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper;
@Resource @Resource
TestPlanLoadCaseService testPlanLoadCaseService; TestPlanLoadCaseService testPlanLoadCaseService;
@Resource @Resource
TestPlanService testPlanService; TestPlanService testPlanService;
@Resource
LoadTestReportMapper loadTestReportMapper;
private final ExecutorService executorService = Executors.newFixedThreadPool(20);
public List<TestPlanReportDTO> list(QueryTestPlanReportRequest request) { public List<TestPlanReportDTO> list(QueryTestPlanReportRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
@ -76,9 +78,7 @@ public class TestPlanReportService {
return returnList; return returnList;
} }
public TestPlanReport genTestPlanReport(String planId, String userId) { public TestPlanReport genTestPlanReport(String planId, String userId,String triggerMode) {
TestPlanReportDTO returnDTO = new TestPlanReportDTO();
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId); TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId);
TestPlanApiCaseExample apiExample = new TestPlanApiCaseExample(); TestPlanApiCaseExample apiExample = new TestPlanApiCaseExample();
@ -107,7 +107,7 @@ public class TestPlanReportService {
testPlanReport.setName(testPlan.getName() + "-" + DateUtils.getTimeString(new Date())); testPlanReport.setName(testPlan.getName() + "-" + DateUtils.getTimeString(new Date()));
} catch (Exception e) { } catch (Exception e) {
} }
testPlanReport.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); testPlanReport.setTriggerMode(triggerMode);
testPlanReport.setCreator(userId); testPlanReport.setCreator(userId);
testPlanReport.setStartTime(System.currentTimeMillis()); testPlanReport.setStartTime(System.currentTimeMillis());
testPlanReport.setEndTime(System.currentTimeMillis()); testPlanReport.setEndTime(System.currentTimeMillis());
@ -145,77 +145,6 @@ public class TestPlanReportService {
return testPlanReport; return testPlanReport;
} }
public TestPlanReportDTO updateTestPlanReport(String planId) throws Exception {
TestPlanReportDTO returnDTO = new TestPlanReportDTO();
QueryTestPlanRequest queryTestPlanRequest = new QueryTestPlanRequest();
queryTestPlanRequest.setId(planId);
TestPlanDTO testPlan = extTestPlanMapper.list(queryTestPlanRequest).get(0);
JSONObject content = JSONObject.parseObject("{\"components\":[1,2,3,4,5]}");
JSONArray componentIds = content.getJSONArray("components");
List<ReportComponent> components = ReportComponentFactory.createComponents(componentIds.toJavaList(String.class), testPlan);
List<Issues> issues = testPlanService.buildFunctionalCaseReport(planId, components);
testPlanService.buildApiCaseReport(planId, components);
testPlanService.buildScenarioCaseReport(planId, components);
TestCaseReportMetricDTO testCaseReportMetricDTO = new TestCaseReportMetricDTO();
components.forEach(component -> {
component.afterBuild(testCaseReportMetricDTO);
});
String testPlanReportID = UUID.randomUUID().toString();
TestPlanReport testPlanReport = new TestPlanReport();
testPlanReport.setTestPlanId(planId);
testPlanReport.setId(testPlanReportID);
testPlanReport.setCreateTime(System.currentTimeMillis());
testPlanReport.setUpdateTime(System.currentTimeMillis());
testPlanReport.setName(testPlan.getName() + "-" + DateUtils.getTimeString(new Date()));
testPlanReport.setStatus("error");
testPlanReport.setTriggerMode(ReportTriggerMode.MANUAL.name());
testPlanReport.setCreator(SessionUtils.getUser().getId());
testPlanReport.setStartTime(System.currentTimeMillis());
testPlanReport.setEndTime(System.currentTimeMillis());
testPlanReport.setIsApiCaseExecuting(false);
testPlanReport.setIsScenarioExecuting(false);
testPlanReport.setIsPerformanceExecuting(false);
testPlanReport.setPrincipal(testPlan.getPrincipal());
testPlanReportMapper.insert(testPlanReport);
TestPlanReportDataWithBLOBs testPlanReportData = new TestPlanReportDataWithBLOBs();
testPlanReportData.setId(UUID.randomUUID().toString());
testPlanReportData.setTestPlanReportId(testPlanReportID);
testPlanReportData.setExecuteResult(JSONObject.toJSONString(testCaseReportMetricDTO.getExecuteResult()));
testPlanReportData.setFailurTestCases(JSONObject.toJSONString(testCaseReportMetricDTO.getFailureTestCases()));
testPlanReportData.setModuleExecuteResult(JSONArray.toJSONString(testCaseReportMetricDTO.getModuleExecuteResult()));
TestPlanApiCaseExample apiExample = new TestPlanApiCaseExample();
apiExample.createCriteria().andTestPlanIdEqualTo(planId);
List<String> apiCaseIdList = testPlanApiCaseMapper.selectByExample(apiExample)
.stream().map(TestPlanApiCase::getApiCaseId).collect(Collectors.toList());
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
example.createCriteria().andTestPlanIdEqualTo(planId);
List<String> scenarioIdList = testPlanScenarioCaseMapper.selectByExample(example)
.stream().map(TestPlanApiScenario::getApiScenarioId).collect(Collectors.toList());
List<String> performanceIdList = new ArrayList<>();
testPlanReportData.setApiCaseInfo(JSONArray.toJSONString(apiCaseIdList));
testPlanReportData.setScenarioInfo(JSONArray.toJSONString(scenarioIdList));
testPlanReportData.setPerformanceInfo(JSONArray.toJSONString(performanceIdList));
testPlanReportData.setIssuesInfo(JSONArray.toJSONString(issues));
testPlanReportDataMapper.insert(testPlanReportData);
return returnDTO;
}
// public TestCaseReport getTestCaseReport(String id) {
// return null;
// }
public TestPlanReportDTO getMetric(String reportId) { public TestPlanReportDTO getMetric(String reportId) {
TestPlanReportDTO returnDTO = new TestPlanReportDTO(); TestPlanReportDTO returnDTO = new TestPlanReportDTO();
TestPlanReport report = testPlanReportMapper.selectByPrimaryKey(reportId); TestPlanReport report = testPlanReportMapper.selectByPrimaryKey(reportId);
@ -252,64 +181,82 @@ public class TestPlanReportService {
return returnDTO; return returnDTO;
} }
public synchronized void updateReport(List<String> testPlanReportIdList, String runMode) { public synchronized void updateReport(List<String> testPlanReportIdList, String runMode,String triggerMode) {
planReportForeach:
for (String planReportId : testPlanReportIdList) { for (String planReportId : testPlanReportIdList) {
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(planReportId); this.countReportByTestPlanReportId(planReportId,runMode,triggerMode);
QueryTestPlanRequest queryTestPlanRequest = new QueryTestPlanRequest();
queryTestPlanRequest.setId(testPlanReport.getTestPlanId());
TestPlanDTO testPlan = extTestPlanMapper.list(queryTestPlanRequest).get(0);
//因为接口案例是单个案例开线程运行 所以要检查是否都执行完成全部执行完成时才会进行统一整理
if (StringUtils.equalsAny(runMode, ApiRunMode.SCHEDULE_API_PLAN.name())) {
List<String> statusList = extTestPlanApiCaseMapper.getStatusByTestPlanId(testPlan.getId());
for (String status : statusList) {
if (status == null) {
continue planReportForeach;
}
}
}
testPlanReport.setEndTime(System.currentTimeMillis());
testPlanReport.setUpdateTime(System.currentTimeMillis());
JSONObject content = JSONObject.parseObject("{\"components\":[1,2,3,4,5]}");
JSONArray componentIds = content.getJSONArray("components");
List<ReportComponent> components = ReportComponentFactory.createComponents(componentIds.toJavaList(String.class), testPlan);
testPlanService.buildApiCaseReport(testPlanReport.getTestPlanId(), components);
testPlanService.buildScenarioCaseReport(testPlanReport.getTestPlanId(), components);
testPlanService.buildLoadCaseReport(testPlanReport.getTestPlanId(), components);
if (StringUtils.equals(runMode, ApiRunMode.SCHEDULE_API_PLAN.name())) {
testPlanReport.setIsApiCaseExecuting(false);
} else if (StringUtils.equals(runMode, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
testPlanReport.setIsScenarioExecuting(false);
} else if (StringUtils.equals(runMode, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name())) {
testPlanReport.setIsPerformanceExecuting(false);
}
TestCaseReportMetricDTO testCaseReportMetricDTO = new TestCaseReportMetricDTO();
components.forEach(component -> {
component.afterBuild(testCaseReportMetricDTO);
});
this.update(testPlanReport);
TestPlanReportDataExample example = new TestPlanReportDataExample();
example.createCriteria().andTestPlanReportIdEqualTo(planReportId);
List<TestPlanReportDataWithBLOBs> testPlanReportDataList = testPlanReportDataMapper.selectByExampleWithBLOBs(example);
if (!testPlanReportDataList.isEmpty()) {
TestPlanReportDataWithBLOBs testPlanReportData = testPlanReportDataList.get(0);
testPlanReportData.setExecuteResult(JSONObject.toJSONString(testCaseReportMetricDTO.getExecuteResult()));
testPlanReportData.setFailurTestCases(JSONObject.toJSONString(testCaseReportMetricDTO.getFailureTestCases()));
testPlanReportData.setModuleExecuteResult(JSONArray.toJSONString(testCaseReportMetricDTO.getModuleExecuteResult()));
testPlanReportDataMapper.updateByPrimaryKeyWithBLOBs(testPlanReportData);
}
} }
} }
/**
*
* @param planReportId 测试计划报告ID
* @param resourceRunMode 资源的运行模式,triggerMode非Scedule可以为null
* @param triggerMode 触发方式 ReportTriggerMode.enum
*/
public void countReportByTestPlanReportId(String planReportId,String resourceRunMode,String triggerMode) {
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(planReportId);
QueryTestPlanRequest queryTestPlanRequest = new QueryTestPlanRequest();
queryTestPlanRequest.setId(testPlanReport.getTestPlanId());
TestPlanDTO testPlan = extTestPlanMapper.list(queryTestPlanRequest).get(0);
//因为接口案例的定时任务是单个案例开线程运行 所以要检查是否都执行完成全部执行完成时才会进行统一整理
if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(),triggerMode)
&&StringUtils.equalsAny(resourceRunMode, ApiRunMode.SCHEDULE_API_PLAN.name())) {
List<String> statusList = extTestPlanApiCaseMapper.getStatusByTestPlanId(testPlan.getId());
for (String status : statusList) {
if (status == null) {
return;
}
}
}
testPlanReport.setEndTime(System.currentTimeMillis());
testPlanReport.setUpdateTime(System.currentTimeMillis());
JSONObject content = JSONObject.parseObject("{\"components\":[1,2,3,4,5]}");
JSONArray componentIds = content.getJSONArray("components");
List<ReportComponent> components = ReportComponentFactory.createComponents(componentIds.toJavaList(String.class), testPlan);
testPlanService.buildApiCaseReport(testPlanReport.getTestPlanId(), components);
testPlanService.buildScenarioCaseReport(testPlanReport.getTestPlanId(), components);
testPlanService.buildLoadCaseReport(testPlanReport.getTestPlanId(), components);
//只针对定时任务做处理
if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(),triggerMode)
&&StringUtils.equals(resourceRunMode, ApiRunMode.SCHEDULE_API_PLAN.name())) {
testPlanReport.setIsApiCaseExecuting(false);
} else if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(),triggerMode)
&&StringUtils.equals(resourceRunMode, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
testPlanReport.setIsScenarioExecuting(false);
} else if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(),triggerMode)
&&StringUtils.equals(resourceRunMode, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name())) {
testPlanReport.setIsPerformanceExecuting(false);
}else {
testPlanReport.setIsPerformanceExecuting(false);
testPlanReport.setIsScenarioExecuting(false);
testPlanReport.setIsApiCaseExecuting(false);
}
TestCaseReportMetricDTO testCaseReportMetricDTO = new TestCaseReportMetricDTO();
components.forEach(component -> {
component.afterBuild(testCaseReportMetricDTO);
});
this.update(testPlanReport);
TestPlanReportDataExample example = new TestPlanReportDataExample();
example.createCriteria().andTestPlanReportIdEqualTo(planReportId);
List<TestPlanReportDataWithBLOBs> testPlanReportDataList = testPlanReportDataMapper.selectByExampleWithBLOBs(example);
if (!testPlanReportDataList.isEmpty()) {
TestPlanReportDataWithBLOBs testPlanReportData = testPlanReportDataList.get(0);
testPlanReportData.setExecuteResult(JSONObject.toJSONString(testCaseReportMetricDTO.getExecuteResult()));
testPlanReportData.setFailurTestCases(JSONObject.toJSONString(testCaseReportMetricDTO.getFailureTestCases()));
testPlanReportData.setModuleExecuteResult(JSONArray.toJSONString(testCaseReportMetricDTO.getModuleExecuteResult()));
testPlanReportDataMapper.updateByPrimaryKeyWithBLOBs(testPlanReportData);
}
}
public void update(TestPlanReport report) { public void update(TestPlanReport report) {
if (!report.getIsApiCaseExecuting() && !report.getIsPerformanceExecuting() && !report.getIsScenarioExecuting()) { if (!report.getIsApiCaseExecuting() && !report.getIsPerformanceExecuting() && !report.getIsScenarioExecuting()) {
try { try {
@ -381,7 +328,7 @@ public class TestPlanReportService {
* @param testPlanReport * @param testPlanReport
* @param performaneReportIDList * @param performaneReportIDList
*/ */
public void updatePerformanceInfo(TestPlanReport testPlanReport, List<String> performaneReportIDList) { public void updatePerformanceInfo(TestPlanReport testPlanReport, List<String> performaneReportIDList,String triggerMode) {
TestPlanReportDataExample example = new TestPlanReportDataExample(); TestPlanReportDataExample example = new TestPlanReportDataExample();
example.createCriteria().andTestPlanReportIdEqualTo(testPlanReport.getId()); example.createCriteria().andTestPlanReportIdEqualTo(testPlanReport.getId());
List<TestPlanReportDataWithBLOBs> reportDataList = testPlanReportDataMapper.selectByExampleWithBLOBs(example); List<TestPlanReportDataWithBLOBs> reportDataList = testPlanReportDataMapper.selectByExampleWithBLOBs(example);
@ -389,11 +336,54 @@ public class TestPlanReportService {
models.setPerformanceInfo(JSONArray.toJSONString(performaneReportIDList)); models.setPerformanceInfo(JSONArray.toJSONString(performaneReportIDList));
testPlanReportDataMapper.updateByPrimaryKeyWithBLOBs(models); testPlanReportDataMapper.updateByPrimaryKeyWithBLOBs(models);
} }
/**
* 虽然kafka已经设置了topic推送但是在1.18日测试时发现无法收到消息
* 由于Tapd为完成任务较多无法抽时间查看问题暂时先保留以下逻辑解决完Tpad任务之后查看原因再删除以下代码
*/
executorService.submit(() -> {
//错误数据检查集合 如果错误数据出现超过20次则取消该条数据的检查
Map<String,Integer> errorDataCheckMap = new HashMap<>();
while (performaneReportIDList.size()>0) {
List<String> selectList = new ArrayList<>(performaneReportIDList);
for (String loadTestReportId:selectList) {
LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReportId);
if(loadTestReportFromDatabase == null){
//检查错误数据
if(errorDataCheckMap.containsKey(loadTestReportId)){
if(errorDataCheckMap.get(loadTestReportId)>20){
performaneReportIDList.remove(loadTestReportId);
}else {
errorDataCheckMap.put(loadTestReportId,errorDataCheckMap.get(loadTestReportId)+1);
}
}else {
errorDataCheckMap.put(loadTestReportId,1);
}
}else if (StringUtils.equalsAny(loadTestReportFromDatabase.getStatus(),
PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
performaneReportIDList.remove(loadTestReportId);
System.out.println("over");
}
}
if(performaneReportIDList.isEmpty()){
List<String> testPlanReportList = new ArrayList<>();
testPlanReportList.add(testPlanReport.getId());
this.updateReport(testPlanReportList, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(),triggerMode);
}else {
try {
//查询定时任务是否关闭
Thread.sleep(1000 * 10);// 检查 loadtest 的状态
} catch (InterruptedException e) {
}
}
}
return true;
});
} }
public void updatePerformanceTestStatus(String reportId) { public void updatePerformanceTestStatus(String reportId,String triggerMode) {
List<String> testPlanReportId = extTestPlanMapper.findIdByPerformanceReportId(reportId); List<String> testPlanReportId = extTestPlanMapper.findIdByPerformanceReportId(reportId);
this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name()); this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(),triggerMode);
} }
public void delete(List<String> testPlanReportIdList) { public void delete(List<String> testPlanReportIdList) {

View File

@ -2,6 +2,7 @@ package io.metersphere.track.service;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.base.mapper.ProjectMapper;
import io.metersphere.base.mapper.TestCaseReviewMapper;
import io.metersphere.base.mapper.TestCaseReviewProjectMapper; import io.metersphere.base.mapper.TestCaseReviewProjectMapper;
import io.metersphere.track.request.testreview.TestReviewRelevanceRequest; import io.metersphere.track.request.testreview.TestReviewRelevanceRequest;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -17,18 +18,25 @@ import java.util.stream.Collectors;
public class TestReviewProjectService { public class TestReviewProjectService {
@Resource @Resource
ProjectMapper projectMapper; private ProjectMapper projectMapper;
@Resource @Resource
TestCaseReviewProjectMapper testCaseReviewProjectMapper; private TestCaseReviewProjectMapper testCaseReviewProjectMapper;
@Resource
private TestCaseReviewMapper testCaseReviewMapper;
public List<String> getProjectIdsByPlanId(String reviewId) { public List<String> getProjectIdsByReviewId(String reviewId) {
TestCaseReviewProjectExample example = new TestCaseReviewProjectExample(); TestCaseReviewProjectExample example = new TestCaseReviewProjectExample();
example.createCriteria().andReviewIdEqualTo(reviewId); example.createCriteria().andReviewIdEqualTo(reviewId);
List<String> projectIds = testCaseReviewProjectMapper.selectByExample(example) List<String> projectIds = testCaseReviewProjectMapper.selectByExample(example)
.stream() .stream()
.map(TestCaseReviewProject::getProjectId) .map(TestCaseReviewProject::getProjectId)
.collect(Collectors.toList()); .collect(Collectors.toList());
TestCaseReview caseReview = testCaseReviewMapper.selectByPrimaryKey(reviewId);
if (caseReview != null && StringUtils.isNotBlank(caseReview.getProjectId())) {
if (!projectIds.contains(caseReview.getProjectId())) {
projectIds.add(caseReview.getProjectId());
}
}
if (projectIds.isEmpty()) { if (projectIds.isEmpty()) {
return null; return null;
} }

View File

@ -0,0 +1,55 @@
alter table test_case_review add project_id varchar(50) null comment '用例评审所属项目';
DROP PROCEDURE IF EXISTS test_cursor;
DELIMITER //
CREATE PROCEDURE test_cursor()
BEGIN
DECLARE reviewId VARCHAR(64);
DECLARE done INT DEFAULT 0;
DECLARE cursor1 CURSOR FOR (SELECT id
FROM test_case_review
WHERE project_id IS NULL);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cursor1;
outer_loop:
LOOP
FETCH cursor1 INTO reviewId;
IF done
THEN
LEAVE outer_loop;
END IF;
select count(1) as s, project_id
into @num, @projectId
from test_case_review_test_case
join test_case on case_id = test_case.id
where review_id = reviewId
group by project_id
order by s desc
limit 1;
IF @projectId = ''
THEN
select test_case_review_project.project_id
into @projectId
from test_case_review
join test_case_review_project on test_case_review.id = test_case_review_project.review_id
where test_case_review.id = reviewId
limit 1;
END IF;
UPDATE test_case_review SET test_case_review.project_id = @projectId WHERE test_case_review.id = reviewId;
DELETE FROM test_case_review_project
WHERE test_case_review_project.project_id = @projectId
AND test_case_review_project.review_id = reviewId;
SET @projectId = '';
SET done = 0;
END LOOP;
CLOSE cursor1;
END //
DELIMITER ;
CALL test_cursor();
DROP PROCEDURE IF EXISTS test_cursor;

View File

@ -12,7 +12,7 @@
<el-table-column type="selection" width="50"/> <el-table-column type="selection" width="50"/>
<ms-table-select-all v-if="!referenced" <ms-table-select-all v-if="!referenced"
:page-size="pageSize" :page-size="pageSize>total?total:pageSize"
:total="total" :total="total"
@selectPageAll="isSelectDataAll(false)" @selectPageAll="isSelectDataAll(false)"
@selectAll="isSelectDataAll(true)"/> @selectAll="isSelectDataAll(true)"/>

View File

@ -20,7 +20,7 @@
<el-table-column type="selection" width="50"/> <el-table-column type="selection" width="50"/>
<ms-table-select-all <ms-table-select-all
:page-size="pageSize" :page-size="pageSize>total?total:pageSize"
:total="total" :total="total"
@selectPageAll="isSelectDataAll(false)" @selectPageAll="isSelectDataAll(false)"
@selectAll="isSelectDataAll(true)"/> @selectAll="isSelectDataAll(true)"/>

View File

@ -19,7 +19,7 @@
<el-table-column width="50" type="selection"/> <el-table-column width="50" type="selection"/>
<ms-table-select-all <ms-table-select-all
:page-size="pageSize" :page-size="pageSize>total?total:pageSize"
:total="total" :total="total"
@selectPageAll="isSelectDataAll(false)" @selectPageAll="isSelectDataAll(false)"
@selectAll="isSelectDataAll(true)"/> @selectAll="isSelectDataAll(true)"/>

View File

@ -105,8 +105,10 @@
return; return;
} }
if (this.response.headers.indexOf("Content-Type: application/json") > 0) { if (this.response.headers.indexOf("Content-Type: application/json") > 0) {
this.$refs.modeDropdown.handleCommand(BODY_FORMAT.JSON); if (this.$refs.modeDropdown) {
this.msCodeReload(); this.$refs.modeDropdown.handleCommand(BODY_FORMAT.JSON);
this.msCodeReload();
}
} }
}, },
msCodeReload() { msCodeReload() {

View File

@ -52,11 +52,11 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column-->
prop="projectName" <!-- prop="projectName"-->
:label="$t('test_track.plan.plan_project')" <!-- :label="$t('test_track.plan.plan_project')"-->
show-overflow-tooltip> <!-- show-overflow-tooltip>-->
</el-table-column> <!-- </el-table-column>-->
</el-table> </el-table>
@ -99,14 +99,6 @@ export default {
} }
this.result = this.$get('/test/case/review/list/all/relate/' + type, response => { this.result = this.$get('/test/case/review/list/all/relate/' + type, response => {
this.tableData = response.data; this.tableData = response.data;
for (let i = 0; i < this.tableData.length; i++) {
let path = "/test/case/review/project";
this.$post(path, {id: this.tableData[i].id}, res => {
let arr = res.data;
let projectName = arr.map(data => data.name).join("、");
this.$set(this.tableData[i], "projectName", projectName);
});
}
}); });
}, },
intoPlan(row) { intoPlan(row) {

View File

@ -21,7 +21,13 @@
</el-col> </el-col>
<el-col :span="11" :offset="2"> <el-col :span="11" :offset="2">
<el-form-item :label="$t('test_track.plan.related_project')" :label-width="formLabelWidth" prop="projectIds"> <el-form-item :label-width="formLabelWidth" prop="projectIds">
<template slot="label">
<el-tooltip class="item" effect="dark" :content="$t('test_track.plan.related_tip')" placement="top">
<i class="el-icon-warning"/>
</el-tooltip>
{{ $t('test_track.plan.related_project') }}
</template>
<el-select <el-select
v-model="form.projectIds" v-model="form.projectIds"
:placeholder="$t('test_track.plan.input_related_project')" :placeholder="$t('test_track.plan.input_related_project')"

View File

@ -120,15 +120,18 @@
<ms-table-operator :is-tester-permission="true" @editClick="handleEdit(scope.row)" <ms-table-operator :is-tester-permission="true" @editClick="handleEdit(scope.row)"
@deleteClick="handleDelete(scope.row)"> @deleteClick="handleDelete(scope.row)">
<template v-slot:middle> <template v-slot:middle>
<ms-table-operator-button :isTesterPermission="true" type="success" v-if="!scope.row.reportId" <ms-table-operator-button :isTesterPermission="true" style="background-color: #85888E;border-color: #85888E" v-if="!scope.row.reportId"
:tip="$t('test_track.plan_view.create_report')" icon="el-icon-document" :tip="$t('test_track.plan_view.create_report')" icon="el-icon-document"
@exec="openTestReportTemplate(scope.row)"/> @exec="openTestReportTemplate(scope.row)"/>
<ms-table-operator-button type="success" v-if="scope.row.reportId" <ms-table-operator-button v-if="scope.row.reportId"
:tip="$t('test_track.plan_view.view_report')" icon="el-icon-document" :tip="$t('test_track.plan_view.view_report')" icon="el-icon-document"
@exec="openReport(scope.row.id, scope.row.reportId)"/> @exec="openReport(scope.row.id, scope.row.reportId)"/>
</template> </template>
</ms-table-operator> </ms-table-operator>
<ms-table-operator-button style="margin-left: 10px;color:#6C317C" type="" <ms-table-operator-button style="margin-left: 10px;color:#85888E;border-color: #85888E; border-width: thin;" v-if="!scope.row.scheduleId" type="text"
:tip="$t('commons.trigger_mode.schedule')" icon="el-icon-time"
@exec="scheduleTask(scope.row)"/>
<ms-table-operator-button style="margin-left: 10px;color:#6C317C; border-color: #6C317C; border-width: thin;" v-if="scope.row.scheduleId" type="text"
:tip="$t('commons.trigger_mode.schedule')" icon="el-icon-time" :tip="$t('commons.trigger_mode.schedule')" icon="el-icon-time"
@exec="scheduleTask(scope.row)"/> @exec="scheduleTask(scope.row)"/>
</template> </template>

View File

@ -8,13 +8,21 @@
<el-table border class="adjust-table" :data="tableData" <el-table border class="adjust-table" :data="tableData"
@filter-change="filter" @sort-change="sort"> @filter-change="filter" @sort-change="sort">
<el-table-column min-width="300" prop="name" :label="$t('test_track.report.list.name')" show-overflow-tooltip></el-table-column> <el-table-column min-width="300" prop="name" :label="$t('test_track.report.list.name')" show-overflow-tooltip></el-table-column>
<el-table-column prop="testPlanName" :label="$t('test_track.report.list.test_plan')" show-overflow-tooltip></el-table-column> <el-table-column prop="testPlanName" sortable :label="$t('test_track.report.list.test_plan')" show-overflow-tooltip></el-table-column>
<el-table-column prop="creator" :label="$t('test_track.report.list.creator')" show-overflow-tooltip></el-table-column> <el-table-column prop="creator" :label="$t('test_track.report.list.creator')" show-overflow-tooltip></el-table-column>
<el-table-column prop="createTime" :label="$t('test_track.report.list.create_time' )" show-overflow-tooltip></el-table-column> <el-table-column prop="createTime" sortable :label="$t('test_track.report.list.create_time' )" show-overflow-tooltip>
<el-table-column prop="triggerMode" :label="$t('test_track.report.list.trigger_mode')" show-overflow-tooltip></el-table-column> <template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column prop="triggerMode" :label="$t('test_track.report.list.trigger_mode')" show-overflow-tooltip>
<template v-slot:default="scope">
<report-trigger-mode-item :trigger-mode="scope.row.triggerMode"/>
</template>
</el-table-column>
<el-table-column min-width="150" :label="$t('commons.operating')"> <el-table-column min-width="150" :label="$t('commons.operating')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-table-operator-button type="success" :tip="$t('test_track.plan_view.view_report')" icon="el-icon-document" <ms-table-operator-button :tip="$t('test_track.plan_view.view_report')" icon="el-icon-document"
@exec="openReport(scope.row.id)"/> @exec="openReport(scope.row.id)"/>
<ms-table-operator-button type="danger" :tip="$t('commons.delete')" icon="el-icon-delete" <ms-table-operator-button type="danger" :tip="$t('commons.delete')" icon="el-icon-delete"
@exec="handleDelete(scope.row)" /> @exec="handleDelete(scope.row)" />
@ -24,10 +32,6 @@
<ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize" <ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/> :total="total"/>
<test-plan-report-view @refresh="initTableData" ref="testPlanReportView"/> <test-plan-report-view @refresh="initTableData" ref="testPlanReportView"/>
<!-- <ms-delete-confirm :title="$t('test_track.plan.plan_delete')" @delete="_handleDelete" ref="deleteConfirm"-->
<!-- :with-tip="enableDeleteTip">-->
<!-- {{ $t('test_track.plan.plan_delete_tip') }}-->
<!-- </ms-delete-confirm>-->
</el-card> </el-card>
</template> </template>
@ -40,12 +44,14 @@ import {_filter, _sort, checkoutTestManagerOrTestUser} from "@/common/js/utils";
import {TEST_PLAN_REPORT_CONFIGS} from "../../../common/components/search/search-components"; import {TEST_PLAN_REPORT_CONFIGS} from "../../../common/components/search/search-components";
import {getCurrentProjectID} from "../../../../../common/js/utils"; import {getCurrentProjectID} from "../../../../../common/js/utils";
import TestPlanReportView from "@/business/components/track/report/components/TestPlanReportView"; import TestPlanReportView from "@/business/components/track/report/components/TestPlanReportView";
import ReportTriggerModeItem from "@/business/components/common/tableItem/ReportTriggerModeItem";
export default { export default {
name: "TestPlanReportList", name: "TestPlanReportList",
components: { components: {
TestPlanReportView, TestPlanReportView,
MsTableOperator, MsTableOperatorButton, MsTableHeader, MsTablePagination MsTableOperator, MsTableOperatorButton, MsTableHeader, MsTablePagination,
ReportTriggerModeItem
}, },
data() { data() {
return { return {

View File

@ -23,7 +23,13 @@
</el-col> </el-col>
<el-col :span="11" :offset="2"> <el-col :span="11" :offset="2">
<el-form-item :label="$t('test_track.review.review_project')" :label-width="formLabelWidth" prop="projectIds"> <el-form-item :label-width="formLabelWidth" prop="projectIds">
<template slot="label">
<el-tooltip class="item" effect="dark" :content="$t('test_track.review.related_tip')" placement="top">
<i class="el-icon-warning"/>
</el-tooltip>
{{ $t('test_track.review.related_project') }}
</template>
<el-select <el-select
v-model="form.projectIds" v-model="form.projectIds"
:placeholder="$t('test_track.review.input_review_project')" :placeholder="$t('test_track.review.input_review_project')"
@ -111,7 +117,7 @@
import TestPlanStatusButton from "../../plan/common/TestPlanStatusButton"; import TestPlanStatusButton from "../../plan/common/TestPlanStatusButton";
import {WORKSPACE_ID} from "@/common/js/constants"; import {WORKSPACE_ID} from "@/common/js/constants";
import {listenGoBack, removeGoBackListener} from "@/common/js/utils"; import {getCurrentProjectID, listenGoBack, removeGoBackListener} from "@/common/js/utils";
export default { export default {
name: "TestCaseReviewEdit", name: "TestCaseReviewEdit",
@ -134,7 +140,7 @@ export default {
{required: true, message: this.$t('test_track.plan.input_plan_name'), trigger: 'blur'}, {required: true, message: this.$t('test_track.plan.input_plan_name'), trigger: 'blur'},
{max: 30, message: this.$t('test_track.length_less_than') + '30', trigger: 'blur'} {max: 30, message: this.$t('test_track.length_less_than') + '30', trigger: 'blur'}
], ],
projectIds: [{required: true, message: this.$t('test_track.plan.input_plan_project'), trigger: 'change'}], // projectIds: [{required: true, message: this.$t('test_track.plan.input_plan_project'), trigger: 'change'}],
userIds: [{required: true, message: this.$t('test_track.plan.input_plan_principal'), trigger: 'change'}], userIds: [{required: true, message: this.$t('test_track.plan.input_plan_principal'), trigger: 'change'}],
stage: [{required: true, message: this.$t('test_track.plan.input_plan_stage'), trigger: 'change'}], stage: [{required: true, message: this.$t('test_track.plan.input_plan_stage'), trigger: 'change'}],
description: [{max: 200, message: this.$t('test_track.length_less_than') + '200', trigger: 'blur'}], description: [{max: 200, message: this.$t('test_track.length_less_than') + '200', trigger: 'blur'}],
@ -218,7 +224,7 @@ export default {
getProjects() { getProjects() {
this.result = this.$get("/project/listAll", (response) => { this.result = this.$get("/project/listAll", (response) => {
if (response.success) { if (response.success) {
this.projects = response.data; this.projects = response.data.filter(da => da.id !== getCurrentProjectID());
} else { } else {
this.$warning()(response.message); this.$warning()(response.message);
} }

View File

@ -142,6 +142,7 @@ export default {
if (!getCurrentProjectID()) { if (!getCurrentProjectID()) {
return; return;
} }
this.condition.projectId = getCurrentProjectID();
this.result = this.$post("/test/case/review/list/" + this.currentPage + "/" + this.pageSize, this.condition, response => { this.result = this.$post("/test/case/review/list/" + this.currentPage + "/" + this.pageSize, this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
@ -150,9 +151,7 @@ export default {
let path = "/test/case/review/project"; let path = "/test/case/review/project";
this.$post(path, {id: this.tableData[i].id}, res => { this.$post(path, {id: this.tableData[i].id}, res => {
let arr = res.data; let arr = res.data;
let projectName = arr.map(data => data.name).join("、"); let projectIds = arr.filter(d => d.id !== this.tableData[i].projectId).map(data => data.id);
let projectIds = arr.map(data => data.id);
this.$set(this.tableData[i], "projectName", projectName);
this.$set(this.tableData[i], "projectIds", projectIds); this.$set(this.tableData[i], "projectIds", projectIds);
}); });
this.$post('/test/case/review/reviewer', {id: this.tableData[i].id}, res => { this.$post('/test/case/review/reviewer', {id: this.tableData[i].id}, res => {

View File

@ -1081,6 +1081,7 @@ export default {
plan_name: "Test plan name", plan_name: "Test plan name",
plan_project: "Project", plan_project: "Project",
related_project: "Related Project", related_project: "Related Project",
related_tip: "After linking the project, you can add test cases under the linking project to the test plan list",
plan_stage: "Stage", plan_stage: "Stage",
plan_status: "Status", plan_status: "Status",
smoke_test: "Smoke test", smoke_test: "Smoke test",
@ -1126,6 +1127,8 @@ export default {
review_project: "Project", review_project: "Project",
review_creator: "Creator", review_creator: "Creator",
review_status: "Status", review_status: "Status",
related_project: "Related Project",
related_tip: "After the project is associated, you can add test cases under the associated project to the review list",
end_time: "EndTime", end_time: "EndTime",
delete: "Delete", delete: "Delete",
input_review_name: "Please enter the name of the review", input_review_name: "Please enter the name of the review",

View File

@ -1082,6 +1082,7 @@ export default {
plan_name: "计划名称", plan_name: "计划名称",
plan_project: "所属项目", plan_project: "所属项目",
related_project: "关联项目", related_project: "关联项目",
related_tip: "关联项目后可以添加关联项目下的测试用例到测试计划列表",
plan_stage: "测试阶段", plan_stage: "测试阶段",
plan_status: "当前状态", plan_status: "当前状态",
smoke_test: "冒烟测试", smoke_test: "冒烟测试",
@ -1125,6 +1126,8 @@ export default {
review_name: "评审名称", review_name: "评审名称",
reviewer: "评审人", reviewer: "评审人",
review_project: "所属项目", review_project: "所属项目",
related_project: "关联项目",
related_tip: "关联项目后可以添加关联项目下的测试用例到评审列表",
review_creator: "发起人", review_creator: "发起人",
review_status: "当前状态", review_status: "当前状态",
end_time: "截止时间", end_time: "截止时间",

View File

@ -1082,6 +1082,7 @@ export default {
plan_name: "計劃名稱", plan_name: "計劃名稱",
plan_project: "所屬項目", plan_project: "所屬項目",
related_project: "關聯項目", related_project: "關聯項目",
related_tip: "關聯項目後可以添加關聯項目下的測試用例到測試計劃列表",
plan_stage: "測試階段", plan_stage: "測試階段",
plan_status: "當前狀態", plan_status: "當前狀態",
smoke_test: "冒煙測試", smoke_test: "冒煙測試",
@ -1125,6 +1126,8 @@ export default {
review_name: "評審名稱", review_name: "評審名稱",
reviewer: "評審人", reviewer: "評審人",
review_project: "所屬項目", review_project: "所屬項目",
related_project: "關聯項目",
related_tip: "關聯項目後可以添加關聯項目下的測試用例到評審列表",
review_creator: "發起人", review_creator: "發起人",
review_status: "當前狀態", review_status: "當前狀態",
end_time: "截止時間", end_time: "截止時間",