From 25be141c048b527f72130d7c5aa06cbac2145fed Mon Sep 17 00:00:00 2001 From: CaptainB Date: Thu, 13 Jan 2022 18:46:49 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=A6=86=E7=9B=96jmeter=E4=B8=AD=E7=9A=84system.properties?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../performance/engine/EngineFactory.java | 22 ++ .../components/PerformanceAdvancedConfig.vue | 308 +++++++++++------- 2 files changed, 218 insertions(+), 112 deletions(-) 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 73e98af37b..01eb9ec2ed 100644 --- a/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java +++ b/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java @@ -215,9 +215,12 @@ public class EngineFactory { */ Map testResourceFiles = new HashMap<>(); byte[] props = getJMeterProperties(loadTestReport, engineContext); + byte[] sysProps = getSystemProperties(loadTestReport, engineContext); byte[] hosts = getDNSConfig(loadTestReport, engineContext); // JMeter Properties testResourceFiles.put("ms.properties", props); + // System Properties + testResourceFiles.put("sys.properties", sysProps); // DNS testResourceFiles.put("hosts", hosts); @@ -287,6 +290,25 @@ public class EngineFactory { return props.toString().getBytes(StandardCharsets.UTF_8); } + private static byte[] getSystemProperties(LoadTestReportWithBLOBs loadTestReportWithBLOBs, EngineContext engineContext) { + StringBuilder props = new StringBuilder("# System Properties\n"); + if (StringUtils.isNotEmpty(loadTestReportWithBLOBs.getAdvancedConfiguration())) { + JSONObject advancedConfiguration = JSONObject.parseObject(loadTestReportWithBLOBs.getAdvancedConfiguration()); + engineContext.addProperties(advancedConfiguration); + JSONArray systemProperties = advancedConfiguration.getJSONArray("systemProperties"); + if (systemProperties != null) { + for (int i = 0; i < systemProperties.size(); i++) { + JSONObject prop = systemProperties.getJSONObject(i); + if (!prop.getBoolean("enable")) { + continue; + } + props.append(prop.getString("name")).append("=").append(prop.getString("value")).append("\n"); + } + } + } + return props.toString().getBytes(StandardCharsets.UTF_8); + } + public static byte[] mergeJmx(List jmxFiles) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); diff --git a/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue b/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue index 772865a1af..fc666f7501 100644 --- a/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue +++ b/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue @@ -9,9 +9,9 @@ + size="mini" v-model="timeout" + controls-position="right" + :min="0"/> ms @@ -25,9 +25,9 @@ + size="mini" :min="0" + controls-position="right" + v-model="responseTimeout"/> ms @@ -40,9 +40,9 @@
{{ $t('load_test.granularity') }} + placement="left" + width="300" + trigger="hover">