fix(性能测试): 修复从接口自动化创建性能测试没有场景的bug
This commit is contained in:
parent
73e9824c5f
commit
0664c5a569
|
@ -2,6 +2,7 @@ package io.metersphere.controller;
|
||||||
|
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import io.metersphere.base.domain.FileMetadata;
|
||||||
import io.metersphere.base.domain.Project;
|
import io.metersphere.base.domain.Project;
|
||||||
import io.metersphere.commons.constants.RoleConstants;
|
import io.metersphere.commons.constants.RoleConstants;
|
||||||
import io.metersphere.commons.utils.PageUtils;
|
import io.metersphere.commons.utils.PageUtils;
|
||||||
|
@ -86,8 +87,8 @@ public class ProjectController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "upload/files/{projectId}", consumes = {"multipart/form-data"})
|
@PostMapping(value = "upload/files/{projectId}", consumes = {"multipart/form-data"})
|
||||||
public void uploadFiles(@PathVariable String projectId, @RequestPart(value = "file") List<MultipartFile> files) {
|
public List<FileMetadata> uploadFiles(@PathVariable String projectId, @RequestPart(value = "file") List<MultipartFile> files) {
|
||||||
projectService.uploadFiles(projectId, files);
|
return projectService.uploadFiles(projectId, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "delete/file/{fileId}")
|
@GetMapping(value = "delete/file/{fileId}")
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -169,18 +170,20 @@ public class ProjectService {
|
||||||
return projectMapper.selectByPrimaryKey(id);
|
return projectMapper.selectByPrimaryKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void uploadFiles(String projectId, List<MultipartFile> files) {
|
public List<FileMetadata> uploadFiles(String projectId, List<MultipartFile> files) {
|
||||||
|
List<FileMetadata> result = new ArrayList<>();
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (MultipartFile file : files) {
|
for (MultipartFile file : files) {
|
||||||
QueryProjectFileRequest request = new QueryProjectFileRequest();
|
QueryProjectFileRequest request = new QueryProjectFileRequest();
|
||||||
request.setName(file.getOriginalFilename());
|
request.setName(file.getOriginalFilename());
|
||||||
if (CollectionUtils.isEmpty(fileService.getProjectFiles(projectId, request))) {
|
if (CollectionUtils.isEmpty(fileService.getProjectFiles(projectId, request))) {
|
||||||
fileService.saveFile(file, projectId);
|
result.add(fileService.saveFile(file, projectId));
|
||||||
} else {
|
} else {
|
||||||
MSException.throwException(Translator.get("project_file_already_exists"));
|
MSException.throwException(Translator.get("project_file_already_exists"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteFile(String fileId) {
|
public void deleteFile(String fileId) {
|
||||||
|
|
|
@ -141,7 +141,13 @@ export default {
|
||||||
this.existFiles = data.listObject;
|
this.existFiles = data.listObject;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleImport() {
|
handleImport(file) {
|
||||||
|
if (file) { // 接口测试创建的性能测试
|
||||||
|
console.log(file);
|
||||||
|
this.selectIds.add(file.id);
|
||||||
|
this.getJmxContents();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.selectIds.size === 0) {
|
if (this.selectIds.size === 0) {
|
||||||
this.loadFileVisible = false;
|
this.loadFileVisible = false;
|
||||||
return;
|
return;
|
||||||
|
@ -163,7 +169,7 @@ export default {
|
||||||
this.tableData.push({
|
this.tableData.push({
|
||||||
name: row.name,
|
name: row.name,
|
||||||
size: (row.size / 1024).toFixed(2) + ' KB',
|
size: (row.size / 1024).toFixed(2) + ' KB',
|
||||||
type: 'JMX',
|
type: row.type.toUpperCase(),
|
||||||
updateTime: row.lastModified,
|
updateTime: row.lastModified,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -173,6 +179,9 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.getJmxContents();
|
||||||
|
},
|
||||||
|
getJmxContents() {
|
||||||
this.projectLoadingResult = this.$post('/performance/export/jmx', [...this.selectIds], (response) => {
|
this.projectLoadingResult = this.$post('/performance/export/jmx', [...this.selectIds], (response) => {
|
||||||
let data = response.data;
|
let data = response.data;
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
@ -199,7 +208,6 @@ export default {
|
||||||
this.loadFileVisible = false;
|
this.loadFileVisible = false;
|
||||||
this.selectIds.clear();
|
this.selectIds.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
beforeUploadFile(file) {
|
beforeUploadFile(file) {
|
||||||
if (!this.fileValidator(file)) {
|
if (!this.fileValidator(file)) {
|
||||||
|
@ -227,7 +235,7 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleUpload(uploadResources) {
|
handleUpload(uploadResources, apiImport) {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
let file = uploadResources.file;
|
let file = uploadResources.file;
|
||||||
|
@ -246,6 +254,10 @@ export default {
|
||||||
self.$request(options, (response) => {
|
self.$request(options, (response) => {
|
||||||
self.$success(this.$t('commons.save_success'));
|
self.$success(this.$t('commons.save_success'));
|
||||||
self.getProjectFiles();
|
self.getProjectFiles();
|
||||||
|
if (apiImport) {
|
||||||
|
let row = response.data[0];
|
||||||
|
self.handleImport(row);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -333,7 +333,8 @@ export default {
|
||||||
this.$refs.existFiles.beforeUploadFile(file);
|
this.$refs.existFiles.beforeUploadFile(file);
|
||||||
},
|
},
|
||||||
handleUpload(file) {
|
handleUpload(file) {
|
||||||
this.$refs.existFiles.handleUpload(file);
|
// 从api创建的测试
|
||||||
|
this.$refs.existFiles.handleUpload(file, true);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue