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

修复接口场景调试时选择的环境带有全局前后置脚本返回的报告不准确的问题
This commit is contained in:
song-tianyang 2022-01-18 18:17:06 +08:00 committed by song-tianyang
parent 459983e597
commit 5e4c0a6885
2 changed files with 19 additions and 2 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

@ -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());