fix(性能测试): 修复性能测试定时任务报告不发送通知

This commit is contained in:
Captain.B 2020-11-02 13:20:44 +08:00
parent 41340cde89
commit 4534463216
1 changed files with 10 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package io.metersphere.performance.notice;
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
import io.metersphere.base.mapper.LoadTestReportMapper;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.utils.LogUtil;
@ -34,6 +35,9 @@ public class PerformanceNoticeTask {
private MailService mailService;
@Resource
private SystemParameterService systemParameterService;
@Resource
private LoadTestReportMapper loadTestReportMapper;
private final ExecutorService executorService = Executors.newFixedThreadPool(20);
private boolean isRunning = true;
@ -45,14 +49,16 @@ public class PerformanceNoticeTask {
public void registerNoticeTask(LoadTestReportWithBLOBs loadTestReport) {
executorService.submit(() -> {
while (isRunning) {
if (StringUtils.equals(loadTestReport.getStatus(), PerformanceTestStatus.Completed.name())) {
LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReport.getId());
if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Completed.name())) {
isRunning = false;
sendSuccessNotice(loadTestReport);
sendSuccessNotice(loadTestReportFromDatabase);
return;
}
if (StringUtils.equals(loadTestReport.getStatus(), PerformanceTestStatus.Error.name())) {
if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Error.name())) {
isRunning = false;
sendFailNotice(loadTestReport);
sendFailNotice(loadTestReportFromDatabase);
return;
}
try {