Skip to content

Commit c827f6f

Browse files
authored
Avoid clash between source field and header field in CsvProcessorTests (#51962) (#52070)
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 #50209
1 parent 2588022 commit c827f6f

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
@@ -287,8 +287,9 @@ private IngestDocument processDocument(String[] headers, String csv, boolean tri
287287
private IngestDocument processDocument(String[] headers, String csv, boolean trim, Object emptyValue) {
288288
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
289289
Arrays.stream(headers).filter(ingestDocument::hasField).forEach(ingestDocument::removeField);
290+
String fieldName = randomAlphaOfLength(11);
291+
ingestDocument.setFieldValue(fieldName, csv);
290292

291-
String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, csv);
292293
char quoteChar = quote.isEmpty() ? '"' : quote.charAt(0);
293294
CsvProcessor processor = new CsvProcessor(randomAlphaOfLength(5), fieldName, headers, trim, separator, quoteChar, false,
294295
emptyValue);

0 commit comments

Comments
 (0)