Merge remote-tracking branch 'origin/master' into master

This commit is contained in:
Captain.B 2020-11-13 15:54:33 +08:00
commit 28e1fb3a6f
5 changed files with 34 additions and 28 deletions

View File

@ -341,7 +341,7 @@ public class MailService {
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
List<SystemParameter> paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue()); List<SystemParameter> paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue());
javaMailSender.setDefaultEncoding("UTF-8"); javaMailSender.setDefaultEncoding("UTF-8");
javaMailSender.setProtocol("smtps"); javaMailSender.setProtocol("smtp");
for (SystemParameter p : paramList) { for (SystemParameter p : paramList) {
switch (p.getParamKey()) { switch (p.getParamKey()) {
case "smtp.host": case "smtp.host":
@ -362,8 +362,8 @@ public class MailService {
} }
Properties props = new Properties(); Properties props = new Properties();
props.put("mail.smtp.auth", "true"); props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.starttls.enable", "false");
props.put("mail.smtp.starttls.required", "true"); props.put("mail.smtp.starttls.required", "false");
props.put("mail.smtp.timeout", "30000"); props.put("mail.smtp.timeout", "30000");
props.put("mail.smtp.connectiontimeout", "5000"); props.put("mail.smtp.connectiontimeout", "5000");
javaMailSender.setJavaMailProperties(props); javaMailSender.setJavaMailProperties(props);

View File

@ -39,34 +39,36 @@ public class PerformanceNoticeTask {
private LoadTestReportMapper loadTestReportMapper; private LoadTestReportMapper loadTestReportMapper;
private final ExecutorService executorService = Executors.newFixedThreadPool(20); private final ExecutorService executorService = Executors.newFixedThreadPool(20);
private boolean isRunning = true;
@PreDestroy private boolean isRunning=false;
/*@PreDestroy
public void preDestroy() { public void preDestroy() {
isRunning = false; isRunning = false;
} }*/
public void registerNoticeTask(LoadTestReportWithBLOBs loadTestReport) { public void registerNoticeTask(LoadTestReportWithBLOBs loadTestReport) {
int count = 20; isRunning=true;
while (count-- > 0) { executorService.submit(() -> {
LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReport.getId()); LogUtil.info("性能测试定时任务");
if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Completed.name())) { while (isRunning) {
isRunning = false; LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReport.getId());
sendSuccessNotice(loadTestReportFromDatabase); if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Completed.name())) {
return; sendSuccessNotice(loadTestReportFromDatabase);
isRunning=false;
}
if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Error.name())) {
sendFailNotice(loadTestReportFromDatabase);
isRunning=false;
}
try {
//查询定时任务是否关闭
Thread.sleep(1000 * 30);// 每分钟检查 loadtest 的状态
} catch (InterruptedException e) {
LogUtil.error(e);
}
} }
if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Error.name())) { });
isRunning = false;
sendFailNotice(loadTestReportFromDatabase);
return;
}
count--;
try {
Thread.sleep(1000 * 4L);// 每分钟检查 loadtest 的状态
} catch (InterruptedException e) {
LogUtil.error(e);
}
}
} }
public void sendSuccessNotice(LoadTestReportWithBLOBs loadTestReport) { public void sendSuccessNotice(LoadTestReportWithBLOBs loadTestReport) {

View File

@ -207,6 +207,7 @@ public class PerformanceTestService {
@Transactional(noRollbackFor = MSException.class)// 保存失败的信息 @Transactional(noRollbackFor = MSException.class)// 保存失败的信息
public String run(RunTestPlanRequest request) { public String run(RunTestPlanRequest request) {
LogUtil.info("性能测试run测试");
final LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(request.getId()); final LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(request.getId());
if (request.getUserId() != null) { if (request.getUserId() != null) {
loadTest.setUserId(request.getUserId()); loadTest.setUserId(request.getUserId());

View File

@ -168,7 +168,10 @@ public class ReportService {
public void checkReportStatus(String reportId) { public void checkReportStatus(String reportId) {
LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId);
String reportStatus = loadTestReport.getStatus(); String reportStatus="";
if(loadTestReport!=null){
reportStatus = loadTestReport.getStatus();
}
if (StringUtils.equals(PerformanceTestStatus.Error.name(), reportStatus)) { if (StringUtils.equals(PerformanceTestStatus.Error.name(), reportStatus)) {
MSException.throwException("Report generation error!"); MSException.throwException("Report generation error!");
} }

View File

@ -28,7 +28,7 @@
</el-form-item> </el-form-item>
<el-form-item prop="password"> <el-form-item prop="password">
<el-input v-model="form.password" :placeholder="$t('commons.password')" show-password autocomplete="off" <el-input v-model="form.password" :placeholder="$t('commons.password')" show-password autocomplete="off"
maxlength="20" show-word-limit/> maxlength="30" show-word-limit/>
</el-form-item> </el-form-item>
</div> </div>
<div class="btn"> <div class="btn">
@ -81,7 +81,7 @@ export default {
], ],
password: [ password: [
{required: true, message: this.$t('commons.input_password'), trigger: 'blur'}, {required: true, message: this.$t('commons.input_password'), trigger: 'blur'},
{min: 6, max: 20, message: this.$t('commons.input_limit', [6, 20]), trigger: 'blur'} {min: 6, max: 30, message: this.$t('commons.input_limit', [6, 30]), trigger: 'blur'}
] ]
}, },
msg: '', msg: '',