diff options
Diffstat (limited to 'container-search/src/test/java/com')
10 files changed, 105 insertions, 280 deletions
diff --git a/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java index affa6161440..ff91f346195 100644 --- a/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java @@ -9,7 +9,7 @@ import com.yahoo.container.handler.ClustersStatus; import com.yahoo.container.handler.VipStatus; import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig; import com.yahoo.prelude.fastsearch.FastHit; -import com.yahoo.prelude.fastsearch.VespaBackEndSearcher; +import com.yahoo.prelude.fastsearch.VespaBackend; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.config.ClusterConfig; @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -38,7 +39,6 @@ import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -51,21 +51,6 @@ public class ClusterSearcherTestCase { private static final double DELTA = 0.0000000000000001; - @Test - void testNoBackends() { - ClusterSearcher cluster = new ClusterSearcher(createSchemaInfo(), Set.of("dummy")); - try { - Execution execution = new Execution(cluster, Execution.Context.createContextStub()); - Query query = new Query("query=hello"); - query.setHits(10); - com.yahoo.search.Result result = execution.search(query); - assertNotNull(result.hits().getError()); - assertEquals("No backends in service. Try later", result.hits().getError().getMessage()); - } finally { - cluster.deconstruct(); - } - } - private static SchemaInfo createSchemaInfo() { var schemas = Stream.of("type1", "type2", "type3", "type4", "type5", "type6") .map(name -> new Schema.Builder(name).build()).toList(); @@ -89,10 +74,11 @@ public class ClusterSearcherTestCase { @Test void testThatDocumentTypesAreResolved() { + var backend = new MyMockBackend(false); SchemaInfo schemaInfo = createSchemaInfo(); - ClusterSearcher cluster1 = new ClusterSearcher(schemaInfo, Set.of("type1", "type2", "type3")); + ClusterSearcher cluster1 = new ClusterSearcher(schemaInfo, Map.of("type1", backend, "type2", backend, "type3", backend)); try { - ClusterSearcher type1 = new ClusterSearcher(schemaInfo, Set.of("type6")); + ClusterSearcher type1 = new ClusterSearcher(schemaInfo, Map.of("type6", backend)); try { assertEquals(Set.of("type1", "type2", "type3"), resolve(cluster1, "")); assertEquals(Set.of("type6"), resolve(type1, "")); @@ -129,10 +115,11 @@ public class ClusterSearcherTestCase { @Test void testThatDocumentTypesAreResolvedTODO_REMOVE() { + var backend = new MyMockBackend(false); SchemaInfo schemaInfo = createSchemaInfo(); - ClusterSearcher cluster1 = new ClusterSearcher(schemaInfo, Set.of("type1", "type2", "type3")); + ClusterSearcher cluster1 = new ClusterSearcher(schemaInfo, Map.of("type1", backend, "type2", backend, "type3", backend)); try { - ClusterSearcher type1 = new ClusterSearcher(schemaInfo, Set.of("type6")); + ClusterSearcher type1 = new ClusterSearcher(schemaInfo, Map.of("type6", backend)); try { assertEquals(Set.of(), resolve(cluster1, "&sources=cluster2")); } finally { @@ -143,13 +130,38 @@ public class ClusterSearcherTestCase { } } - private static class MyMockSearcher extends VespaBackEndSearcher { + @Test + void testThatMultipleBackendsAreUsed() { + var backendA = new MyMockBackend(false); + var backendB = new MyMockBackend(false); + SchemaInfo schemaInfo = createSchemaInfo(); + var cluster1 = new ClusterSearcher(schemaInfo, Map.of("type1", backendA, "type2", backendB, "type3", backendA), + new InThreadExecutorService()); + try { + Execution execution = new Execution(cluster1, Execution.Context.createContextStub()); + execution.search(new Query("?query=hello")); + assertEquals(2, backendA.queries().size()); + assertEquals(1, backendB.queries().size()); + execution.search(new Query("?query=hello&restrict=type1")); + assertEquals(3, backendA.queries().size()); + assertEquals(1, backendB.queries().size()); + execution.search(new Query("?query=hello&restrict=type2,type3")); + assertEquals(4, backendA.queries().size()); + assertEquals(2, backendB.queries().size()); + } finally { + cluster1.deconstruct(); + } + } + + private static class MyMockBackend extends VespaBackend { private final String type1 = "type1"; private final String type2 = "type2"; private final String type3 = "type3"; private final Map<String, List<Hit>> results = new LinkedHashMap<>(); private final boolean expectAttributePrefetch; + + private final List<Query> queries = new ArrayList<>(); static final String ATTRIBUTE_PREFETCH = "attributeprefetch"; private String getId(String type, int i) { @@ -200,7 +212,7 @@ public class ClusterSearcherTestCase { createHit(getId(type3, 2), 5))); } - MyMockSearcher(boolean expectAttributePrefetch) { + MyMockBackend(boolean expectAttributePrefetch) { this.expectAttributePrefetch = expectAttributePrefetch; init(); } @@ -210,8 +222,11 @@ public class ClusterSearcherTestCase { return null; // search() is overriden, this should never be called } + List<Query> queries() { return queries; } + @Override public com.yahoo.search.Result search(String schema, Query query) { + queries.add(query); com.yahoo.search.Result result = new com.yahoo.search.Result(query); List<Hit> hits = getHits(query); if (hits != null) { @@ -267,10 +282,14 @@ public class ClusterSearcherTestCase { } private Execution createExecution(List<String> docTypesList, boolean expectAttributePrefetch) { + var backend = new MyMockBackend(expectAttributePrefetch); + Map<String, VespaBackend> searchers = new HashMap<>(); + for(String schema : docTypesList) { + searchers.put(schema, backend); + } Set<String> documentTypes = new LinkedHashSet<>(docTypesList); ClusterSearcher cluster = new ClusterSearcher(toSchemaInfo(documentTypes, "mycluster"), - documentTypes, - new MyMockSearcher(expectAttributePrefetch), + searchers, new InThreadExecutorService()); try { List<Schema> schemas = new ArrayList<>(); @@ -428,7 +447,7 @@ public class ClusterSearcherTestCase { assertResult(6, List.of(7.0, 9.0), getResult(3, 2, extra, ex)); assertResult(6, List.of(9.0, 10.0), getResult(4, 2, extra, ex)); assertResult(6, List.of(10.0), getResult(5, 2, extra, ex)); - assertResult(6, List.of(), getResult(6, 2, extra, ex)); + assertResult(6, List.of(), getResult(6, 2, extra, ex)); } private static ClusterSearcher createSearcher(String clusterName, Double maxQueryTimeout, Double maxQueryCacheTimeout, @@ -449,7 +468,11 @@ public class ClusterSearcherTestCase { clusterConfig.maxQueryCacheTimeout(maxQueryCacheTimeout); DocumentdbInfoConfig.Builder documentDbConfig = new DocumentdbInfoConfig.Builder(); - documentDbConfig.documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("type1")); + documentDbConfig.documentdb(new DocumentdbInfoConfig.Documentdb.Builder() + .name("type1") + .mode(streamingMode + ? DocumentdbInfoConfig.Documentdb.Mode.Enum.STREAMING + : DocumentdbInfoConfig.Documentdb.Mode.Enum.INDEX)); var schema = new Schema.Builder("type1"); DispatchConfig dispatchConfig = new DispatchConfig.Builder().build(); diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/DocsumDefinitionTestCase.java index ade094115fe..ba9988b865c 100644 --- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/DocsumDefinitionTestCase.java @@ -1,14 +1,6 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.prelude.fastsearch.test; +package com.yahoo.prelude.fastsearch; -import com.yahoo.prelude.fastsearch.ByteField; -import com.yahoo.prelude.fastsearch.DataField; -import com.yahoo.prelude.fastsearch.DocsumDefinition; -import com.yahoo.prelude.fastsearch.DocsumDefinitionSet; -import com.yahoo.prelude.fastsearch.FastHit; -import com.yahoo.prelude.fastsearch.IntegerField; -import com.yahoo.prelude.fastsearch.StringField; -import com.yahoo.document.DocumentId; import com.yahoo.document.GlobalId; import com.yahoo.search.schema.DocumentSummary; import com.yahoo.search.schema.Schema; diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/IndexedBackendTestCase.java index 8270700a66b..917206bf00c 100644 --- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/IndexedBackendTestCase.java @@ -1,14 +1,9 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.prelude.fastsearch.test; +package com.yahoo.prelude.fastsearch; import com.yahoo.container.QrSearchersConfig; import com.yahoo.container.handler.VipStatus; import com.yahoo.container.protect.Error; -import com.yahoo.prelude.fastsearch.ClusterParams; -import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig; -import com.yahoo.prelude.fastsearch.FastSearcher; -import com.yahoo.prelude.fastsearch.SummaryParameters; -import com.yahoo.prelude.fastsearch.VespaBackEndSearcher; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.dispatch.MockDispatcher; @@ -38,14 +33,14 @@ import static org.junit.jupiter.api.Assertions.*; * * @author bratseth */ -public class FastSearcherTestCase { +public class IndexedBackendTestCase { private static final String SCHEMA = "test"; private static final String CLUSTER = "test"; @Test void testNullQuery() { - Logger.getLogger(FastSearcher.class.getName()).setLevel(Level.ALL); - FastSearcher fastSearcher = new FastSearcher("container.0", + Logger.getLogger(IndexedBackend.class.getName()).setLevel(Level.ALL); + IndexedBackend fastSearcher = new IndexedBackend("container.0", MockDispatcher.create(List.of()), new SummaryParameters(null), new ClusterParams("testhittype"), @@ -62,7 +57,7 @@ public class FastSearcherTestCase { assertEquals(Error.NULL_QUERY.code, message.getCode()); } - private Result doSearch(VespaBackEndSearcher searcher, Query query, int offset, int hits) { + private Result doSearch(VespaBackend searcher, Query query, int offset, int hits) { query.setOffset(offset); query.setHits(hits); return searcher.search(SCHEMA, query); @@ -70,7 +65,7 @@ public class FastSearcherTestCase { @Test void testSinglePassGroupingIsForcedWithSingleNodeGroups() { - FastSearcher fastSearcher = new FastSearcher("container.0", + IndexedBackend fastSearcher = new IndexedBackend("container.0", MockDispatcher.create(List.of(new Node(CLUSTER, 0, "host0", 0))), new SummaryParameters(null), new ClusterParams("testhittype"), @@ -93,7 +88,7 @@ public class FastSearcherTestCase { @Test void testRankProfileValidation() { - FastSearcher fastSearcher = new FastSearcher("container.0", + IndexedBackend fastSearcher = new IndexedBackend("container.0", MockDispatcher.create(List.of(new Node(CLUSTER, 0, "host0", 0))), new SummaryParameters(null), new ClusterParams("testhittype"), @@ -112,7 +107,7 @@ public class FastSearcherTestCase { .add(new RankProfile.Builder("default").setHasRankFeatures(false) .setHasSummaryFeatures(false) .build()); - FastSearcher backend = new FastSearcher("container.0", + IndexedBackend backend = new IndexedBackend("container.0", MockDispatcher.create(Collections.singletonList(new Node(CLUSTER, 0, "host0", 0))), new SummaryParameters(null), new ClusterParams("testhittype"), @@ -132,7 +127,7 @@ public class FastSearcherTestCase { void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() { MockDispatcher dispatcher = MockDispatcher.create(List.of(new Node(CLUSTER, 0, "host0", 0), new Node(CLUSTER, 2, "host1", 0))); - FastSearcher fastSearcher = new FastSearcher("container.0", + IndexedBackend fastSearcher = new IndexedBackend("container.0", dispatcher, new SummaryParameters(null), new ClusterParams("testhittype"), @@ -182,11 +177,11 @@ public class FastSearcherTestCase { assertTrue(vipStatus.isInRotation()); //Verify that deconstruct does not touch vipstatus } - private String searchError(String query, VespaBackEndSearcher searcher) { + private String searchError(String query, VespaBackend searcher) { return search(query, searcher).hits().getError().getDetailedMessage(); } - private Result search(String query, VespaBackEndSearcher searcher) { + private Result search(String query, VespaBackend searcher) { return searcher.search(SCHEMA, new Query(query)); } diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/PartialFillTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/PartialFillTestCase.java index a033ccdace6..7760e204d4b 100644 --- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/PartialFillTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/PartialFillTestCase.java @@ -1,12 +1,8 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.prelude.fastsearch.test; +package com.yahoo.prelude.fastsearch; -import com.yahoo.component.chain.Chain; -import com.yahoo.prelude.fastsearch.FastHit; -import com.yahoo.prelude.fastsearch.VespaBackEndSearcher; import com.yahoo.search.Query; import com.yahoo.search.Result; -import com.yahoo.search.Searcher; import com.yahoo.search.result.ErrorHit; import com.yahoo.search.result.ErrorMessage; import org.junit.jupiter.api.Test; @@ -22,7 +18,7 @@ import static org.junit.jupiter.api.Assertions.*; */ public class PartialFillTestCase { - public static class FS4 extends VespaBackEndSearcher { + public static class FS4 extends VespaBackend { public List<Result> history = new ArrayList<>(); protected Result doSearch2(String schema, Query query) { return new Result(query); @@ -32,7 +28,7 @@ public class PartialFillTestCase { } } - public static class BadFS4 extends VespaBackEndSearcher { + public static class BadFS4 extends VespaBackend { protected Result doSearch2(String schema, Query query) { return new Result(query); } @@ -137,14 +133,8 @@ public class PartialFillTestCase { } } - private void doFill(VespaBackEndSearcher searcher, Result result, String summaryClass) { + private void doFill(VespaBackend searcher, Result result, String summaryClass) { searcher.fill(result, summaryClass); } - private Chain<Searcher> chainedAsSearchChain(Searcher topOfChain) { - List<Searcher> searchers = new ArrayList<>(); - searchers.add(topOfChain); - return new Chain<>(searchers); - } - } diff --git a/container-search/src/test/java/com/yahoo/prelude/test/IntegrationTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/IntegrationTestCase.java deleted file mode 100644 index 0a3e7bda318..00000000000 --- a/container-search/src/test/java/com/yahoo/prelude/test/IntegrationTestCase.java +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.prelude.test; - -import com.yahoo.search.result.Hit; -import com.yahoo.search.Result; -import com.yahoo.search.Searcher; -import com.yahoo.search.searchchain.Execution; -import org.junit.jupiter.api.Test; - -/** - * Runs a query thru the configured search chain from a real http channel - * to a mock fdispatch channel. The setup is rather complicated, as the point is - * to span as much of the processing from query to result as possible. - * - * @author bratseth - */ -public class IntegrationTestCase { - - public static class SecondSearcher extends Searcher { - public Result search(com.yahoo.search.Query query, Execution execution) { - Result result = execution.search(query); - result.hits().add(new Hit("searcher:2",1000)); - return result; - } - } - public static class ThirdSearcher extends Searcher { - public Result search(com.yahoo.search.Query query, Execution execution) { - Result result = execution.search(query); - result.hits().add(new Hit("searcher:3",1000)); - return result; - } - } - - @Test - void testQuery() throws java.io.IOException { - /* - TODO: (JSB) This blocks forever on Linux (not Windows) because - the ServerSocketChannel.accept method in Server - seems to starve the test running thread, - causing it to get stuck in waitForServerInitialization. - This must be caused by starvation because - replacing the test with Thread.sleep(n) - gives the same result if n is large enough (2000 - is large enough, 1000 is not. - Resolve this in some way, perhaps by switching to - non-blocking io (and then remember to remove the next line). - */ - } - - /* - if (1==1) return; - ServerThread serverThread=new ServerThread(); - try { - serverThread.start(); - waitForServerInitialization(); - insertMockFs4Channel(); - ByteBuffer buffer=ByteBuffer.allocate(4096); - buffer.put(getBytes("GET /?query=hans HTTP/1.1\n\n")); - SocketChannel socket= - SocketChannel.open(new InetSocketAddress(Server.get().getHost(), - Server.get().getPort())); - buffer.flip(); - socket.write(buffer); - - buffer.clear(); - socket.read(buffer); - // TODO: Validate return too - - } - finally { - serverThread.interrupt(); - } - } - - private static void assertCorrectQueryData(QueryPacket packet) { - assertEquals("Query x packet " + - "[query: query 'RANK hans bcatpat.bidxpatlvl1:hans' [path='/']]", - packet.toString()); - } - - private void insertMockFs4Channel() { - Searcher current=SearchChain.get(); - while (current.getChained().getChained()!=null) - current=current.getChained(); - assertTrue(current.getChained() instanceof FastSearcher); - FastSearcher mockFastSearcher= - new FastSearcher(new MockFSChannel(), - "file:etc/qr-summary.cf", - "testhittype"); - current.setChained(mockFastSearcher); - } - - private void waitForServerInitialization() { - int sleptMs=0; - while (Server.get().getHost()==null) { - try { Thread.sleep(10); } catch (Exception e) {} - sleptMs+=10; - } - } - - private class ServerThread extends Thread { - - public void run() { - try { - Server.get().start(8081,new SearchRequestHandler()); - } - catch (java.io.IOException e) { - throw new RuntimeException("Failed",e); - } - } - } - - private byte[] getBytes(String string) { - try { - return string.getBytes("utf-8"); - } - catch (java.io.UnsupportedEncodingException e) { - throw new RuntimeException("Won't happen",e); - } - } - */ - /** A channel which returns hardcoded packets of the same type as fdispatch */ - /* - private static class MockFSChannel extends Channel { - - public MockFSChannel() {} - - public void sendPacket(Packet packet) { - if (packet instanceof QueryPacket) { - assertCorrectQueryData((QueryPacket)packet); - } - else { - throw new RuntimeException("Mock channel don't know what to reply to " + - packet); - } - } - - public Packet[] receivePackets() { - List packets=new java.util.ArrayList(); - QueryResultPacket result=QueryResultPacket.create(); - result.addDocument(new DocumentInfo(123,2003,234,1000,1)); - result.addDocument(new DocumentInfo(456,1855,234,1001,1)); - packets.add(result); - addDocsums(packets); - return (Packet[])packets.toArray(new Packet[packets.size()]); - } - - private void addDocsums(List packets) { - ByteBuffer buffer=createDocsumPacketData(DocsumDefinitionTestCase.docsum4); - buffer.position(0); - packets.add(PacketDecoder.decode(buffer)); - - buffer=createDocsumPacketData(DocsumDefinitionTestCase.docsum4); - buffer.position(0); - packets.add(PacketDecoder.decode(buffer)); - - packets.add(EolPacket.create()); - } - - private ByteBuffer createDocsumPacketData(byte[] docsumData) { - ByteBuffer buffer=ByteBuffer.allocate(docsumData.length+12+4); - buffer.limit(buffer.capacity()); - buffer.position(0); - buffer.putInt(docsumData.length+8+4); - buffer.putInt(205); // Docsum packet code - buffer.putInt(0); - buffer.putInt(0); - buffer.put(docsumData); - return buffer; - } - - } - */ -} 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 23846db3f0b..c966fbc200d 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 @@ -3,7 +3,7 @@ package com.yahoo.search.dispatch; import com.yahoo.compress.CompressionType; import com.yahoo.prelude.Pong; -import com.yahoo.prelude.fastsearch.VespaBackEndSearcher; +import com.yahoo.prelude.fastsearch.VespaBackend; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.cluster.ClusterMonitor; @@ -236,7 +236,7 @@ public class DispatcherTest { // This factory just forwards search to the dummy RPC layer above, nothing more. InvokerFactoryFactory invokerFactories = (rpcConnectionPool, searchGroups, dispatchConfig) -> new InvokerFactory(searchGroups, dispatchConfig) { - @Override protected Optional<SearchInvoker> createNodeSearchInvoker(VespaBackEndSearcher searcher, Query query, int maxHits, Node node) { + @Override protected Optional<SearchInvoker> createNodeSearchInvoker(VespaBackend searcher, Query query, int maxHits, Node node) { return Optional.of(new SearchInvoker(Optional.of(node)) { @Override protected Object sendSearchRequest(Query query, Object context) { rpcPool.getConnection(node.key()).request(null, null, 0, null, null, 0); @@ -248,7 +248,7 @@ public class DispatcherTest { @Override protected void release() { } }); }; - @Override public FillInvoker createFillInvoker(VespaBackEndSearcher searcher, Result result) { + @Override public FillInvoker createFillInvoker(VespaBackend searcher, Result result) { return new FillInvoker() { @Override protected void getFillResults(Result result, String summaryClass) { fail(); } @Override protected void sendFillRequest(Result result, String summaryClass) { fail(); } @@ -369,7 +369,7 @@ public class DispatcherTest { } @Override - public Optional<SearchInvoker> createSearchInvoker(VespaBackEndSearcher searcher, + public Optional<SearchInvoker> createSearchInvoker(VespaBackend searcher, Query query, List<Node> nodes, boolean acceptIncompleteCoverage, @@ -391,7 +391,7 @@ public class DispatcherTest { } @Override - protected Optional<SearchInvoker> createNodeSearchInvoker(VespaBackEndSearcher searcher, + protected Optional<SearchInvoker> createNodeSearchInvoker(VespaBackend searcher, Query query, int maxHitsPerNode, Node node) { @@ -400,7 +400,7 @@ public class DispatcherTest { } @Override - public FillInvoker createFillInvoker(VespaBackEndSearcher searcher, Result result) { + public FillInvoker createFillInvoker(VespaBackend searcher, Result result) { fail("Unexpected call to createFillInvoker"); return null; } 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 2600d8612f8..ef8e0522337 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 @@ -5,7 +5,7 @@ package com.yahoo.search.dispatch.rpc; import ai.vespa.searchlib.searchprotocol.protobuf.SearchProtocol; import com.google.common.collect.ImmutableMap; import com.yahoo.compress.CompressionType; -import com.yahoo.prelude.fastsearch.VespaBackEndSearcher; +import com.yahoo.prelude.fastsearch.VespaBackend; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.dispatch.searchcluster.Node; @@ -117,8 +117,8 @@ public class RpcSearchInvokerTest { }; } - private VespaBackEndSearcher mockSearcher() { - return new VespaBackEndSearcher() { + private VespaBackend mockSearcher() { + return new VespaBackend() { @Override protected Result doSearch2(String schema, Query query) { fail("Unexpected call"); diff --git a/container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java index 4455c8a04a5..87d18c18db5 100644 --- a/container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java @@ -5,7 +5,6 @@ import static org.junit.jupiter.api.Assertions.*; import java.util.Arrays; import java.util.List; -import java.util.Map; import com.yahoo.search.schema.DocumentSummary; import com.yahoo.search.schema.Schema; @@ -21,7 +20,7 @@ import com.yahoo.search.result.Hit; import com.yahoo.search.searchchain.Execution; import com.yahoo.search.searchchain.testutil.DocumentSourceSearcher; import static com.yahoo.search.searchchain.testutil.DocumentSourceSearcher.DEFAULT_SUMMARY_CLASS; -import static com.yahoo.prelude.fastsearch.VespaBackEndSearcher.SORTABLE_ATTRIBUTES_SUMMARY_CLASS; +import static com.yahoo.prelude.fastsearch.VespaBackend.SORTABLE_ATTRIBUTES_SUMMARY_CLASS; /** diff --git a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/MetricsSearcherTestCase.java b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/MetricsSearcherTestCase.java index 831261bb91a..5cc0e6b060b 100644 --- a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/MetricsSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/MetricsSearcherTestCase.java @@ -134,9 +134,9 @@ public class MetricsSearcherTestCase { private void assignContextProperties(Query query, String loadType) { if (loadType != null && loadType.equals(LOADTYPE1)) { - query.getContext(true).setProperty(StreamingSearcher.STREAMING_STATISTICS, visitorStats); + query.getContext(true).setProperty(StreamingBackend.STREAMING_STATISTICS, visitorStats); } else { - query.getContext(true).setProperty(StreamingSearcher.STREAMING_STATISTICS, null); + query.getContext(true).setProperty(StreamingBackend.STREAMING_STATISTICS, null); } } } diff --git a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/StreamingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/StreamingSearcherTestCase.java index c7e95f802ab..b96dd97f76c 100644 --- a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/StreamingSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/StreamingSearcherTestCase.java @@ -159,7 +159,7 @@ public class StreamingSearcherTestCase { } } - private static Result executeQuery(StreamingSearcher searcher, Query query) { + private static Result executeQuery(StreamingBackend searcher, Query query) { return searcher.doSearch2("test", query); } @@ -181,7 +181,7 @@ public class StreamingSearcherTestCase { return queries; } - private static void checkError(StreamingSearcher searcher, String queryString, String message, String detailedMessage) { + private static void checkError(StreamingBackend searcher, String queryString, String message, String detailedMessage) { for (Query query : generateTestQueries(queryString)) { Result result = executeQuery(searcher, query); assertNotNull(result.hits().getError()); @@ -194,7 +194,7 @@ public class StreamingSearcherTestCase { } } - private static void checkSearch(StreamingSearcher searcher, String queryString, int hitCount, String idPrefix) { + private static void checkSearch(StreamingBackend searcher, String queryString, int hitCount, String idPrefix) { for (Query query : generateTestQueries(queryString)) { Result result = executeQuery(searcher, query); assertNull(result.hits().getError()); @@ -212,11 +212,11 @@ public class StreamingSearcherTestCase { } } - private static void checkGrouping(StreamingSearcher searcher, String queryString, int hitCount) { + private static void checkGrouping(StreamingBackend searcher, String queryString, int hitCount) { checkSearch(searcher, queryString, hitCount, null); } - private static void checkMatchFeatures(StreamingSearcher searcher) { + private static void checkMatchFeatures(StreamingBackend searcher) { String queryString = "/?streaming.selection=true&query=match_features"; Result result = executeQuery(searcher, new Query(queryString)); assertNull(result.hits().getError()); @@ -229,7 +229,7 @@ public class StreamingSearcherTestCase { @Test void testBasics() { MockVisitorFactory factory = new MockVisitorFactory(); - StreamingSearcher searcher = new StreamingSearcher(factory); + StreamingBackend searcher = new StreamingBackend(factory); var schema = new Schema.Builder("test"); schema.add(new com.yahoo.search.schema.DocumentSummary.Builder("default").build()); @@ -276,25 +276,25 @@ public class StreamingSearcherTestCase { String groupId2 = "id:namespace:mytype:g=group2:userspecific"; String badId = "unknowscheme:namespace:something"; - assertTrue(StreamingSearcher.verifyDocId(userId1, generalQuery, true)); - - assertTrue(StreamingSearcher.verifyDocId(userId1, generalQuery, false)); - assertTrue(StreamingSearcher.verifyDocId(userId2, generalQuery, false)); - assertTrue(StreamingSearcher.verifyDocId(groupId1, generalQuery, false)); - assertTrue(StreamingSearcher.verifyDocId(groupId2, generalQuery, false)); - assertFalse(StreamingSearcher.verifyDocId(badId, generalQuery, false)); - - assertTrue(StreamingSearcher.verifyDocId(userId1, user1Query, false)); - assertFalse(StreamingSearcher.verifyDocId(userId2, user1Query, false)); - assertFalse(StreamingSearcher.verifyDocId(groupId1, user1Query, false)); - assertFalse(StreamingSearcher.verifyDocId(groupId2, user1Query, false)); - assertFalse(StreamingSearcher.verifyDocId(badId, user1Query, false)); - - assertFalse(StreamingSearcher.verifyDocId(userId1, group1Query, false)); - assertFalse(StreamingSearcher.verifyDocId(userId2, group1Query, false)); - assertTrue(StreamingSearcher.verifyDocId(groupId1, group1Query, false)); - assertFalse(StreamingSearcher.verifyDocId(groupId2, group1Query, false)); - assertFalse(StreamingSearcher.verifyDocId(badId, group1Query, false)); + assertTrue(StreamingBackend.verifyDocId(userId1, generalQuery, true)); + + assertTrue(StreamingBackend.verifyDocId(userId1, generalQuery, false)); + assertTrue(StreamingBackend.verifyDocId(userId2, generalQuery, false)); + assertTrue(StreamingBackend.verifyDocId(groupId1, generalQuery, false)); + assertTrue(StreamingBackend.verifyDocId(groupId2, generalQuery, false)); + assertFalse(StreamingBackend.verifyDocId(badId, generalQuery, false)); + + assertTrue(StreamingBackend.verifyDocId(userId1, user1Query, false)); + assertFalse(StreamingBackend.verifyDocId(userId2, user1Query, false)); + assertFalse(StreamingBackend.verifyDocId(groupId1, user1Query, false)); + assertFalse(StreamingBackend.verifyDocId(groupId2, user1Query, false)); + assertFalse(StreamingBackend.verifyDocId(badId, user1Query, false)); + + assertFalse(StreamingBackend.verifyDocId(userId1, group1Query, false)); + assertFalse(StreamingBackend.verifyDocId(userId2, group1Query, false)); + assertTrue(StreamingBackend.verifyDocId(groupId1, group1Query, false)); + assertFalse(StreamingBackend.verifyDocId(groupId2, group1Query, false)); + assertFalse(StreamingBackend.verifyDocId(badId, group1Query, false)); } private static class TraceFixture { @@ -304,13 +304,13 @@ public class StreamingSearcherTestCase { TracingOptions options; MockVisitorFactory factory; - StreamingSearcher searcher; + StreamingBackend searcher; private TraceFixture(Long firstTimestamp, Long... additionalTimestamps) { clock = MockUtils.mockedClockReturning(firstTimestamp, additionalTimestamps); options = new TracingOptions(sampler, exporter, clock, 8, 2.0); factory = new MockVisitorFactory(); - searcher = new StreamingSearcher(factory, options); + searcher = new StreamingBackend(factory, options); } private TraceFixture() { |