fix(测试计划): 修复测试计划执行报告看不到性能测试用例的问题

修复测试计划执行报告看不到性能测试用例的问题
This commit is contained in:
song-tianyang 2022-01-12 15:36:39 +08:00 committed by song-tianyang
parent c2b5ed5dfc
commit 4807af0c42
5 changed files with 55 additions and 50 deletions

View File

@ -11,6 +11,7 @@ import java.util.List;
public interface ExtTestPlanLoadCaseMapper { public interface ExtTestPlanLoadCaseMapper {
List<String> selectIdsNotInPlan(@Param("request") LoadCaseRequest request); List<String> selectIdsNotInPlan(@Param("request") LoadCaseRequest request);
List<TestPlanLoadCaseDTO> selectTestPlanLoadCaseList(@Param("request") LoadCaseRequest request); List<TestPlanLoadCaseDTO> selectTestPlanLoadCaseList(@Param("request") LoadCaseRequest request);
List<TestPlanLoadCaseDTO> selectByIdIn(@Param("request") LoadCaseRequest request); List<TestPlanLoadCaseDTO> selectByIdIn(@Param("request") LoadCaseRequest request);
@ -26,15 +27,16 @@ public interface ExtTestPlanLoadCaseMapper {
List<PlanReportCaseDTO> selectForPlanReport(String planId); List<PlanReportCaseDTO> selectForPlanReport(String planId);
List<TestPlanLoadCaseDTO> getCases(@Param("planId") String planId, @Param("status") String status); List<TestPlanLoadCaseDTO> getCases(@Param("planId") String planId, @Param("status") String status);
List<TestPlanLoadCaseDTO> getCasesByIds(@Param("ids") Collection<String> ids, @Param("planId") String planId, @Param("status") String status);
List<TestPlanLoadCaseDTO> getCasesByIds(@Param("ids") Collection<String> ids, @Param("reportIds") Collection<String> reportIds);
List<String> selectPlanIds(); List<String> selectPlanIds();
List<String> getIdsOrderByUpdateTime(@Param("planId") String planId); List<String> getIdsOrderByUpdateTime(@Param("planId") String planId);
Long getPreOrder(@Param("planId")String planId, @Param("baseOrder") Long baseOrder); Long getPreOrder(@Param("planId") String planId, @Param("baseOrder") Long baseOrder);
Long getLastOrder(@Param("planId")String planId, @Param("baseOrder") Long baseOrder); Long getLastOrder(@Param("planId") String planId, @Param("baseOrder") Long baseOrder);
List<String> selectIdByLoadCaseReportIdAndStatusIsRun(String reportId); List<String> selectIdByLoadCaseReportIdAndStatusIsRun(String reportId);

View File

@ -345,17 +345,18 @@
<select id="getCasesByIds" resultType="io.metersphere.track.dto.TestPlanLoadCaseDTO"> <select id="getCasesByIds" resultType="io.metersphere.track.dto.TestPlanLoadCaseDTO">
select tplc.id, lt.id as caseId, lt.name, lt.num, lt.project_id, select tplc.id, lt.id as caseId, lt.name, lt.num, lt.project_id,
tplc.status ,tplc.create_user, tplc.load_report_id ltr.status ,tplc.create_user, tplc.load_report_id,ltr.id AS reportId
from test_plan_load_case tplc from test_plan_load_case tplc
inner join load_test lt on tplc.load_case_id = lt.id inner join load_test lt on tplc.load_case_id = lt.id
<if test="status != null"> inner join load_test_report ltr ON ltr.test_id = lt.id
and tplc.status = 'error' where tplc.id IN
</if>
where tplc.test_plan_id = #{planId}
and lt.id IN
<foreach collection="ids" item="id" separator="," open="(" close=")"> <foreach collection="ids" item="id" separator="," open="(" close=")">
#{id} #{id}
</foreach> </foreach>
and ltr.id IN
<foreach collection="reportIds" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select> </select>
<select id="selectPlanIds" resultType="java.lang.String"> <select id="selectPlanIds" resultType="java.lang.String">

View File

@ -408,8 +408,8 @@ public class TestPlanLoadCaseService {
return buildCases(cases); return buildCases(cases);
} }
public List<TestPlanLoadCaseDTO> getAllCases(Collection<String> ids, String planId, String status) { public List<TestPlanLoadCaseDTO> getAllCases(Collection<String> ids, Collection<String> reportIds) {
List<TestPlanLoadCaseDTO> cases = extTestPlanLoadCaseMapper.getCasesByIds(ids, planId, status); List<TestPlanLoadCaseDTO> cases = extTestPlanLoadCaseMapper.getCasesByIds(ids, reportIds);
return buildCases(cases); return buildCases(cases);
} }

View File

@ -1071,16 +1071,16 @@ public class TestPlanService {
//执行接口案例任务 //执行接口案例任务
Map<String,String> apiCaseReportMap = this.executeApiTestCase(triggerMode, planReportId,userId, new ArrayList<>(reportInfoDTO.getApiTestCaseDataMap().keySet()), runModeConfig); Map<String, String> apiCaseReportMap = this.executeApiTestCase(triggerMode, planReportId, userId, new ArrayList<>(reportInfoDTO.getApiTestCaseDataMap().keySet()), runModeConfig);
//执行场景执行任务 //执行场景执行任务
Map<String,String> scenarioReportMap = this.executeScenarioCase(planReportId, testPlanID, projectID, runModeConfig, triggerMode, userId, reportInfoDTO.getPlanScenarioIdMap()); Map<String, String> scenarioReportMap = this.executeScenarioCase(planReportId, testPlanID, projectID, runModeConfig, triggerMode, userId, reportInfoDTO.getPlanScenarioIdMap());
//执行性能测试任务 //执行性能测试任务
Map<String,String> loadCaseReportMap = this.executeLoadCaseTask(runModeConfig, triggerMode, reportInfoDTO.getPerformanceIdMap()); Map<String, String> loadCaseReportMap = this.executeLoadCaseTask(runModeConfig, triggerMode, reportInfoDTO.getPerformanceIdMap());
testPlanReportService.createTestPlanReportContentReportIds(planReportId, apiCaseReportMap,scenarioReportMap,loadCaseReportMap); testPlanReportService.createTestPlanReportContentReportIds(planReportId, apiCaseReportMap, scenarioReportMap, loadCaseReportMap);
return planReportId; return planReportId;
} }
private Map<String,String> executeApiTestCase(String triggerMode, String planReportId, String userId, List<String> planCaseIds, RunModeConfigDTO runModeConfig) { private Map<String, String> executeApiTestCase(String triggerMode, String planReportId, String userId, List<String> planCaseIds, RunModeConfigDTO runModeConfig) {
BatchRunDefinitionRequest request = new BatchRunDefinitionRequest(); BatchRunDefinitionRequest request = new BatchRunDefinitionRequest();
request.setTriggerMode(triggerMode); request.setTriggerMode(triggerMode);
request.setPlanIds(planCaseIds); request.setPlanIds(planCaseIds);
@ -1091,7 +1091,7 @@ public class TestPlanService {
return this.parseMsExecREsponseDTOToTestIdReportMap(dtoList); return this.parseMsExecREsponseDTOToTestIdReportMap(dtoList);
} }
private Map<String,String> executeScenarioCase(String planReportId, String testPlanID, String projectID, RunModeConfigDTO runModeConfig, String triggerMode, String userId, Map<String, String> planScenarioIdMap) { private Map<String, String> executeScenarioCase(String planReportId, String testPlanID, String projectID, RunModeConfigDTO runModeConfig, String triggerMode, String userId, Map<String, String> planScenarioIdMap) {
if (!planScenarioIdMap.isEmpty()) { if (!planScenarioIdMap.isEmpty()) {
SchedulePlanScenarioExecuteRequest scenarioRequest = new SchedulePlanScenarioExecuteRequest(); SchedulePlanScenarioExecuteRequest scenarioRequest = new SchedulePlanScenarioExecuteRequest();
String senarionReportID = UUID.randomUUID().toString(); String senarionReportID = UUID.randomUUID().toString();
@ -1116,19 +1116,19 @@ public class TestPlanService {
scenarioRequest.setTestPlanID(testPlanID); scenarioRequest.setTestPlanID(testPlanID);
scenarioRequest.setTestPlanReportId(planReportId); scenarioRequest.setTestPlanReportId(planReportId);
scenarioRequest.setConfig(runModeConfig); scenarioRequest.setConfig(runModeConfig);
List<MsExecResponseDTO> dtoList = this.scenarioRunModeConfig(scenarioRequest); List<MsExecResponseDTO> dtoList = this.scenarioRunModeConfig(scenarioRequest);
return this.parseMsExecREsponseDTOToTestIdReportMap(dtoList); return this.parseMsExecREsponseDTOToTestIdReportMap(dtoList);
}else { } else {
return new HashMap<>(); return new HashMap<>();
} }
} }
private Map<String, String> parseMsExecREsponseDTOToTestIdReportMap(List<MsExecResponseDTO> dtoList) { private Map<String, String> parseMsExecREsponseDTOToTestIdReportMap(List<MsExecResponseDTO> dtoList) {
Map<String,String> returnMap = new HashMap<>(); Map<String, String> returnMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(dtoList)){ if (CollectionUtils.isNotEmpty(dtoList)) {
dtoList.forEach( item -> { dtoList.forEach(item -> {
if(StringUtils.isNotEmpty(item.getTestId()) && StringUtils.isNotEmpty(item.getReportId())){ if (StringUtils.isNotEmpty(item.getTestId()) && StringUtils.isNotEmpty(item.getReportId())) {
returnMap.put(item.getTestId(),item.getReportId()); returnMap.put(item.getTestId(), item.getReportId());
} }
}); });
} }
@ -1676,18 +1676,14 @@ public class TestPlanService {
} }
} }
public void buildLoadReport(TestPlanSimpleReportDTO report, JSONObject config, Map<String, String> loadCaseReportMap, String planId, boolean saveResponse) { public void buildLoadReport(TestPlanSimpleReportDTO report, JSONObject config, Map<String, String> loadCaseReportMap, boolean saveResponse) {
if (MapUtils.isEmpty(loadCaseReportMap)) { if (MapUtils.isEmpty(loadCaseReportMap)) {
return; return;
} }
if (checkReportConfig(config, "load")) { if (checkReportConfig(config, "load")) {
List<TestPlanLoadCaseDTO> allCases = null; List<TestPlanLoadCaseDTO> allCases = null;
if (checkReportConfig(config, "load", "all")) { if (checkReportConfig(config, "load", "all")) {
allCases = testPlanLoadCaseService.getAllCases(loadCaseReportMap.keySet(), planId, null); allCases = testPlanLoadCaseService.getAllCases(loadCaseReportMap.keySet(), loadCaseReportMap.values());
for (TestPlanLoadCaseDTO dto : allCases) {
String reportId = loadCaseReportMap.get(dto.getId());
dto.setReportId(reportId);
}
if (saveResponse) { if (saveResponse) {
buildLoadResponse(allCases); buildLoadResponse(allCases);
} }
@ -1718,7 +1714,7 @@ public class TestPlanService {
TestPlanSimpleReportDTO report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO); TestPlanSimpleReportDTO report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO);
buildFunctionalReport(report, config, testPlanReport.getTestPlanId()); buildFunctionalReport(report, config, testPlanReport.getTestPlanId());
buildApiReport(report, config, testPlanExecuteReportDTO); buildApiReport(report, config, testPlanExecuteReportDTO);
buildLoadReport(report, config, testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap(), testPlanReport.getTestPlanId(), false); buildLoadReport(report, config, testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap(), false);
return report; return report;
} else { } else {
return null; return null;

View File

@ -1,34 +1,34 @@
<template> <template>
<el-card> <el-card>
<el-scrollbar> <el-scrollbar>
<el-table <el-table
row-key="id" row-key="id"
@row-click="rowClick" @row-click="rowClick"
:highlight-current-row="true" :highlight-current-row="true"
:data="loadTestCases"> :data="loadTestCases">
<el-table-column <el-table-column
prop="num" prop="num"
:label="$t('commons.id')" :label="$t('commons.id')"
show-overflow-tooltip> show-overflow-tooltip>
<template v-slot:default="{row}"> <template v-slot:default="{row}">
{{row.isCustomNum ? row.customNum : row.num }} {{ row.isCustomNum ? row.customNum : row.num }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="name" prop="name"
:label="$t('commons.name')" :label="$t('commons.name')"
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="userName" prop="userName"
:label="$t('commons.create_user')"> :label="$t('commons.create_user')">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="status" prop="status"
column-key="status" column-key="status"
:label="$t('test_track.plan_view.execute_result')"> :label="$t('test_track.plan_view.execute_result')">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<el-tag size="mini" type="danger" v-if="row.status === 'error'"> <el-tag size="mini" type="danger" v-if="row.status === 'error'">
{{ row.status }} {{ row.status }}
@ -39,7 +39,12 @@
<el-tag size="mini" v-else-if="row.status === 'run'"> <el-tag size="mini" v-else-if="row.status === 'run'">
{{ row.status }} {{ row.status }}
</el-tag> </el-tag>
<span v-else>-</span> <el-tag size="mini" v-else-if="row.status === 'Completed'">
{{ row.status }}
</el-tag>
<el-tag size="mini" v-else>
{{ row.status }}
</el-tag>
</template> </template>
</el-table-column> </el-table-column>
@ -58,6 +63,7 @@ import {
getSharePlanLoadAllCase, getSharePlanLoadAllCase,
getSharePlanLoadFailureCase getSharePlanLoadFailureCase
} from "@/network/test-plan"; } from "@/network/test-plan";
export default { export default {
name: "LoadFailureResult", name: "LoadFailureResult",
components: {StatusTableItem, MethodTableItem, TypeTableItem}, components: {StatusTableItem, MethodTableItem, TypeTableItem},
@ -72,7 +78,7 @@ export default {
}, },
data() { data() {
return { return {
loadTestCases: [] loadTestCases: []
} }
}, },
mounted() { mounted() {