aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2023-01-25 21:07:20 +0100
committerJon Bratseth <bratseth@gmail.com>2023-01-25 21:07:20 +0100
commit8509fd404dbfe90349072bfbe5e7cc7164023725 (patch)
treec1d55c230ffed72c75f80a644f5e1b40daa07734 /container-search/src/test/java/com/yahoo/search
parenta0deac28d2261734f6c3be07c4a4041b0f8d52af (diff)
Validate rank profiles early
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search')
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java19
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/config/test/query-profile-variants2.cfg8
-rw-r--r--container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTest.java13
-rw-r--r--container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java10
4 files changed, 29 insertions, 21 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java b/container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java
index da1d09fec1e..cbe4ddcbc63 100644
--- a/container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java
+++ b/container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java
@@ -50,10 +50,12 @@ public class RankProfileInputTest {
assertEquals(Tensor.from(tensorString), query.getRanking().getFeatures().getTensor("query(myTensor1)").get());
}
- { // Resolution is limited to the correct sources
- Query query = createTensor1Query(tensorString, "bOnly", "sources=a");
- assertEquals(0, query.errors().size());
- assertEquals(tensorString, query.properties().get("ranking.features.query(myTensor1)"), "Not converted to tensor");
+ try {
+ createTensor1Query(tensorString, "bOnly", "sources=a");
+ fail("Expected exception");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals("No profile named 'bOnly' exists in schemas [a]", Exceptions.toMessageString(e));
}
}
@@ -237,20 +239,19 @@ public class RankProfileInputTest {
private SchemaInfo createSchemaInfo() {
List<Schema> schemas = new ArrayList<>();
- RankProfile common = new RankProfile.Builder("commonProfile")
+ RankProfile.Builder common = new RankProfile.Builder("commonProfile")
.addInput("query(myTensor1)", TensorType.fromSpec("tensor(a{},b{})"))
.addInput("query(myTensor2)", TensorType.fromSpec("tensor(x[2],y[2])"))
.addInput("query(myTensor3)", TensorType.fromSpec("tensor(x[2],y[2])"))
- .addInput("query(myTensor4)", TensorType.fromSpec("tensor<float>(x[5])"))
- .build();
+ .addInput("query(myTensor4)", TensorType.fromSpec("tensor<float>(x[5])"));
schemas.add(new Schema.Builder("a")
- .add(common)
+ .add(common.build())
.add(new RankProfile.Builder("inconsistent")
.addInput("query(myTensor1)", TensorType.fromSpec("tensor(a{},b{})"))
.build())
.build());
schemas.add(new Schema.Builder("b")
- .add(common)
+ .add(common.build())
.add(new RankProfile.Builder("inconsistent")
.addInput("query(myTensor1)", TensorType.fromSpec("tensor(x[10])"))
.build())
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/query-profile-variants2.cfg b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/query-profile-variants2.cfg
index ec091ecf2ea..cf17bc6ffcf 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/query-profile-variants2.cfg
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/query-profile-variants2.cfg
@@ -1,16 +1,14 @@
queryprofile[4]
queryprofile[0].id "default"
-queryprofile[0].property[5]
+queryprofile[0].property[4]
queryprofile[0].property[0].name "hits"
queryprofile[0].property[0].value "5"
queryprofile[0].property[1].name "model.defaultIndex"
queryprofile[0].property[1].value "title"
queryprofile[0].property[2].name "ranking.features.query(scorelimit)"
queryprofile[0].property[2].value "-20"
-queryprofile[0].property[3].name "ranking.profile"
-queryprofile[0].property[3].value "production1"
-queryprofile[0].property[4].name "ranking.properties.dotProduct.X"
-queryprofile[0].property[4].value "(a:1,b:2)"
+queryprofile[0].property[3].name "ranking.properties.dotProduct.X"
+queryprofile[0].property[3].value "(a:1,b:2)"
queryprofile[1].id "multi"
queryprofile[1].inherit[1]
queryprofile[1].inherit[0] "default"
diff --git a/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTest.java b/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTest.java
index 40d6f19c275..ba0c3f87900 100644
--- a/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTest.java
+++ b/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTest.java
@@ -2,9 +2,11 @@
package com.yahoo.search.schema;
import com.yahoo.tensor.TensorType;
+import com.yahoo.yolean.Exceptions;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author bratseth
@@ -40,10 +42,17 @@ public class SchemaInfoTest {
"a", "", "inconsistent", "query(myTensor1)");
tester.assertInput(TensorType.fromSpec("tensor(x[10])"),
"b", "", "inconsistent", "query(myTensor1)");
- tester.assertInput(null,
- "a", "", "bOnly", "query(myTensor1)");
tester.assertInput(TensorType.fromSpec("tensor(a{},b{})"),
"ab", "", "bOnly", "query(myTensor1)");
+ try {
+ tester.assertInput(null,
+ "a", "", "bOnly", "query(myTensor1)");
+ fail("Expected exception since bOnly is not in a");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals("No profile named 'bOnly' exists in schemas [a]",
+ Exceptions.toMessageString(e));
+ }
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java b/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java
index 4e7dc27e73c..a46f3480d50 100644
--- a/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java
+++ b/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java
@@ -58,14 +58,13 @@ public class SchemaInfoTester {
static SchemaInfo createSchemaInfo() {
List<Schema> schemas = new ArrayList<>();
- RankProfile common = new RankProfile.Builder("commonProfile")
+ RankProfile.Builder common = new RankProfile.Builder("commonProfile")
.addInput("query(myTensor1)", TensorType.fromSpec("tensor(a{},b{})"))
.addInput("query(myTensor2)", TensorType.fromSpec("tensor(x[2],y[2])"))
.addInput("query(myTensor3)", TensorType.fromSpec("tensor(x[2],y[2])"))
- .addInput("query(myTensor4)", TensorType.fromSpec("tensor<float>(x[5])"))
- .build();
+ .addInput("query(myTensor4)", TensorType.fromSpec("tensor<float>(x[5])"));
schemas.add(new Schema.Builder("a")
- .add(common)
+ .add(common.build())
.add(new RankProfile.Builder("inconsistent")
.addInput("query(myTensor1)", TensorType.fromSpec("tensor(a{},b{})"))
.build())
@@ -76,7 +75,7 @@ public class SchemaInfoTester {
.build())
.build());
schemas.add(new Schema.Builder("b")
- .add(common)
+ .add(common.build())
.add(new RankProfile.Builder("inconsistent")
.addInput("query(myTensor1)", TensorType.fromSpec("tensor(x[10])"))
.build())
@@ -92,6 +91,7 @@ public class SchemaInfoTester {
/** Creates the same schema info as createSchemaInfo from config objects. */
static SchemaInfo createSchemaInfoFromConfig() {
+
var indexInfoConfig = new IndexInfoConfig.Builder();
var rankProfileCommon = new SchemaInfoConfig.Schema.Rankprofile.Builder();