diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java index 69859eb472..9df5094bff 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java @@ -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; } diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java index 889a3241d2..1c7338facb 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java @@ -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(); diff --git a/api-test/backend/src/main/java/io/metersphere/api/jmeter/NewDriverManager.java b/api-test/backend/src/main/java/io/metersphere/api/jmeter/NewDriverManager.java index 949e51c497..ba346bc4cc 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/jmeter/NewDriverManager.java +++ b/api-test/backend/src/main/java/io/metersphere/api/jmeter/NewDriverManager.java @@ -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 jarIds = value.stream().distinct().filter(s -> !s.isHasFile()).map(ProjectJarConfig::getId).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(jarIds)) { - List 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 jarIds = value.stream().distinct().filter(s -> !s.isHasFile()).map(ProjectJarConfig::getId).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(jarIds)) { + List fileInfoDTOS = fileMetadataService.downloadFileByIds(jarIds); + ApiFileUtil.createFiles(fileInfoDTOS, key, value); + } } }); } diff --git a/api-test/backend/src/main/java/io/metersphere/commons/constants/ExtendedParameter.java b/api-test/backend/src/main/java/io/metersphere/commons/constants/ExtendedParameter.java index 70d8af34ee..19be0417a1 100644 --- a/api-test/backend/src/main/java/io/metersphere/commons/constants/ExtendedParameter.java +++ b/api-test/backend/src/main/java/io/metersphere/commons/constants/ExtendedParameter.java @@ -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"; } diff --git a/framework/sdk-parent/jmeter/src/main/java/io/metersphere/dto/JmeterRunRequestDTO.java b/framework/sdk-parent/jmeter/src/main/java/io/metersphere/dto/JmeterRunRequestDTO.java index d122aaedcb..ac71ecd255 100644 --- a/framework/sdk-parent/jmeter/src/main/java/io/metersphere/dto/JmeterRunRequestDTO.java +++ b/framework/sdk-parent/jmeter/src/main/java/io/metersphere/dto/JmeterRunRequestDTO.java @@ -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> customJarInfo; + public JmeterRunRequestDTO() { } diff --git a/framework/sdk-parent/jmeter/src/main/java/io/metersphere/utils/JarConfigUtils.java b/framework/sdk-parent/jmeter/src/main/java/io/metersphere/utils/JarConfigUtils.java index ea9cc6a25e..6ccbdc025c 100644 --- a/framework/sdk-parent/jmeter/src/main/java/io/metersphere/utils/JarConfigUtils.java +++ b/framework/sdk-parent/jmeter/src/main/java/io/metersphere/utils/JarConfigUtils.java @@ -62,9 +62,7 @@ public class JarConfigUtils { //本地没有文件,需要从服务器下载 jarConfigs.add(projectJarConfig); } - if (CollectionUtils.isNotEmpty(jarConfigs)) { - jarConfigsMap.put(item, jarConfigs); - } + jarConfigsMap.put(item, jarConfigs); }); } });