diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-03-08 15:25:10 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2024-03-08 15:25:10 +0100 |
commit | eadc775a626fd2604545a6b9a2b77784ca60ba15 (patch) | |
tree | 9807f085e26d663abadcebda56ed76ded1d72759 /container-search/src/test/java/com/yahoo/search/dispatch | |
parent | 2852c75009353bed9c0456f6dd0c5c1f7d96df39 (diff) |
- Do not use Searcher interface below the prelude cluster searcher.
- It is not necessary and provides no value.
- It also hides some important aspects, like the schema.
- And it simplifies testing.
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/dispatch')
4 files changed, 23 insertions, 25 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java index 8dc74110291..23846db3f0b 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java @@ -18,7 +18,6 @@ import com.yahoo.search.dispatch.searchcluster.Pinger; import com.yahoo.search.dispatch.searchcluster.PongHandler; import com.yahoo.search.dispatch.searchcluster.SearchCluster; import com.yahoo.search.dispatch.searchcluster.SearchGroups; -import com.yahoo.search.searchchain.Execution; import com.yahoo.vespa.config.search.DispatchConfig; import com.yahoo.vespa.config.search.DispatchNodesConfig; import com.yahoo.yolean.UncheckedInterruptedException; @@ -243,7 +242,7 @@ public class DispatcherTest { rpcPool.getConnection(node.key()).request(null, null, 0, null, null, 0); return null; }; - @Override protected InvokerResult getSearchResult(Execution execution) { + @Override protected InvokerResult getSearchResult() { return new InvokerResult(new Result(new Query())); } @Override protected void release() { } @@ -288,11 +287,11 @@ public class DispatcherTest { // Start some searches, one against each group, since we have a round-robin policy. SearchInvoker search0 = dispatcher.getSearchInvoker(new Query(), null); - search0.search(new Query(), null); + search0.search(new Query()); // Unknown whether the first or second search hits node0, so we must track that. int offset = nodeIdOfSearcher0.get(); SearchInvoker search1 = dispatcher.getSearchInvoker(new Query(), null); - search1.search(new Query(), null); + search1.search(new Query()); // Wait for the current cluster monitor to be mid-ping-round. doPing.set(true); @@ -330,7 +329,7 @@ public class DispatcherTest { // Next search should hit group0 again, this time on node2. SearchInvoker search2 = dispatcher.getSearchInvoker(new Query(), null); - search2.search(new Query(), null); + search2.search(new Query()); // Searches against nodes 1 and 2 complete. (offset == 0 ? search0 : search1).close(); 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 fac75b1dd68..8ced7d3895e 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 @@ -61,7 +61,7 @@ public class InterleavedSearchInvokerTest { expectedEvents.add(new Event(4900, 100, 1)); expectedEvents.add(new Event(4800, 100, 2)); - invoker.search(query, null); + invoker.search(query); assertTrue(expectedEvents.isEmpty(), "All test scenario events processed"); } @@ -75,7 +75,7 @@ public class InterleavedSearchInvokerTest { expectedEvents.add(new Event(4700, 300, 1)); expectedEvents.add(null); - Result result = invoker.search(query, null); + Result result = invoker.search(query); assertTrue(expectedEvents.isEmpty(), "All test scenario events processed"); assertNull(result.hits().getErrorHit(), "Result is not marked as an error"); @@ -94,7 +94,7 @@ public class InterleavedSearchInvokerTest { expectedEvents.add(new Event(2400, 100, 2)); expectedEvents.add(new Event(0, 0, null)); - Result result = invoker.search(query, null); + Result result = invoker.search(query); assertTrue(expectedEvents.isEmpty(), "All test scenario events processed"); assertNull(result.hits().getErrorHit(), "Result is not marked as an error"); @@ -113,7 +113,7 @@ public class InterleavedSearchInvokerTest { expectedEvents.add(new Event(null, 100, 0)); expectedEvents.add(new Event(null, 200, 1)); - Result result = invoker.search(query, null); + Result result = invoker.search(query); Coverage cov = result.getCoverage(true); assertEquals(100000L, cov.getDocs()); @@ -134,7 +134,7 @@ public class InterleavedSearchInvokerTest { expectedEvents.add(new Event(null, 100, 0)); expectedEvents.add(new Event(null, 200, 1)); - Result result = invoker.search(query, null); + Result result = invoker.search(query); Coverage cov = result.getCoverage(true); assertEquals(23420L, cov.getDocs()); @@ -156,7 +156,7 @@ public class InterleavedSearchInvokerTest { expectedEvents.add(new Event(null, 100, 0)); expectedEvents.add(new Event(null, 200, 1)); - Result result = invoker.search(query, null); + Result result = invoker.search(query); Coverage cov = result.getCoverage(true); assertEquals(9900L, cov.getDocs()); @@ -178,7 +178,7 @@ public class InterleavedSearchInvokerTest { expectedEvents.add(new Event(null, 100, 0)); expectedEvents.add(null); - Result result = invoker.search(query, null); + Result result = invoker.search(query); Coverage cov = result.getCoverage(true); assertEquals(50155L, cov.getDocs()); @@ -213,7 +213,7 @@ public class InterleavedSearchInvokerTest { query.setHits(8); query.properties().set(Dispatcher.topKProbability, topKProbability); SearchInvoker[] invokers = invoker.invokers().toArray(new SearchInvoker[0]); - Result result = invoker.search(query, null); + Result result = invoker.search(query); assertEquals(2, invokers.length); assertEquals(expectedK, ((MockInvoker) invokers[0]).hitsRequested); assertEquals(8, result.hits().size()); @@ -264,7 +264,7 @@ public class InterleavedSearchInvokerTest { void requireThatMergeOfConcreteHitsObeySorting() throws IOException { try (InterleavedSearchInvoker invoker = createInterLeavedTestInvoker(A5, B5, new Group(0, List.of()))) { query.setHits(12); - Result result = invoker.search(query, null); + Result result = invoker.search(query); assertEquals(10, result.hits().size()); assertEquals(11.0, result.hits().get(0).getRelevance().getScore(), DELTA); assertEquals(1.0, result.hits().get(9).getRelevance().getScore(), DELTA); @@ -273,7 +273,7 @@ public class InterleavedSearchInvokerTest { } try ( InterleavedSearchInvoker invoker = createInterLeavedTestInvoker(B5, A5, new Group(0, List.of()))) { - Result result = invoker.search(query, null); + Result result = invoker.search(query); assertEquals(10, result.hits().size()); assertEquals(11.0, result.hits().get(0).getRelevance().getScore(), DELTA); assertEquals(1.0, result.hits().get(9).getRelevance().getScore(), DELTA); @@ -287,7 +287,7 @@ public class InterleavedSearchInvokerTest { try (InterleavedSearchInvoker invoker = createInterLeavedTestInvoker(A5, B5, new Group(0, List.of()))) { query.setHits(3); query.setOffset(5); - Result result = invoker.search(query, null); + Result result = invoker.search(query); assertEquals(3, result.hits().size()); assertEquals(7.0, result.hits().get(0).getRelevance().getScore(), DELTA); assertEquals(3.0, result.hits().get(2).getRelevance().getScore(), DELTA); @@ -297,7 +297,7 @@ public class InterleavedSearchInvokerTest { try (InterleavedSearchInvoker invoker = createInterLeavedTestInvoker(B5, A5, new Group(0, List.of()))) { query.setOffset(5); - Result result = invoker.search(query, null); + Result result = invoker.search(query); assertEquals(3, result.hits().size()); assertEquals(7.0, result.hits().get(0).getRelevance().getScore(), DELTA); assertEquals(3.0, result.hits().get(2).getRelevance().getScore(), DELTA); @@ -311,7 +311,7 @@ public class InterleavedSearchInvokerTest { try (InterleavedSearchInvoker invoker = createInterLeavedTestInvoker(A5Aux, B5Aux, new Group(0, List.of()))) { query.setHits(3); query.setOffset(5); - Result result = invoker.search(query, null); + Result result = invoker.search(query); assertEquals(7, result.hits().size()); assertEquals(7.0, result.hits().get(0).getRelevance().getScore(), DELTA); assertEquals(3.0, result.hits().get(2).getRelevance().getScore(), DELTA); @@ -322,7 +322,7 @@ public class InterleavedSearchInvokerTest { try (InterleavedSearchInvoker invoker = createInterLeavedTestInvoker(B5Aux, A5Aux, new Group(0, List.of()))) { query.setOffset(5); - Result result = invoker.search(query, null); + Result result = invoker.search(query); assertEquals(7, result.hits().size()); assertEquals(7.0, result.hits().get(0).getRelevance().getScore(), DELTA); assertEquals(3.0, result.hits().get(2).getRelevance().getScore(), DELTA); @@ -359,7 +359,7 @@ public class InterleavedSearchInvokerTest { 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); + Result result = invoker.search(query); assertEquals(1, ((GroupingListHit) result.hits().get(0)).getGroupingList().size()); } for (SearchInvoker invoker : invokers) { @@ -404,7 +404,7 @@ public class InterleavedSearchInvokerTest { expectedEvents.add(new Event(null, 1, 1)); expectedEvents.add(new Event(null, 100, 0)); - Result result = invoker.search(query, null); + Result result = invoker.search(query); Coverage cov = result.getCoverage(true); assertEquals(50155L, cov.getDocs()); diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java b/container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java index a1521a88fb7..e43f3b0bd9a 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java @@ -40,7 +40,7 @@ class MockInvoker extends SearchInvoker { } @Override - protected InvokerResult getSearchResult(Execution execution) { + protected InvokerResult getSearchResult() { InvokerResult ret = new InvokerResult(query, 10); if (coverage != null) { ret.getResult().setCoverage(coverage); diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java index 3f527f34f31..2600d8612f8 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java @@ -9,7 +9,6 @@ import com.yahoo.prelude.fastsearch.VespaBackEndSearcher; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.dispatch.searchcluster.Node; -import com.yahoo.search.searchchain.Execution; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -45,7 +44,7 @@ public class RpcSearchInvokerTest { assertEquals(10, request.getHits()); assertEquals(3, request.getOffset()); - assertTrue(request.getQueryTreeBlob().size() > 0); + assertFalse(request.getQueryTreeBlob().isEmpty()); var invoker2 = new RpcSearchInvoker(mockSearcher(), compressor, new Node("test", 8, "eight", 1), mockPool, 1000); RpcSearchInvoker.RpcContext context2 = (RpcSearchInvoker.RpcContext) invoker2.sendSearchRequest(q, context); @@ -121,7 +120,7 @@ public class RpcSearchInvokerTest { private VespaBackEndSearcher mockSearcher() { return new VespaBackEndSearcher() { @Override - protected Result doSearch2(Query query, Execution execution) { + protected Result doSearch2(String schema, Query query) { fail("Unexpected call"); return null; } |