提交 df34a7af 编写于 作者: C Captain.B

env

上级 56d8182e
......@@ -20,6 +20,7 @@ public class KafkaProperties {
private String clientId;
private String connectionsMaxIdleMs;
private KafkaProperties.Ssl ssl = new KafkaProperties.Ssl();
private KafkaProperties.Log log = new KafkaProperties.Log();
public String getAcks() {
return acks;
......@@ -239,4 +240,24 @@ public class KafkaProperties {
public void setSsl(Ssl ssl) {
this.ssl = ssl;
}
public static class Log {
private String topic;
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
}
public Log getLog() {
return log;
}
public void setLog(Log log) {
this.log = log;
}
}
......@@ -15,6 +15,7 @@ public class EngineContext {
private String reportId;
private Map<String, Object> properties = new HashMap<>();
private Map<String, String> testData = new HashMap<>();
private Map<String, String> env = new HashMap<>();
public String getTestId() {
return testId;
......@@ -48,6 +49,14 @@ public class EngineContext {
this.properties.putAll(props);
}
public Map<String, String> getEnv() {
return env;
}
public void setEnv(Map<String, String> env) {
this.env = env;
}
public Object getProperty(String key) {
return this.properties.get(key);
}
......
......@@ -9,6 +9,7 @@ import io.metersphere.base.domain.TestResourcePool;
import io.metersphere.commons.constants.FileType;
import io.metersphere.commons.constants.ResourcePoolTypeEnum;
import io.metersphere.commons.exception.MSException;
import io.metersphere.config.KafkaProperties;
import io.metersphere.engine.docker.DockerTestEngine;
import io.metersphere.engine.kubernetes.KubernetesTestEngine;
import io.metersphere.i18n.Translator;
......@@ -31,6 +32,7 @@ import java.util.stream.Collectors;
public class EngineFactory {
private static FileService fileService;
private static TestResourcePoolService testResourcePoolService;
private static KafkaProperties kafkaProperties;
public static Engine createEngine(LoadTestWithBLOBs loadTest) {
String resourcePoolId = loadTest.getTestResourcePoolId();
......@@ -78,6 +80,12 @@ public class EngineFactory {
engineContext.setResourcePoolId(loadTest.getTestResourcePoolId());
engineContext.setStartTime(startTime);
engineContext.setReportId(reportId);
HashMap<String, String> env = new HashMap<String, String>() {{
put("BOOTSTRAP_SERVERS", kafkaProperties.getBootstrapServers());
put("LOG_TOPIC", kafkaProperties.getLog().getTopic());
put("REPORT_ID", reportId);
}};
engineContext.setEnv(env);
if (StringUtils.isNotEmpty(loadTest.getLoadConfiguration())) {
final JSONArray jsonArray = JSONObject.parseArray(loadTest.getLoadConfiguration());
......@@ -130,4 +138,9 @@ public class EngineFactory {
public void setTestResourcePoolService(TestResourcePoolService testResourcePoolService) {
EngineFactory.testResourcePoolService = testResourcePoolService;
}
@Resource
public void setKafkaProperties(KafkaProperties kafkaProperties) {
EngineFactory.kafkaProperties = kafkaProperties;
}
}
......@@ -82,6 +82,7 @@ public class DockerTestEngine extends AbstractEngine {
testRequest.setFileString(content);
testRequest.setImage(JMETER_IMAGE);
testRequest.setTestData(context.getTestData());
testRequest.setEnv(context.getEnv());
restTemplate.postForObject(uri, testRequest, String.class);
}
......
......@@ -9,6 +9,7 @@ public class TestRequest extends BaseRequest {
private String fileString;
private String image;
private Map<String, String> testData = new HashMap<>();
private Map<String, String> env = new HashMap<>();
public int getSize() {
return size;
......@@ -41,4 +42,12 @@ public class TestRequest extends BaseRequest {
public void setTestData(Map<String, String> testData) {
this.testData = testData;
}
public Map<String, String> getEnv() {
return env;
}
public void setEnv(Map<String, String> env) {
this.env = env;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册