Skip to content

Commit

Permalink
Avoid clash between source field and header field in CsvProcessorTests (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
probakowski committed Feb 7, 2020
1 parent 5c2c0e5 commit ac1bff6
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ac1bff6

Please sign in to comment.