From 8ff65f355f7556f113fbd70bcea8cfacb590f1a2 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Wed, 5 Feb 2020 18:38:27 +0100 Subject: [PATCH] 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 #50209 --- .../org/elasticsearch/ingest/common/CsvProcessorTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/CsvProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/CsvProcessorTests.java index 9e0a2b683e3ff..f6eea0a70939d 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/CsvProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/CsvProcessorTests.java @@ -223,8 +223,9 @@ private IngestDocument processDocument(String[] headers, String csv) throws Exce private IngestDocument processDocument(String[] headers, String csv, boolean trim) throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); Arrays.stream(headers).filter(ingestDocument::hasField).forEach(ingestDocument::removeField); + String fieldName = randomAlphaOfLength(11); + ingestDocument.setFieldValue(fieldName, csv); - String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, csv); char quoteChar = quote.isEmpty() ? '"' : quote.charAt(0); CsvProcessor processor = new CsvProcessor(randomAlphaOfLength(5), fieldName, headers, trim, separator, quoteChar, false);