调整JMeter Home设置方式
This commit is contained in:
parent
a1b7d214b0
commit
84716a42ef
|
@ -2,10 +2,12 @@ FROM registry.fit2cloud.com/metersphere/fabric8-java-alpine-openjdk8-jre
|
|||
|
||||
MAINTAINER FIT2CLOUD <support@fit2cloud.com>
|
||||
|
||||
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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
api_load_script_error="Load script error"
|
|
@ -30,5 +30,4 @@ user_email_is_null=用户邮箱不能为空
|
|||
password_is_null=密码不能为空
|
||||
workspace_not_exists=工作空间不存在
|
||||
#api
|
||||
api_load_script_error="读取脚本失败"
|
||||
api_file_not_found_error="文件未找到"
|
||||
api_load_script_error="读取脚本失败"
|
Loading…
Reference in New Issue