diff --git a/Dockerfile b/Dockerfile index ce96082847..bcb7739b13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,10 @@ RUN mkdir -p /opt/apps ADD backend/target/backend-1.0.jar /opt/apps +ADD backend/class/jmeter/apache-jmeter-5.2.1.zip /opt/jmeter + +RUN rm -rf /opt/jmeter && unzip -o apache-jmeter-5.2.1.zip && rm -rf /opt/jmeter/apache-jmeter-5.2.1.zip + 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 147ac67d16..585d37b186 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java @@ -1,6 +1,8 @@ package io.metersphere.api.jmeter; import io.metersphere.commons.exception.MSException; +import io.metersphere.commons.utils.CommonBeanFactory; +import io.metersphere.config.JmeterProperties; import io.metersphere.i18n.Translator; import org.apache.jmeter.save.SaveService; import org.apache.jmeter.util.JMeterUtils; @@ -14,8 +16,10 @@ import java.lang.reflect.Field; public class JMeterService { public void run(InputStream is) { - JMeterUtils.loadJMeterProperties("/Users/q4speed/Downloads/apache-jmeter-5.2.1/bin/jmeter.properties"); - JMeterUtils.setJMeterHome("/Users/q4speed/Downloads/apache-jmeter-5.2.1"); + String JMETER_HOME = CommonBeanFactory.getBean(JmeterProperties.class).getHome(); + String JMETER_PROPERTIES = JMETER_HOME + "/bin/jmeter.properties"; + JMeterUtils.loadJMeterProperties(JMETER_PROPERTIES); + JMeterUtils.setJMeterHome(JMETER_HOME); try { Object scriptWrapper = SaveService.loadElement(is); HashTree testPlan = getHashTree(scriptWrapper); diff --git a/backend/src/main/java/io/metersphere/config/JmeterProperties.java b/backend/src/main/java/io/metersphere/config/JmeterProperties.java index 5621c4c247..8319b6da7e 100644 --- a/backend/src/main/java/io/metersphere/config/JmeterProperties.java +++ b/backend/src/main/java/io/metersphere/config/JmeterProperties.java @@ -10,6 +10,8 @@ public class JmeterProperties { private String image; + private String home; + public String getImage() { return image; } @@ -17,4 +19,12 @@ public class JmeterProperties { public void setImage(String image) { this.image = image; } + + public String getHome() { + return home; + } + + public void setHome(String home) { + this.home = home; + } } diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 2805932dce..671b65f503 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -63,4 +63,5 @@ kafka.ssl.provider= kafka.ssl.truststore-type= # jmeter -jmeter.image=registry.fit2cloud.com/metersphere/jmeter-master:0.0.4 \ No newline at end of file +jmeter.image=registry.fit2cloud.com/metersphere/jmeter-master:0.0.4 +jmeter.home=/opt/jmeter/apache-jmeter-5.2.1 \ No newline at end of file diff --git a/backend/src/main/resources/jmeter/apache-jmeter-5.2.1.zip b/backend/src/main/resources/jmeter/apache-jmeter-5.2.1.zip new file mode 100644 index 0000000000..c90e43584f Binary files /dev/null and b/backend/src/main/resources/jmeter/apache-jmeter-5.2.1.zip differ