[TEST] Fix sporadic failures in CompletionSuggestSearchIT#testTiebreak

Relates #34508
This commit is contained in:
Jim Ferenczi 2018-10-20 01:05:48 +02:00
parent 48ab6d7c92
commit ba87c543c0
1 changed files with 3 additions and 7 deletions

View File

@ -54,7 +54,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -99,11 +98,10 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
int numDocs = randomIntBetween(3, 50); int numDocs = randomIntBetween(3, 50);
List<IndexRequestBuilder> indexRequestBuilders = new ArrayList<>(); List<IndexRequestBuilder> indexRequestBuilders = new ArrayList<>();
Set<String> entrySet = new HashSet<>(); String[] entries = new String[numDocs];
for (int i = 0; i < numDocs; i++) { for (int i = 0; i < numDocs; i++) {
String value = "a" + randomValueOtherThanMany(v -> entrySet.contains(v), String value = "a" + randomAlphaOfLengthBetween(1, 10);
() -> randomAlphaOfLengthBetween(1, 10)); entries[i] = value;
entrySet.add(value);
indexRequestBuilders.add(client().prepareIndex(INDEX, TYPE, "" + i) indexRequestBuilders.add(client().prepareIndex(INDEX, TYPE, "" + i)
.setSource(jsonBuilder() .setSource(jsonBuilder()
.startObject() .startObject()
@ -114,8 +112,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
.endObject() .endObject()
)); ));
} }
String[] entries = entrySet.stream()
.toArray(String[]::new);
Arrays.sort(entries); Arrays.sort(entries);
indexRandom(true, indexRequestBuilders); indexRandom(true, indexRequestBuilders);
for (int i = 1; i < numDocs; i++) { for (int i = 1; i < numDocs; i++) {