diff --git a/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java b/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java index 80c7cf6118..e9b113ca9e 100644 --- a/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java +++ b/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java @@ -42,6 +42,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; @@ -156,10 +157,24 @@ public class EngineFactory { /* {"timeout":10,"statusCode":["302","301"],"params":[{"name":"param1","enable":true,"value":"0","edit":false}],"domains":[{"domain":"baidu.com","enable":true,"ip":"127.0.0.1","edit":false}]} */ + Map testResourceFiles = new HashMap<>(); + StringBuilder props = new StringBuilder("# JMeter Properties\n"); if (StringUtils.isNotEmpty(loadTest.getAdvancedConfiguration())) { JSONObject advancedConfiguration = JSONObject.parseObject(loadTest.getAdvancedConfiguration()); engineContext.addProperties(advancedConfiguration); + JSONArray properties = advancedConfiguration.getJSONArray("properties"); + if (properties != null) { + for (int i = 0; i < properties.size(); i++) { + JSONObject prop = properties.getJSONObject(i); + if (!prop.getBoolean("enable")) { + continue; + } + props.append(prop.getString("name")).append("=").append(prop.getString("value")).append("\n"); + } + } } + // JMeter Properties + testResourceFiles.put("ms.properties", props.toString().getBytes(StandardCharsets.UTF_8)); final EngineSourceParser engineSourceParser = EngineSourceParserFactory.createEngineSourceParser(engineContext.getFileType()); @@ -168,13 +183,12 @@ public class EngineFactory { } if (CollectionUtils.isNotEmpty(resourceFiles)) { - Map data = new HashMap<>(); resourceFiles.forEach(cf -> { FileContent csvContent = fileService.getFileContent(cf.getId()); - data.put(cf.getName(), csvContent.getFile()); + testResourceFiles.put(cf.getName(), csvContent.getFile()); }); - engineContext.setTestResourceFiles(data); } + engineContext.setTestResourceFiles(testResourceFiles); try (ByteArrayInputStream source = new ByteArrayInputStream(jmxBytes)) { String content = engineSourceParser.parse(engineContext, source); diff --git a/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue b/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue index 266ffd6ca2..1743765043 100644 --- a/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue +++ b/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue @@ -9,8 +9,8 @@ + :disabled="readOnly" size="mini" v-model="timeout" + :min="0"/> ms @@ -24,8 +24,8 @@ + :disabled="readOnly" size="mini" :min="0" + v-model="responseTimeout"/> ms @@ -38,9 +38,9 @@
{{ $t('load_test.granularity') }} + placement="left" + width="300" + trigger="hover">