From e84588723429725491d937c0317c6a45c985005c Mon Sep 17 00:00:00 2001 From: metersphere-bot <78466014+metersphere-bot@users.noreply.github.com> Date: Wed, 25 Aug 2021 21:31:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=86=E4=BA=AB=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E6=8A=A5=E5=91=8A=E6=8A=A5?= =?UTF-8?q?=E9=94=99=20(#5700)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: chenjianxing --- .../api/service/ApiScenarioReportService.java | 2 +- .../controller/ShareController.java | 85 ++- .../service/TestPlanScenarioCaseService.java | 2 +- .../report/components/ErrorLog.vue | 84 ++- .../report/components/LogDetails.vue | 69 +- .../report/components/MonitorCard.vue | 41 +- .../report/components/RequestStatistics.vue | 30 +- .../report/components/TestDetails.vue | 247 +++---- .../report/components/TestOverview.vue | 606 ++++++++++-------- .../comonents/load/LoadCaseReportView.vue | 27 +- frontend/src/common/js/utils.js | 4 +- frontend/src/network/load-test.js | 91 +++ 12 files changed, 809 insertions(+), 479 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 157a0ae86a..77d756e4f3 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -94,7 +94,7 @@ public class ApiScenarioReportService { public APIScenarioReportResult get(String reportId) { APIScenarioReportResult reportResult = extApiScenarioReportMapper.get(reportId); ApiScenarioReportDetail detail = apiScenarioReportDetailMapper.selectByPrimaryKey(reportId); - if (detail != null) { + if (detail != null && reportResult != null) { reportResult.setContent(new String(detail.getContent(), StandardCharsets.UTF_8)); } return reportResult; diff --git a/backend/src/main/java/io/metersphere/controller/ShareController.java b/backend/src/main/java/io/metersphere/controller/ShareController.java index 4cd7edb8de..a0ce8897c8 100644 --- a/backend/src/main/java/io/metersphere/controller/ShareController.java +++ b/backend/src/main/java/io/metersphere/controller/ShareController.java @@ -1,5 +1,7 @@ package io.metersphere.controller; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import io.metersphere.api.dto.APIReportResult; import io.metersphere.api.dto.automation.APIScenarioReportResult; import io.metersphere.api.dto.automation.TestPlanFailureApiDTO; @@ -8,9 +10,15 @@ import io.metersphere.api.service.ApiDefinitionService; import io.metersphere.api.service.ApiScenarioReportService; import io.metersphere.api.service.ShareInfoService; import io.metersphere.base.domain.IssuesDao; +import io.metersphere.base.domain.LoadTestReportLog; import io.metersphere.base.domain.LoadTestReportWithBLOBs; -import io.metersphere.performance.base.ReportTimeInfo; +import io.metersphere.commons.utils.PageUtils; +import io.metersphere.commons.utils.Pager; +import io.metersphere.dto.LogDetailDTO; +import io.metersphere.performance.base.*; import io.metersphere.performance.dto.LoadTestExportJmx; +import io.metersphere.performance.dto.MetricData; +import io.metersphere.performance.service.MetricQueryService; import io.metersphere.performance.service.PerformanceReportService; import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.track.dto.TestPlanCaseDTO; @@ -53,6 +61,8 @@ public class ShareController { PerformanceTestService performanceTestService; @Resource TestPlanReportService testPlanReportService; + @Resource + MetricQueryService metricService; @GetMapping("/issues/plan/get/{shareId}/{planId}") public List getIssuesByPlanoId(@PathVariable String shareId, @PathVariable String planId) { @@ -150,13 +160,13 @@ public class ShareController { return testPlanLoadCaseService.isExistReport(request); } - @GetMapping("/performance/report/get-jmx-content/{reportId}") - public LoadTestExportJmx getJmxContent(@PathVariable String reportId) { + @GetMapping("/performance/report/get-jmx-content/{shareId}/{reportId}") + public LoadTestExportJmx getJmxContent(@PathVariable String shareId, @PathVariable String reportId) { return performanceReportService.getJmxContent(reportId); } - @GetMapping("/performance/get-jmx-content/{testId}") - public List getOldJmxContent(@PathVariable String testId) { + @GetMapping("/performance/get-jmx-content/{shareId}/{testId}") + public List getOldJmxContent(@PathVariable String shareId, @PathVariable String testId) { // checkPermissionService.checkPerformanceTestOwner(testId); return performanceTestService.getJmxContent(testId); } @@ -167,4 +177,69 @@ public class ShareController { return testPlanReportService.getReport(reportId); } + @GetMapping("/performance/report/content/testoverview/{shareId}/{reportId}") + public TestOverview getTestOverview(@PathVariable String shareId, @PathVariable String reportId) { + return performanceReportService.getTestOverview(reportId); + } + + @GetMapping("/performance/report/content/load_chart/{shareId}/{reportId}") + public List getLoadChartData(@PathVariable String shareId, @PathVariable String reportId) { + return performanceReportService.getLoadChartData(reportId); + } + + @GetMapping("/performance/report/content/res_chart/{shareId}/{reportId}") + public List getResponseTimeChartData(@PathVariable String shareId, @PathVariable String reportId) { + return performanceReportService.getResponseTimeChartData(reportId); + } + + @GetMapping("/performance/report/content/error_chart/{shareId}/{reportId}") + public List getErrorChartData(@PathVariable String shareId, @PathVariable String reportId) { + return performanceReportService.getErrorChartData(reportId); + } + + @GetMapping("/performance/report/content/response_code_chart/{shareId}/{reportId}") + public List getResponseCodeChartData(@PathVariable String shareId, @PathVariable String reportId) { + return performanceReportService.getResponseCodeChartData(reportId); + } + + @GetMapping("/performance/report/content/{shareId}/{reportKey}/{reportId}") + public List getReportChart(@PathVariable String shareId, @PathVariable String reportKey, @PathVariable String reportId) { + return performanceReportService.getReportChart(reportKey, reportId); + } + + @GetMapping("/performance/report/content/{shareId}/{reportId}") + public List getReportContent(@PathVariable String shareId, @PathVariable String reportId) { + return performanceReportService.getReportStatistics(reportId); + } + + @GetMapping("/performance/report/content/errors/{shareId}/{reportId}") + public List getReportErrors(@PathVariable String shareId, @PathVariable String reportId) { + return performanceReportService.getReportErrors(reportId); + } + + @GetMapping("/performance/report/content/errors_top5/{shareId}/{reportId}") + public List getReportErrorsTop5(@PathVariable String shareId, @PathVariable String reportId) { + return performanceReportService.getReportErrorsTOP5(reportId); + } + + @GetMapping("/performance/report/log/resource/{shareId}/{reportId}") + public List getResourceIds(@PathVariable String shareId, @PathVariable String reportId) { + return performanceReportService.getReportLogResource(reportId); + } + + @GetMapping("/performance/report/log/{shareId}/{reportId}/{resourceId}/{goPage}") + public Pager> logs(@PathVariable String shareId, @PathVariable String reportId, @PathVariable String resourceId, @PathVariable int goPage) { + Page page = PageHelper.startPage(goPage, 1, true); + return PageUtils.setPageInfo(page, performanceReportService.getReportLogs(reportId, resourceId)); + } + + @GetMapping("/metric/query/{shareId}/{id}") + public List queryMetric(@PathVariable String shareId, @PathVariable("id") String reportId) { + return metricService.queryMetric(reportId); + } + + @GetMapping("/metric/query/resource/{shareId}/{id}") + public List queryReportResource(@PathVariable String shareId, @PathVariable("id") String reportId) { + return metricService.queryReportResource(reportId); + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java index 209c62df7f..283b808112 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java @@ -78,7 +78,7 @@ public class TestPlanScenarioCaseService { apiTestCases.forEach(item -> { Project project = projectMap.get(item.getProjectId()); - if (project.getScenarioCustomNum() != null && project.getScenarioCustomNum()) { + if (project != null && project.getScenarioCustomNum() != null && project.getScenarioCustomNum()) { item.setCustomNum(item.getCustomNum()); } else { item.setCustomNum(item.getNum().toString()); diff --git a/frontend/src/business/components/performance/report/components/ErrorLog.vue b/frontend/src/business/components/performance/report/components/ErrorLog.vue index 6b47234157..9d8196f91b 100644 --- a/frontend/src/business/components/performance/report/components/ErrorLog.vue +++ b/frontend/src/business/components/performance/report/components/ErrorLog.vue @@ -153,6 +153,11 @@ diff --git a/frontend/src/business/components/performance/report/components/LogDetails.vue b/frontend/src/business/components/performance/report/components/LogDetails.vue index 3e49988119..696eef9fb8 100644 --- a/frontend/src/business/components/performance/report/components/LogDetails.vue +++ b/frontend/src/business/components/performance/report/components/LogDetails.vue @@ -20,6 +20,11 @@ diff --git a/frontend/src/business/components/performance/report/components/MonitorCard.vue b/frontend/src/business/components/performance/report/components/MonitorCard.vue index 68a9584dc0..58ded80778 100644 --- a/frontend/src/business/components/performance/report/components/MonitorCard.vue +++ b/frontend/src/business/components/performance/report/components/MonitorCard.vue @@ -29,12 +29,16 @@ diff --git a/frontend/src/business/components/performance/report/components/TestDetails.vue b/frontend/src/business/components/performance/report/components/TestDetails.vue index de4a53f124..60d70ae128 100644 --- a/frontend/src/business/components/performance/report/components/TestDetails.vue +++ b/frontend/src/business/components/performance/report/components/TestDetails.vue @@ -293,6 +293,10 @@