提交 4f7768a8 编写于 作者: C Captain.B

feat(性能测试): 性能测试支持jar

上级 ff601575
......@@ -3,7 +3,7 @@ package io.metersphere.commons.constants;
public enum FileType {
JMX(".jmx"), CSV(".csv"), JSON(".json"), PDF(".pdf"),
JPG(".jpg"), PNG(".png"), JPEG(".jpeg"), DOC(".doc"),
XLSX(".xlsx"), DOCX(".docx");
XLSX(".xlsx"), DOCX(".docx"), JAR(".jar");
// 保存后缀
private String suffix;
......
......@@ -17,6 +17,7 @@ public class EngineContext {
private Map<String, Object> properties = new HashMap<>();
private Map<String, String> testData = new HashMap<>();
private Map<String, String> env = new HashMap<>();
private Map<String, byte[]> testJars = new HashMap<>();
public String getTestId() {
return testId;
......@@ -126,4 +127,13 @@ public class EngineContext {
public void setResourceIndex(Integer resourceIndex) {
this.resourceIndex = resourceIndex;
}
public Map<String, byte[]> getTestJars() {
return testJars;
}
public void setTestJars(Map<String, byte[]> testJars) {
this.testJars = testJars;
}
}
......@@ -63,6 +63,7 @@ public class EngineFactory {
});
List<FileMetadata> csvFiles = fileMetadataList.stream().filter(f -> StringUtils.equalsIgnoreCase(f.getType(), FileType.CSV.name())).collect(Collectors.toList());
List<FileMetadata> jarFiles = fileMetadataList.stream().filter(f -> StringUtils.equalsIgnoreCase(f.getType(), FileType.JAR.name())).collect(Collectors.toList());
final FileContent fileContent = fileService.getFileContent(jmxFile.getId());
if (fileContent == null) {
MSException.throwException(Translator.get("run_load_test_file_content_not_found") + loadTest.getId());
......@@ -125,6 +126,15 @@ public class EngineFactory {
engineContext.setTestData(data);
}
if (CollectionUtils.isNotEmpty(jarFiles)) {
Map<String, byte[]> data = new HashMap<>();
jarFiles.forEach(jf -> {
FileContent content = fileService.getFileContent(jf.getId());
data.put(jf.getName(), content.getFile());
});
engineContext.setTestJars(data);
}
return engineContext;
}
......
......@@ -83,6 +83,7 @@ public class DockerTestEngine extends AbstractEngine {
testRequest.setFileString(content);
testRequest.setImage(JMETER_IMAGE);
testRequest.setTestData(context.getTestData());
testRequest.setTestJars(context.getTestJars());
testRequest.setEnv(context.getEnv());
......
......@@ -14,4 +14,5 @@ public class TestRequest extends BaseRequest {
private String image;
private Map<String, String> testData = new HashMap<>();
private Map<String, String> env = new HashMap<>();
private Map<String, byte[]> testJars = new HashMap<>();
}
......@@ -1215,7 +1215,7 @@ view.results.tree.renderers_order=.RenderAsText,.RenderAsRegexp,.RenderAsBoundar
# All entries will be added to the class path of the system class loader
# and also to the path of the JMeter internal loader.
# Paths with spaces may cause problems for the JVM
#user.classpath=../classes;../lib
user.classpath=/test/
# List of directories (separated by ;) that JMeter will search for utility
# and plugin dependency classes.
......
<template>
<div v-loading="result.loading">
<el-upload
accept=".jmx,.csv"
accept=".jmx,.csv,.jar"
drag
action=""
:limit="fileNumLimit"
......@@ -77,7 +77,7 @@ export default {
fileList: [],
tableData: [],
uploadList: [],
fileNumLimit: 5,
fileNumLimit: 10,
};
},
created() {
......@@ -197,7 +197,7 @@ export default {
return this.fileList;// 表示修改了已经上传的文件列表
},
validConfig() {
let newJmxNum = 0, oldJmxNum = 0, newCsvNum = 0, oldCsvNum = 0;
let newJmxNum = 0, oldJmxNum = 0, newCsvNum = 0, oldCsvNum = 0, newJarNum = 0, oldJarNum = 0;
if (this.uploadList.length > 0) {
this.uploadList.forEach(f => {
if (f.name.toLowerCase().endsWith(".jmx")) {
......@@ -206,6 +206,9 @@ export default {
if (f.name.toLowerCase().endsWith(".csv")) {
newCsvNum++;
}
if (f.name.toLowerCase().endsWith(".jar")) {
newJarNum++;
}
});
}
if (this.fileList.length > 0) {
......@@ -216,9 +219,12 @@ export default {
if (f.name.toLowerCase().endsWith(".csv")) {
oldCsvNum++;
}
if (f.name.toLowerCase().endsWith(".jar")) {
oldJarNum++;
}
});
}
if (newCsvNum + oldCsvNum > this.fileNumLimit - 1) {
if (newCsvNum + oldCsvNum + newJarNum + oldJarNum > this.fileNumLimit - 1) {
this.handleExceed();
return false;
}
......
Subproject commit f6f172c6451d0f9c51f5e3246a66dde9edcd7a5d
Subproject commit b9091a47b197faef77c72b134b7cf604fe3209f0
......@@ -397,7 +397,7 @@ export default {
file_status: 'File Status',
last_modify_time: 'Modify time',
upload_tips: 'Drag files here, or <em> click to upload </em>',
upload_type: 'Only JMX/CSV files can be uploaded',
upload_type: 'Only JMX/CSV/JAR files can be uploaded',
related_file_not_found: "No related test file found!",
delete_file_confirm: 'Confirm delete file:',
file_size_limit: "The number of files exceeds the limit!",
......
......@@ -395,7 +395,7 @@ export default {
file_status: '文件状态',
last_modify_time: '修改时间',
upload_tips: '将文件拖到此处,或<em>点击上传</em>',
upload_type: '只能上传JMX/CSV文件',
upload_type: '只能上传JMX/CSV/JAR文件',
related_file_not_found: "未找到关联的测试文件!",
delete_file_confirm: '确认删除文件: ',
file_size_limit: "文件个数超出限制!",
......
......@@ -397,7 +397,7 @@ export default {
file_status: '文件狀態',
last_modify_time: '修改時間',
upload_tips: '將文件拖到此處,或<em>點擊上傳</em>',
upload_type: '只能上傳JMX/CSV文件',
upload_type: '只能上傳JMX/CSV/JAR文件',
related_file_not_found: "未找到關聯的測試文件!",
delete_file_confirm: '確認刪除文件: ',
file_size_limit: "文件個數超出限制!",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册