From 5e4c0a68852c0f634039532ffa5afcb88dacb4c9 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Tue, 18 Jan 2022 18:17:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E8=B0=83=E8=AF=95):=20=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E8=B0=83=E8=AF=95=E6=97=B6=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E7=9A=84=E7=8E=AF=E5=A2=83=E5=B8=A6=E6=9C=89=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E5=89=8D=E5=90=8E=E7=BD=AE=E8=84=9A=E6=9C=AC=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=9A=84=E6=8A=A5=E5=91=8A=E4=B8=8D=E5=87=86=E7=A1=AE=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复接口场景调试时选择的环境带有全局前后置脚本返回的报告不准确的问题 --- .../api/exec/utils/ResultParseUtil.java | 17 +++++++++++++++++ .../metersphere/api/jmeter/MsDebugListener.java | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/api/exec/utils/ResultParseUtil.java diff --git a/backend/src/main/java/io/metersphere/api/exec/utils/ResultParseUtil.java b/backend/src/main/java/io/metersphere/api/exec/utils/ResultParseUtil.java new file mode 100644 index 0000000000..37b7ea18d5 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/exec/utils/ResultParseUtil.java @@ -0,0 +1,17 @@ +package io.metersphere.api.exec.utils; + +import io.metersphere.dto.RequestResult; +import org.apache.commons.lang3.StringUtils; + +public class ResultParseUtil { + + private static final String PRE_PROCESS_SCRIPT = "PRE_PROCESSOR_ENV_"; + private static final String POST_PROCESS_SCRIPT = "POST_PROCESSOR_ENV_"; + + public static boolean isNotAutoGenerateSampler(RequestResult result) { + if (StringUtils.equals(result.getMethod(), "Request") && StringUtils.startsWithAny(result.getName(), PRE_PROCESS_SCRIPT, POST_PROCESS_SCRIPT)) { + return false; + } + return true; + } +} diff --git a/backend/src/main/java/io/metersphere/api/jmeter/MsDebugListener.java b/backend/src/main/java/io/metersphere/api/jmeter/MsDebugListener.java index 3f4affe895..c10b9f7f5a 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/MsDebugListener.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/MsDebugListener.java @@ -22,6 +22,7 @@ import com.alibaba.fastjson.JSONObject; import io.metersphere.api.dto.ErrorReportLibraryParseDTO; import io.metersphere.api.dto.RunningParamKeys; import io.metersphere.api.exec.queue.PoolExecBlockingQueueUtil; +import io.metersphere.api.exec.utils.ResultParseUtil; import io.metersphere.api.service.MsResultService; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.ErrorReportLibraryUtil; @@ -151,8 +152,7 @@ public class MsDebugListener extends AbstractListenerElement implements SampleLi this.setVars(result); if (isSampleWanted(result.isSuccessful()) && !StringUtils.equals(result.getSampleLabel(), RunningParamKeys.RUNNING_DEBUG_SAMPLER_NAME)) { RequestResult requestResult = JMeterBase.getRequestResult(result); - if (requestResult != null) { - + if (requestResult != null && ResultParseUtil.isNotAutoGenerateSampler(requestResult)) { MsgDto dto = new MsgDto(); dto.setExecEnd(false); dto.setReportId("send." + this.getName());