refactor(接口定义): 修改传参方式

--story=1011108 --user=王孝刚 资源池加载插件直接从MinIO获取
https://www.tapd.cn/55049933/s/1331634
This commit is contained in:
wxg0103 2023-02-10 14:21:49 +08:00 committed by wxg0103
parent 71ff9cd25a
commit ced2fc21a1
6 changed files with 27 additions and 26 deletions

View File

@ -266,7 +266,7 @@ public class ApiExecuteService {
if (MapUtils.isNotEmpty(projectJarMap)) {
TestPlan test = (TestPlan) runRequest.getHashTree().getArray()[0];
test.setProperty(ApiTestConstants.JAR_PATH, JSON.toJSONString(projectJarMap.keySet().stream().toList()));
runRequest.getExtendedParameters().put(ExtendedParameter.PROJECT_JAR_MAP, JSON.toJSONString(projectJarMap));
runRequest.setCustomJarInfo(projectJarMap);
}
return runRequest;
}

View File

@ -23,7 +23,6 @@ import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
import io.metersphere.base.mapper.plan.ext.ExtTestPlanScenarioCaseMapper;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.ApiTestConstants;
import io.metersphere.commons.constants.ExtendedParameter;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.enums.ApiReportStatus;
import io.metersphere.commons.exception.MSException;
@ -455,7 +454,7 @@ public class ApiScenarioExecuteService {
if (MapUtils.isNotEmpty(loadJar)) {
TestPlan test = (TestPlan) runRequest.getHashTree().getArray()[0];
test.setProperty(ApiTestConstants.JAR_PATH, JSON.toJSONString(loadJar.keySet().stream().toList()));
runRequest.getExtendedParameters().put(ExtendedParameter.PROJECT_JAR_MAP, JSON.toJSONString(loadJar));
runRequest.setCustomJarInfo(loadJar);
}
jMeterService.run(runRequest);
return request.getId();

View File

@ -59,24 +59,26 @@ public class NewDriverManager {
//获取文件内容
FileMetadataService fileMetadataService = CommonBeanFactory.getBean(FileMetadataService.class);
map.forEach((key, value) -> {
//历史数据
value.stream().distinct().filter(s -> s.isHasFile()).forEach(s -> {
//获取文件内容
byte[] bytes = new byte[0];
// 兼容历史数据
bytes = fileMetadataService.getContent(s.getId());
ApiFileUtil.createFile(StringUtils.join(ApiFileUtil.LOCAL_JAR,
File.separator,
key,
File.separator,
s.getId(),
File.separator,
String.valueOf(s.getUpdateTime()), ".jar"), bytes);
});
List<String> jarIds = value.stream().distinct().filter(s -> !s.isHasFile()).map(ProjectJarConfig::getId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(jarIds)) {
List<FileInfoDTO> fileInfoDTOS = fileMetadataService.downloadFileByIds(jarIds);
ApiFileUtil.createFiles(fileInfoDTOS, key, value);
if (CollectionUtils.isNotEmpty(value)) {
//历史数据
value.stream().distinct().filter(s -> s.isHasFile()).forEach(s -> {
//获取文件内容
byte[] bytes = new byte[0];
// 兼容历史数据
bytes = fileMetadataService.getContent(s.getId());
ApiFileUtil.createFile(StringUtils.join(ApiFileUtil.LOCAL_JAR,
File.separator,
key,
File.separator,
s.getId(),
File.separator,
String.valueOf(s.getUpdateTime()), ".jar"), bytes);
});
List<String> jarIds = value.stream().distinct().filter(s -> !s.isHasFile()).map(ProjectJarConfig::getId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(jarIds)) {
List<FileInfoDTO> fileInfoDTOS = fileMetadataService.downloadFileByIds(jarIds);
ApiFileUtil.createFiles(fileInfoDTOS, key, value);
}
}
});
}

View File

@ -3,7 +3,5 @@ package io.metersphere.commons.constants;
public class ExtendedParameter {
public static final String SYNC_STATUS = "SYN_RES";
public static final String SAVE_RESULT = "SAVE_RESULT";
public static final String PROJECT_ID = "projectId";
public static final String TEST_END = "TEST_END";
public static final String PROJECT_JAR_MAP = "PROJECT_JAR_MAP";
}

View File

@ -6,6 +6,7 @@ import lombok.Data;
import org.apache.jorphan.collections.HashTree;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@Data
@ -93,6 +94,9 @@ public class JmeterRunRequestDTO {
//MinIO配置和系统插件信息
private PluginConfigDTO pluginConfigDTO;
//自定义jar信息
private Map<String, List<ProjectJarConfig>> customJarInfo;
public JmeterRunRequestDTO() {
}

View File

@ -62,9 +62,7 @@ public class JarConfigUtils {
//本地没有文件需要从服务器下载
jarConfigs.add(projectJarConfig);
}
if (CollectionUtils.isNotEmpty(jarConfigs)) {
jarConfigsMap.put(item, jarConfigs);
}
jarConfigsMap.put(item, jarConfigs);
});
}
});