# 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());
List<String> testPlanReportIdList = new ArrayList<>();
testPlanReportIdList.add(debugReportId);
testPlanReportService.updateReport(testPlanReportIdList,ApiRunMode.SCHEDULE_API_PLAN.name());
testPlanReportService.updateReport(testPlanReportIdList,ApiRunMode.SCHEDULE_API_PLAN.name(),ReportTriggerMode.SCHEDULE.name());
}else {
apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.API_PLAN.name());
}

View File

@ -190,7 +190,7 @@ public class ApiDefinitionService {
.andProtocolEqualTo(request.getProtocol()).andPathEqualTo(request.getPath())
.andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId());
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"));
}
} else {

View File

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

View File

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

View File

@ -563,6 +563,76 @@ public class TestCaseReviewExample {
addCriterion("end_time not between", value1, value2, "endTime");
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 {

View File

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

View File

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

View File

@ -98,8 +98,9 @@
<select id="list" resultType="io.metersphere.track.dto.TestPlanDTOWithMetric"
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 schedule ON schedule.resource_id = test_plan.id
JOIN project on project.id = test_plan.project_id
<where>
<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
FROM test_plan tp
INNER JOIN test_plan_report tpr on tp.id = tpr.test_plan_id
-- INNER JOIN
<where>
<if test="name != null">
and tpr.name like CONCAT('%', #{name},'%')
@ -26,7 +25,12 @@
<if test="orders != null and orders.size() > 0">
order by
<foreach collection="orders" separator="," item="order">
<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>
</if>
</select>

View File

@ -202,11 +202,10 @@
<select id="findRelateTestReviewId" resultType="java.lang.String">
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_project on test_case_review_project.review_id = test_case_review.id
inner join project on project.id = test_case_review_project.project_id
inner join project on project.id = test_case_review.project_id
where test_case_review_test_case.review_id = #{userId}
and project.workspace_id = #{workspaceId}
and test_case_review_project.project_id = #{projectId}
and test_case_review.project_id = #{projectId}
</select>
<select id="listTestCaseByProjectIds" resultType="io.metersphere.track.dto.TestReviewCaseDTO">
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.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.config.KafkaProperties;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.reflections8.Reflections;
import org.springframework.kafka.annotation.KafkaListener;
@ -21,6 +22,8 @@ public class LoadTestConsumer {
LoadTestReport loadTestReport = JSON.parseObject(record.value(), LoadTestReport.class);
Reflections reflections = new Reflections(Application.class);
Set<Class<? extends LoadTestFinishEvent>> subTypes = reflections.getSubTypesOf(LoadTestFinishEvent.class);
LogUtil.info("Execute Over: LoadTestConsumer");
System.out.println("Execute Over: LoadTestConsumer");
subTypes.forEach(s -> {
try {
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.ReportTriggerMode;
import io.metersphere.commons.constants.ScheduleGroup;
import io.metersphere.commons.consumer.LoadTestFinishEvent;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.performance.service.PerformanceTestService;
@ -25,6 +24,8 @@ import org.quartz.*;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 情景测试Job
@ -102,7 +103,7 @@ public class TestPlanTestJob extends MsScheduleJob {
void businessExecute(JobExecutionContext context) {
LogUtil.info("-------------- start testplan schedule ----------");
//首先创建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()) {
String apiCaseID = entry.getKey();
@ -127,39 +128,38 @@ public class TestPlanTestJob extends MsScheduleJob {
scenarioRequest.setTestPlanID(this.resourceId);
scenarioRequest.setRunMode(ApiRunMode.SCHEDULE_SCENARIO_PLAN.name());
scenarioRequest.setTestPlanReportId(testPlanReport.getId());
String reportID = apiAutomationService.run(scenarioRequest);
apiAutomationService.run(scenarioRequest);
LogUtil.info("-------------- testplan schedule ---------- scenario case over -----------------");
//执行性能测试任务
boolean havePerformanceTask = false;
List<String> performaneReportIDList = new ArrayList<>();
for (Map.Entry<String,String> entry: this.performanceIdMap.entrySet()) {
String id = entry.getKey();
String caseID = entry.getValue();
RunTestPlanRequest performanceRequest = new RunTestPlanRequest();
performanceRequest.setId(id);
performanceRequest.setId(caseID);
performanceRequest.setTestPlanLoadId(caseID);
performanceRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
String reportId = null;
havePerformanceTask = true;
try {
reportId = performanceTestService.run(performanceRequest);
}catch (Exception e){
}
if(reportID!=null){
if(reportId!=null){
performaneReportIDList.add(reportId);
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId());
testPlanLoadCase.setLoadReportId(reportId);
testPlanLoadCaseService.update(testPlanLoadCase);
performaneReportIDList.add(reportID);
}
}catch (Exception e){
e.printStackTrace();
}
}
if(!performaneReportIDList.isEmpty()){
//性能测试时保存性能测试报告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.ReportTriggerMode;
import io.metersphere.commons.consumer.LoadTestFinishEvent;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.BaseSystemConfigDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.notice.sender.NoticeModel;
@ -70,6 +71,7 @@ public class PerformanceNoticeEvent implements LoadTestFinishEvent {
@Override
public void execute(LoadTestReport loadTestReport) {
LogUtil.info("PerformanceNoticeEvent OVER:" + loadTestReport.getTriggerMode()+";"+loadTestReport.getStatus());
if (StringUtils.equals(ReportTriggerMode.API.name(), loadTestReport.getTriggerMode())
|| StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), loadTestReport.getTriggerMode())) {
if (StringUtils.equalsAny(loadTestReport.getStatus(),

View File

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

View File

@ -4,6 +4,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.TestCaseReport;
import io.metersphere.base.domain.TestPlanReport;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
@ -52,4 +53,10 @@ public class TestPlanReportController {
public void delete(@RequestBody List<String> 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 userName;
private List<String> projectIds;
private String scheduleId;
}

View File

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

View File

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

View File

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

View File

@ -4,7 +4,9 @@ import io.metersphere.base.domain.LoadTestReport;
import io.metersphere.base.domain.TestPlanReport;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.consumer.LoadTestFinishEvent;
import io.metersphere.commons.utils.LogUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -22,10 +24,11 @@ public class TestPlanLoadCaseEvent implements LoadTestFinishEvent {
@Override
public void execute(LoadTestReport loadTestReport) {
LogUtil.info("PerformanceNoticeEvent OVER:" + loadTestReport.getTriggerMode()+";"+loadTestReport.getStatus());
if (StringUtils.equals(NoticeConstants.Mode.SCHEDULE, loadTestReport.getTriggerMode()) ) {
if (StringUtils.equalsAny(loadTestReport.getStatus(),
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.ExtTestPlanMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanReportMapper;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.constants.TestPlanStatus;
import io.metersphere.commons.constants.*;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.DateUtils;
import io.metersphere.commons.utils.ServiceUtils;
@ -33,6 +30,8 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
/**
@ -62,9 +61,12 @@ public class TestPlanReportService {
ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper;
@Resource
TestPlanLoadCaseService testPlanLoadCaseService;
@Resource
TestPlanService testPlanService;
@Resource
LoadTestReportMapper loadTestReportMapper;
private final ExecutorService executorService = Executors.newFixedThreadPool(20);
public List<TestPlanReportDTO> list(QueryTestPlanReportRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
@ -76,9 +78,7 @@ public class TestPlanReportService {
return returnList;
}
public TestPlanReport genTestPlanReport(String planId, String userId) {
TestPlanReportDTO returnDTO = new TestPlanReportDTO();
public TestPlanReport genTestPlanReport(String planId, String userId,String triggerMode) {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId);
TestPlanApiCaseExample apiExample = new TestPlanApiCaseExample();
@ -107,7 +107,7 @@ public class TestPlanReportService {
testPlanReport.setName(testPlan.getName() + "-" + DateUtils.getTimeString(new Date()));
} catch (Exception e) {
}
testPlanReport.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
testPlanReport.setTriggerMode(triggerMode);
testPlanReport.setCreator(userId);
testPlanReport.setStartTime(System.currentTimeMillis());
testPlanReport.setEndTime(System.currentTimeMillis());
@ -145,77 +145,6 @@ public class TestPlanReportService {
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) {
TestPlanReportDTO returnDTO = new TestPlanReportDTO();
TestPlanReport report = testPlanReportMapper.selectByPrimaryKey(reportId);
@ -252,21 +181,32 @@ public class TestPlanReportService {
return returnDTO;
}
public synchronized void updateReport(List<String> testPlanReportIdList, String runMode) {
planReportForeach:
public synchronized void updateReport(List<String> testPlanReportIdList, String runMode,String triggerMode) {
for (String planReportId : testPlanReportIdList) {
this.countReportByTestPlanReportId(planReportId,runMode,triggerMode);
}
}
/**
*
* @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.equalsAny(runMode, ApiRunMode.SCHEDULE_API_PLAN.name())) {
//因为接口案例的定时任务是单个案例开线程运行 所以要检查是否都执行完成全部执行完成时才会进行统一整理
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) {
continue planReportForeach;
return;
}
}
}
@ -281,12 +221,20 @@ public class TestPlanReportService {
testPlanService.buildScenarioCaseReport(testPlanReport.getTestPlanId(), components);
testPlanService.buildLoadCaseReport(testPlanReport.getTestPlanId(), components);
if (StringUtils.equals(runMode, ApiRunMode.SCHEDULE_API_PLAN.name())) {
//只针对定时任务做处理
if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(),triggerMode)
&&StringUtils.equals(resourceRunMode, ApiRunMode.SCHEDULE_API_PLAN.name())) {
testPlanReport.setIsApiCaseExecuting(false);
} else if (StringUtils.equals(runMode, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
} else if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(),triggerMode)
&&StringUtils.equals(resourceRunMode, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
testPlanReport.setIsScenarioExecuting(false);
} else if (StringUtils.equals(runMode, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name())) {
} 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 -> {
@ -306,9 +254,8 @@ public class TestPlanReportService {
testPlanReportDataMapper.updateByPrimaryKeyWithBLOBs(testPlanReportData);
}
}
}
}
public void update(TestPlanReport report) {
if (!report.getIsApiCaseExecuting() && !report.getIsPerformanceExecuting() && !report.getIsScenarioExecuting()) {
@ -381,7 +328,7 @@ public class TestPlanReportService {
* @param testPlanReport
* @param performaneReportIDList
*/
public void updatePerformanceInfo(TestPlanReport testPlanReport, List<String> performaneReportIDList) {
public void updatePerformanceInfo(TestPlanReport testPlanReport, List<String> performaneReportIDList,String triggerMode) {
TestPlanReportDataExample example = new TestPlanReportDataExample();
example.createCriteria().andTestPlanReportIdEqualTo(testPlanReport.getId());
List<TestPlanReportDataWithBLOBs> reportDataList = testPlanReportDataMapper.selectByExampleWithBLOBs(example);
@ -389,11 +336,54 @@ public class TestPlanReportService {
models.setPerformanceInfo(JSONArray.toJSONString(performaneReportIDList));
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);
this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name());
this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(),triggerMode);
}
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.mapper.ProjectMapper;
import io.metersphere.base.mapper.TestCaseReviewMapper;
import io.metersphere.base.mapper.TestCaseReviewProjectMapper;
import io.metersphere.track.request.testreview.TestReviewRelevanceRequest;
import org.apache.commons.lang3.StringUtils;
@ -17,18 +18,25 @@ import java.util.stream.Collectors;
public class TestReviewProjectService {
@Resource
ProjectMapper projectMapper;
private ProjectMapper projectMapper;
@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();
example.createCriteria().andReviewIdEqualTo(reviewId);
List<String> projectIds = testCaseReviewProjectMapper.selectByExample(example)
.stream()
.map(TestCaseReviewProject::getProjectId)
.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()) {
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"/>
<ms-table-select-all v-if="!referenced"
:page-size="pageSize"
:page-size="pageSize>total?total:pageSize"
:total="total"
@selectPageAll="isSelectDataAll(false)"
@selectAll="isSelectDataAll(true)"/>

View File

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

View File

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

View File

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

View File

@ -52,11 +52,11 @@
</template>
</el-table-column>
<el-table-column
prop="projectName"
:label="$t('test_track.plan.plan_project')"
show-overflow-tooltip>
</el-table-column>
<!-- <el-table-column-->
<!-- prop="projectName"-->
<!-- :label="$t('test_track.plan.plan_project')"-->
<!-- show-overflow-tooltip>-->
<!-- </el-table-column>-->
</el-table>
@ -99,14 +99,6 @@ export default {
}
this.result = this.$get('/test/case/review/list/all/relate/' + type, response => {
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) {

View File

@ -21,7 +21,13 @@
</el-col>
<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
v-model="form.projectIds"
: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)"
@deleteClick="handleDelete(scope.row)">
<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"
@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"
@exec="openReport(scope.row.id, scope.row.reportId)"/>
</template>
</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"
@exec="scheduleTask(scope.row)"/>
</template>

View File

@ -8,13 +8,21 @@
<el-table border class="adjust-table" :data="tableData"
@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 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="createTime" :label="$t('test_track.report.list.create_time' )" show-overflow-tooltip></el-table-column>
<el-table-column prop="triggerMode" :label="$t('test_track.report.list.trigger_mode')" show-overflow-tooltip></el-table-column>
<el-table-column prop="createTime" sortable :label="$t('test_track.report.list.create_time' )" show-overflow-tooltip>
<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')">
<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)"/>
<ms-table-operator-button type="danger" :tip="$t('commons.delete')" icon="el-icon-delete"
@exec="handleDelete(scope.row)" />
@ -24,10 +32,6 @@
<ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/>
<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>
</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 {getCurrentProjectID} from "../../../../../common/js/utils";
import TestPlanReportView from "@/business/components/track/report/components/TestPlanReportView";
import ReportTriggerModeItem from "@/business/components/common/tableItem/ReportTriggerModeItem";
export default {
name: "TestPlanReportList",
components: {
TestPlanReportView,
MsTableOperator, MsTableOperatorButton, MsTableHeader, MsTablePagination
MsTableOperator, MsTableOperatorButton, MsTableHeader, MsTablePagination,
ReportTriggerModeItem
},
data() {
return {

View File

@ -23,7 +23,13 @@
</el-col>
<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
v-model="form.projectIds"
:placeholder="$t('test_track.review.input_review_project')"
@ -111,7 +117,7 @@
import TestPlanStatusButton from "../../plan/common/TestPlanStatusButton";
import {WORKSPACE_ID} from "@/common/js/constants";
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
import {getCurrentProjectID, listenGoBack, removeGoBackListener} from "@/common/js/utils";
export default {
name: "TestCaseReviewEdit",
@ -134,7 +140,7 @@ export default {
{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'}
],
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'}],
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'}],
@ -218,7 +224,7 @@ export default {
getProjects() {
this.result = this.$get("/project/listAll", (response) => {
if (response.success) {
this.projects = response.data;
this.projects = response.data.filter(da => da.id !== getCurrentProjectID());
} else {
this.$warning()(response.message);
}

View File

@ -142,6 +142,7 @@ export default {
if (!getCurrentProjectID()) {
return;
}
this.condition.projectId = getCurrentProjectID();
this.result = this.$post("/test/case/review/list/" + this.currentPage + "/" + this.pageSize, this.condition, response => {
let data = response.data;
this.total = data.itemCount;
@ -150,9 +151,7 @@ export default {
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("、");
let projectIds = arr.map(data => data.id);
this.$set(this.tableData[i], "projectName", projectName);
let projectIds = arr.filter(d => d.id !== this.tableData[i].projectId).map(data => data.id);
this.$set(this.tableData[i], "projectIds", projectIds);
});
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_project: "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_status: "Status",
smoke_test: "Smoke test",
@ -1126,6 +1127,8 @@ export default {
review_project: "Project",
review_creator: "Creator",
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",
delete: "Delete",
input_review_name: "Please enter the name of the review",

View File

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

View File

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