From c593aa214767e15ae946974756faf644a0cc15b4 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Mon, 28 Jun 2021 11:26:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=9C=BA=E6=99=AF-?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=EF=BC=8C?= =?UTF-8?q?=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95-=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E5=9C=BA=E6=99=AF):=20=E8=A7=A3=E5=86=B3=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=BC=95=E7=94=A8=E5=9C=BA=E6=99=AF=E6=97=B6?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=87=AA=E5=8A=A8=E5=8A=A0=E8=BD=BDcsv?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E8=AE=BE=E7=BD=AE=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=9C=A8=E5=9C=BA=E6=99=AF=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E4=B8=AD=E4=BD=BF=E7=94=A8=E4=B8=8D=E6=98=AF?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E5=80=BC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决性能测试引用场景时没有自动加载csv文件的问题,解决设置环境变量参数在场景执行过程中使用不是最新值的问题 --- .../metersphere/api/controller/ApiAutomationController.java | 1 - backend/src/main/java/io/metersphere/api/dto/JmxInfoDTO.java | 4 +++- .../metersphere/api/dto/automation/ApiScenrioExportJmx.java | 4 ++++ .../main/java/io/metersphere/api/service/APITestService.java | 4 +++- .../java/io/metersphere/api/service/ApiAutomationService.java | 1 + .../api/automation/scenario/common/Jsr233ProcessorContent.vue | 2 +- 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java index 9229f3fa41..a3aaca55c8 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -279,6 +279,5 @@ public class ApiAutomationController { public List exportJmx(@RequestBody ApiScenarioBatchRequest request) { return apiAutomationService.exportJmx(request); } - } diff --git a/backend/src/main/java/io/metersphere/api/dto/JmxInfoDTO.java b/backend/src/main/java/io/metersphere/api/dto/JmxInfoDTO.java index 76e1e0c41c..00ae9a2dca 100644 --- a/backend/src/main/java/io/metersphere/api/dto/JmxInfoDTO.java +++ b/backend/src/main/java/io/metersphere/api/dto/JmxInfoDTO.java @@ -1,9 +1,10 @@ package io.metersphere.api.dto; -import lombok.AllArgsConstructor; +import io.metersphere.base.domain.FileMetadata; import lombok.Getter; import lombok.Setter; +import java.util.List; import java.util.Map; /** @@ -18,6 +19,7 @@ public class JmxInfoDTO { private String xml; private String id; private Map attachFiles; + private List fileMetadataList; public JmxInfoDTO(String name,String xml,Map attachFiles){ this.name = name; diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenrioExportJmx.java b/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenrioExportJmx.java index 0c1989dca0..5e5f7df412 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenrioExportJmx.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenrioExportJmx.java @@ -1,5 +1,6 @@ package io.metersphere.api.dto.automation; +import io.metersphere.base.domain.FileMetadata; import lombok.Getter; import lombok.Setter; @@ -13,6 +14,9 @@ public class ApiScenrioExportJmx { private Integer version; List files; + //性能测试引用场景时需要场景下的附件 + private List fileMetadataList; + public ApiScenrioExportJmx(String name, String jmx) { this.name = name; this.jmx = jmx; diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index 4369fdeeaa..b61754798d 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -530,11 +530,13 @@ public class APITestService { //处理附件 Map attachmentFiles = new HashMap<>(); + List fileMetadataList = new ArrayList<>(); for (String filePath: attachmentFilePathList) { File file = new File(filePath); if(file.exists() && file.isFile()){ try{ FileMetadata fileMetadata = fileService.saveFile(file,FileUtil.readAsByteArray(file)); + fileMetadataList.add(fileMetadata); attachmentFiles.put(fileMetadata.getId(),fileMetadata.getName()); }catch (Exception e){ e.printStackTrace(); @@ -543,7 +545,7 @@ public class APITestService { } JmxInfoDTO returnDTO = new JmxInfoDTO("Demo.jmx",jmxString,attachmentFiles); - + returnDTO.setFileMetadataList(fileMetadataList); return returnDTO; } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 1d23d7513e..57364332be 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1766,6 +1766,7 @@ public class ApiAutomationService { } } scenrioExportJmx.setVersion(item.getVersion()); + scenrioExportJmx.setFileMetadataList(dto.getFileMetadataList()); resList.add(scenrioExportJmx); } } diff --git a/frontend/src/business/components/api/automation/scenario/common/Jsr233ProcessorContent.vue b/frontend/src/business/components/api/automation/scenario/common/Jsr233ProcessorContent.vue index 8e5606f2e2..073e5f985b 100644 --- a/frontend/src/business/components/api/automation/scenario/common/Jsr233ProcessorContent.vue +++ b/frontend/src/business/components/api/automation/scenario/common/Jsr233ProcessorContent.vue @@ -43,7 +43,7 @@ }, { title: this.$t('api_test.request.processor.param_environment_set_global_variable'), - value: 'vars.put(${__metersphere_env_id}+"key","value")', + value: 'vars.put(${__metersphere_env_id}+"key","value");\n'+'vars.put("key","value");', }, { title: this.$t('api_test.request.processor.code_add_report_length'),