加载测试数据

This commit is contained in:
Captain.B 2020-03-20 15:40:12 +08:00
parent 12453009ea
commit 48a620c9cd
3 changed files with 18 additions and 1 deletions

View File

@ -11,6 +11,7 @@ public class EngineContext {
private String fileType;
private String content;
private Map<String, Object> properties = new HashMap<>();
private Map<String, String> testData = new HashMap<>();
public String getTestId() {
return testId;
@ -67,4 +68,12 @@ public class EngineContext {
public void setFileType(String fileType) {
this.fileType = fileType;
}
public Map<String, String> getTestData() {
return testData;
}
public void setTestData(Map<String, String> testData) {
this.testData = testData;
}
}

View File

@ -19,7 +19,9 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.ByteArrayInputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class EngineFactory {
@ -68,10 +70,12 @@ public class EngineFactory {
engineContext.setContent(content);
if (CollectionUtils.isNotEmpty(csvFiles)) {
Map<String, String> data = new HashMap<>();
csvFiles.forEach(cf -> {
FileContent csvContent = fileService.getFileContent(cf.getId());
engineContext.addProperty(cf.getName(), new String(csvContent.getFile()));
data.put(cf.getName(), new String(csvContent.getFile()));
});
engineContext.setTestData(data);
}
return engineContext;

View File

@ -11,6 +11,7 @@ import io.metersphere.engine.kubernetes.crds.jmeter.Jmeter;
import io.metersphere.engine.kubernetes.crds.jmeter.JmeterSpec;
import io.metersphere.engine.kubernetes.provider.ClientCredential;
import io.metersphere.engine.kubernetes.provider.KubernetesProvider;
import org.apache.commons.collections.MapUtils;
import java.util.HashMap;
@ -48,6 +49,9 @@ public class KubernetesTestEngine implements Engine {
}});
item.setData(new HashMap<String, String>() {{
put(context.getTestId() + ".jmx", context.getContent());
if (MapUtils.isNotEmpty(context.getTestData())) {
putAll(context.getTestData());
}
}});
client.configMaps().inNamespace(context.getNamespace()).create(item);
}