fix(测试跟踪): 修复测试计划报告中不展示Timeout的接口用例和未生成性能报告的性能用例

修复测试计划报告中不展示Timeout的接口用例和未生成性能报告的性能用例
This commit is contained in:
song-tianyang 2022-07-11 17:32:32 +08:00 committed by f2c-ci-robot[bot]
parent 72eaa5ebd4
commit 358e3b2c1e
8 changed files with 103 additions and 54 deletions

View File

@ -33,4 +33,6 @@ public interface ExtLoadTestReportMapper {
List<String> selectReportIdByTestId(@Param("testId") String testId);
String selectStatusById(String id);
}

View File

@ -12,7 +12,8 @@
</resultMap>
<sql id="Base_Column_List">
id, test_id, name, create_time, update_time, status
id
, test_id, name, create_time, update_time, status
</sql>
<sql id="condition">
@ -66,7 +67,8 @@
<select id="getReportList" resultType="io.metersphere.dto.ReportDTO">
select ltr.id, ltr.name, ltr.test_id as testId, ltr.max_users maxUsers, ltr.avg_response_time avgResponseTime,
ltr.tps, ltr.test_start_time as testStartTime, ltr.test_end_time as testEndTime, ltr.test_duration as testDuration,
ltr.tps, ltr.test_start_time as testStartTime, ltr.test_end_time as testEndTime, ltr.test_duration as
testDuration,
ltr.description, user.name as userName, project.name as
projectName, ltr.trigger_mode,
ltr.create_time as createTime, ltr.update_time as updateTime, ltr.status as status, ltr.test_name as testName,
@ -136,9 +138,13 @@
<select id="getReportTestAndProInfo" resultType="io.metersphere.dto.ReportDTO">
select ltr.*,
p.id as projectId, p.name as projectName, user.name as userName
from load_test_report ltr left join load_test lt on ltr.test_id = lt.id join project p on ltr.project_id = p.id
JOIN user on ltr.user_id = user.id
p.id as projectId,
p.name as projectName,
user.name as userName
from load_test_report ltr
left join load_test lt on ltr.test_id = lt.id
join project p on ltr.project_id = p.id
JOIN user on ltr.user_id = user.id
where ltr.id = #{id}
</select>
@ -147,9 +153,9 @@
date_format(from_unixtime(create_time / 1000), '%Y-%m-%d') AS x
FROM load_test_report
WHERE test_id IN (SELECT load_test.id
FROM load_test
JOIN project ON load_test.project_id = project.id
WHERE workspace_id = #{workspaceId,jdbcType=VARCHAR})
FROM load_test
JOIN project ON load_test.project_id = project.id
WHERE workspace_id = #{workspaceId,jdbcType=VARCHAR})
AND create_time
> #{startTimestamp}
GROUP BY x
@ -197,12 +203,22 @@
<select id="getFileMetadataById" resultType="io.metersphere.base.domain.FileMetadata">
SELECT file_metadata.*
FROM load_test_report_file
JOIN file_metadata ON file_id = file_metadata.id
JOIN file_metadata ON file_id = file_metadata.id
WHERE report_id = #{reportId}
ORDER BY sort
</select>
<select id="selectReportIdByTestId" resultType="string">
SELECT id FROM load_test_report WHERE test_id = #{testId} AND `status` !='Completed'
SELECT id
FROM load_test_report
WHERE test_id = #{testId}
AND `status` !='Completed'
</select>
<select id="selectStatusById" resultType="string">
SELECT status
FROM load_test_report
WHERE id = #{0}
</select>
</mapper>

View File

@ -28,7 +28,7 @@ public interface ExtTestPlanLoadCaseMapper {
List<TestPlanLoadCaseDTO> getCases(@Param("planId") String planId, @Param("status") String status);
List<TestPlanLoadCaseDTO> getCasesByIds(@Param("ids") Collection<String> ids, @Param("reportIds") Collection<String> reportIds);
List<TestPlanLoadCaseDTO> getCasesByIds(@Param("ids") Collection<String> ids);
List<String> selectPlanIds();

View File

@ -17,13 +17,14 @@
select load_test.id
from load_test
where load_test.project_id = #{request.projectId}
<if test="!request.repeatCase">
and load_test.id not in (
select tplc.load_case_id from test_plan_load_case tplc where tplc.test_plan_id = #{request.testPlanId}
)
</if>
<if test="!request.repeatCase">
and load_test.id not in (
select tplc.load_case_id from test_plan_load_case tplc where tplc.test_plan_id = #{request.testPlanId}
)
</if>
<if test="request.name != null and request.name != ''">
and (load_test.name like CONCAT('%', #{request.name},'%') OR load_test.num like CONCAT('%', #{request.name},'%'))
and (load_test.name like CONCAT('%', #{request.name},'%') OR load_test.num like CONCAT('%',
#{request.name},'%'))
</if>
<if test="request.versionId != null">
and load_test.version_id = #{request.versionId}
@ -282,45 +283,47 @@
</if>
</select>
<select id="getStatusByTestPlanId" resultType="java.lang.String">
select status from test_plan_load_case tplc where tplc.test_plan_id = #{planId}
select status
from test_plan_load_case tplc
where tplc.test_plan_id = #{planId}
</select>
<select id="selectForPlanReport" resultType="io.metersphere.track.dto.PlanReportCaseDTO">
select tplc.id,tplc.status from test_plan_load_case tplc
inner join load_test lt on tplc.load_case_id = lt.id
select tplc.id, tplc.status
from test_plan_load_case tplc
inner join load_test lt on tplc.load_case_id = lt.id
where tplc.test_plan_id = #{planId};
</select>
<select id="getCases" resultType="io.metersphere.track.dto.TestPlanLoadCaseDTO">
select tplc.id, lt.id as caseId, lt.name, lt.num, lt.project_id,
tplc.status ,tplc.create_user, tplc.load_report_id
tplc.status ,tplc.create_user, tplc.load_report_id
from test_plan_load_case tplc
inner join load_test lt on tplc.load_case_id = lt.id
<if test="status != null">
and tplc.status = 'error'
</if>
<if test="status != null">
and tplc.status = 'error'
</if>
where tplc.test_plan_id = #{planId} ORDER BY tplc.order DESC
</select>
<select id="getCasesByIds" resultType="io.metersphere.track.dto.TestPlanLoadCaseDTO">
select tplc.id, lt.id as caseId, lt.name, lt.num, lt.project_id,
ltr.status ,tplc.create_user, tplc.load_report_id,ltr.id AS reportId
tplc.create_user, tplc.load_report_id
from test_plan_load_case tplc
inner join load_test lt on tplc.load_case_id = lt.id
inner join load_test_report ltr ON ltr.test_id = lt.id
where tplc.id IN
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and ltr.id IN
<foreach collection="reportIds" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select>
<select id="selectPlanIds" resultType="java.lang.String">
select DISTINCT test_plan_id from test_plan_load_case;
select DISTINCT test_plan_id
from test_plan_load_case;
</select>
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
select id from test_plan_load_case where test_plan_id = #{planId} order by update_time ASC;
select id
from test_plan_load_case
where test_plan_id = #{planId}
order by update_time ASC;
</select>
<select id="getLastOrder" resultType="java.lang.Long">
@ -340,8 +343,10 @@
</select>
<select id="selectIdByLoadCaseReportIdAndStatusIsRun" resultType="java.lang.String">
select `id` from test_plan_load_case where load_report_id = #{planId}
and `status` = 'run'
select `id`
from test_plan_load_case
where load_report_id = #{planId}
and `status` = 'run'
</select>
<update id="updateStatusNullById">
update test_plan_load_case tplc

View File

@ -20,6 +20,7 @@ import io.metersphere.commons.utils.*;
import io.metersphere.controller.request.OrderRequest;
import io.metersphere.controller.request.ResetOrderRequest;
import io.metersphere.dto.LoadTestDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.performance.request.QueryTestPlanRequest;
import io.metersphere.performance.request.RunTestPlanRequest;
@ -385,8 +386,21 @@ public class TestPlanLoadCaseService {
return buildCases(cases);
}
public List<TestPlanLoadCaseDTO> getAllCases(Collection<String> ids, Collection<String> reportIds) {
List<TestPlanLoadCaseDTO> cases = extTestPlanLoadCaseMapper.getCasesByIds(ids, reportIds);
public List<TestPlanLoadCaseDTO> getAllCases(Map<String, String> loadCaseReportMap) {
List<TestPlanLoadCaseDTO> cases = extTestPlanLoadCaseMapper.getCasesByIds(loadCaseReportMap.keySet());
for (TestPlanLoadCaseDTO loadCaseDTO : cases) {
String reportID = loadCaseReportMap.get(loadCaseDTO.getId());
String status = null;
if (StringUtils.isNoneEmpty(reportID)) {
status = extLoadTestReportMapper.selectStatusById(reportID);
}
if (StringUtils.isEmpty(status)) {
status = Translator.get("not_execute");
}
loadCaseDTO.setReportId(reportID);
loadCaseDTO.setLoadReportId(reportID);
loadCaseDTO.setStatus(status);
}
return buildCases(cases);
}

View File

@ -1650,7 +1650,7 @@ public class TestPlanService {
if (checkReportConfig(config, "load")) {
List<TestPlanLoadCaseDTO> allCases = null;
if (checkReportConfig(config, "load", "all")) {
allCases = testPlanLoadCaseService.getAllCases(loadCaseReportMap.keySet(), loadCaseReportMap.values());
allCases = testPlanLoadCaseService.getAllCases(loadCaseReportMap);
if (saveResponse) {
buildLoadResponse(allCases);
}

View File

@ -10,7 +10,8 @@
</template>
<api-cases :is-db="isDb" :share-id="shareId" :is-share="isShare" :report="report" :is-template="isTemplate"
:plan-id="planId" @setSize="setFailureSize"/>
<el-button class="rerun-button" plain size="mini" v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
<el-button class="rerun-button" plain size="mini"
v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
{{ $t('api_test.automation.rerun') }}
</el-button>
</el-tab-pane>
@ -20,7 +21,8 @@
</template>
<api-cases :is-db="isDb" :is-error-report="true" :share-id="shareId" :is-share="isShare" :report="report"
:is-template="isTemplate" :plan-id="planId" @setSize="setErrorReportSize"/>
<el-button class="rerun-button" plain size="mini" v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
<el-button class="rerun-button" plain size="mini"
v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
{{ $t('api_test.automation.rerun') }}
</el-button>
@ -32,7 +34,8 @@
<api-cases :is-db="isDb" :is-un-execute="true" :share-id="shareId" :is-share="isShare" :report="report"
:is-template="isTemplate" :plan-id="planId" @setSize="setUnExecuteSize"/>
<el-button class="rerun-button" plain size="mini" v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
<el-button class="rerun-button" plain size="mini"
v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
{{ $t('api_test.automation.rerun') }}
</el-button>
</el-tab-pane>
@ -43,7 +46,8 @@
</template>
<api-cases :is-db="isDb" :is-all="true" :share-id="shareId" :is-share="isShare" :report="report"
:is-template="isTemplate" :plan-id="planId" @setSize="setAllSize"/>
<el-button class="rerun-button" plain size="mini" v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
<el-button class="rerun-button" plain size="mini"
v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
{{ $t('api_test.automation.rerun') }}
</el-button>
@ -83,7 +87,10 @@ export default {
computed: {
resultEnable() {
let disable = this.report.config && this.report.config.api.children.result.enable === false;
return !disable;
return !disable && this.report.apiResult && (
(this.report.apiResult.apiCaseData && this.report.apiResult.apiCaseData.length > 0)
|| (this.report.apiResult.apiScenarioData && this.report.apiResult.apiScenarioData.length > 0)
);
},
failureEnable() {
let disable = this.report.config && this.report.config.api.children.failure.enable === false;

View File

@ -5,10 +5,14 @@
<test-plan-report-buttons :is-db="isDb" :plan-id="planId" :is-share="isShare" :report="report"
v-if="!isTemplate && !isShare"/>
<test-plan-overview-report v-if="overviewEnable" :report="report"/>
<test-plan-summary-report v-if="summaryEnable" :is-db="isDb" :is-template="isTemplate" :is-share="isShare" :report="report" :plan-id="planId"/>
<test-plan-functional-report v-if="functionalEnable" :is-db="isDb" :share-id="shareId" :is-share="isShare" :is-template="isTemplate" :plan-id="planId" :report="report"/>
<test-plan-api-report v-if="apiEnable" :is-db="isDb" :share-id="shareId" :is-share="isShare" :is-template="isTemplate" :report="report" :plan-id="planId"/>
<test-plan-load-report v-if="loadEnable" :is-db="isDb" :share-id="shareId" :is-share="isShare" :is-template="isTemplate" :report="report" :plan-id="planId"/>
<test-plan-summary-report v-if="summaryEnable" :is-db="isDb" :is-template="isTemplate" :is-share="isShare"
:report="report" :plan-id="planId"/>
<test-plan-functional-report v-if="functionalEnable" :is-db="isDb" :share-id="shareId" :is-share="isShare"
:is-template="isTemplate" :plan-id="planId" :report="report"/>
<test-plan-api-report v-if="apiEnable" :is-db="isDb" :share-id="shareId" :is-share="isShare"
:is-template="isTemplate" :report="report" :plan-id="planId"/>
<test-plan-load-report v-if="loadEnable" :is-db="isDb" :share-id="shareId" :is-share="isShare"
:is-template="isTemplate" :report="report" :plan-id="planId"/>
</el-card>
</ms-main-container>
<test-plan-report-navigation-bar
@ -25,7 +29,6 @@
import TestPlanFunctionalReport
from "@/business/components/track/plan/view/comonents/report/detail/TestPlanFunctionalReport";
import {
getExportReport,
getShareTestPlanReport,
getShareTestPlanReportContent,
getTestPlanReport,
@ -43,6 +46,7 @@ import TestPlanReportNavigationBar
from "@/business/components/track/plan/view/comonents/report/detail/TestPlanReportNavigationBar";
import MsContainer from "@/business/components/common/components/MsContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
export default {
name: "TestPlanReportContent",
components: {
@ -58,7 +62,7 @@ export default {
TestPlanFunctionalReport,
},
props: {
planId:String,
planId: String,
isShare: Boolean,
isTemplate: Boolean,
isDb: Boolean,
@ -102,15 +106,16 @@ export default {
functionalEnable() {
let disable = this.report.config && this.report.config.functional.enable === false;
return !disable && this.report.functionResult
&& this.report.functionResult.caseData && this.report.functionResult.caseData.length > 0 ;
&& this.report.functionResult.caseData && this.report.functionResult.caseData.length > 0;
},
apiEnable() {
let disable = this.report.config && this.report.config.api.enable === false;
return !disable && this.report.apiResult &&
return !disable && ((this.report.apiResult &&
(
(this.report.apiResult.apiCaseData && this.report.apiResult.apiCaseData.length > 0)
(this.report.apiResult.apiCaseData && this.report.apiResult.apiCaseData.length > 0)
|| (this.report.apiResult.apiScenarioData && this.report.apiResult.apiScenarioData.length > 0)
);
)) || (this.report.apiAllCases && this.report.apiAllCases.length > 0) || (this.report.scenarioAllCases && this.report.scenarioAllCases.length > 0));
},
loadEnable() {
let disable = this.report.config && this.report.config.load.enable === false;
@ -126,7 +131,7 @@ export default {
this.$setLang(this.report.lang);
}
this.report.config = this.getDefaultConfig(this.report);
} else if (this.isDb) {
} else if (this.isDb) {
if (this.isShare) {
//
this.result = getShareTestPlanReportContent(this.shareId, this.reportId, (data) => {
@ -159,7 +164,7 @@ export default {
dbConfig = JSON.parse(configStr);
}
}
let config = {
let config = {
overview: {
enable: true,
name: this.$t('test_track.report.overview')