diff --git a/backend/src/main/java/io/metersphere/commons/constants/ReportKeys.java b/backend/src/main/java/io/metersphere/commons/constants/ReportKeys.java index 2b483d1fd7..809d8c4936 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/ReportKeys.java +++ b/backend/src/main/java/io/metersphere/commons/constants/ReportKeys.java @@ -1,6 +1,6 @@ package io.metersphere.commons.constants; public enum ReportKeys { - LoadChart, ResponseTimeChart, Errors, ErrorsTop5, RequestStatistics, Overview, TimeInfo + LoadChart, ResponseTimeChart, Errors, ErrorsTop5, RequestStatistics, Overview, TimeInfo, ResultStatus } diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 1ff2a366a7..95a7829806 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -5,10 +5,7 @@ import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.ExtLoadTestMapper; import io.metersphere.base.mapper.ext.ExtLoadTestReportDetailMapper; import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper; -import io.metersphere.commons.constants.APITestStatus; -import io.metersphere.commons.constants.PerformanceTestStatus; -import io.metersphere.commons.constants.ScheduleGroup; -import io.metersphere.commons.constants.ScheduleType; +import io.metersphere.commons.constants.*; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.ServiceUtils; @@ -281,6 +278,13 @@ public class PerformanceTestService { loadTestReportDetailMapper.insertSelective(reportDetail); // append \n extLoadTestReportDetailMapper.appendLine(testReport.getId(), "\n"); + // 保存一个 reportStatus + LoadTestReportResult reportResult = new LoadTestReportResult(); + reportResult.setId(UUID.randomUUID().toString()); + reportResult.setReportId(testReport.getId()); + reportResult.setReportKey(ReportKeys.ResultStatus.name()); + reportResult.setReportValue("Ready"); // 初始化一个 result_status, 这个值用在data-streaming中 + loadTestReportResultMapper.insertSelective(reportResult); } catch (MSException e) { LogUtil.error(e); loadTest.setStatus(PerformanceTestStatus.Error.name()); diff --git a/backend/src/main/java/io/metersphere/performance/service/ReportService.java b/backend/src/main/java/io/metersphere/performance/service/ReportService.java index 14e52e2817..b88ba8e864 100644 --- a/backend/src/main/java/io/metersphere/performance/service/ReportService.java +++ b/backend/src/main/java/io/metersphere/performance/service/ReportService.java @@ -25,11 +25,10 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; -import javax.annotation.Resource; - @Service @Transactional(rollbackFor = Exception.class) public class ReportService { @@ -154,11 +153,7 @@ public class ReportService { public void checkReportStatus(String reportId) { LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); String reportStatus = loadTestReport.getStatus(); - if (StringUtils.equals(PerformanceTestStatus.Running.name(), reportStatus)) { - MSException.throwException("Reporting in progress..."); - } else if (StringUtils.equals(PerformanceTestStatus.Reporting.name(), reportStatus)) { - MSException.throwException("Reporting in progress..."); - } else if (StringUtils.equals(PerformanceTestStatus.Error.name(), reportStatus)) { + if (StringUtils.equals(PerformanceTestStatus.Error.name(), reportStatus)) { MSException.throwException("Report generation error!"); } } diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index 18a14d58a0..06768327cc 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -37,7 +37,7 @@ - + @@ -114,17 +114,17 @@ if (this.reportId) { this.result = this.$get("/performance/report/content/report_time/" + this.reportId) .then(res => { - let data = res.data.data; - if (data) { - this.startTime = data.startTime; - this.endTime = data.endTime; - let duration = data.duration; - this.minutes = Math.floor(duration / 60); - this.seconds = duration % 60; - } - }).catch(() => { - this.clearData(); - }) + let data = res.data.data; + if (data) { + this.startTime = data.startTime; + this.endTime = data.endTime; + let duration = data.duration; + this.minutes = Math.floor(duration / 60); + this.seconds = duration % 60; + } + }).catch(() => { + this.clearData(); + }) } }, checkReportStatus(status) { @@ -136,11 +136,7 @@ this.$warning(this.$t('report.start_status')); break; case 'Reporting': - this.$info(this.$t('report.being_generated')); - break; case 'Running': - this.$warning(this.$t('report.run_status')); - break; case 'Completed': default: break; @@ -165,7 +161,7 @@ this.$set(this.report, "id", this.reportId); this.$set(this.report, "status", data.status); this.checkReportStatus(data.status); - if (this.status === "Completed") { + if (this.status === "Completed" || this.status === "Running") { this.initReportTimeInfo(); } }) diff --git a/frontend/src/business/components/performance/report/components/ErrorLog.vue b/frontend/src/business/components/performance/report/components/ErrorLog.vue index 8fb16abece..f14a5ea0c4 100644 --- a/frontend/src/business/components/performance/report/components/ErrorLog.vue +++ b/frontend/src/business/components/performance/report/components/ErrorLog.vue @@ -155,7 +155,7 @@ handler(val) { let status = val.status; this.id = val.id; - if (status === "Completed") { + if (status === "Completed" || status === "Running") { this.initTableData(); } else { this.tableData = []; diff --git a/frontend/src/business/components/performance/report/components/LogDetails.vue b/frontend/src/business/components/performance/report/components/LogDetails.vue index 1831aaf014..3dcc9e8fe0 100644 --- a/frontend/src/business/components/performance/report/components/LogDetails.vue +++ b/frontend/src/business/components/performance/report/components/LogDetails.vue @@ -81,7 +81,7 @@ handler(val) { let status = val.status; this.id = val.id; - if (status === "Completed") { + if (status === "Completed" || status === "Running") { this.getResource(); } else { this.resource = []; diff --git a/frontend/src/business/components/performance/report/components/RequestStatistics.vue b/frontend/src/business/components/performance/report/components/RequestStatistics.vue index 907eb7abea..06639703f8 100644 --- a/frontend/src/business/components/performance/report/components/RequestStatistics.vue +++ b/frontend/src/business/components/performance/report/components/RequestStatistics.vue @@ -161,7 +161,7 @@ handler(val){ let status = val.status; this.id = val.id; - if (status === "Completed") { + if (status === "Completed" || status === "Running") { this.initTableData(); } else { this.tableData = []; diff --git a/frontend/src/business/components/performance/report/components/TestOverview.vue b/frontend/src/business/components/performance/report/components/TestOverview.vue index 10707b0f96..d83882e385 100644 --- a/frontend/src/business/components/performance/report/components/TestOverview.vue +++ b/frontend/src/business/components/performance/report/components/TestOverview.vue @@ -324,10 +324,10 @@ }, watch: { report: { - handler(val){ + handler(val) { let status = val.status; this.id = val.id; - if (status === "Completed") { + if (status === "Completed" || status === "Running") { this.initTableData(); } else { this.maxUsers = '0'; @@ -340,7 +340,7 @@ this.resOption = {}; } }, - deep:true + deep: true } }, props: ['report'] diff --git a/frontend/src/business/components/track/plan/view/comonents/test/PerformanceTestResult.vue b/frontend/src/business/components/track/plan/view/comonents/test/PerformanceTestResult.vue index 1afc71f167..fcbb1c6de3 100644 --- a/frontend/src/business/components/track/plan/view/comonents/test/PerformanceTestResult.vue +++ b/frontend/src/business/components/track/plan/view/comonents/test/PerformanceTestResult.vue @@ -151,11 +151,7 @@ this.$warning(this.$t('report.start_status')); break; case 'Reporting': - this.$info(this.$t('report.being_generated')); - break; case 'Running': - this.$warning(this.$t('report.run_status')); - break; case 'Completed': default: break;