fix(接口测试): 公共脚本执行收不到结果

This commit is contained in:
AgAngle 2024-01-31 14:17:45 +08:00 committed by Craftsman
parent bb9013de65
commit de1426f54a
5 changed files with 13 additions and 8 deletions

View File

@ -24,8 +24,11 @@ public class TaskRequestDTO implements Serializable {
/** /**
* 是否需要实时接收单个步骤的结果 * 是否需要实时接收单个步骤的结果
*/ */
private Boolean realTime; private Boolean realTime = false;
/**
* 是否保存执行结果
*/
private Boolean saveResult = true;
/** /**
* 执行的资源ID * 执行的资源ID
*/ */

View File

@ -20,7 +20,7 @@ public class MsCommentScriptElement extends AbstractMsTestElement {
private String script; private String script;
/** /**
* 脚本语言 * 脚本语言
* @see ScriptProcessor.ScriptLanguageType * @see io.metersphere.project.constants.ScriptLanguageType
*/ */
private String scriptLanguage; private String scriptLanguage;
/** /**

View File

@ -105,7 +105,7 @@ public class JmeterTestElementParser implements TestElementParser {
private DebugSampler getDebugSampler() { private DebugSampler getDebugSampler() {
DebugSampler debugSampler = new DebugSampler(); DebugSampler debugSampler = new DebugSampler();
debugSampler.setEnabled(true); debugSampler.setEnabled(true);
debugSampler.setName("DebugSampler"); debugSampler.setName("RunningDebugSampler");
debugSampler.setProperty(TestElement.TEST_CLASS, DebugSampler.class.getName()); debugSampler.setProperty(TestElement.TEST_CLASS, DebugSampler.class.getName());
debugSampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); debugSampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));

View File

@ -7,9 +7,9 @@ import io.metersphere.plugin.api.dto.ParameterConfig;
import io.metersphere.plugin.api.spi.AbstractJmeterElementConverter; import io.metersphere.plugin.api.spi.AbstractJmeterElementConverter;
import io.metersphere.project.dto.environment.KeyValueParam; import io.metersphere.project.dto.environment.KeyValueParam;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.jmeter.extractor.BeanShellPostProcessor;
import org.apache.jmeter.extractor.JSR223PostProcessor;
import org.apache.jmeter.modifiers.UserParameters; import org.apache.jmeter.modifiers.UserParameters;
import org.apache.jmeter.protocol.java.sampler.BeanShellSampler;
import org.apache.jmeter.protocol.java.sampler.JSR223Sampler;
import org.apache.jmeter.save.SaveService; import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.testelement.TestElement;
import org.apache.jorphan.collections.HashTree; import org.apache.jorphan.collections.HashTree;
@ -48,9 +48,9 @@ public class MsCommentScriptElementConverter extends AbstractJmeterElementConver
scriptProcessor.setScript(msElement.getScript()); scriptProcessor.setScript(msElement.getScript());
TestElement scriptElement; TestElement scriptElement;
if (ScriptProcessorConverter.isJSR233(scriptProcessor)) { if (ScriptProcessorConverter.isJSR233(scriptProcessor)) {
scriptElement = new JSR223PostProcessor(); scriptElement = new JSR223Sampler();
} else { } else {
scriptElement = new BeanShellPostProcessor(); scriptElement = new BeanShellSampler();
} }
ScriptProcessorConverter.parse(scriptElement, scriptProcessor); ScriptProcessorConverter.parse(scriptElement, scriptProcessor);
hashTree.add(scriptElement); hashTree.add(scriptElement);

View File

@ -117,6 +117,7 @@ public class ApiExecuteService {
TaskRequestDTO taskRequest = new TaskRequestDTO(); TaskRequestDTO taskRequest = new TaskRequestDTO();
BeanUtils.copyBean(taskRequest, request); BeanUtils.copyBean(taskRequest, request);
taskRequest.setRealTime(true); taskRequest.setRealTime(true);
taskRequest.setSaveResult(false);
taskRequest.setResourceId(testId); taskRequest.setResourceId(testId);
setServerInfoParam(taskRequest); setServerInfoParam(taskRequest);
@ -205,6 +206,7 @@ public class ApiExecuteService {
TaskRequestDTO taskRequest = new TaskRequestDTO(); TaskRequestDTO taskRequest = new TaskRequestDTO();
setServerInfoParam(taskRequest); setServerInfoParam(taskRequest);
taskRequest.setRealTime(true); taskRequest.setRealTime(true);
taskRequest.setSaveResult(false);
taskRequest.setReportId(reportId); taskRequest.setReportId(reportId);
taskRequest.setResourceId(testId); taskRequest.setResourceId(testId);
taskRequest.setResourceType(ApiExecuteResourceType.API_DEBUG.name()); taskRequest.setResourceType(ApiExecuteResourceType.API_DEBUG.name());