fix(性能测试): 修复删除测试之后再删除报告报错的问题

This commit is contained in:
Captain.B 2021-06-22 10:39:26 +08:00 committed by 刘瑞斌
parent 748c71d1ba
commit 7a1e44353a
1 changed files with 18 additions and 16 deletions

View File

@ -96,24 +96,26 @@ public class PerformanceReportService {
LogUtil.info("Delete report started, report ID: %s" + reportId);
try {
final Engine engine = EngineFactory.createEngine(loadTest);
if (engine == null) {
MSException.throwException(String.format("Delete report fail. create engine failreport ID%s", reportId));
}
if (loadTest != null) {
try {
final Engine engine = EngineFactory.createEngine(loadTest);
if (engine == null) {
MSException.throwException(String.format("Delete report fail. create engine failreport 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);
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);
}
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
loadTest.setStatus(PerformanceTestStatus.Saved.name());
loadTestMapper.updateByPrimaryKeySelective(loadTest);
}
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
loadTest.setStatus(PerformanceTestStatus.Saved.name());
loadTestMapper.updateByPrimaryKeySelective(loadTest);
}
// delete load_test_report_result