修改JMeter Home位置

This commit is contained in:
q4speed 2020-05-09 15:32:43 +08:00
parent 85bf0d0ba1
commit ac6235d334
5 changed files with 22 additions and 3 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;
}
}

View File

@ -64,3 +64,4 @@ kafka.ssl.truststore-type=
# jmeter
jmeter.image=registry.fit2cloud.com/metersphere/jmeter-master:0.0.4
jmeter.home=/opt/jmeter/apache-jmeter-5.2.1