From 62fa6fd9c65e3e4fbd3cb0e177df7e59f0f1d971 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 27 Jul 2020 11:11:31 +0800 Subject: [PATCH 1/5] =?UTF-8?q?refactor:=20=E6=89=A7=E8=A1=8C=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=B9=8B=E5=90=8E=E8=B7=B3=E8=BD=AC=E5=88=B0=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E6=9F=A5=E7=9C=8B=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/PerformanceReportView.vue | 22 ++++++++++------ .../report/components/ErrorLog.vue | 3 +++ .../report/components/LogDetails.vue | 3 +++ .../report/components/RequestStatistics.vue | 3 +++ .../report/components/TestOverview.vue | 3 +++ .../test/EditPerformanceTestPlan.vue | 25 ++++++++++++------- frontend/src/i18n/en-US.js | 2 +- frontend/src/i18n/zh-CN.js | 2 +- frontend/src/i18n/zh-TW.js | 2 +- 9 files changed, 45 insertions(+), 20 deletions(-) diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index 9f046180bd..926d479e7e 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -14,11 +14,11 @@ - {{$t('report.test_stop_now')}} - {{$t('report.test_execute_again')}} @@ -156,7 +156,7 @@ this.$warning(this.$t('report.generation_error')); break; case 'Starting': - this.$warning(this.$t('report.start_status')); + this.$alert(this.$t('report.start_status')); break; case 'Reporting': case 'Running': @@ -190,26 +190,32 @@ cancelButtonText: this.$t('commons.cancel'), type: 'warning' }).then(() => { - this.result = this.$post('/performance/run', {id: testId, triggerMode: 'MANUAL'}, () => { - this.$success(this.$t('load_test.is_running')) - this.$router.push({path: '/performance/report/all'}) + this.result = this.$post('/performance/run', {id: testId, triggerMode: 'MANUAL'}, (response) => { + this.reportId = response.data; + this.$router.push({path: '/performance/report/view/' + this.reportId}) + // 注册 socket + this.initWebSocket(); }) }).catch(() => { }); }, onOpen() { - window.console.log("open WebSocket"); + window.console.log("socket opening."); }, onError(e) { window.console.error(e) }, onMessage(e) { this.$set(this.report, "refresh", e.data); // 触发刷新 + this.$set(this.report, "status", 'Running'); this.initReportTimeInfo(); + window.console.log('receive a message:', e.data); }, onClose(e) { - this.$set(this.report, "refresh", e.data); // 触发刷新 + this.$set(this.report, "refresh", Math.random()); // 触发刷新 + this.$set(this.report, "status", 'Completed'); this.initReportTimeInfo(); + window.console.log("socket closed."); } }, created() { diff --git a/frontend/src/business/components/performance/report/components/ErrorLog.vue b/frontend/src/business/components/performance/report/components/ErrorLog.vue index f14a5ea0c4..5e63438dc7 100644 --- a/frontend/src/business/components/performance/report/components/ErrorLog.vue +++ b/frontend/src/business/components/performance/report/components/ErrorLog.vue @@ -153,6 +153,9 @@ watch: { report: { handler(val) { + if (!val.status || !val.id) { + return; + } let status = val.status; this.id = val.id; if (status === "Completed" || status === "Running") { diff --git a/frontend/src/business/components/performance/report/components/LogDetails.vue b/frontend/src/business/components/performance/report/components/LogDetails.vue index ec0f8cfb71..3802182848 100644 --- a/frontend/src/business/components/performance/report/components/LogDetails.vue +++ b/frontend/src/business/components/performance/report/components/LogDetails.vue @@ -80,6 +80,9 @@ watch: { report: { handler(val) { + if (!val.status || !val.id) { + return; + } let status = val.status; this.id = val.id; if (status === "Completed" || status === "Running") { diff --git a/frontend/src/business/components/performance/report/components/RequestStatistics.vue b/frontend/src/business/components/performance/report/components/RequestStatistics.vue index 6803511189..29f27afe96 100644 --- a/frontend/src/business/components/performance/report/components/RequestStatistics.vue +++ b/frontend/src/business/components/performance/report/components/RequestStatistics.vue @@ -162,6 +162,9 @@ watch: { report: { handler(val){ + if (!val.status || !val.id) { + return; + } let status = val.status; this.id = val.id; if (status === "Completed" || status === "Running") { diff --git a/frontend/src/business/components/performance/report/components/TestOverview.vue b/frontend/src/business/components/performance/report/components/TestOverview.vue index d83882e385..ee94b5473b 100644 --- a/frontend/src/business/components/performance/report/components/TestOverview.vue +++ b/frontend/src/business/components/performance/report/components/TestOverview.vue @@ -325,6 +325,9 @@ watch: { report: { handler(val) { + if (!val.status || !val.id) { + return; + } let status = val.status; this.id = val.id; if (status === "Completed" || status === "Running") { diff --git a/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue b/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue index 114d9e9189..44b9d511ee 100644 --- a/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue +++ b/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue @@ -4,11 +4,13 @@ - @@ -103,7 +113,8 @@ title: 'Logging', report: {}, isReadOnly: false, - websocket: null + websocket: null, + dialogFormVisible: false, } }, methods: { @@ -171,18 +182,16 @@ this.minutes = '0'; this.seconds = '0'; }, - stopTest(reportId) { - this.$confirm(this.$t('report.test_stop_now_confirm'), '', { - confirmButtonText: this.$t('commons.confirm'), - cancelButtonText: this.$t('commons.cancel'), - type: 'warning' - }).then(() => { - this.result = this.$get('/performance/stop/' + reportId, () => { - this.$success(this.$t('report.test_stop_success')); + stopTest(forceStop) { + this.result = this.$get('/performance/stop/' + this.reportId + '/' + forceStop, () => { + this.$success(this.$t('report.test_stop_success')); + this.$set(this.report, "refresh", Math.random()); // 触发刷新 + this.$set(this.report, "status", 'Completed'); + if (forceStop) { this.$router.push('/performance/report/all'); - }) - }).catch(() => { - }); + } + }) + this.dialogFormVisible = false; }, rerun(testId) { this.$confirm(this.$t('report.test_rerun_confirm'), '', { diff --git a/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue b/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue index 44b9d511ee..34da329f74 100644 --- a/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue +++ b/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue @@ -184,7 +184,6 @@ this.testPlan.id = response.data; this.$success(this.$t('commons.save_success')); this.result = this.$post(this.runPath, {id: this.testPlan.id, triggerMode: 'MANUAL'}, (response) => { - this.$success(this.$t('load_test.is_running')) let reportId = response.data; this.$router.push({path: '/performance/report/view/' + reportId}) }) diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 6bb00926c8..324e84b21a 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -261,7 +261,11 @@ export default { start_status: 'The test is in the beginning state, we will automatically display it on the page after we generate the report!', run_status: 'The test is running, please check the report later!', user_name: 'Creator', - project_name: 'Project Name' + project_name: 'Project Name', + force_stop_tips: 'Terminating the servers will immediately kill the servers and the JTL files will be lost.', + stop_tips: 'A Graceful shutdown will archive the JTL files and then stop the servers.', + force_stop_btn: 'Terminating', + stop_btn: 'Graceful shutdown', }, load_test: { operating: 'Operating', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index c4f8404a98..03ef679a3c 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -260,7 +260,10 @@ export default { run_status: '测试处于运行状态,请稍后查看报告!', user_name: '创建人', project_name: '所属项目', - + force_stop_tips: '强制停止测试会立刻结束当前测试并删除报告数据', + stop_tips: '停止测试会结束当前测试并保留报告数据', + force_stop_btn: '强制停止', + stop_btn: '停止', }, load_test: { operating: '操作', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index ffd6f8c4f4..d5a24140a0 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -259,7 +259,11 @@ export default { start_status: '測試處於開始狀態, 我們生成報告後會自動展示到頁面上!', run_status: '測試處於運行狀態,請稍後查看報告!', user_name: '創建人', - project_name: '所屬項目' + project_name: '所屬項目', + force_stop_tips: '強制停止測試會立刻結束當前測試並刪除報告數據', + stop_tips: '停止測試會結束當前測試並保留報告數據', + force_stop_btn: '強制停止', + stop_btn: '停止', }, load_test: { operating: '操作', From c6fb64e7540850646394eb87a3e6ffac1e1a79f3 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 27 Jul 2020 13:31:33 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/performance/report/PerformanceReportView.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index 2db660c33f..af89dc539a 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -185,8 +185,7 @@ stopTest(forceStop) { this.result = this.$get('/performance/stop/' + this.reportId + '/' + forceStop, () => { this.$success(this.$t('report.test_stop_success')); - this.$set(this.report, "refresh", Math.random()); // 触发刷新 - this.$set(this.report, "status", 'Completed'); + this.report.status = 'Completed'; if (forceStop) { this.$router.push('/performance/report/all'); } From 01b6f1b7bf9aead897fbf01ee1c47df3010b1de5 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 27 Jul 2020 13:35:01 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E5=81=9C=E6=AD=A2=E6=97=B6=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/performance/report/PerformanceReportView.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index af89dc539a..e2cab7ec1e 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -185,9 +185,10 @@ stopTest(forceStop) { this.result = this.$get('/performance/stop/' + this.reportId + '/' + forceStop, () => { this.$success(this.$t('report.test_stop_success')); - this.report.status = 'Completed'; if (forceStop) { this.$router.push('/performance/report/all'); + } else { + this.report.status = 'Completed'; } }) this.dialogFormVisible = false;