From a94453b51821b73486157faa62db645c2dcad0dd Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Fri, 13 Nov 2020 14:15:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E7=99=BB=E9=99=86=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=EF=BC=8C=E9=82=AE=E7=AE=B1=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/service/MailService.java | 6 +-- .../notice/PerformanceNoticeTask.java | 46 ++++++++++--------- .../service/PerformanceTestService.java | 1 + .../performance/service/ReportService.java | 5 +- frontend/src/login/Login.vue | 4 +- 5 files changed, 34 insertions(+), 28 deletions(-) diff --git a/backend/src/main/java/io/metersphere/notice/service/MailService.java b/backend/src/main/java/io/metersphere/notice/service/MailService.java index 3efeca32ae..14479ce941 100644 --- a/backend/src/main/java/io/metersphere/notice/service/MailService.java +++ b/backend/src/main/java/io/metersphere/notice/service/MailService.java @@ -341,7 +341,7 @@ public class MailService { JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); List 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); diff --git a/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeTask.java b/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeTask.java index 5b041a02b4..db8cbbd74a 100644 --- a/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeTask.java +++ b/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeTask.java @@ -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) { - LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReport.getId()); - if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Completed.name())) { - isRunning = false; - sendSuccessNotice(loadTestReportFromDatabase); - return; + isRunning=true; + executorService.submit(() -> { + LogUtil.info("性能测试定时任务"); + while (isRunning) { + LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReport.getId()); + if (StringUtils.equals(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Completed.name())) { + 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) { diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 1dc40dfe1d..fe338d2858 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -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()); diff --git a/backend/src/main/java/io/metersphere/performance/service/ReportService.java b/backend/src/main/java/io/metersphere/performance/service/ReportService.java index b50f6d4c23..a7dd4ca8b2 100644 --- a/backend/src/main/java/io/metersphere/performance/service/ReportService.java +++ b/backend/src/main/java/io/metersphere/performance/service/ReportService.java @@ -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!"); } diff --git a/frontend/src/login/Login.vue b/frontend/src/login/Login.vue index 7c4e25cf23..2e783bc085 100644 --- a/frontend/src/login/Login.vue +++ b/frontend/src/login/Login.vue @@ -28,7 +28,7 @@ + maxlength="30" show-word-limit/>
@@ -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: 20, message: this.$t('commons.input_limit', [6, 30]), trigger: 'blur'} ] }, msg: '', From d3862866fe92b19b4ae15242be44df26c8c79b8e Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Fri, 13 Nov 2020 14:19:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E7=99=BB=E9=99=86=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=EF=BC=8C=E9=82=AE=E7=AE=B1=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/login/Login.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/login/Login.vue b/frontend/src/login/Login.vue index 2e783bc085..fd3487e192 100644 --- a/frontend/src/login/Login.vue +++ b/frontend/src/login/Login.vue @@ -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, 30]), trigger: 'blur'} + {min: 6, max: 30, message: this.$t('commons.input_limit', [6, 30]), trigger: 'blur'} ] }, msg: '',