fix(接口场景-添加环境变量,性能测试-引用场景): 解决性能测试引用场景时没有自动加载csv文件的问题,解决设置环境变量参数在场景执行过程中使用不是最新值的问题
解决性能测试引用场景时没有自动加载csv文件的问题,解决设置环境变量参数在场景执行过程中使用不是最新值的问题
This commit is contained in:
parent
5903c0e84a
commit
c593aa2147
|
@ -279,6 +279,5 @@ public class ApiAutomationController {
|
||||||
public List<ApiScenrioExportJmx> exportJmx(@RequestBody ApiScenarioBatchRequest request) {
|
public List<ApiScenrioExportJmx> exportJmx(@RequestBody ApiScenarioBatchRequest request) {
|
||||||
return apiAutomationService.exportJmx(request);
|
return apiAutomationService.exportJmx(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package io.metersphere.api.dto;
|
package io.metersphere.api.dto;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import io.metersphere.base.domain.FileMetadata;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +19,7 @@ public class JmxInfoDTO {
|
||||||
private String xml;
|
private String xml;
|
||||||
private String id;
|
private String id;
|
||||||
private Map<String, String> attachFiles;
|
private Map<String, String> attachFiles;
|
||||||
|
private List<FileMetadata> fileMetadataList;
|
||||||
|
|
||||||
public JmxInfoDTO(String name,String xml,Map<String, String> attachFiles){
|
public JmxInfoDTO(String name,String xml,Map<String, String> attachFiles){
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package io.metersphere.api.dto.automation;
|
package io.metersphere.api.dto.automation;
|
||||||
|
|
||||||
|
import io.metersphere.base.domain.FileMetadata;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@ -13,6 +14,9 @@ public class ApiScenrioExportJmx {
|
||||||
private Integer version;
|
private Integer version;
|
||||||
List<String> files;
|
List<String> files;
|
||||||
|
|
||||||
|
//性能测试引用场景时需要场景下的附件
|
||||||
|
private List<FileMetadata> fileMetadataList;
|
||||||
|
|
||||||
public ApiScenrioExportJmx(String name, String jmx) {
|
public ApiScenrioExportJmx(String name, String jmx) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.jmx = jmx;
|
this.jmx = jmx;
|
||||||
|
|
|
@ -530,11 +530,13 @@ public class APITestService {
|
||||||
//处理附件
|
//处理附件
|
||||||
Map<String, String> attachmentFiles = new HashMap<>();
|
Map<String, String> attachmentFiles = new HashMap<>();
|
||||||
|
|
||||||
|
List<FileMetadata> fileMetadataList = new ArrayList<>();
|
||||||
for (String filePath: attachmentFilePathList) {
|
for (String filePath: attachmentFilePathList) {
|
||||||
File file = new File(filePath);
|
File file = new File(filePath);
|
||||||
if(file.exists() && file.isFile()){
|
if(file.exists() && file.isFile()){
|
||||||
try{
|
try{
|
||||||
FileMetadata fileMetadata = fileService.saveFile(file,FileUtil.readAsByteArray(file));
|
FileMetadata fileMetadata = fileService.saveFile(file,FileUtil.readAsByteArray(file));
|
||||||
|
fileMetadataList.add(fileMetadata);
|
||||||
attachmentFiles.put(fileMetadata.getId(),fileMetadata.getName());
|
attachmentFiles.put(fileMetadata.getId(),fileMetadata.getName());
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -543,7 +545,7 @@ public class APITestService {
|
||||||
}
|
}
|
||||||
|
|
||||||
JmxInfoDTO returnDTO = new JmxInfoDTO("Demo.jmx",jmxString,attachmentFiles);
|
JmxInfoDTO returnDTO = new JmxInfoDTO("Demo.jmx",jmxString,attachmentFiles);
|
||||||
|
returnDTO.setFileMetadataList(fileMetadataList);
|
||||||
return returnDTO;
|
return returnDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1766,6 +1766,7 @@ public class ApiAutomationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scenrioExportJmx.setVersion(item.getVersion());
|
scenrioExportJmx.setVersion(item.getVersion());
|
||||||
|
scenrioExportJmx.setFileMetadataList(dto.getFileMetadataList());
|
||||||
resList.add(scenrioExportJmx);
|
resList.add(scenrioExportJmx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: this.$t('api_test.request.processor.param_environment_set_global_variable'),
|
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'),
|
title: this.$t('api_test.request.processor.code_add_report_length'),
|
||||||
|
|
Loading…
Reference in New Issue