aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/schema
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/schema
parenta0deac28d2261734f6c3be07c4a4041b0f8d52af (diff)
Validate rank profiles early
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/schema')
-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
2 files changed, 16 insertions, 7 deletions
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();