aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/vespa
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/test/java/com/yahoo/vespa')
-rw-r--r--container-search/src/test/java/com/yahoo/vespa/streamingvisitors/MetricsSearcherTestCase.java4
-rw-r--r--container-search/src/test/java/com/yahoo/vespa/streamingvisitors/StreamingSearcherTestCase.java66
-rw-r--r--container-search/src/test/java/com/yahoo/vespa/streamingvisitors/StreamingVisitorTest.java32
3 files changed, 43 insertions, 59 deletions
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 3d9a958c757..8d264f9860b 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
@@ -9,14 +9,12 @@ import com.yahoo.messagebus.routing.Route;
import com.yahoo.prelude.fastsearch.ClusterParams;
import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
import com.yahoo.document.select.parser.ParseException;
-import com.yahoo.prelude.fastsearch.SummaryParameters;
import com.yahoo.prelude.fastsearch.TimeoutException;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.result.Hit;
import com.yahoo.search.schema.Schema;
import com.yahoo.search.schema.SchemaInfo;
-import com.yahoo.search.searchchain.Execution;
import com.yahoo.searchlib.aggregation.Grouping;
import com.yahoo.vdslib.DocumentSummary;
import com.yahoo.vdslib.SearchResult;
@@ -47,6 +45,7 @@ public class StreamingSearcherTestCase {
public static final String USERDOC_ID_PREFIX = "id:namespace:mytype:n=1:userspecific";
public static final String GROUPDOC_ID_PREFIX = "id:namespace:mytype:g=group1:userspecific";
+ private static final ClusterParams CLUSTER_PARAMS = new ClusterParams("clusterName");
private static class MockVisitor implements Visitor {
private final Query query;
@@ -160,10 +159,8 @@ public class StreamingSearcherTestCase {
}
}
- private static Result executeQuery(StreamingSearcher searcher, Query query) {
- Execution execution = new Execution(Execution.Context.createContextStub());
- query.getModel().setRestrict("test");
- return searcher.doSearch2(query, execution);
+ private static Result executeQuery(StreamingBackend searcher, Query query) {
+ return searcher.doSearch2("test", query);
}
private static Query[] generateTestQueries(String queryString) {
@@ -184,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());
@@ -197,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());
@@ -215,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());
@@ -232,15 +229,12 @@ public class StreamingSearcherTestCase {
@Test
void testBasics() {
MockVisitorFactory factory = new MockVisitorFactory();
- StreamingSearcher searcher = new StreamingSearcher(factory);
-
var schema = new Schema.Builder("test");
schema.add(new com.yahoo.search.schema.DocumentSummary.Builder("default").build());
- searcher.init("container.0",
- new SummaryParameters("default"),
- new ClusterParams("clusterName"),
+ ClusterParams clusterParams = new ClusterParams("clusterName", "server.0", "default",
new DocumentdbInfoConfig.Builder().documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("test")).build(),
new SchemaInfo(List.of(schema.build()), List.of()));
+ StreamingBackend searcher = new StreamingBackend(clusterParams, "search-cluster-A", factory, "content-cluster-A");
// Magic query values are used to trigger specific behaviors from mock visitor.
checkError(searcher, "/?query=noselection",
@@ -279,25 +273,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 {
@@ -307,13 +301,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(CLUSTER_PARAMS, "search-cluster-A", factory, "content-cluster-A", options);
}
private TraceFixture() {
diff --git a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/StreamingVisitorTest.java b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/StreamingVisitorTest.java
index 8be60b7c3b0..30fb33ee8c8 100644
--- a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/StreamingVisitorTest.java
+++ b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/StreamingVisitorTest.java
@@ -23,6 +23,7 @@ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import static org.junit.jupiter.api.Assertions.*;
@@ -76,7 +77,7 @@ public class StreamingVisitorTest {
};
}
- private class QueryArguments {
+ private static class QueryArguments {
// General query parameters
String query = "test";
double timeout = 0.5;
@@ -188,25 +189,21 @@ public class StreamingVisitorTest {
return query;
}
- private void verifyVisitorParameters(VisitorParameters params, QueryArguments qa, String searchCluster, String docType, Route route) {
+ private void verifyVisitorParameters(VisitorParameters params, QueryArguments qa, String searchCluster, String schema, Route route) {
//System.out.println("params="+params);
// Verify parameters based on properties
if (qa.userId != null) {
- assertEquals(docType + " and ( id.user=="+qa.userId + " )", params.getDocumentSelection());
+ assertEquals(schema + " and ( id.user=="+qa.userId + " )", params.getDocumentSelection());
} else if (qa.groupName != null) {
- assertEquals(docType + " and ( id.group==\""+qa.groupName+"\" )", params.getDocumentSelection());
+ assertEquals(schema + " and ( id.group==\""+qa.groupName+"\" )", params.getDocumentSelection());
} else if ((qa.selection == null) || qa.selection.isEmpty()) {
- assertEquals(docType, params.getDocumentSelection());
+ assertEquals(schema, params.getDocumentSelection());
} else {
- assertEquals(docType + " and ( " + qa.selection + " )", params.getDocumentSelection());
+ assertEquals(schema + " and ( " + qa.selection + " )", params.getDocumentSelection());
}
assertEquals(qa.from, params.getFromTimestamp());
assertEquals(qa.to, params.getToTimestamp());
- if (qa.priority != null) {
- assertEquals(qa.priority, params.getPriority());
- } else {
- assertEquals(DocumentProtocol.Priority.VERY_HIGH, params.getPriority());
- }
+ assertEquals(Objects.requireNonNullElse(qa.priority, DocumentProtocol.Priority.VERY_HIGH), params.getPriority());
if (qa.maxBucketsPerVisitor != 0) {
assertEquals(qa.maxBucketsPerVisitor, params.getMaxBucketsPerVisitor());
} else {
@@ -227,17 +224,10 @@ public class StreamingVisitorTest {
//System.err.println("query="+new String(params.getLibraryParameters().get("querystackcount")));
assertNotNull(params.getLibraryParameters().get("querystackcount")); // TODO: Check contents
assertEquals(searchCluster, new String(params.getLibraryParameters().get("searchcluster")));
- if (qa.summary != null) {
- assertEquals(qa.summary, new String(params.getLibraryParameters().get("summaryclass")));
- } else {
- assertEquals("default", new String(params.getLibraryParameters().get("summaryclass")));
- }
+ assertEquals(schema, new String(params.getLibraryParameters().get("schema")));
+ assertEquals(Objects.requireNonNullElse(qa.summary, "default"), new String(params.getLibraryParameters().get("summaryclass")));
assertEquals(Integer.toString(qa.offset+qa.hits), new String(params.getLibraryParameters().get("summarycount")));
- if (qa.profile != null) {
- assertEquals(qa.profile, new String(params.getLibraryParameters().get("rankprofile")));
- } else {
- assertEquals("default", new String(params.getLibraryParameters().get("rankprofile")));
- }
+ assertEquals(Objects.requireNonNullElse(qa.profile, "default"), new String(params.getLibraryParameters().get("rankprofile")));
//System.err.println("queryflags="+new String(params.getLibraryParameters().get("queryflags")));
assertNotNull(params.getLibraryParameters().get("queryflags")); // TODO: Check contents
if (qa.location != null) {