From 4d2427373be6f5efa96b1e15dfc4deba56db56ad Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Thu, 7 Oct 2021 06:49:57 -0500 Subject: [PATCH] Fix failing URLDecodeProcessorTests::testProcessor test (#78690) --- .../AbstractStringProcessorTestCase.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AbstractStringProcessorTestCase.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AbstractStringProcessorTestCase.java index e1f2ecbdbdc45..4ad36e39919f8 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AbstractStringProcessorTestCase.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AbstractStringProcessorTestCase.java @@ -38,8 +38,14 @@ protected Class expectedResultType() { public void testProcessor() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); - String fieldValue = RandomDocumentPicks.randomString(random()); - String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, modifyInput(fieldValue)); + String fieldValue; + String fieldName; + String modifiedFieldValue; + do { + fieldValue = RandomDocumentPicks.randomString(random()); + modifiedFieldValue = modifyInput(fieldValue); + fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, modifiedFieldValue); + } while (isSupportedValue(modifiedFieldValue) == false); Processor processor = newProcessor(fieldName, randomBoolean(), fieldName); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, expectedResultType()), equalTo(expectedResult(fieldValue))); @@ -48,8 +54,13 @@ public void testProcessor() throws Exception { List fieldValueList = new ArrayList<>(); List expectedList = new ArrayList<>(); for (int i = 0; i < numItems; i++) { - String randomString = RandomDocumentPicks.randomString(random()); - fieldValueList.add(modifyInput(randomString)); + String randomString; + String modifiedRandomString; + do { + randomString = RandomDocumentPicks.randomString(random()); + modifiedRandomString = modifyInput(randomString); + } while (isSupportedValue(modifiedRandomString) == false); + fieldValueList.add(modifiedRandomString); expectedList.add(expectedResult(randomString)); } String multiValueFieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValueList);