Skip to content

Commit 8ff65f3

Browse files
committed
Avoid clash between source field and header field in CsvProcessorTests
This change fixes flakiness in `CsvProcessorTests` where source field can be the same as one of the headers used by tests which messes up asserts when we check that field is not present after processor run. Closes elastic#50209
1 parent f03b6ff commit 8ff65f3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/CsvProcessorTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ private IngestDocument processDocument(String[] headers, String csv) throws Exce
223223
private IngestDocument processDocument(String[] headers, String csv, boolean trim) throws Exception {
224224
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
225225
Arrays.stream(headers).filter(ingestDocument::hasField).forEach(ingestDocument::removeField);
226+
String fieldName = randomAlphaOfLength(11);
227+
ingestDocument.setFieldValue(fieldName, csv);
226228

227-
String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, csv);
228229
char quoteChar = quote.isEmpty() ? '"' : quote.charAt(0);
229230
CsvProcessor processor = new CsvProcessor(randomAlphaOfLength(5), fieldName, headers, trim, separator, quoteChar, false);
230231

0 commit comments

Comments
 (0)