aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java')
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java53
1 files changed, 22 insertions, 31 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
index 15656ffb457..178d3383805 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
@@ -10,7 +10,6 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.dispatch.searchcluster.Group;
import com.yahoo.search.dispatch.searchcluster.Node;
-import com.yahoo.search.dispatch.searchcluster.SearchCluster;
import com.yahoo.search.result.Coverage;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
@@ -22,7 +21,6 @@ import com.yahoo.searchlib.expression.IntegerResultNode;
import com.yahoo.searchlib.expression.StringResultNode;
import com.yahoo.test.ManualClock;
import com.yahoo.vespa.config.search.DispatchConfig;
-import com.yahoo.vespa.config.search.DispatchNodesConfig;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@@ -40,8 +38,6 @@ import java.util.stream.StreamSupport;
import static com.yahoo.container.handler.Coverage.DEGRADED_BY_MATCH_PHASE;
import static com.yahoo.container.handler.Coverage.DEGRADED_BY_TIMEOUT;
-import static com.yahoo.search.dispatch.MockSearchCluster.createDispatchConfig;
-import static com.yahoo.search.dispatch.MockSearchCluster.createNodesConfig;
import static org.junit.jupiter.api.Assertions.*;
/**
@@ -53,11 +49,12 @@ public class InterleavedSearchInvokerTest {
private final Query query = new TestQuery();
private final LinkedList<Event> expectedEvents = new LinkedList<>();
private final List<SearchInvoker> invokers = new ArrayList<>();
+ DispatchConfig dispatchConfig = new DispatchConfig.Builder().build();
+ TopKEstimator hitEstimator = new TopKEstimator(30, dispatchConfig.topKProbability(), 0.05);
@Test
void requireThatAdaptiveTimeoutsAreNotUsedWithFullCoverageRequirement() throws IOException {
- SearchCluster cluster = new MockSearchCluster("!", createDispatchConfig(100.0), createNodesConfig(), 1, 3);
- try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 3)) {
+ try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 3)) {
expectedEvents.add(new Event(5000, 100, 0));
expectedEvents.add(new Event(4900, 100, 1));
@@ -71,8 +68,7 @@ public class InterleavedSearchInvokerTest {
@Test
void requireThatTimeoutsAreNotMarkedAsAdaptive() throws IOException {
- SearchCluster cluster = new MockSearchCluster("!", createDispatchConfig(100.0), createNodesConfig(), 1, 3);
- try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 3)) {
+ try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 3)) {
expectedEvents.add(new Event(5000, 300, 0));
expectedEvents.add(new Event(4700, 300, 1));
@@ -90,8 +86,7 @@ public class InterleavedSearchInvokerTest {
@Test
void requireThatAdaptiveTimeoutDecreasesTimeoutWhenCoverageIsReached() throws IOException {
- SearchCluster cluster = new MockSearchCluster("!", createDispatchConfig(50.0), createNodesConfig(), 1, 4);
- try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 4)) {
+ try (SearchInvoker invoker = createInterleavedInvoker(hitEstimator, MockSearchCluster.createDispatchConfig(50.0), new Group(0, List.of()), 4)) {
expectedEvents.add(new Event(5000, 100, 0));
expectedEvents.add(new Event(4900, 100, 1));
@@ -110,10 +105,9 @@ public class InterleavedSearchInvokerTest {
@Test
void requireCorrectCoverageCalculationWhenAllNodesOk() throws IOException {
- SearchCluster cluster = new MockSearchCluster("!", 1, 2);
invokers.add(new MockInvoker(0, createCoverage(50155, 50155, 50155, 1, 1, 0)));
invokers.add(new MockInvoker(1, createCoverage(49845, 49845, 49845, 1, 1, 0)));
- try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 0)) {
+ try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 0)) {
expectedEvents.add(new Event(null, 100, 0));
expectedEvents.add(new Event(null, 200, 1));
@@ -132,10 +126,9 @@ public class InterleavedSearchInvokerTest {
@Test
void requireCorrectCoverageCalculationWhenResultsAreLimitedByMatchPhase() throws IOException {
- SearchCluster cluster = new MockSearchCluster("!", 1, 2);
invokers.add(new MockInvoker(0, createCoverage(10101, 50155, 50155, 1, 1, DEGRADED_BY_MATCH_PHASE)));
invokers.add(new MockInvoker(1, createCoverage(13319, 49845, 49845, 1, 1, DEGRADED_BY_MATCH_PHASE)));
- try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 0)) {
+ try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 0)) {
expectedEvents.add(new Event(null, 100, 0));
expectedEvents.add(new Event(null, 200, 1));
@@ -155,10 +148,9 @@ public class InterleavedSearchInvokerTest {
@Test
void requireCorrectCoverageCalculationWhenResultsAreLimitedBySoftTimeout() throws IOException {
- SearchCluster cluster = new MockSearchCluster("!", 1, 2);
invokers.add(new MockInvoker(0, createCoverage(5000, 50155, 50155, 1, 1, DEGRADED_BY_TIMEOUT)));
invokers.add(new MockInvoker(1, createCoverage(4900, 49845, 49845, 1, 1, DEGRADED_BY_TIMEOUT)));
- try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 0)) {
+ try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 0)) {
expectedEvents.add(new Event(null, 100, 0));
expectedEvents.add(new Event(null, 200, 1));
@@ -178,10 +170,9 @@ public class InterleavedSearchInvokerTest {
@Test
void requireCorrectCoverageCalculationWhenOneNodeIsUnexpectedlyDown() throws IOException {
- SearchCluster cluster = new MockSearchCluster("!", 1, 2);
invokers.add(new MockInvoker(0, createCoverage(50155, 50155, 50155, 1, 1, 0)));
invokers.add(new MockInvoker(1, createCoverage(49845, 49845, 49845, 1, 1, 0)));
- try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 0)) {
+ try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 0)) {
expectedEvents.add(new Event(null, 100, 0));
expectedEvents.add(null);
@@ -342,7 +333,6 @@ public class InterleavedSearchInvokerTest {
@Test
void requireThatGroupingsAreMerged() throws IOException {
- SearchCluster cluster = new MockSearchCluster("!", 1, 2);
List<SearchInvoker> invokers = new ArrayList<>();
Grouping grouping1 = new Grouping(0);
@@ -365,7 +355,7 @@ public class InterleavedSearchInvokerTest {
.addAggregationResult(new MinAggregationResult().setMin(new IntegerResultNode(6)).setTag(3))));
invokers.add(new MockInvoker(0).setHits(List.of(new GroupingListHit(List.of(grouping2)))));
- try (InterleavedSearchInvoker invoker = new InterleavedSearchInvoker(Timer.monotonic, invokers, cluster, new Group(0, List.of()), Collections.emptySet())) {
+ try (InterleavedSearchInvoker invoker = new InterleavedSearchInvoker(Timer.monotonic, invokers, hitEstimator, dispatchConfig, new Group(0, List.of()), Collections.emptySet())) {
invoker.responseAvailable(invokers.get(0));
invoker.responseAvailable(invokers.get(1));
Result result = invoker.search(query, null);
@@ -377,11 +367,12 @@ public class InterleavedSearchInvokerTest {
}
private static InterleavedSearchInvoker createInterLeavedTestInvoker(List<Double> a, List<Double> b, Group group) {
- SearchCluster cluster = new MockSearchCluster("!", 1, 2);
+ DispatchConfig dispatchConfig = new DispatchConfig.Builder().build();
+ TopKEstimator hitEstimator = new TopKEstimator(30, dispatchConfig.topKProbability(), 0.05);
List<SearchInvoker> invokers = new ArrayList<>();
invokers.add(createInvoker(a, 0));
invokers.add(createInvoker(b, 1));
- InterleavedSearchInvoker invoker = new InterleavedSearchInvoker(Timer.monotonic, invokers, cluster, group, Collections.emptySet());
+ InterleavedSearchInvoker invoker = new InterleavedSearchInvoker(Timer.monotonic, invokers, hitEstimator, dispatchConfig, group, Collections.emptySet());
invoker.responseAvailable(invokers.get(0));
invoker.responseAvailable(invokers.get(1));
return invoker;
@@ -402,13 +393,12 @@ public class InterleavedSearchInvokerTest {
return hits;
}
- void verifyCorrectCoverageCalculationWhenDegradedCoverageIsExpected(DispatchConfig dispatchConfig, DispatchNodesConfig nodesConfig, int expectedCoverage) throws IOException {
- SearchCluster cluster = new MockSearchCluster("!", dispatchConfig, nodesConfig, 1, 2);
+ void verifyCorrectCoverageCalculationWhenDegradedCoverageIsExpected(int expectedCoverage) throws IOException {
invokers.add(new MockInvoker(0, createCoverage(50155, 50155, 60000, 1, 1, 0)));
Coverage errorCoverage = new Coverage(0, 0, 0);
errorCoverage.setNodesTried(1);
invokers.add(new SearchErrorInvoker(ErrorMessage.createBackendCommunicationError("node is down"), errorCoverage));
- try (SearchInvoker invoker = createInterleavedInvoker(cluster, new Group(0, List.of()), 0)) {
+ try (SearchInvoker invoker = createInterleavedInvoker(new Group(0, List.of()), 0)) {
expectedEvents.add(new Event(null, 1, 1));
expectedEvents.add(new Event(null, 100, 0));
@@ -429,19 +419,20 @@ public class InterleavedSearchInvokerTest {
@Test
void requireCorrectCoverageCalculationWhenDegradedCoverageIsExpectedUsingTargetActiveDocs() throws IOException {
- verifyCorrectCoverageCalculationWhenDegradedCoverageIsExpected(MockSearchCluster.createDispatchConfigBuilder(100.0)
- .redundancy(1)
- .build(),
- MockSearchCluster.createNodesConfig(),
+ verifyCorrectCoverageCalculationWhenDegradedCoverageIsExpected(
42);
}
- private InterleavedSearchInvoker createInterleavedInvoker(SearchCluster searchCluster, Group group, int numInvokers) {
+ private InterleavedSearchInvoker createInterleavedInvoker(Group group, int numInvokers) {
+ return createInterleavedInvoker(hitEstimator, dispatchConfig, group, numInvokers);
+ }
+ private InterleavedSearchInvoker createInterleavedInvoker(TopKEstimator hitEstimator, DispatchConfig dispatchConfig,
+ Group group, int numInvokers) {
for (int i = 0; i < numInvokers; i++) {
invokers.add(new MockInvoker(i));
}
- return new InterleavedSearchInvoker(Timer.wrap(clock), invokers, searchCluster, group,null) {
+ return new InterleavedSearchInvoker(Timer.wrap(clock), invokers, hitEstimator, dispatchConfig, group,null) {
@Override
protected LinkedBlockingQueue<SearchInvoker> newQueue() {