修复了压测中因为网络原因导致的jmx下载失败的bug

This commit is contained in:
Melissa.Lu 2021-12-03 13:43:22 +08:00 committed by 刘瑞斌
parent 7f0de8ca96
commit beafdc1b31
1 changed files with 12 additions and 1 deletions

View File

@ -20,6 +20,8 @@ import java.util.Map;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import static org.python.modules.time.Time.sleep;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class JmeterFileService { public class JmeterFileService {
@ -30,7 +32,16 @@ public class JmeterFileService {
public byte[] downloadZip(String reportId, double[] ratios, int resourceIndex) { public byte[] downloadZip(String reportId, double[] ratios, int resourceIndex) {
try { try {
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); LoadTestReportWithBLOBs loadTestReport = null;
double waitingSeconds = 0;
while (loadTestReport == null) {
if (waitingSeconds > 12000) {
break;
}
sleep(0.3);
waitingSeconds += 0.3;
loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId);
}
if (loadTestReport == null) { if (loadTestReport == null) {
MSException.throwException("测试报告不存在或还没产生"); MSException.throwException("测试报告不存在或还没产生");
} }