diff --git a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java index 78e77a9e6e..2a2258c8df 100644 --- a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java +++ b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java @@ -21,6 +21,7 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; + import javax.annotation.Resource; import java.util.List; @@ -95,6 +96,11 @@ public class PerformanceTestController { return performanceTestService.run(request); } + @GetMapping("stop/{reportId}") + public void stopTest(@PathVariable String reportId) { + performanceTestService.stopTest(reportId); + } + @GetMapping("/file/metadata/{testId}") public List getFileMetadata(@PathVariable String testId) { return fileService.getFileMetadataByTestId(testId); 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 85ba2709f9..d52b798984 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -393,4 +393,8 @@ public class PerformanceTestService { private void addOrUpdatePerformanceTestCronJob(Schedule request) { scheduleService.addOrUpdateCronJob(request, PerformanceTestJob.getJobKey(request.getResourceId()), PerformanceTestJob.getTriggerKey(request.getResourceId()), PerformanceTestJob.class); } + + public void stopTest(String reportId) { + reportService.deleteReport(reportId); + } } diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index 06768327cc..c48d8264a9 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -13,12 +13,21 @@ {{reportName}} - - - - - - + + + {{$t('report.test_stop_now')}} + + + @@ -147,7 +156,20 @@ this.endTime = '0'; 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')); + this.$router.push('/performance/report/all'); + }) + }).catch(() => { + }); + }, }, created() { this.isReadOnly = false; diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 109d667e34..c300de901e 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -204,6 +204,8 @@ export default { 'test_start_time': 'Test Start Time', 'test_end_time': 'Test End Time', 'test_stop_now': 'Test Stop Now', + 'test_stop_now_confirm': 'Are you sure you want to stop the current test immediately?', + 'test_stop_success': 'Test stop successfully', 'test_execute_again': 'Test Execute Again', 'export': 'Export', 'compare': 'Compare', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 6fade1939f..8009c20cac 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -202,6 +202,8 @@ export default { 'test_start_time': '开始时间', 'test_end_time': '结束时间', 'test_stop_now': '立即停止', + 'test_stop_now_confirm': '确定要立即停止当前测试吗?', + 'test_stop_success': '停止成功', 'test_execute_again': '再次执行', 'export': '导出', 'compare': '比较', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index da38e64eec..6d9b83dbdc 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -202,6 +202,8 @@ export default { 'test_start_time': '開始時間', 'test_end_time': '結束時間', 'test_stop_now': '立即停止', + 'test_stop_now_confirm': '確定要立即停止當前測試嗎?', + 'test_stop_success': '停止成功', 'test_execute_again': '再次執行', 'export': '導出', 'compare': '比較',