fix(接口测试): 接口调试执行报错

This commit is contained in:
AgAngle 2024-02-07 15:46:27 +08:00 committed by jianxing
parent 110cbe7005
commit 68bd55647d
11 changed files with 16 additions and 23 deletions

View File

@ -1,4 +1,4 @@
package io.metersphere.project.enums;
package io.metersphere.sdk.constants;
/**
* @author: LAN

View File

@ -33,6 +33,6 @@ public class SocketMsgDTO implements Serializable {
/**
* 结果内容
*/
private String taskResult;
private Object taskResult;
}

View File

@ -1,6 +1,5 @@
package io.metersphere.api.parser.jmeter.validator;
package io.metersphere.sdk.util;
import io.metersphere.sdk.util.LogUtils;
import org.apache.commons.lang3.StringUtils;
public class EnumValidator {

View File

@ -5,6 +5,7 @@ import io.metersphere.plugin.api.spi.AbstractMsTestElement;
import io.metersphere.project.dto.environment.EnvironmentInfoDTO;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
/**
@ -26,14 +27,14 @@ public class ApiParamConfig extends ParameterConfig {
* key AbstractMsTestElement 实现类对象
* value 为对应的插件 ID
*/
private Map<Class<? extends AbstractMsTestElement>, String> testElementClassPluginIdMap;
private Map<Class<? extends AbstractMsTestElement>, String> testElementClassPluginIdMap = HashMap.newHashMap(0);
/**
* AbstractMsTestElement 实现类与接口协议的映射
* key AbstractMsTestElement 实现类对象
* value 为对应的接口协议
* 环境前后置忽略协议需要使用
*/
private Map<Class<? extends AbstractMsTestElement>, String> testElementClassProtocalMap;
private Map<Class<? extends AbstractMsTestElement>, String> testElementClassProtocalMap = HashMap.newHashMap(0);
@Override

View File

@ -28,10 +28,6 @@ public class ApiResourceRunRequest {
* 环境或者环境组ID
*/
private String environmentId;
/**
* 执行模式
*/
private String runMode;
/**
* 资源类型
* @see io.metersphere.api.constants.ApiResourceType

View File

@ -1,7 +1,7 @@
package io.metersphere.api.parser.jmeter.processor.assertion;
import io.metersphere.project.api.assertion.MsAssertion;
import io.metersphere.api.parser.jmeter.validator.EnumValidator;
import io.metersphere.sdk.util.EnumValidator;
import io.metersphere.plugin.api.dto.ParameterConfig;
import io.metersphere.sdk.constants.MsAssertionCondition;
import org.apache.commons.lang3.BooleanUtils;

View File

@ -1,7 +1,7 @@
package io.metersphere.api.parser.jmeter.processor.assertion;
import io.metersphere.project.api.assertion.MsResponseHeaderAssertion;
import io.metersphere.api.parser.jmeter.validator.EnumValidator;
import io.metersphere.sdk.util.EnumValidator;
import io.metersphere.plugin.api.dto.ParameterConfig;
import io.metersphere.sdk.constants.MsAssertionCondition;
import org.apache.commons.lang3.BooleanUtils;

View File

@ -12,7 +12,6 @@ import io.metersphere.plugin.api.dto.ParameterConfig;
import io.metersphere.plugin.api.spi.AbstractMsTestElement;
import io.metersphere.project.domain.ProjectApplication;
import io.metersphere.project.dto.customfunction.request.CustomFunctionRunRequest;
import io.metersphere.project.mapper.ProjectMapper;
import io.metersphere.project.service.FileAssociationService;
import io.metersphere.project.service.FileManagementService;
import io.metersphere.project.service.FileMetadataService;
@ -153,6 +152,9 @@ public class ApiExecuteService {
// 设置插件文件信息
taskRequest.setPluginFiles(apiPluginService.getFileInfoByProjectId(projectId));
ApiRunModeConfigDTO runModeConfig = new ApiRunModeConfigDTO();
runModeConfig.setRunMode(ApiExecuteRunMode.BACKEND_DEBUG.name());
taskRequest.setRunModeConfig(runModeConfig);
TestResourcePoolReturnDTO testResourcePoolDTO = getGetResourcePoolNodeDTO(projectId);
TestResourceNodeDTO testResourceNodeDTO = getProjectExecuteNode(testResourcePoolDTO);
@ -223,9 +225,6 @@ public class ApiExecuteService {
taskRequest.setReportId(reportId);
taskRequest.setResourceId(testId);
taskRequest.setResourceType(ApiExecuteResourceType.API_DEBUG.name());
ApiRunModeConfigDTO apiRunModeConfig = new ApiRunModeConfigDTO();
apiRunModeConfig.setRunMode(ApiExecuteRunMode.BACKEND_DEBUG.name());
taskRequest.setRunModeConfig(apiRunModeConfig);
doDebug(reportId, testId, taskRequest, executeScript, runRequest.getProjectId());
return reportId;

View File

@ -16,7 +16,6 @@ import io.metersphere.plugin.api.spi.AbstractMsTestElement;
import io.metersphere.project.dto.environment.EnvironmentInfoDTO;
import io.metersphere.project.service.EnvironmentService;
import io.metersphere.project.service.ProjectService;
import io.metersphere.sdk.constants.ApiExecuteRunMode;
import io.metersphere.sdk.constants.DefaultRepositoryDir;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.BeanUtils;
@ -197,19 +196,20 @@ public class ApiDebugService {
public String debug(ApiDebugRunRequest request) {
String id = request.getId();
String reportId = request.getReportId();
ApiResourceRunRequest runRequest = BeanUtils.copyBean(new ApiResourceRunRequest(), request);
runRequest.setProjectId(request.getProjectId());
runRequest.setTestId(id);
runRequest.setReportId(id);
runRequest.setReportId(reportId);
runRequest.setResourceType(ApiResourceType.API_DEBUG.name());
runRequest.setRunMode(ApiExecuteRunMode.BACKEND_DEBUG.name());
runRequest.setEnvironmentId(request.getEnvironmentId());
runRequest.setTestElement(ApiDataUtils.parseObject(JSON.toJSONString(request.getRequest()), AbstractMsTestElement.class));
ApiParamConfig paramConfig = new ApiParamConfig();
paramConfig.setTestElementClassPluginIdMap(apiPluginService.getTestElementPluginMap());
paramConfig.setReportId(request.getReportId());
paramConfig.setTestElementClassProtocalMap(apiPluginService.getTestElementProtocolMap());
paramConfig.setReportId(reportId);
EnvironmentInfoDTO environmentInfoDTO = environmentService.get(request.getEnvironmentId());
// 设置环境
paramConfig.setEnvConfig(environmentInfoDTO);

View File

@ -1053,7 +1053,6 @@ public class ApiScenarioService {
runRequest.setTestId(request.getId());
runRequest.setReportId(request.getReportId());
runRequest.setResourceType(ApiResourceType.API_SCENARIO.name());
runRequest.setRunMode(ApiExecuteRunMode.BACKEND_DEBUG.name());
runRequest.setTempFileIds(request.getTempFileIds());
runRequest.setGrouped(request.getGrouped());
runRequest.setEnvironmentId(request.getEnvironmentId());

View File

@ -1,7 +1,6 @@
package io.metersphere.project.dto;
import io.metersphere.project.enums.FakeErrorType;
import io.metersphere.sdk.constants.TemplateScene;
import io.metersphere.sdk.constants.FakeErrorType;
import io.metersphere.system.valid.EnumValue;
import io.metersphere.validation.groups.Created;
import io.swagger.v3.oas.annotations.media.Schema;