diff --git a/backend/src/main/java/io/metersphere/engine/EngineContext.java b/backend/src/main/java/io/metersphere/engine/EngineContext.java index c88ab8cfad..499c18f0f6 100644 --- a/backend/src/main/java/io/metersphere/engine/EngineContext.java +++ b/backend/src/main/java/io/metersphere/engine/EngineContext.java @@ -11,6 +11,7 @@ public class EngineContext { private String fileType; private String content; private Map properties = new HashMap<>(); + private Map 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 getTestData() { + return testData; + } + + public void setTestData(Map testData) { + this.testData = testData; + } } diff --git a/backend/src/main/java/io/metersphere/engine/EngineFactory.java b/backend/src/main/java/io/metersphere/engine/EngineFactory.java index 2d3104dd20..5037afeaab 100644 --- a/backend/src/main/java/io/metersphere/engine/EngineFactory.java +++ b/backend/src/main/java/io/metersphere/engine/EngineFactory.java @@ -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 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; diff --git a/backend/src/main/java/io/metersphere/engine/kubernetes/KubernetesTestEngine.java b/backend/src/main/java/io/metersphere/engine/kubernetes/KubernetesTestEngine.java index f803ad032d..25a5bb4e76 100644 --- a/backend/src/main/java/io/metersphere/engine/kubernetes/KubernetesTestEngine.java +++ b/backend/src/main/java/io/metersphere/engine/kubernetes/KubernetesTestEngine.java @@ -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() {{ put(context.getTestId() + ".jmx", context.getContent()); + if (MapUtils.isNotEmpty(context.getTestData())) { + putAll(context.getTestData()); + } }}); client.configMaps().inNamespace(context.getNamespace()).create(item); }