From 08253e818eef65122ea4396ec6907d7a7afbd7ec Mon Sep 17 00:00:00 2001 From: q4speed Date: Thu, 28 May 2020 17:22:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A9=BA=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E6=9B=BF=E6=8D=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/business/components/api/test/model/ScenarioModel.js | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/business/components/api/test/model/ScenarioModel.js b/frontend/src/business/components/api/test/model/ScenarioModel.js index 36aba58975..fbbc897956 100644 --- a/frontend/src/business/components/api/test/model/ScenarioModel.js +++ b/frontend/src/business/components/api/test/model/ScenarioModel.js @@ -543,6 +543,7 @@ class JMXGenerator { } replace(str) { + if (!str) return str; return str.replace(/&/g, "&").replace(//g, ">").replace(/'/g, "'").replace(/"/g, """); } From dd9b03c206b55b32a23f082d5702738ae4f0b7ee Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Thu, 28 May 2020 23:07:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95-?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=B5=8B=E8=AF=95=E6=88=96=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E4=BC=9A=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/PerformanceReportView.vue | 108 ++++++++++++------ .../report/components/ErrorLog.vue | 33 ++++-- .../report/components/LogDetails.vue | 24 ++-- .../report/components/RequestStatistics.vue | 26 +++-- .../report/components/TestOverview.vue | 51 +++++++-- 5 files changed, 170 insertions(+), 72 deletions(-) diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index 1e06df3e67..a53a0fb150 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -37,16 +37,17 @@ - + + - + - + - + @@ -89,6 +90,7 @@ minutes: '0', seconds: '0', title: 'Logging', + report: {} } }, methods: { @@ -108,8 +110,9 @@ }, initReportTimeInfo() { if (this.reportId) { - this.result = this.$get("/performance/report/content/report_time/" + this.reportId, res => { - let data = res.data; + 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; @@ -117,55 +120,90 @@ this.minutes = Math.floor(duration / 60); this.seconds = duration % 60; } + }).catch(() => { + this.clearData(); }) } }, - }, - mounted() { - this.reportId = this.$route.path.split('/')[4]; - this.result = this.$get("/performance/report/" + this.reportId, res => { - let data = res.data; - this.status = data.status; - switch (data.status) { + checkReportStatus(status) { + switch (status) { case 'Error': this.$warning(this.$t('report.generation_error')); break; case 'Starting': + this.$warning("测试处于开始状态,请稍后查看报告!"); + break; case 'Reporting': this.$info(this.$t('report.being_generated')); break; case 'Running': + this.$warning("测试处于运行状态,请稍后查看报告!"); break; + case 'Completed': default: break; } + }, + clearData() { + this.startTime = '0'; + this.endTime = '0'; + this.minutes = '0'; + this.seconds = '0'; + } + }, + created() { + this.reportId = this.$route.path.split('/')[4]; + this.result = this.$get("/performance/report/" + this.reportId, res => { + let data = res.data; + this.status = data.status; + this.$set(this.report, "id", this.reportId); + this.$set(this.report, "status", data.status); + this.checkReportStatus(data.status); + if (this.status === "Completed") { + this.initReportTimeInfo(); + } }) this.initBreadcrumb(); - this.initReportTimeInfo(); + }, watch: { '$route'(to) { - let reportId = to.path.split('/')[4]; - if (reportId) { - this.$get("/performance/report/test/pro/info/" + reportId, response => { - let data = response.data; - if (data) { - this.reportName = data.name; - this.testName = data.testName; - this.projectName = data.projectName; - } - }); - this.result = this.$get("/performance/report/content/report_time/" + this.reportId, res => { - let data = res.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; - } - }) - window.location.reload(); + if (to.name === "perReportView") { + let reportId = to.path.split('/')[4]; + this.reportId = reportId; + if (reportId) { + this.$get("/performance/report/test/pro/info/" + reportId, response => { + let data = response.data; + if (data) { + this.status = data.status; + this.reportName = data.name; + this.testName = data.testName; + this.projectName = data.projectName; + + this.$set(this.report, "id", reportId); + this.$set(this.report, "status", data.status); + + this.checkReportStatus(data.status); + if (this.status === "Completed") { + 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(); + }) + } else { + this.clearData(); + } + } + }); + + } } } } diff --git a/frontend/src/business/components/performance/report/components/ErrorLog.vue b/frontend/src/business/components/performance/report/components/ErrorLog.vue index b9e5239be3..237b3a9579 100644 --- a/frontend/src/business/components/performance/report/components/ErrorLog.vue +++ b/frontend/src/business/components/performance/report/components/ErrorLog.vue @@ -131,27 +131,40 @@ data() { return { tableData: [], - errorTop5: [] + errorTop5: [], + id: '' } }, methods: { initTableData() { - this.$get("/performance/report/content/errors/" + this.id, res => { - this.tableData = res.data; + this.$get("/performance/report/content/errors/" + this.id).then(res => { + this.tableData = res.data.data; + }).catch(() => { + this.tableData = []; }) - this.$get("/performance/report/content/errors_top5/" + this.id, res => { - this.errorTop5 = res.data; + this.$get("/performance/report/content/errors_top5/" + this.id).then(res => { + this.errorTop5 = res.data.data; + }).catch(() => { + this.errorTop5 = []; }) } }, watch: { - status() { - if ("Completed" === this.status) { - this.initTableData() - } + report: { + handler(val){ + let status = val.status; + this.id = val.id; + if (status === "Completed") { + this.initTableData(); + } else { + this.tableData = []; + this.errorTop5 = []; + } + }, + deep:true } }, - props: ['id','status'] + props: ['report'] } diff --git a/frontend/src/business/components/performance/report/components/LogDetails.vue b/frontend/src/business/components/performance/report/components/LogDetails.vue index 2d17185f00..68e184f184 100644 --- a/frontend/src/business/components/performance/report/components/LogDetails.vue +++ b/frontend/src/business/components/performance/report/components/LogDetails.vue @@ -12,17 +12,19 @@ diff --git a/frontend/src/business/components/performance/report/components/RequestStatistics.vue b/frontend/src/business/components/performance/report/components/RequestStatistics.vue index 419f4e372b..907eb7abea 100644 --- a/frontend/src/business/components/performance/report/components/RequestStatistics.vue +++ b/frontend/src/business/components/performance/report/components/RequestStatistics.vue @@ -95,13 +95,16 @@ name: "RequestStatistics", data() { return { - tableData: [] + tableData: [], + id: '' } }, methods: { initTableData() { - this.$get("/performance/report/content/" + this.id, res => { - this.tableData = res.data; + this.$get("/performance/report/content/" + this.id).then(res => { + this.tableData = res.data.data; + }).catch(() => { + this.tableData = []; }) }, getSummaries(param) { @@ -154,13 +157,20 @@ } }, watch: { - status() { - if ("Completed" === this.status) { - this.initTableData() - } + report: { + handler(val){ + let status = val.status; + this.id = val.id; + if (status === "Completed") { + this.initTableData(); + } else { + this.tableData = []; + } + }, + deep:true } }, - props: ['id', 'status'] + props: ['report'] } diff --git a/frontend/src/business/components/performance/report/components/TestOverview.vue b/frontend/src/business/components/performance/report/components/TestOverview.vue index 8f04a363b4..269823ca8b 100644 --- a/frontend/src/business/components/performance/report/components/TestOverview.vue +++ b/frontend/src/business/components/performance/report/components/TestOverview.vue @@ -80,22 +80,31 @@ responseTime90: "0", avgBandwidth: "0", loadOption: {}, - resOption: {} + resOption: {}, + id: '' } }, methods: { initTableData() { - this.$get("/performance/report/content/testoverview/" + this.id, res => { - let data = res.data; + this.$get("/performance/report/content/testoverview/" + this.id).then(res => { + let data = res.data.data; this.maxUsers = data.maxUsers; this.avgThroughput = data.avgThroughput; this.errors = data.errors; this.avgResponseTime = data.avgResponseTime; this.responseTime90 = data.responseTime90; this.avgBandwidth = data.avgBandwidth; + }).catch(() => { + this.maxUsers = '0'; + this.avgThroughput = '0'; + this.errors = '0'; + this.avgResponseTime = '0'; + this.responseTime90 = '0'; + this.avgBandwidth = '0'; + this.$warning("报告生成错误!") }) - this.$get("/performance/report/content/load_chart/" + this.id, res => { - let data = res.data; + this.$get("/performance/report/content/load_chart/" + this.id).then(res => { + let data = res.data.data; let yAxisList = data.filter(m => m.yAxis2 === -1).map(m => m.yAxis); let yAxis2List = data.filter(m => m.yAxis === -1).map(m => m.yAxis2); let yAxisListMax = this._getChartMax(yAxisList); @@ -166,9 +175,11 @@ setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'}) }) this.loadOption = this.generateOption(loadOption, data, setting); + }).catch(() => { + this.loadOption = {}; }) - this.$get("/performance/report/content/res_chart/" + this.id, res => { - let data = res.data; + this.$get("/performance/report/content/res_chart/" + this.id).then(res => { + let data = res.data.data; let yAxisList = data.filter(m => m.yAxis2 === -1).map(m => m.yAxis); let yAxis2List = data.filter(m => m.yAxis === -1).map(m => m.yAxis2); let yAxisListMax = this._getChartMax(yAxisList); @@ -246,6 +257,8 @@ }) this.resOption = this.generateOption(resOption, data, setting); + }).catch(() => { + this.resOption = {}; }) }, generateOption(option, data, setting) { @@ -310,13 +323,27 @@ } }, watch: { - status() { - if ("Completed" === this.status) { - this.initTableData() - } + report: { + handler(val){ + let status = val.status; + this.id = val.id; + if (status === "Completed") { + this.initTableData(); + } else { + this.maxUsers = '0'; + this.avgThroughput = '0'; + this.errors = '0'; + this.avgResponseTime = '0'; + this.responseTime90 = '0'; + this.avgBandwidth = '0'; + this.loadOption = {}; + this.resOption = {}; + } + }, + deep:true } }, - props: ['id', 'status'] + props: ['report'] }