Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public class SearchProfileResultsBuilderTests extends ESTestCase {
public void testFetchWithoutQuery() {
Map<SearchShardTarget, SearchProfileQueryPhaseResult> searchPhase = randomSearchPhaseResults();
Map<SearchShardTarget, SearchProfileQueryPhaseResult> searchPhase = randomSearchPhaseResults(rarely() ? 0 : between(1, 2));
FetchSearchResult fetchPhase = fetchResult(
randomValueOtherThanMany(searchPhase::containsKey, SearchProfileResultsBuilderTests::randomTarget),
null
Expand All @@ -40,7 +40,7 @@ public void testFetchWithoutQuery() {
}

public void testQueryWithoutAnyFetch() {
Map<SearchShardTarget, SearchProfileQueryPhaseResult> searchPhase = randomSearchPhaseResults();
Map<SearchShardTarget, SearchProfileQueryPhaseResult> searchPhase = randomSearchPhaseResults(between(1, 2));
FetchSearchResult fetchPhase = fetchResult(searchPhase.keySet().iterator().next(), null);
SearchProfileResults result = builder(searchPhase).build(List.of(fetchPhase));
assertThat(
Expand All @@ -51,7 +51,7 @@ public void testQueryWithoutAnyFetch() {
}

public void testQueryAndFetch() {
Map<SearchShardTarget, SearchProfileQueryPhaseResult> searchPhase = randomSearchPhaseResults();
Map<SearchShardTarget, SearchProfileQueryPhaseResult> searchPhase = randomSearchPhaseResults(between(1, 2));
List<FetchSearchResult> fetchPhase = searchPhase.entrySet()
.stream()
.map(e -> fetchResult(e.getKey(), new ProfileResult("fetch", "", Map.of(), Map.of(), 1, List.of())))
Expand All @@ -67,8 +67,7 @@ public void testQueryAndFetch() {
);
}

private static Map<SearchShardTarget, SearchProfileQueryPhaseResult> randomSearchPhaseResults() {
int size = rarely() ? 0 : randomIntBetween(1, 2);
private static Map<SearchShardTarget, SearchProfileQueryPhaseResult> randomSearchPhaseResults(int size) {
Map<SearchShardTarget, SearchProfileQueryPhaseResult> results = new HashMap<>(size);
while (results.size() < size) {
results.put(randomTarget(), SearchProfileQueryPhaseResultTests.createTestItem());
Expand Down