From 5753a391a23832f3402522374caef3fa6a7e7e6b Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 15 Apr 2020 14:20:26 +0800 Subject: [PATCH] run test error changed --- .../service/PerformanceTestService.java | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/io/metersphere/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/service/PerformanceTestService.java index 3e6d2be506..ddd644d5fd 100644 --- a/backend/src/main/java/io/metersphere/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/service/PerformanceTestService.java @@ -200,35 +200,30 @@ public class PerformanceTestService { testReport.setTestId(loadTest.getId()); testReport.setName(loadTest.getName()); // 启动测试 - testReport.setContent(HEADERS); - testReport.setStatus(TestStatus.Starting.name()); - loadTestReportMapper.insertSelective(testReport); - - LoadTestReportDetail reportDetail = new LoadTestReportDetail(); - reportDetail.setContent(HEADERS); - reportDetail.setReportId(testReport.getId()); - loadTestReportDetailMapper.insertSelective(reportDetail); try { - // 标记running状态 + engine.start(); + // 启动正常修改状态 starting loadTest.setStatus(TestStatus.Starting.name()); loadTestMapper.updateByPrimaryKeySelective(loadTest); + // 启动正常插入 report + testReport.setContent(HEADERS); + testReport.setStatus(TestStatus.Starting.name()); + loadTestReportMapper.insertSelective(testReport); + + LoadTestReportDetail reportDetail = new LoadTestReportDetail(); + reportDetail.setContent(HEADERS); + reportDetail.setReportId(testReport.getId()); + loadTestReportDetailMapper.insertSelective(reportDetail); // append \n extLoadTestReportMapper.appendLine(testReport.getId(), "\n"); // append \n extLoadTestReportDetailMapper.appendLine(testReport.getId(), "\n"); - // - engine.start(); } catch (MSException e) { LogUtil.error(e); - loadTest.setStatus(TestStatus.Error.name()); loadTest.setDescription(e.getMessage()); loadTestMapper.updateByPrimaryKeySelective(loadTest); - // - testReport.setStatus(TestStatus.Error.name()); - testReport.setDescription(e.getMessage()); - loadTestReportMapper.updateByPrimaryKeySelective(testReport); throw e; } }