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

View File

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

View File

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

View File

@ -168,7 +168,10 @@ public class ReportService {
public void checkReportStatus(String 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)) {
MSException.throwException("Report generation error!");
}

View File

@ -28,7 +28,7 @@
</el-form-item>
<el-form-item prop="password">
<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>
</div>
<div class="btn">
@ -81,7 +81,7 @@ export default {
],
password: [
{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: '',