diff --git a/Dockerfile b/Dockerfile index ce96082847..2b95f96957 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 && mkdir -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/application.properties b/backend/src/main/resources/application.properties index 2db3e8cb57..32cd3cb002 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -65,4 +65,4 @@ kafka.ssl.truststore-type= # jmeter jmeter.image=registry.fit2cloud.com/metersphere/jmeter-master:0.0.4 -jmeter.home=jmeter \ No newline at end of file +jmeter.home=/opt/jmeter \ No newline at end of file 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