fix: 性能测试报告报错

This commit is contained in:
chenjianxing 2021-08-25 09:54:03 +08:00 committed by jianxing
parent 7dcc7de2ed
commit 52fad8d632
3 changed files with 30 additions and 8 deletions

View File

@ -10,7 +10,9 @@ import io.metersphere.api.service.ShareInfoService;
import io.metersphere.base.domain.IssuesDao; import io.metersphere.base.domain.IssuesDao;
import io.metersphere.base.domain.LoadTestReportWithBLOBs; import io.metersphere.base.domain.LoadTestReportWithBLOBs;
import io.metersphere.performance.base.ReportTimeInfo; import io.metersphere.performance.base.ReportTimeInfo;
import io.metersphere.performance.dto.LoadTestExportJmx;
import io.metersphere.performance.service.PerformanceReportService; import io.metersphere.performance.service.PerformanceReportService;
import io.metersphere.performance.service.PerformanceTestService;
import io.metersphere.track.dto.TestPlanCaseDTO; import io.metersphere.track.dto.TestPlanCaseDTO;
import io.metersphere.track.dto.TestPlanLoadCaseDTO; import io.metersphere.track.dto.TestPlanLoadCaseDTO;
import io.metersphere.track.dto.TestPlanSimpleReportDTO; import io.metersphere.track.dto.TestPlanSimpleReportDTO;
@ -47,6 +49,8 @@ public class ShareController {
ShareInfoService shareInfoService; ShareInfoService shareInfoService;
@Resource @Resource
PerformanceReportService performanceReportService; PerformanceReportService performanceReportService;
@Resource
PerformanceTestService performanceTestService;
@GetMapping("/issues/plan/get/{shareId}/{planId}") @GetMapping("/issues/plan/get/{shareId}/{planId}")
public List<IssuesDao> getIssuesByPlanoId(@PathVariable String shareId, @PathVariable String planId) { public List<IssuesDao> getIssuesByPlanoId(@PathVariable String shareId, @PathVariable String planId) {
@ -144,5 +148,15 @@ public class ShareController {
return testPlanLoadCaseService.isExistReport(request); return testPlanLoadCaseService.isExistReport(request);
} }
@GetMapping("/performance/report/get-jmx-content/{reportId}")
public LoadTestExportJmx getJmxContent(@PathVariable String reportId) {
return performanceReportService.getJmxContent(reportId);
}
@GetMapping("/performance/get-jmx-content/{testId}")
public List<LoadTestExportJmx> getOldJmxContent(@PathVariable String testId) {
// checkPermissionService.checkPerformanceTestOwner(testId);
return performanceTestService.getJmxContent(testId);
}
} }

View File

@ -154,9 +154,10 @@ import echarts from "echarts";
import MsChart from "@/business/components/common/chart/MsChart"; import MsChart from "@/business/components/common/chart/MsChart";
import {findThreadGroup} from "@/business/components/performance/test/model/ThreadGroup"; import {findThreadGroup} from "@/business/components/performance/test/model/ThreadGroup";
import { import {
getOldPerformanceJmxContent,
getPerformanceJmxContent, getPerformanceJmxContent,
getPerformanceLoadConfig, getPerformanceLoadConfig,
getPerformanceReport, getSharePerformanceJmxContent, getPerformanceReport, getShareOldPerformanceJmxContent, getSharePerformanceJmxContent,
getSharePerformanceLoadConfig, getSharePerformanceLoadConfig,
getSharePerformanceReport getSharePerformanceReport
} from "@/network/load-test"; } from "@/network/load-test";
@ -360,21 +361,21 @@ export default {
if (!threadGroups || threadGroups.length === 0) { if (!threadGroups || threadGroups.length === 0) {
if (this.planReportTemplate) { if (this.planReportTemplate) {
//todo //todo
if (this.planReportTemplate.jmxContentFix) { if (this.planReportTemplate.oldJmxContent) {
this.calculateLoadConfiguration(this.planReportTemplate.jmxContentFix); this.calculateLoadConfiguration(this.planReportTemplate.oldJmxContent);
} }
} else if (this.isShare){ } else if (this.isShare){
this.result = getSharePerformanceJmxContent(this.shareId, this.report.id, data => { this.result = getShareOldPerformanceJmxContent(this.shareId, this.report.testId, data => {
data.forEach(d => this._handleGetJmxContent(d, threadGroups)); data.forEach(d => this.handleGetOldJmxContent(d, threadGroups));
}); });
} else { } else {
this.result = getPerformanceJmxContent(this.report.id, data => { this.result = getOldPerformanceJmxContent(this.report.testId, data => {
data.forEach(d => this._handleGetJmxContent(d, threadGroups)); data.forEach(d => this.handleGetOldJmxContent(d, threadGroups));
}); });
} }
} }
}, },
_handleGetJmxContent(d, threadGroups) { handleGetOldJmxContent(d, threadGroups) {
threadGroups = threadGroups.concat(findThreadGroup(d.jmx, d.name)); threadGroups = threadGroups.concat(findThreadGroup(d.jmx, d.name));
threadGroups.forEach(tg => { threadGroups.forEach(tg => {
tg.options = {}; tg.options = {};

View File

@ -27,3 +27,10 @@ export function getPerformanceJmxContent(reportId, callback) {
export function getSharePerformanceJmxContent(shareId, reportId, callback) { export function getSharePerformanceJmxContent(shareId, reportId, callback) {
return reportId ? baseGet('/share/performance/report/get-jmx-content/' + shareId + '/' + reportId, callback) : {}; return reportId ? baseGet('/share/performance/report/get-jmx-content/' + shareId + '/' + reportId, callback) : {};
} }
export function getOldPerformanceJmxContent(testId, callback) {
return testId ? baseGet('/performance/get-jmx-content/' + testId, callback) : {};
}
export function getShareOldPerformanceJmxContent(testId, callback) {
return testId ? baseGet('/performance/get-jmx-content/' + testId, callback) : {};
}