diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-04-23 21:07:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-23 21:07:39 +0200 |
commit | bbc315437e29723c60d17b7f715a3f11c97d2536 (patch) | |
tree | 518dee932199dcc396ef395cb64317068fb3975c /container-search/src/test/java | |
parent | 60b66c70d7fd7c7f17bb88d6e1fef06d63ea0910 (diff) | |
parent | d43d1012473e54da068d68e7f95719c94ebdb1a4 (diff) |
Merge pull request #5677 from vespa-engine/bratseth/dispatch-summaries-take-5
Bratseth/dispatch summaries take 5
Diffstat (limited to 'container-search/src/test/java')
4 files changed, 59 insertions, 25 deletions
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/test/DocsumDefinitionTestCase.java index 1abfea268f2..b0bbdda32df 100644 --- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java @@ -47,7 +47,7 @@ public class DocsumDefinitionTestCase { } assertEquals(7, set.size()); - DocsumDefinition docsum0 = set.getDocsumDefinition("default"); + DocsumDefinition docsum0 = set.getDocsum("default"); assertNotNull(docsum0); assertEquals("default", docsum0.getName()); 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/test/FastSearcherTestCase.java index 20150fc2671..3cfd8b337fc 100644 --- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java @@ -4,6 +4,7 @@ package com.yahoo.prelude.fastsearch.test; import com.google.common.collect.ImmutableList; import com.yahoo.component.chain.Chain; import com.yahoo.config.subscription.ConfigGetter; +import com.yahoo.container.handler.VipStatus; import com.yahoo.container.search.Fs4Config; import com.yahoo.fs4.mplex.*; import com.yahoo.fs4.test.QueryTestCase; @@ -14,6 +15,7 @@ import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig; import com.yahoo.container.protect.Error; import com.yahoo.fs4.*; import com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend; +import com.yahoo.prelude.fastsearch.test.fs4mock.MockFS4ResourcePool; import com.yahoo.prelude.fastsearch.test.fs4mock.MockFSChannel; import com.yahoo.processing.execution.Execution.Trace; import com.yahoo.search.Query; @@ -111,30 +113,45 @@ public class FastSearcherTestCase { .summaryclass(new DocumentdbInfoConfig.Documentdb.Summaryclass.Builder().name("simple").id(7)) .rankprofile(new DocumentdbInfoConfig.Documentdb.Rankprofile.Builder() .name("simpler").hasRankFeatures(false).hasSummaryFeatures(false)))); + + List<SearchCluster.Node> nodes = new ArrayList<>(); + nodes.add(new SearchCluster.Node("host1", 5000, 0)); + nodes.add(new SearchCluster.Node("host2", 5000, 0)); + + MockFS4ResourcePool mockFs4ResourcePool = new MockFS4ResourcePool(); FastSearcher fastSearcher = new FastSearcher(new MockBackend(), - new FS4ResourcePool(1), - new MockDispatcher(Collections.emptyList()), + mockFs4ResourcePool, + new MockDispatcher(nodes, mockFs4ResourcePool, 1, new VipStatus()), new SummaryParameters(null), new ClusterParams("testhittype"), - new CacheParams(100, 1e64), + new CacheParams(0, 0), documentdbConfigWithOneDb); - String query = "?query=sddocname:a&dispatch.summaries"; - Result result = doSearch(fastSearcher,new Query(query), 0, 10); - ErrorMessage message = result.hits().getError(); - - assertNotNull("Got error", message); - assertEquals("Invalid query parameter", message.getMessage()); - assertEquals("When using dispatch.summaries and your summary/rankprofile require the query, you need to enable ranking.queryCache.", message.getDetailedMessage()); - assertEquals(Error.INVALID_QUERY_PARAMETER.code, message.getCode()); + { // No direct.summaries + String query = "?query=sddocname:a&summary=simple"; + Result result = doSearch(fastSearcher, new Query(query), 0, 10); + doFill(fastSearcher, result); + ErrorMessage error = result.hits().getError(); + assertNull("Since we don't route to the dispatcher we hit the mock backend, so no error", error); + } - query = "?query=sddocname:a&dispatch.summaries&ranking.queryCache"; - result = doSearch(fastSearcher,new Query(query), 0, 10); - assertNull(result.hits().getError()); + { // direct.summaries due to query cache + String query = "?query=sddocname:a&ranking.queryCache"; + Result result = doSearch(fastSearcher, new Query(query), 0, 10); + doFill(fastSearcher, result); + ErrorMessage error = result.hits().getError(); + assertEquals("Since we don't actually run summary backends we get this error when the Dispatcher is used", + "Error response from rpc node connection to host1:0: Connection error", error.getDetailedMessage()); + } - query = "?query=sddocname:a&dispatch.summaries&summary=simple&ranking=simpler"; - result = doSearch(fastSearcher,new Query(query), 0, 10); - assertNull(result.hits().getError()); + { // direct.summaries due to no summary features + String query = "?query=sddocname:a&dispatch.summaries&summary=simple&ranking=simpler"; + Result result = doSearch(fastSearcher, new Query(query), 0, 10); + doFill(fastSearcher, result); + ErrorMessage error = result.hits().getError(); + assertEquals("Since we don't actually run summary backends we get this error when the Dispatcher is used", + "Error response from rpc node connection to host1:0: Connection error", error.getDetailedMessage()); + } } @Test @@ -281,7 +298,7 @@ public class FastSearcherTestCase { assertEquals(100, fastSearcher.getCacheControl().capacity()); // Default cache =100MB - Query query = new Query("?query=ignored"); + Query query = new Query("?query=ignored&dispatch.summaries=false"); query.getRanking().setQueryCache(true); Result result = doSearch(fastSearcher, query, 0, 10); @@ -321,7 +338,6 @@ public class FastSearcherTestCase { answer.flip(); answer.get(expected); - assertEquals(expected.length, actual.length); for (int i = 0; i < expected.length; ++i) { if (expected[i] == IGNORE) { actual[i] = IGNORE; diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/fs4mock/MockFSChannel.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/fs4mock/MockFSChannel.java index 8d705406774..37a74831e56 100644 --- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/fs4mock/MockFSChannel.java +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/fs4mock/MockFSChannel.java @@ -96,13 +96,13 @@ public class MockFSChannel extends FS4Channel { && lastQueryPacket.getLastOffset() >= 1) { result.addDocument( new DocumentInfo(DocsumDefinitionTestCase.createGlobalId(123), - 2003, 234, 1000)); + 2003, 234, 0)); } if (lastQueryPacket.getOffset() <= 1 && lastQueryPacket.getLastOffset() >= 2) { result.addDocument( new DocumentInfo(DocsumDefinitionTestCase.createGlobalId(456), - 1855, 234, 1001)); + 1855, 234, 1)); } packets.add(result); } diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/FillTestCase.java b/container-search/src/test/java/com/yahoo/search/dispatch/FillTestCase.java index 9938498fa1a..ed421be1947 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/FillTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/FillTestCase.java @@ -2,6 +2,11 @@ package com.yahoo.search.dispatch; import com.yahoo.compress.CompressionType; +import com.yahoo.log.event.Collection; +import com.yahoo.prelude.fastsearch.DocsumDefinition; +import com.yahoo.prelude.fastsearch.DocsumDefinitionSet; +import com.yahoo.prelude.fastsearch.DocsumField; +import com.yahoo.prelude.fastsearch.DocumentDatabase; import com.yahoo.prelude.fastsearch.FastHit; import com.yahoo.search.Query; import com.yahoo.search.Result; @@ -10,7 +15,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; @@ -44,7 +52,8 @@ public class FillTestCase { client.setDocsumReponse("host1", 2, "summaryClass1", map("field1", "s.1.2", "field2", 2)); client.setDocsumReponse("host2", 3, "summaryClass1", map("field1", "s.2.3", "field2", 3)); client.setDocsumReponse("host0", 4, "summaryClass1", map("field1", "s.0.4", "field2", 4)); - dispatcher.fill(result, "summaryClass1", CompressionType.valueOf("LZ4")); + + dispatcher.fill(result, "summaryClass1", db(), CompressionType.valueOf("LZ4")); assertEquals("s.0.0", result.hits().get("hit:0").getField("field1").toString()); assertEquals("s.2.1", result.hits().get("hit:1").getField("field1").toString()); @@ -79,7 +88,7 @@ public class FillTestCase { client.setDocsumReponse("host1", 2, "summaryClass1", new HashMap<>()); client.setDocsumReponse("host2", 3, "summaryClass1", map("field1", "s.2.3", "field2", 3)); client.setDocsumReponse("host0", 4, "summaryClass1",new HashMap<>()); - dispatcher.fill(result, "summaryClass1", CompressionType.valueOf("LZ4")); + dispatcher.fill(result, "summaryClass1", db(), CompressionType.valueOf("LZ4")); assertEquals("s.0.0", result.hits().get("hit:0").getField("field1").toString()); assertEquals("s.2.1", result.hits().get("hit:1").getField("field1").toString()); @@ -108,11 +117,20 @@ public class FillTestCase { Result result = new Result(query); result.hits().add(createHit(0, 0)); - dispatcher.fill(result, "summaryClass1", CompressionType.valueOf("LZ4")); + dispatcher.fill(result, "summaryClass1", db(), CompressionType.valueOf("LZ4")); assertEquals("Malfunctioning", result.hits().getError().getDetailedMessage()); } + private DocumentDatabase db() { + List<DocsumField> fields = new ArrayList<>(); + fields.add(DocsumField.create("field1", "string")); + fields.add(DocsumField.create("field2", "int64")); + DocsumDefinitionSet docsums = new DocsumDefinitionSet(Collections.singleton(new DocsumDefinition("summaryClass1", + fields))); + return new DocumentDatabase("default", docsums, Collections.emptySet()); + } + private FastHit createHit(int sourceNodeId, int hitId) { FastHit hit = new FastHit("hit:" + hitId, 1.0); hit.setPartId(sourceNodeId, 0); |