Skip to content

Commit ac1bff6

Browse files
authored
Avoid clash between source field and header field in CsvProcessorTests (#51962) (#52072)
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 5c2c0e5 commit ac1bff6

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)