From 84716a42ef7015a12d4022b05ec38efbd750e315 Mon Sep 17 00:00:00 2001 From: q4speed Date: Mon, 11 May 2020 10:23:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4JMeter=20Home=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 +++- .../metersphere/api/jmeter/JMeterService.java | 17 ++--------------- .../resources/i18n/messages_en_US.properties | 3 +-- .../resources/i18n/messages_zh_CN.properties | 3 +-- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index ce96082847..fb5afd3d7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,12 @@ FROM registry.fit2cloud.com/metersphere/fabric8-java-alpine-openjdk8-jre MAINTAINER FIT2CLOUD -RUN mkdir -p /opt/apps +RUN mkdir -p /opt/apps && mkdi -p /opt/jmeter ADD backend/target/backend-1.0.jar /opt/apps +ADD backend/target/classes/jmeter/ /opt/jmeter/ + ENV JAVA_APP_JAR=/opt/apps/backend-1.0.jar ENV AB_OFF=true diff --git a/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java b/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java index 74282e34bd..bc5207fa0a 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java @@ -1,16 +1,13 @@ package io.metersphere.api.jmeter; import io.metersphere.commons.exception.MSException; -import io.metersphere.commons.utils.LogUtil; import io.metersphere.config.JmeterProperties; import io.metersphere.i18n.Translator; import org.apache.jmeter.save.SaveService; import org.apache.jmeter.util.JMeterUtils; import org.apache.jorphan.collections.HashTree; import org.springframework.stereotype.Service; -import org.springframework.util.ResourceUtils; -import java.io.FileNotFoundException; import java.io.InputStream; import java.lang.reflect.Field; @@ -25,8 +22,8 @@ public class JMeterService { public void run(InputStream is) { String JMETER_HOME = jmeterProperties.getHome(); String JMETER_PROPERTIES = JMETER_HOME + "/bin/jmeter.properties"; - JMeterUtils.loadJMeterProperties(getPath(JMETER_PROPERTIES)); - JMeterUtils.setJMeterHome(getPath(JMETER_HOME)); + JMeterUtils.loadJMeterProperties(JMETER_PROPERTIES); + JMeterUtils.setJMeterHome(JMETER_HOME); try { Object scriptWrapper = SaveService.loadElement(is); HashTree testPlan = getHashTree(scriptWrapper); @@ -43,14 +40,4 @@ public class JMeterService { field.setAccessible(true); return (HashTree) field.get(scriptWrapper); } - - private String getPath(String path) { - try { - return ResourceUtils.getURL(ResourceUtils.CLASSPATH_URL_PREFIX + path).getPath(); - } catch (FileNotFoundException e) { - LogUtil.error("file not found: " + path, e); - MSException.throwException(Translator.get("api_file_not_found_error")); - } - return null; - } } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 9ee4d6b1d3..db75d19904 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -30,5 +30,4 @@ user_email_is_null=User email cannot be null password_is_null=Password cannot be null workspace_not_exists=Workspace is not exists #api -api_load_script_error="Load script error" -api_file_not_found_error="File not found" \ No newline at end of file +api_load_script_error="Load script error" \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index a514441820..29bde1069c 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -30,5 +30,4 @@ user_email_is_null=用户邮箱不能为空 password_is_null=密码不能为空 workspace_not_exists=工作空间不存在 #api -api_load_script_error="读取脚本失败" -api_file_not_found_error="文件未找到" \ No newline at end of file +api_load_script_error="读取脚本失败" \ No newline at end of file