fix(接口测试): 修复接口测试转性能测试后附件会丢失的问题

--bug=1017144 --user=宋天阳 【性能测试】性能测试-引用所选环境变量中带csv文件的场景,执行时提示缺少文件
https://www.tapd.cn/55049933/s/1258621
This commit is contained in:
song-tianyang 2022-10-11 16:51:47 +08:00 committed by 刘瑞斌
parent 15fb461d68
commit 25020bae6f
2 changed files with 19 additions and 12 deletions

View File

@ -1556,8 +1556,8 @@ public class ApiScenarioService {
if (StringUtils.isNotEmpty(item.getScenarioDefinition())) {
HashTreeInfoDTO hashTreeInfoDTO = generateJmx(item);
if (StringUtils.isNotEmpty(hashTreeInfoDTO.getJmx())) {
ApiScenarioExportJmxDTO scenariosExportJmx = new ApiScenarioExportJmxDTO(item.getName(), DataFormattingUtil.updateJmxString(hashTreeInfoDTO.getJmx(), false).getXml());
JmxInfoDTO dto = DataFormattingUtil.updateJmxString(hashTreeInfoDTO.getJmx(), true);
ApiScenarioExportJmxDTO scenariosExportJmx = new ApiScenarioExportJmxDTO(item.getName(), dto.getXml());
dto.addFileMetadataLists(hashTreeInfoDTO.getRepositoryFiles());
scenariosExportJmx.setId(item.getId());
scenariosExportJmx.setVersion(item.getVersion());

View File

@ -456,17 +456,24 @@ public class FileMetadataService {
final FileMetadataWithBLOBs fileMetadata = new FileMetadataWithBLOBs();
this.initBase(fileMetadata);
fileMetadata.setName(fileName);
fileMetadata.setSize(fileSize);
String fileType = MetadataUtils.getFileType(fileName);
fileMetadata.setType(fileType);
checkName(fileMetadata);
FileRequest request = new FileRequest(fileMetadata.getProjectId(), fileMetadata.getName(), fileMetadata.getType());
String path = fileManagerService.upload(fileByte, request);
fileMetadata.setPath(path);
fileMetadata.setLatest(true);
fileMetadata.setRefId(fileMetadata.getId());
fileMetadataMapper.insert(fileMetadata);
return fileMetadata;
FileMetadataExample example = new FileMetadataExample();
example.createCriteria().andProjectIdEqualTo(fileMetadata.getProjectId()).andNameEqualTo(fileMetadata.getName());
List<FileMetadata> list = fileMetadataMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(list)) {
return list.get(0);
} else {
fileMetadata.setSize(fileSize);
String fileType = MetadataUtils.getFileType(fileName);
fileMetadata.setType(fileType);
checkName(fileMetadata);
FileRequest request = new FileRequest(fileMetadata.getProjectId(), fileMetadata.getName(), fileMetadata.getType());
String path = fileManagerService.upload(fileByte, request);
fileMetadata.setPath(path);
fileMetadata.setLatest(true);
fileMetadata.setRefId(fileMetadata.getId());
fileMetadataMapper.insert(fileMetadata);
return fileMetadata;
}
}
private void initBase(FileMetadata fileMetadata) {