aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude/cluster
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-09-20 12:06:30 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2019-09-20 12:06:30 +0200
commitf0475fac6d3c95212b88768b971ebc035d0c3d46 (patch)
treed34e0445ca7d9288cd1bf2d499231aea0f435f78 /container-search/src/test/java/com/yahoo/prelude/cluster
parent0419474326ad85730a8f8d02caa7e027474ed018 (diff)
Take streaming search up and also add unit test for it.
Diffstat (limited to 'container-search/src/test/java/com/yahoo/prelude/cluster')
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java37
1 files changed, 26 insertions, 11 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 9ea7276583b..3e6e88c72c1 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
@@ -5,6 +5,7 @@ import com.yahoo.cloud.config.ClusterInfoConfig;
import com.yahoo.component.ComponentId;
import com.yahoo.container.QrConfig;
import com.yahoo.container.QrSearchersConfig;
+import com.yahoo.container.handler.ClustersStatus;
import com.yahoo.container.handler.VipStatus;
import com.yahoo.container.protect.Error;
import com.yahoo.prelude.IndexFacts;
@@ -264,8 +265,7 @@ public class ClusterSearcherTestCase {
Set<String> documentTypes = new LinkedHashSet<>(docTypesList);
ClusterSearcher cluster = new ClusterSearcher(documentTypes);
try {
- cluster.addBackendSearcher(new MyMockSearcher(
- expectAttributePrefetch));
+ cluster.addBackendSearcher(new MyMockSearcher(expectAttributePrefetch));
cluster.setValidRankProfile("default", documentTypes);
cluster.addValidRankProfile("testprofile", "type1");
return new Execution(cluster, Execution.Context.createContextStub());
@@ -513,19 +513,23 @@ public class ClusterSearcherTestCase {
assertEquals(3, result.getTotalHitCount());
}
- private static ClusterSearcher createSearcher(Double maxQueryTimeout,
- Double maxQueryCacheTimeout) {
+ private static ClusterSearcher createSearcher(String clusterName, Double maxQueryTimeout, Double maxQueryCacheTimeout,
+ boolean streamingMode, VipStatus vipStatus)
+ {
QrSearchersConfig.Builder qrSearchersConfig = new QrSearchersConfig.Builder();
- QrSearchersConfig.Searchcluster.Builder searchClusterConfig =
- new QrSearchersConfig.Searchcluster.Builder().name("test-cluster");
+ QrSearchersConfig.Searchcluster.Builder searchClusterConfig = new QrSearchersConfig.Searchcluster.Builder();
+ searchClusterConfig.name(clusterName);
+ if (streamingMode) {
+ searchClusterConfig.indexingmode(QrSearchersConfig.Searchcluster.Indexingmode.Enum.STREAMING);
+ searchClusterConfig.searchdef("streaming_sd");
+ }
qrSearchersConfig.searchcluster(searchClusterConfig);
- QrSearchersConfig.Searchcluster.Dispatcher.Builder dispatcherConfig =
- new QrSearchersConfig.Searchcluster.Dispatcher.Builder();
+ QrSearchersConfig.Searchcluster.Dispatcher.Builder dispatcherConfig = new QrSearchersConfig.Searchcluster.Dispatcher.Builder();
dispatcherConfig.host("localhost");
dispatcherConfig.port(0);
searchClusterConfig.dispatcher(dispatcherConfig);
- ClusterConfig.Builder clusterConfig = new ClusterConfig.Builder().clusterName("test-cluster");
+ ClusterConfig.Builder clusterConfig = new ClusterConfig.Builder().clusterName(clusterName);
if (maxQueryTimeout != null)
clusterConfig.maxQueryTimeout(maxQueryTimeout);
if (maxQueryCacheTimeout != null)
@@ -543,7 +547,7 @@ public class ClusterSearcherTestCase {
Statistics.nullImplementation,
new MockMetric(),
new FS4ResourcePool(new QrConfig.Builder().build()),
- new VipStatus());
+ vipStatus);
}
private static ClusterInfoConfig createClusterInfoConfig() {
@@ -558,7 +562,9 @@ public class ClusterSearcherTestCase {
Execution exec;
Query query;
QueryTimeoutFixture(Double maxQueryTimeout, Double maxQueryCacheTimeout) {
- searcher = createSearcher(maxQueryTimeout, maxQueryCacheTimeout);
+ String clusterName = "test-cluster";
+ VipStatus vipStatus = new VipStatus(new QrSearchersConfig.Builder().searchcluster(new QrSearchersConfig.Searchcluster.Builder().name(clusterName)).build(), new ClustersStatus());
+ searcher = createSearcher(clusterName, maxQueryTimeout, maxQueryCacheTimeout, false, vipStatus);
exec = new Execution(searcher, Execution.Context.createContextStub());
query = new Query("?query=hello&restrict=type1");
}
@@ -568,6 +574,15 @@ public class ClusterSearcherTestCase {
}
@Test
+ public void testThatVipStatusIsSetUpForStreamingSearch() {
+ String clusterName = "test-cluster";
+ VipStatus vipStatus = new VipStatus(new QrSearchersConfig.Builder().searchcluster(new QrSearchersConfig.Searchcluster.Builder().name(clusterName)).build(), new ClustersStatus());
+ assertFalse(vipStatus.isInRotation());
+ ClusterSearcher searcher = createSearcher(clusterName, 1.0, 10.0, true, vipStatus);
+ assertTrue(vipStatus.isInRotation());
+ }
+
+ @Test
public void testThatQueryTimeoutIsCappedWithDefaultMax() {
QueryTimeoutFixture f = new QueryTimeoutFixture(null, null);
f.query.setTimeout(600001);