From 9dd9620dac51588c0f40292fb5d8eb1456fc2925 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Mon, 20 Dec 2021 14:58:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E5=A4=9A?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=89=A7=E8=A1=8C=E6=98=AF=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=8D=A1=E5=9C=A8starting=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1008998 --user=刘瑞斌 【性能测试】多个node执行性能测试失败 https://www.tapd.cn/55049933/s/1083328 --- .../performance/service/JmeterFileService.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/metersphere/performance/service/JmeterFileService.java b/backend/src/main/java/io/metersphere/performance/service/JmeterFileService.java index 292f6dd410..1b206a28eb 100644 --- a/backend/src/main/java/io/metersphere/performance/service/JmeterFileService.java +++ b/backend/src/main/java/io/metersphere/performance/service/JmeterFileService.java @@ -9,7 +9,6 @@ import io.metersphere.commons.utils.LogUtil; import io.metersphere.performance.engine.EngineContext; import io.metersphere.performance.engine.EngineFactory; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.ByteArrayOutputStream; @@ -17,13 +16,13 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import static org.python.modules.time.Time.sleep; +// 非事务运行 @Service -@Transactional(rollbackFor = Exception.class) public class JmeterFileService { @Resource private ExtLoadTestReportMapper extLoadTestReportMapper; @@ -32,14 +31,14 @@ public class JmeterFileService { public byte[] downloadZip(String reportId, double[] ratios, int resourceIndex) { try { - LoadTestReportWithBLOBs loadTestReport = null; - double waitingSeconds = 0; + LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); + int wait = 0; while (loadTestReport == null) { - if (waitingSeconds > 12000) { + if (wait > 120_000) { break; } - sleep(0.3); - waitingSeconds += 0.3; + TimeUnit.MILLISECONDS.sleep(200); + wait += 200; loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); } if (loadTestReport == null) {