From dac8e8fbfcb0b8f5833c7fdf59798236c49790ea Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 2 Apr 2021 10:15:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=A2=84=E8=AE=A1=E6=89=A7=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xml/reader/jmx/JmeterDocumentParser.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/backend/src/main/java/io/metersphere/performance/parse/xml/reader/jmx/JmeterDocumentParser.java b/backend/src/main/java/io/metersphere/performance/parse/xml/reader/jmx/JmeterDocumentParser.java index 3b9e263ae2..af3d40a777 100644 --- a/backend/src/main/java/io/metersphere/performance/parse/xml/reader/jmx/JmeterDocumentParser.java +++ b/backend/src/main/java/io/metersphere/performance/parse/xml/reader/jmx/JmeterDocumentParser.java @@ -586,7 +586,7 @@ public class JmeterDocumentParser implements DocumentParser { collectionProp.appendChild(createKafkaProp(document, "test.name", context.getTestName())); collectionProp.appendChild(createKafkaProp(document, "test.startTime", context.getStartTime().toString())); collectionProp.appendChild(createKafkaProp(document, "test.reportId", context.getReportId())); - collectionProp.appendChild(createKafkaProp(document, "test.expectedEndTime", (String) context.getProperty("expectedEndTime"))); + collectionProp.appendChild(createKafkaProp(document, "test.expectedDuration", (String) context.getProperty("expectedDuration"))); collectionProp.appendChild(createKafkaProp(document, "test.expectedDelayEndTime", kafkaProperties.getExpectedDelayEndTime())); // 30s elementProp.appendChild(collectionProp); @@ -730,7 +730,7 @@ public class JmeterDocumentParser implements DocumentParser { break; } // 处理预计结束时间 - processExpectedEndTime(duration); + processExpectedDuration(duration); threadGroup.setAttribute("enabled", enabled); if (BooleanUtils.toBoolean(deleted)) { @@ -847,7 +847,7 @@ public class JmeterDocumentParser implements DocumentParser { break; } // 处理预计结束时间 - processExpectedEndTime(duration); + processExpectedDuration(duration); threadGroup.setAttribute("enabled", enabled); if (BooleanUtils.toBoolean(deleted)) { @@ -868,23 +868,22 @@ public class JmeterDocumentParser implements DocumentParser { threadGroup.appendChild(createStringProp(document, "Unit", "S")); } - private void processExpectedEndTime(String duration) { - long startTime = context.getStartTime(); + private void processExpectedDuration(String duration) { Long d = Long.parseLong(duration); Object serialize = context.getProperty("TestPlan.serialize_threadgroups"); - String expectedEndTime = (String) context.getProperty("expectedEndTime"); - if (StringUtils.isBlank(expectedEndTime)) { - expectedEndTime = startTime + ""; + String expectedDuration = (String) context.getProperty("expectedDuration"); + if (StringUtils.isBlank(expectedDuration)) { + expectedDuration = "0"; } - long endTime = Long.parseLong(expectedEndTime); + long durationTime = Long.parseLong(expectedDuration); if (BooleanUtils.toBoolean((String) serialize)) { // 顺序执行线程组 - context.addProperty("expectedEndTime", String.valueOf(endTime + d * 1000)); + context.addProperty("expectedDuration", String.valueOf(durationTime + d * 1000)); } else { // 同时执行线程组 - if (endTime < startTime + d * 1000) { - context.addProperty("expectedEndTime", String.valueOf(startTime + d * 1000)); + if (durationTime < d * 1000) { + context.addProperty("expectedDuration", String.valueOf(d * 1000)); } } } @@ -960,7 +959,7 @@ public class JmeterDocumentParser implements DocumentParser { // 处理预计结束时间, (按照迭代次数 * 线程数)s String duration = String.valueOf(Long.parseLong(loops) * Long.parseLong(threads)); - processExpectedEndTime(duration); + processExpectedDuration(duration); } private void processCheckoutTimer(Element element) {