aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-01-25 11:35:50 +0100
committerGitHub <noreply@github.com>2017-01-25 11:35:50 +0100
commit8d1d103257e9d945a253d3add62a848b62947b3c (patch)
tree69308b219b41d8fd748203bc97f7e6b58c0e5f29 /container-search/src/test/java/com/yahoo
parenta58688d80d09979ffb30947dbabe81a1e37fc95d (diff)
parent6e777d8f51067c83f92ab555a8dbe965b0025703 (diff)
Merge pull request #1595 from yahoo/bratseth/singlenode-force-single-pass-grouping
Force single-pass grouping with single node groups
Diffstat (limited to 'container-search/src/test/java/com/yahoo')
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java72
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java5
2 files changed, 76 insertions, 1 deletions
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 3d08844038e..178f2ffed76 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
@@ -1,6 +1,7 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
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.search.Fs4Config;
@@ -20,6 +21,11 @@ import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.prelude.fastsearch.*;
import com.yahoo.prelude.query.WordItem;
+import com.yahoo.search.dispatch.SearchCluster;
+import com.yahoo.search.grouping.GroupingRequest;
+import com.yahoo.search.grouping.request.AllOperation;
+import com.yahoo.search.grouping.request.EachOperation;
+import com.yahoo.search.grouping.request.GroupingOperation;
import com.yahoo.search.rendering.RendererRegistry;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.searchchain.Execution;
@@ -235,7 +241,7 @@ public class FastSearcherTestCase {
}
@Test
- public void requireThatPropertiesAreReencoded() throws Exception {
+ public void testThatPropertiesAreReencoded() throws Exception {
FastSearcher fastSearcher = createFastSearcher();
assertEquals(100, fastSearcher.getCacheControl().capacity()); // Default cache =100MB
@@ -373,6 +379,70 @@ public class FastSearcherTestCase {
}
}
+
+ @Test
+ public void testSinglePassGroupingIsForcedWithSingleNodeGroups() {
+ FastSearcher fastSearcher = new FastSearcher(new MockBackend(),
+ new FS4ResourcePool(1),
+ new MockDispatcher(new SearchCluster.Node("host0", 123, 0)),
+ new SummaryParameters(null),
+ new ClusterParams("testhittype"),
+ new CacheParams(100, 1e64),
+ documentdbInfoConfig);
+ Query q = new Query("?query=foo");
+ GroupingRequest request1 = GroupingRequest.newInstance(q);
+ request1.setRootOperation(new AllOperation());
+
+ GroupingRequest request2 = GroupingRequest.newInstance(q);
+ AllOperation all = new AllOperation();
+ all.addChild(new EachOperation());
+ all.addChild(new EachOperation());
+ request2.setRootOperation(all);
+
+ assertForceSinglePassIs(false, q);
+ fastSearcher.search(q, new Execution(Execution.Context.createContextStub()));
+ assertForceSinglePassIs(true, q);
+ }
+
+ @Test
+ public void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() {
+ MockDispatcher dispatcher =
+ new MockDispatcher(ImmutableList.of(new SearchCluster.Node("host0", 123, 0),
+ new SearchCluster.Node("host1", 123, 0)));
+
+ FastSearcher fastSearcher = new FastSearcher(new MockBackend(),
+ new FS4ResourcePool(1),
+ dispatcher,
+ new SummaryParameters(null),
+ new ClusterParams("testhittype"),
+ new CacheParams(100, 1e64),
+ documentdbInfoConfig);
+ Query q = new Query("?query=foo");
+ GroupingRequest request1 = GroupingRequest.newInstance(q);
+ request1.setRootOperation(new AllOperation());
+
+ GroupingRequest request2 = GroupingRequest.newInstance(q);
+ AllOperation all = new AllOperation();
+ all.addChild(new EachOperation());
+ all.addChild(new EachOperation());
+ request2.setRootOperation(all);
+
+ assertForceSinglePassIs(false, q);
+ fastSearcher.search(q, new Execution(Execution.Context.createContextStub()));
+ assertForceSinglePassIs(false, q);
+ }
+
+ private void assertForceSinglePassIs(boolean expected, Query query) {
+ for (GroupingRequest request : GroupingRequest.getRequests(query))
+ assertForceSinglePassIs(expected, request.getRootOperation());
+ }
+
+ private void assertForceSinglePassIs(boolean expected, GroupingOperation operation) {
+ assertEquals("Force single pass is " + expected + " in " + operation,
+ expected, operation.getForceSinglePass());
+ for (GroupingOperation child : operation.getChildren())
+ assertForceSinglePassIs(expected, child);
+ }
@Test
public void testPing() throws IOException, InterruptedException {
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java
index dd4b0ef8b5a..a820b0b8743 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java
@@ -7,10 +7,15 @@ import com.yahoo.search.dispatch.Dispatcher;
import com.yahoo.search.dispatch.SearchCluster;
import com.yahoo.vespa.config.search.DispatchConfig;
+import java.util.Collections;
import java.util.List;
class MockDispatcher extends Dispatcher {
+ public MockDispatcher(SearchCluster.Node node) {
+ this(Collections.singletonList(node));
+ }
+
public MockDispatcher(List<SearchCluster.Node> nodes) {
super(toDispatchConfig(nodes), new FS4ResourcePool(1), 1, new VipStatus());
}