diff --git a/backend/src/main/java/io/metersphere/service/ReportService.java b/backend/src/main/java/io/metersphere/service/ReportService.java index 17b2f047fa..38c2e88c92 100644 --- a/backend/src/main/java/io/metersphere/service/ReportService.java +++ b/backend/src/main/java/io/metersphere/service/ReportService.java @@ -1,14 +1,16 @@ package io.metersphere.service; -import io.metersphere.base.domain.LoadTestReport; -import io.metersphere.base.domain.LoadTestReportExample; -import io.metersphere.base.domain.LoadTestReportWithBLOBs; +import io.metersphere.base.domain.*; +import io.metersphere.base.mapper.LoadTestMapper; import io.metersphere.base.mapper.LoadTestReportMapper; import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper; import io.metersphere.commons.constants.PerformanceTestStatus; import io.metersphere.commons.exception.MSException; +import io.metersphere.commons.utils.LogUtil; import io.metersphere.controller.request.ReportRequest; import io.metersphere.dto.ReportDTO; +import io.metersphere.engine.Engine; +import io.metersphere.engine.EngineFactory; import io.metersphere.report.JtlResolver; import io.metersphere.report.base.ChartsData; import io.metersphere.report.base.Errors; @@ -31,6 +33,8 @@ public class ReportService { private LoadTestReportMapper loadTestReportMapper; @Resource private ExtLoadTestReportMapper extLoadTestReportMapper; + @Resource + private LoadTestMapper loadTestMapper; public List getRecentReportList(ReportRequest request) { LoadTestReportExample example = new LoadTestReportExample(); @@ -46,9 +50,38 @@ public class ReportService { } public void deleteReport(String reportId) { + if (StringUtils.isBlank(reportId)) { + MSException.throwException("report id cannot be null"); + } + + LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); + LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(loadTestReport.getTestId()); + + LogUtil.info("Delete report started, report ID: %s" + reportId); + + final Engine engine = EngineFactory.createEngine(loadTest); + if (engine == null) { + MSException.throwException(String.format("Delete report fail. create engine fail,report ID:%s", reportId)); + } + + String reportStatus = loadTestReport.getStatus(); + boolean isRunning = StringUtils.equals(reportStatus, PerformanceTestStatus.Running.name()); + boolean isStarting = StringUtils.equals(reportStatus, PerformanceTestStatus.Starting.name()); + boolean isError = StringUtils.equals(reportStatus, PerformanceTestStatus.Error.name()); + if (isRunning || isStarting || isError) { + LogUtil.info("Start stop engine, report status: %s" + reportStatus); + stopEngine(loadTest, engine); + } + loadTestReportMapper.deleteByPrimaryKey(reportId); } + private void stopEngine(LoadTestWithBLOBs loadTest, Engine engine) { + engine.stop(); + loadTest.setStatus(PerformanceTestStatus.Saved.name()); + loadTestMapper.updateByPrimaryKeySelective(loadTest); + } + public ReportDTO getReportTestAndProInfo(String reportId) { return extLoadTestReportMapper.getReportTestAndProInfo(reportId); } diff --git a/frontend/src/business/components/track/case/TestCase.vue b/frontend/src/business/components/track/case/TestCase.vue index 921e3c1d17..77ce525dfb 100644 --- a/frontend/src/business/components/track/case/TestCase.vue +++ b/frontend/src/business/components/track/case/TestCase.vue @@ -1,43 +1,41 @@ @@ -174,7 +172,6 @@ openRecentTestCaseEditDialog() { let caseId = this.$route.params.caseId; this.getProjectByCaseId(caseId); - // this.refresh(); this.$get('/test/case/get/' + caseId, response => { if (response.data) { this.openTestCaseEditDialog(response.data); @@ -206,20 +203,25 @@ diff --git a/frontend/src/business/components/track/plan/TestPlanView.vue b/frontend/src/business/components/track/plan/TestPlanView.vue index d6e7f0b146..ab722e3c01 100644 --- a/frontend/src/business/components/track/plan/TestPlanView.vue +++ b/frontend/src/business/components/track/plan/TestPlanView.vue @@ -1,38 +1,40 @@ @@ -263,7 +263,14 @@ .status-button { float: right; - margin-right: 1px; + } + + .head-bar { + margin-top: 1%; + } + + .head-right-tip { + color: darkgrey; } diff --git a/frontend/src/business/components/track/plan/components/TestPlanTestCaseList.vue b/frontend/src/business/components/track/plan/components/TestPlanTestCaseList.vue index bcad3964c9..ac518a738f 100644 --- a/frontend/src/business/components/track/plan/components/TestPlanTestCaseList.vue +++ b/frontend/src/business/components/track/plan/components/TestPlanTestCaseList.vue @@ -1,6 +1,6 @@