diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java index 3f2fe29e29..9d40ce6266 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java @@ -43,7 +43,10 @@ import javax.servlet.http.HttpServletResponse; import java.io.InputStream; import java.io.OutputStream; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; import java.util.stream.Collectors; @Service @@ -173,31 +176,41 @@ public class PerformanceReportService { } public List getReportStatistics(String id) { - checkReportStatus(id); + if (isReportError(id)) { + return Collections.emptyList(); + } String reportValue = getContent(id, ReportKeys.RequestStatistics); return JSON.parseArray(reportValue, Statistics.class); } public List getReportErrors(String id) { - checkReportStatus(id); + if (isReportError(id)) { + return Collections.emptyList(); + } String content = getContent(id, ReportKeys.Errors); return JSON.parseArray(content, Errors.class); } public List getReportErrorsTOP5(String id) { - checkReportStatus(id); + if (isReportError(id)) { + return Collections.emptyList(); + } String content = getContent(id, ReportKeys.ErrorsTop5); return JSON.parseArray(content, ErrorsTop5.class); } public TestOverview getTestOverview(String id) { - checkReportStatus(id); + if (isReportError(id)) { + return new TestOverview(); + } String content = getContent(id, ReportKeys.Overview); return JSON.parseObject(content, TestOverview.class); } public ReportTimeInfo getReportTimeInfo(String id) { - checkReportStatus(id); + if (isReportError(id)) { + return new ReportTimeInfo(); + } String content = getContent(id, ReportKeys.TimeInfo); try { return JSON.parseObject(content, ReportTimeInfo.class); @@ -221,26 +234,28 @@ public class PerformanceReportService { } public List getLoadChartData(String id) { - checkReportStatus(id); + if (isReportError(id)) { + return Collections.emptyList(); + } String content = getContent(id, ReportKeys.LoadChart); return JSON.parseArray(content, ChartsData.class); } public List getResponseTimeChartData(String id) { - checkReportStatus(id); + if (isReportError(id)) { + return Collections.emptyList(); + } String content = getContent(id, ReportKeys.ResponseTimeChart); return JSON.parseArray(content, ChartsData.class); } - public void checkReportStatus(String reportId) { + public boolean isReportError(String reportId) { LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); String reportStatus = ""; if (loadTestReport != null) { reportStatus = loadTestReport.getStatus(); } - if (StringUtils.equals(PerformanceTestStatus.Error.name(), reportStatus)) { - MSException.throwException("Report generation error!"); - } + return StringUtils.equals(PerformanceTestStatus.Error.name(), reportStatus); } public LoadTestReportWithBLOBs getLoadTestReport(String id) { @@ -329,13 +344,17 @@ public class PerformanceReportService { } public List getErrorChartData(String id) { - checkReportStatus(id); + if (isReportError(id)) { + return Collections.emptyList(); + } String content = getContent(id, ReportKeys.ErrorsChart); return JSON.parseArray(content, ChartsData.class); } public List getResponseCodeChartData(String id) { - checkReportStatus(id); + if (isReportError(id)) { + return Collections.emptyList(); + } String content = getContent(id, ReportKeys.ResponseCodeChart); return JSON.parseArray(content, ChartsData.class); } @@ -423,7 +442,9 @@ public class PerformanceReportService { } public List getReportChart(String reportKey, String reportId) { - checkReportStatus(reportId); + if (isReportError(reportId)) { + return Collections.emptyList(); + } try { String content = getContent(reportId, ReportKeys.valueOf(reportKey)); return JSON.parseArray(content, ChartsData.class); diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index e967248767..5ab6e659fa 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -330,7 +330,7 @@ export default { this.$set(this.report, "refresh", e.data); // 触发刷新 if (e.data.startsWith('Error')) { this.$set(this.report, "status", 'Error'); - this.$warning(e.data); + this.$error(e.data); return; } this.$set(this.report, "status", 'Running');