aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/searchdefinition
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-09-07 16:09:45 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2021-09-07 16:09:45 +0200
commitcb9d0ba731eac799da1e60e89f18c6f3ee693ea0 (patch)
tree2b789725d345eceb4591c19f66dd42f62cd43b3d /config-model/src/test/java/com/yahoo/searchdefinition
parentb47f8ea6a94051c54dfd565bb70885db5231ac68 (diff)
Verify that rank profile inheritance is correct and sound. The rank profile must exist and be visible in the inheritance tree of the searchdefinition.
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition')
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java37
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java11
2 files changed, 47 insertions, 1 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java
index b4f4608facf..d96052cd8e0 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java
@@ -4,7 +4,6 @@ package com.yahoo.searchdefinition;
import com.yahoo.collections.Pair;
import com.yahoo.component.ComponentId;
import com.yahoo.config.model.api.ModelContext;
-import com.yahoo.config.model.application.provider.BaseDeployLogger;
import com.yahoo.config.model.application.provider.MockFileRegistry;
import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.document.DataType;
@@ -28,7 +27,9 @@ import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* Tests rank profiles
@@ -61,6 +62,40 @@ public class RankProfileTestCase extends SchemaTestCase {
assertEquals(RankType.DEFAULT, setting.getValue());
}
+ @Test
+ public void requireThatIllegalInheritanceIsChecked() throws ParseException {
+ try {
+ RankProfileRegistry registry = new RankProfileRegistry();
+ SearchBuilder builder = new SearchBuilder(registry, setupQueryProfileTypes());
+ builder.importString(
+ "search test {\n" +
+ " document test { } \n" +
+ " rank-profile p1 inherits notexist {}\n" +
+ "}");
+ builder.build(true);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("rank-profile 'p1' inherits 'notexist', but it does not exist anywhere in the inheritance of search 'test'.", e.getMessage());
+ }
+ }
+
+ @Test
+ public void requireThatRankProfilesCanInheritNotYetSeenProfiles() throws ParseException
+ {
+ RankProfileRegistry registry = new RankProfileRegistry();
+ SearchBuilder builder = new SearchBuilder(registry, setupQueryProfileTypes());
+ builder.importString(
+ "search test {\n" +
+ " document test { } \n" +
+ " rank-profile p1 inherits not_yet_defined {}\n" +
+ " rank-profile not_yet_defined inherits not_yet_defined {}\n" +
+ "}");
+ builder.build(true);
+ assertNotNull(registry.get("test","p1"));
+ assertTrue(registry.get("test","p1").inherits("not_yet_defined"));
+ assertNotNull(registry.get("test","not_yet_defined"));
+ }
+
private String createSD(Double termwiseLimit) {
return "search test {\n" +
" document test { \n" +
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java
index 138fb333621..41c5c919a62 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java
@@ -9,6 +9,7 @@ import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
* Tests exporting
@@ -165,6 +166,16 @@ public class ExportingTestCase extends AbstractExportingTestCase {
}
@Test
+ public void testIllegalSidewaysRankProfileInheritance() throws IOException, ParseException {
+ try {
+ assertCorrectDeriving("illegal_sideways_inheritance", "child1", new TestableDeployLogger());
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("rank-profile 'child' inherits 'parent', but it does not exist anywhere in the inheritance of search 'child1'.", e.getMessage());
+ }
+ }
+
+ @Test
public void testLanguage() throws IOException, ParseException {
TestableDeployLogger logger = new TestableDeployLogger();
assertCorrectDeriving("language", logger);