diff --git a/backend/src/main/java/io/metersphere/performance/engine/EngineContext.java b/backend/src/main/java/io/metersphere/performance/engine/EngineContext.java index 75c78ebb44..70586532b4 100644 --- a/backend/src/main/java/io/metersphere/performance/engine/EngineContext.java +++ b/backend/src/main/java/io/metersphere/performance/engine/EngineContext.java @@ -15,6 +15,7 @@ public class EngineContext { private double[] ratios; private Map properties = new HashMap<>(); private Map testResourceFiles = new HashMap<>(); + private Map splitFlag = new HashMap<>(); public String getTestId() { return testId; @@ -108,4 +109,12 @@ public class EngineContext { public void setTestResourceFiles(Map testResourceFiles) { this.testResourceFiles = testResourceFiles; } + + public Map getSplitFlag() { + return splitFlag; + } + + public void setSplitFlag(Map splitFlag) { + this.splitFlag = splitFlag; + } } diff --git a/backend/src/main/java/io/metersphere/performance/parse/xml/reader/JmeterDocumentParser.java b/backend/src/main/java/io/metersphere/performance/parse/xml/reader/JmeterDocumentParser.java index 8ef0c6f2e2..117159e704 100644 --- a/backend/src/main/java/io/metersphere/performance/parse/xml/reader/JmeterDocumentParser.java +++ b/backend/src/main/java/io/metersphere/performance/parse/xml/reader/JmeterDocumentParser.java @@ -236,13 +236,17 @@ public class JmeterDocumentParser implements EngineSourceParser { } private void splitCsvFile(Node item) { + String filename = item.getText(); + // 已经分割过的不再二次分割 + if (BooleanUtils.toBoolean(context.getSplitFlag().get(filename))) { + return; + } Object csvConfig = context.getProperty("csvConfig"); if (csvConfig == null) { return; } double[] ratios = context.getRatios(); int resourceIndex = context.getResourceIndex(); - String filename = item.getText(); byte[] content = context.getTestResourceFiles().get(filename); if (content == null) { return; @@ -298,6 +302,7 @@ public class JmeterDocumentParser implements EngineSourceParser { } // 替换文件 context.getTestResourceFiles().put(filename, csv.toString().getBytes(StandardCharsets.UTF_8)); + context.getSplitFlag().put(filename, true); } private void processResponseAssertion(Element element) {