fix(接口场景调试): 修复接口场景调试时选择的环境带有全局前后置脚本返回的报告不准确的问题

修复接口场景调试时选择的环境带有全局前后置脚本返回的报告不准确的问题
This commit is contained in:
song-tianyang 2022-01-18 17:44:20 +08:00 committed by fit2-zhao
parent dd1880facf
commit 91c1b2a71e
2 changed files with 19 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -20,6 +20,7 @@ package io.metersphere.api.jmeter;
import com.alibaba.fastjson.JSON;
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.LogUtil;
@ -148,7 +149,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());