From 3072ddf3a3373f3cd316e2e2f6eff6ca3e62d7a0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 2 Jul 2021 12:23:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E9=94=99=E8=AF=AF=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/TestPlanLoadCaseService.java | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java index d3a2044f37..b12f05e2f6 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java @@ -135,23 +135,21 @@ public class TestPlanLoadCaseService { } public void runBatch(RunBatchTestPlanRequest request) { - if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) { - try { + try { + if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) { serialRun(request); - } catch (Exception e) { - String message = e.getMessage(); - if (StringUtils.isNotEmpty(message)) { - message = message.replace("io.metersphere.commons.exception.MSException:", ""); - MSException.throwException(message); - }else{ - MSException.throwException("请求参数错误,请刷新后执行"); - } + } else { + ExecutorService executorService = Executors.newFixedThreadPool(request.getRequests().size()); + request.getRequests().forEach(item -> { + executorService.submit(new ParallelExecTask(performanceTestService, testPlanLoadCaseMapper, item)); + }); + } + } catch (Exception e) { + if (StringUtils.isNotEmpty(e.getMessage())) { + MSException.throwException("测试正在运行, 请等待!"); + } else { + MSException.throwException("请求参数错误,请刷新后执行!"); } - } else { - ExecutorService executorService = Executors.newFixedThreadPool(request.getRequests().size()); - request.getRequests().forEach(item -> { - executorService.submit(new ParallelExecTask(performanceTestService, testPlanLoadCaseMapper, item)); - }); } }