diff options
Diffstat (limited to 'config-model/src/test')
32 files changed, 311 insertions, 184 deletions
diff --git a/config-model/src/test/cfg/application/onnx_probe/files/create_dynamic_model.py b/config-model/src/test/cfg/application/onnx_probe/files/create_dynamic_model.py deleted file mode 100755 index b493e394ee4..00000000000 --- a/config-model/src/test/cfg/application/onnx_probe/files/create_dynamic_model.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -import onnx -import numpy as np -from onnx import helper, TensorProto - -INPUT_1 = helper.make_tensor_value_info('input1', TensorProto.FLOAT, ["batch", 2]) -INPUT_2 = helper.make_tensor_value_info('input2', TensorProto.FLOAT, ["batch", 2]) -OUTPUT = helper.make_tensor_value_info('out', TensorProto.FLOAT, ["batch", "dim1", "dim2"]) - -SHAPE = helper.make_tensor('shape', TensorProto.INT64, dims=[3], vals=np.array([1,2,2]).astype(np.int64)) - -nodes = [ - helper.make_node('Concat', ['input1', 'input2'], ['concat'], axis=1), - helper.make_node('Reshape', ['concat', 'shape'], ['out']), -] -graph_def = helper.make_graph(nodes, 'simple_scoring', [INPUT_1, INPUT_2], [OUTPUT], [SHAPE]) -model_def = helper.make_model(graph_def, producer_name='create_dynamic_model.py', opset_imports=[onnx.OperatorSetIdProto(version=12)]) -onnx.save(model_def, 'dynamic_model_2.onnx') diff --git a/config-model/src/test/cfg/application/onnx_probe/files/dynamic_model.onnx b/config-model/src/test/cfg/application/onnx_probe/files/dynamic_model.onnx deleted file mode 100644 index 28c600e2a09..00000000000 --- a/config-model/src/test/cfg/application/onnx_probe/files/dynamic_model.onnx +++ /dev/null @@ -1,21 +0,0 @@ -create_dynamic_model_2.py:Ö -- -input1 -input2concat"Concat* -axis - -concat -shapeout"Reshapesimple_scoring*:BshapeZ -input1 -
-batch -Z -input2 -
-batch -b& -out - -batch -dim1 -dim2B
\ No newline at end of file diff --git a/config-model/src/test/derived/advanced/index-info.cfg b/config-model/src/test/derived/advanced/index-info.cfg index c693597a75e..cf33b038700 100644 --- a/config-model/src/test/derived/advanced/index-info.cfg +++ b/config-model/src/test/derived/advanced/index-info.cfg @@ -51,6 +51,18 @@ indexinfo[].command[].indexname "debug" indexinfo[].command[].command "plain-tokens" indexinfo[].command[].indexname "debug" indexinfo[].command[].command "type string" +indexinfo[].command[].indexname "location.x" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "location.x" +indexinfo[].command[].command "numerical" +indexinfo[].command[].indexname "location.x" +indexinfo[].command[].command "type int" +indexinfo[].command[].indexname "location.y" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "location.y" +indexinfo[].command[].command "numerical" +indexinfo[].command[].indexname "location.y" +indexinfo[].command[].command "type int" indexinfo[].command[].indexname "location" indexinfo[].command[].command "default-position" indexinfo[].command[].indexname "location" diff --git a/config-model/src/test/derived/multiplesummaries/ilscripts.cfg b/config-model/src/test/derived/multiplesummaries/ilscripts.cfg index 5434b0770f7..6429932ab0e 100644 --- a/config-model/src/test/derived/multiplesummaries/ilscripts.cfg +++ b/config-model/src/test/derived/multiplesummaries/ilscripts.cfg @@ -1,27 +1,27 @@ maxtermoccurrences 100 fieldmatchmaxlength 1000000 ilscript[].doctype "multiplesummaries" -ilscript[].docfield[0] "a" -ilscript[].docfield[1] "adynamic" -ilscript[].docfield[2] "abolded" -ilscript[].docfield[3] "b" -ilscript[].docfield[4] "c" -ilscript[].docfield[5] "d" -ilscript[].docfield[6] "e" -ilscript[].docfield[7] "f" -ilscript[].docfield[8] "g" -ilscript[].docfield[9] "h" -ilscript[].docfield[10] "loc" -ilscript[].docfield[11] "mytags" -ilscript[].content[0] "clear_state | guard { input loc | to_pos | zcurve | attribute loc_pos_zcurve; }" -ilscript[].content[1] "clear_state | guard { input a | tokenize normalize stem:\"BEST\" | summary abolded2 | summary aboldeddynamic | summary adynamic2 | attribute a; }" -ilscript[].content[2] "clear_state | guard { input adynamic | tokenize normalize stem:\"BEST\" | summary adynamic | attribute adynamic; }" -ilscript[].content[3] "clear_state | guard { input abolded | tokenize normalize stem:\"BEST\" | summary abolded | attribute abolded; }" -ilscript[].content[4] "clear_state | guard { input b | summary anotherb | summary b; }" -ilscript[].content[5] "clear_state | guard { input c | summary c | attribute c; }" -ilscript[].content[6] "clear_state | guard { input d | tokenize normalize stem:\"BEST\" | summary d; }" -ilscript[].content[7] "clear_state | guard { input e | tokenize normalize stem:\"BEST\" | summary dynamice | summary e; }" -ilscript[].content[8] "clear_state | guard { input f | summary f; }" -ilscript[].content[9] "clear_state | guard { input g | summary g; }" -ilscript[].content[10] "clear_state | guard { input h | summary h; }" -ilscript[].content[11] "clear_state | guard { input mytags | for_each { tokenize normalize stem:\"BEST\" } | index mytags; }" +ilscript[].docfield[] "a" +ilscript[].docfield[] "adynamic" +ilscript[].docfield[] "abolded" +ilscript[].docfield[] "b" +ilscript[].docfield[] "c" +ilscript[].docfield[] "d" +ilscript[].docfield[] "e" +ilscript[].docfield[] "f" +ilscript[].docfield[] "g" +ilscript[].docfield[] "h" +ilscript[].docfield[] "loc" +ilscript[].docfield[] "mytags" +ilscript[].content[] "clear_state | guard { input loc | to_pos | zcurve | attribute loc_pos_zcurve; }" +ilscript[].content[] "clear_state | guard { input a | tokenize normalize stem:\"BEST\" | summary abolded2 | summary aboldeddynamic | summary adynamic2 | attribute a; }" +ilscript[].content[] "clear_state | guard { input adynamic | tokenize normalize stem:\"BEST\" | summary adynamic | attribute adynamic; }" +ilscript[].content[] "clear_state | guard { input abolded | tokenize normalize stem:\"BEST\" | summary abolded | attribute abolded; }" +ilscript[].content[] "clear_state | guard { input b | summary anotherb | summary b; }" +ilscript[].content[] "clear_state | guard { input c | summary c | attribute c; }" +ilscript[].content[] "clear_state | guard { input d | tokenize normalize stem:\"BEST\" | summary d; }" +ilscript[].content[] "clear_state | guard { input e | tokenize normalize stem:\"BEST\" | summary dynamice | summary e; }" +ilscript[].content[] "clear_state | guard { input f | summary f; }" +ilscript[].content[] "clear_state | guard { input g | summary g; }" +ilscript[].content[] "clear_state | guard { input h | summary h; }" +ilscript[].content[] "clear_state | guard { input mytags | for_each { tokenize normalize stem:\"BEST\" } | index mytags; }" diff --git a/config-model/src/test/derived/multiplesummaries/index-info.cfg b/config-model/src/test/derived/multiplesummaries/index-info.cfg index d5002535761..6167dcbef02 100644 --- a/config-model/src/test/derived/multiplesummaries/index-info.cfg +++ b/config-model/src/test/derived/multiplesummaries/index-info.cfg @@ -111,6 +111,18 @@ indexinfo[].command[].indexname "dynamice" indexinfo[].command[].command "index" indexinfo[].command[].indexname "dynamice" indexinfo[].command[].command "type string" +indexinfo[].command[].indexname "loc_pos.x" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "loc_pos.x" +indexinfo[].command[].command "numerical" +indexinfo[].command[].indexname "loc_pos.x" +indexinfo[].command[].command "type int" +indexinfo[].command[].indexname "loc_pos.y" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "loc_pos.y" +indexinfo[].command[].command "numerical" +indexinfo[].command[].indexname "loc_pos.y" +indexinfo[].command[].command "type int" indexinfo[].command[].indexname "loc_pos" indexinfo[].command[].command "default-position" indexinfo[].command[].indexname "loc_pos" diff --git a/config-model/src/test/derived/position_extra/index-info.cfg b/config-model/src/test/derived/position_extra/index-info.cfg index 45813140b1d..97521c14a6a 100644 --- a/config-model/src/test/derived/position_extra/index-info.cfg +++ b/config-model/src/test/derived/position_extra/index-info.cfg @@ -7,6 +7,18 @@ indexinfo[].command[].indexname "pos_str" indexinfo[].command[].command "index" indexinfo[].command[].indexname "pos_str" indexinfo[].command[].command "type string" +indexinfo[].command[].indexname "pos_ext.x" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "pos_ext.x" +indexinfo[].command[].command "numerical" +indexinfo[].command[].indexname "pos_ext.x" +indexinfo[].command[].command "type int" +indexinfo[].command[].indexname "pos_ext.y" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "pos_ext.y" +indexinfo[].command[].command "numerical" +indexinfo[].command[].indexname "pos_ext.y" +indexinfo[].command[].command "type int" indexinfo[].command[].indexname "pos_ext" indexinfo[].command[].command "default-position" indexinfo[].command[].indexname "pos_ext" diff --git a/config-model/src/test/derived/rankexpression/macro.expression b/config-model/src/test/derived/rankingexpression/macro.expression index 054b025b2e7..054b025b2e7 100644 --- a/config-model/src/test/derived/rankexpression/macro.expression +++ b/config-model/src/test/derived/rankingexpression/macro.expression diff --git a/config-model/src/test/derived/rankexpression/overflow.expression b/config-model/src/test/derived/rankingexpression/overflow.expression index 4d3a6faeeb5..4d3a6faeeb5 100644 --- a/config-model/src/test/derived/rankexpression/overflow.expression +++ b/config-model/src/test/derived/rankingexpression/overflow.expression diff --git a/config-model/src/test/derived/rankexpression/rank-profiles.cfg b/config-model/src/test/derived/rankingexpression/rank-profiles.cfg index 6400870b0c4..cf59ae9c326 100644 --- a/config-model/src/test/derived/rankexpression/rank-profiles.cfg +++ b/config-model/src/test/derived/rankingexpression/rank-profiles.cfg @@ -363,3 +363,12 @@ rankprofile[].fef.property[].name "vespa.match.feature" rankprofile[].fef.property[].value "rankingExpression(mymul)" rankprofile[].fef.property[].name "vespa.type.attribute.t1" rankprofile[].fef.property[].value "tensor(m{},v[3])" +rankprofile[].name "withboolean" +rankprofile[].fef.property[].name "rankingExpression(mytrue).rankingScript" +rankprofile[].fef.property[].value "true" +rankprofile[].fef.property[].name "rankingExpression(myfalse).rankingScript" +rankprofile[].fef.property[].value "false" +rankprofile[].fef.property[].name "rankingExpression(mybooleanexpression).rankingScript" +rankprofile[].fef.property[].value "5.0" +rankprofile[].fef.property[].name "vespa.type.attribute.t1" +rankprofile[].fef.property[].value "tensor(m{},v[3])" diff --git a/config-model/src/test/derived/rankexpression/rankexpression.expression b/config-model/src/test/derived/rankingexpression/rankexpression.expression index d6cb73c829d..d6cb73c829d 100644 --- a/config-model/src/test/derived/rankexpression/rankexpression.expression +++ b/config-model/src/test/derived/rankingexpression/rankexpression.expression diff --git a/config-model/src/test/derived/rankexpression/rankexpression.sd b/config-model/src/test/derived/rankingexpression/rankexpression.sd index 73eb1cadadb..25d657eaf0b 100644 --- a/config-model/src/test/derived/rankexpression/rankexpression.sd +++ b/config-model/src/test/derived/rankingexpression/rankexpression.sd @@ -69,7 +69,8 @@ search rankexpression { rank-features: attribute(foo1).out attribute(bar1) rank-features { attribute(foo2).out attribute(bar2).out } rank-features { - attribute(foo3).out attribute(bar3).out } + attribute(foo3).out attribute(bar3).out + } rank-features { attribute(foo4).out attribute(bar4).out @@ -101,7 +102,8 @@ search rankexpression { summary-features: attribute(foo1).out attribute(bar1) summary-features { attribute(foo2).out attribute(bar2).out } summary-features { - attribute(foo3).out attribute(bar3).out } + attribute(foo3).out attribute(bar3).out + } summary-features { attribute(foo4).out attribute(bar4).out @@ -162,10 +164,10 @@ search rankexpression { second-phase { expression: fourtimessum(match,rankBoost) } - macro fourtimessum(var1, var2) { + function fourtimessum(var1, var2) { expression: 4*(var1+var2) } - macro myfeature() { + function myfeature() { expression { 70 * fieldMatch(title).completeness * pow(0 - fieldMatch(title).earliness, 2) + 30 * pow(0 - fieldMatch(description).earliness, 2) @@ -187,21 +189,21 @@ search rankexpression { second-phase { expression: fourtimessum(match,match) + mysummaryfeature + myfeature } - macro fourtimessum(var1, var2) { + function fourtimessum(var1, var2) { expression: 4*(var1+var2) } - macro myfeature() { + function myfeature() { expression { 70 * fieldMatch(title).completeness * pow(0 - fieldMatch(title).earliness, 2) + 30 * pow(0 - fieldMatch(description).earliness, 2) } } - macro mysummaryfeature() { + function mysummaryfeature() { expression { 70 * fieldMatch(title).completeness } } - macro mysummaryfeature2() { + function mysummaryfeature2() { expression { 71 * fieldMatch(title).completeness } @@ -213,7 +215,7 @@ search rankexpression { } rank-profile macros3 { - macro onlyusedinsummaryfeature() { + function onlyusedinsummaryfeature() { expression: 5 } summary-features { @@ -229,7 +231,7 @@ search rankexpression { } rank-profile macros-inherited inherits macros2 { - macro mysummaryfeature() { + function mysummaryfeature() { expression { 80 * fieldMatch(title).completeness } @@ -250,7 +252,7 @@ search rankexpression { } rank-profile macros-inherited3 inherits macros-inherited2 { - macro myfeature() { + function myfeature() { expression { 700 * fieldMatch(title).completeness } @@ -263,17 +265,17 @@ search rankexpression { } rank-profile macros-refering-macros { - macro m2() { + function m2() { expression: m1 * 67 } - macro m1() { + function m1() { expression { 700 * fieldMatch(title).completeness } } - macro m4() { + function m4() { expression: file:macro.expression } @@ -286,7 +288,7 @@ search rankexpression { } rank-profile macros-refering-macros-inherited inherits macros-refering-macros { - macro m3() { + function m3() { expression { if(isNan(attribute(nrtgmp))==1, 0.0, @@ -310,7 +312,7 @@ search rankexpression { } rank-profile macros-refering-macros-inherited-two-levels inherits macros-refering-macros-inherited { - macro m5() { + function m5() { expression { if(isNan(attribute(glmpfw))==1, m1, @@ -336,7 +338,8 @@ search rankexpression { match-features: attribute(foo1).out attribute(bar1) match-features { attribute(foo2).out attribute(bar2).out } match-features { - attribute(foo3).out attribute(bar3).out } + attribute(foo3).out attribute(bar3).out + } match-features { attribute(foo4) myplus @@ -346,4 +349,16 @@ search rankexpression { } } + rank-profile withboolean { + function mytrue() { + expression: true + } + function myfalse() { + expression: false + } + function mybooleanexpression() { + expression: true + if(false, 3.0, 4.0) + } + } + } diff --git a/config-model/src/test/derived/rankexpression/summary.cfg b/config-model/src/test/derived/rankingexpression/summary.cfg index aec076aa8fe..aec076aa8fe 100644 --- a/config-model/src/test/derived/rankexpression/summary.cfg +++ b/config-model/src/test/derived/rankingexpression/summary.cfg diff --git a/config-model/src/test/derived/rankexpression/summarymap.cfg b/config-model/src/test/derived/rankingexpression/summarymap.cfg index bd92b36548c..bd92b36548c 100644 --- a/config-model/src/test/derived/rankexpression/summarymap.cfg +++ b/config-model/src/test/derived/rankingexpression/summarymap.cfg diff --git a/config-model/src/test/derived/types/index-info.cfg b/config-model/src/test/derived/types/index-info.cfg index 2db4ead180b..7f43cd67a6b 100644 --- a/config-model/src/test/derived/types/index-info.cfg +++ b/config-model/src/test/derived/types/index-info.cfg @@ -96,7 +96,7 @@ indexinfo[].command[].command "multivalue" indexinfo[].command[].indexname "tagfield" indexinfo[].command[].command "attribute" indexinfo[].command[].indexname "tagfield" -indexinfo[].command[].command "type tag" +indexinfo[].command[].command "type WeightedSet<string>" indexinfo[].command[].indexname "structfield.s1" indexinfo[].command[].command "index" indexinfo[].command[].indexname "structfield.s1" @@ -704,4 +704,4 @@ indexinfo[].command[].command "index" indexinfo[].command[].indexname "pst_sta_boldingoff_nomatch_tag_01" indexinfo[].command[].command "multivalue" indexinfo[].command[].indexname "pst_sta_boldingoff_nomatch_tag_01" -indexinfo[].command[].command "type tag" +indexinfo[].command[].command "type WeightedSet<string>" diff --git a/config-model/src/test/examples/attributesettings.sd b/config-model/src/test/examples/attributesettings.sd index 2b83f137b96..e7bb2062227 100644 --- a/config-model/src/test/examples/attributesettings.sd +++ b/config-model/src/test/examples/attributesettings.sd @@ -33,12 +33,17 @@ search attributesettings { indexing: attribute weightedset: remove-if-zero weightedset: create-if-nonexistent + attribute: fast-search + attribute: fast-access + attribute: paged } field f6 type weightedset<string> { weightedset: remove-if-zero indexing: attribute weightedset: create-if-nonexistent + attribute: enable-bit-vectors + attribute: enable-only-bit-vector } field f7 type weightedset<string> { diff --git a/config-model/src/test/examples/badparse.sd b/config-model/src/test/examples/badparse.sd new file mode 100755 index 00000000000..caeb1856e6b --- /dev/null +++ b/config-model/src/test/examples/badparse.sd @@ -0,0 +1,7 @@ +# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +search foo { + document foo { + something invalid here { + } + } +} diff --git a/config-model/src/test/examples/multiplesummaries.sd b/config-model/src/test/examples/multiplesummaries.sd index 07ab3c5a104..83e817718aa 100644 --- a/config-model/src/test/examples/multiplesummaries.sd +++ b/config-model/src/test/examples/multiplesummaries.sd @@ -28,6 +28,11 @@ search multiplesummaries { summary field3 type array<int> { } + # TODO disallow duplicates + summary field1 type weightedset<string> { + source: field1 + } + } } diff --git a/config-model/src/test/examples/structoutsideofdocument.sd b/config-model/src/test/examples/structoutsideofdocument.sd index 806351cd709..77bb3224816 100644 --- a/config-model/src/test/examples/structoutsideofdocument.sd +++ b/config-model/src/test/examples/structoutsideofdocument.sd @@ -1,7 +1,7 @@ # Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. search structoutsideofdocument { - # (will fail) + # (will fail with old parser) struct nalle { field foo type int {} @@ -13,3 +13,5 @@ search structoutsideofdocument { indexing: summary } } + +} diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java index 7b2ed2d7a7f..2a58618e11f 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java @@ -74,6 +74,14 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase { assertWeightedSet(schema, "f8", true, false); assertWeightedSet(schema, "f9", false, true); assertWeightedSet(schema, "f10", false, true); + + assertAttrSettings(schema, "f4", false, false, false); + assertAttrSettings(schema, "f5", true, true, true); + assertAttrSettings(schema, "f6", false, false, false); + assertAttrSettings(schema, "f7", false, false, false); + assertAttrSettings(schema, "f8", false, false, false); + assertAttrSettings(schema, "f9", false, false, false); + assertAttrSettings(schema, "f10", false, false, false); } private void assertWeightedSet(Schema schema, String name, boolean createIfNonExistent, boolean removeIfZero) { @@ -82,13 +90,21 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase { Attribute a4 = f4.getAttributes().get(f4.getName()); assertEquals(Attribute.Type.STRING, a4.getType()); assertEquals(Attribute.CollectionType.WEIGHTEDSET, a4.getCollectionType()); - assertFalse(a4.isHuge()); - assertFalse(a4.isFastSearch()); - assertFalse(a4.isFastAccess()); assertEquals(a4.isRemoveIfZero(), removeIfZero); assertEquals(a4.isCreateIfNonExistent(), createIfNonExistent); } + private void assertAttrSettings(Schema schema, String name, boolean fastAccess, boolean fastSearch, boolean paged) { + SDField f4 = (SDField) schema.getDocument().getField(name); + assertEquals(1, f4.getAttributes().size()); + Attribute a4 = f4.getAttributes().get(f4.getName()); + assertEquals(Attribute.Type.STRING, a4.getType()); + assertEquals(Attribute.CollectionType.WEIGHTEDSET, a4.getCollectionType()); + assertEquals(a4.isFastSearch(), fastSearch); + assertEquals(a4.isFastAccess(), fastAccess); + assertEquals(a4.isPaged(), paged); + } + @Test public void requireThatFastAccessCanBeSet() throws IOException, ParseException { Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/attributesettings.sd"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java index 0fcc6e09b02..1bf07aff9d5 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; +import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -12,8 +13,11 @@ import java.io.IOException; * @author bratseth */ public class MultipleSummariesTestCase extends AbstractSchemaTestCase { + @Test public void testArrayImporting() throws IOException, ParseException { - ApplicationBuilder.buildFromFile("src/test/examples/multiplesummaries.sd"); + var builder = new ApplicationBuilder(new TestProperties().setExperimentalSdParsing(true)); + builder.addSchemaFile("src/test/examples/multiplesummaries.sd"); + builder.build(true); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java index 94d25deb16a..e297beef026 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java @@ -192,14 +192,19 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { @Test public void testFunctionInliningWithReplacement() throws ParseException { + checkFunctionReplacement(false); + checkFunctionReplacement(true); + } + + public void checkFunctionReplacement(boolean useXPP) throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); MockDeployLogger deployLogger = new MockDeployLogger(); ApplicationBuilder builder = new ApplicationBuilder(MockApplicationPackage.createEmpty(), - new MockFileRegistry(), - deployLogger, - new TestProperties(), - rankProfileRegistry, - new QueryProfileRegistry()); + new MockFileRegistry(), + deployLogger, + new TestProperties().setExperimentalSdParsing(useXPP), + rankProfileRegistry, + new QueryProfileRegistry()); builder.addSchema( "search test {\n" + " document test { }\n" + @@ -219,8 +224,8 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { Schema s = builder.getSchema(); RankProfile test = rankProfileRegistry.get(s, "test").compile(new QueryProfileRegistry(), new ImportedMlModels()); assertEquals("foo(2)", test.getFirstPhaseRanking().getRoot().toString()); - assertTrue("Does not contain expected warning", deployLogger.contains("Function 'foo' replaces " + - "a previous function with the same name in rank profile 'test'")); + assertTrue("Does not contain expected warning", + deployLogger.contains("Function 'foo' is defined twice in rank profile 'test'")); } /** diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java index c27dd9dfdfb..32f82f44ad0 100755 --- a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java @@ -1,10 +1,13 @@ + // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; +import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.document.config.DocumenttypesConfig; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.searchdefinition.derived.Deriver; import com.yahoo.searchdefinition.parser.ParseException; +import org.junit.Ignore; import org.junit.Test; import java.io.IOException; import static org.junit.Assert.fail; @@ -27,15 +30,19 @@ public class StructTestCase extends AbstractSchemaTestCase { try { ApplicationBuilder.buildFromFile("src/test/examples/badstruct.sd"); fail("Should throw exception."); - } catch (ParseException expected) { + } catch (IllegalArgumentException|ParseException expected) { + System.err.println("As expected, with message: "+expected.getMessage()); // success } } @Test + @Ignore public void testStructAndDocumentWithSameNames() { try { DocumenttypesConfig.Builder dt = Deriver.getDocumentTypesConfig("src/test/examples/structanddocumentwithsamenames.sd"); + // while the above line may work, the config generated will fail. + // See also NameCollisionTestCase. } catch (Exception e) { fail("Should not have thrown exception " + e); } @@ -46,7 +53,17 @@ public class StructTestCase extends AbstractSchemaTestCase { */ @Test(expected = IllegalArgumentException.class) public void testStructOutsideDocumentIllegal() throws IOException, ParseException { - ApplicationBuilder.buildFromFile("src/test/examples/structoutsideofdocument.sd"); + var builder = new ApplicationBuilder(new TestProperties().setExperimentalSdParsing(false)); + builder.addSchemaFile("src/test/examples/structoutsideofdocument.sd"); + } + + /** + * Declaring a struct before a document should work + */ + @Test + public void testStructOutsideDocumentLegal() throws IOException, ParseException { + var builder = new ApplicationBuilder(new TestProperties().setExperimentalSdParsing(true)); + builder.addSchemaFile("src/test/examples/structoutsideofdocument.sd"); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java index 456efdb08ae..ad4ff4be4b3 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java @@ -100,6 +100,7 @@ public abstract class AbstractExportingTestCase extends AbstractSchemaTestCase { DeployLogger logger) throws IOException, ParseException { return assertCorrectDeriving(dirName, searchDefinitionName, new TestProperties(), logger); } + protected DerivedConfiguration assertCorrectDeriving(String dirName, TestProperties properties) throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AnnotationsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AnnotationsTestCase.java index b9f471f4cc7..65d6c15d3e2 100755 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AnnotationsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AnnotationsTestCase.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.derived; +import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -13,55 +14,74 @@ public class AnnotationsTestCase extends AbstractExportingTestCase { @Test public void requireThatStructRegistersIfOnlyUsedByAnnotation() throws IOException, ParseException { - assertCorrectDeriving("annotationsstruct"); + assertCorrectDeriving("annotationsstruct", + new TestProperties().setExperimentalSdParsing(true)); } @Test public void requireThatStructRegistersIfOnlyUsedAsArrayByAnnotation() throws IOException, ParseException { - assertCorrectDeriving("annotationsstructarray"); + assertCorrectDeriving("annotationsstructarray", + new TestProperties().setExperimentalSdParsing(true)); } @Test public void testSimpleAnnotationDeriving() throws IOException, ParseException { - assertCorrectDeriving("annotationssimple"); + assertCorrectDeriving("annotationssimple", + new TestProperties().setExperimentalSdParsing(true)); } @Test public void testAnnotationDerivingWithImplicitStruct() throws IOException, ParseException { - assertCorrectDeriving("annotationsimplicitstruct"); + assertCorrectDeriving("annotationsimplicitstruct", + new TestProperties().setExperimentalSdParsing(true)); } @Test public void testAnnotationDerivingInheritance() throws IOException, ParseException { - assertCorrectDeriving("annotationsinheritance"); + assertCorrectDeriving("annotationsinheritance", + new TestProperties().setExperimentalSdParsing(true)); } @Test public void testAnnotationDerivingInheritance2() throws IOException, ParseException { - assertCorrectDeriving("annotationsinheritance2"); + assertCorrectDeriving("annotationsinheritance2", + new TestProperties().setExperimentalSdParsing(true)); } @Test public void testSimpleReference() throws IOException, ParseException { - assertCorrectDeriving("annotationsreference"); + assertCorrectDeriving("annotationsreference", + new TestProperties().setExperimentalSdParsing(true)); } @Test public void testAdvancedReference() throws IOException, ParseException { - assertCorrectDeriving("annotationsreference2"); + assertCorrectDeriving("annotationsreference2", + new TestProperties().setExperimentalSdParsing(true)); } @Test public void testAnnotationsPolymorphy() throws IOException, ParseException { - assertCorrectDeriving("annotationspolymorphy"); + assertCorrectDeriving("annotationspolymorphy", + new TestProperties().setExperimentalSdParsing(true)); } /** * An annotation declared before document {} won't work, no doc type to add it to. */ @Test(expected = IllegalArgumentException.class) - public void testAnnotationOutsideOfDocumment() throws IOException, ParseException { - assertCorrectDeriving("annotationsoutsideofdocument"); + public void testAnnotationOutsideOfDocumentOld() throws IOException, ParseException { + assertCorrectDeriving("annotationsoutsideofdocument", + new TestProperties().setExperimentalSdParsing(false)); + } + + /** + * An annotation declared before document {} should work. + */ + @Test + public void testAnnotationOutsideOfDocumentNew() throws IOException, ParseException { + assertCorrectDeriving("annotationsoutsideofdocument", + new TestProperties().setExperimentalSdParsing(true)); } } 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 719d353f03a..412206d34ed 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 @@ -25,7 +25,7 @@ public class ExportingTestCase extends AbstractExportingTestCase { @Test public void testPositionArray() throws IOException, ParseException { assertCorrectDeriving("position_array", - new TestProperties().setUseV8GeoPositions(true)); + new TestProperties().setExperimentalSdParsing(true).setUseV8GeoPositions(true)); } @Test @@ -49,7 +49,7 @@ public class ExportingTestCase extends AbstractExportingTestCase { @Test public void testPositionSummary() throws IOException, ParseException { assertCorrectDeriving("position_summary", - new TestProperties().setUseV8GeoPositions(true)); + new TestProperties().setExperimentalSdParsing(true).setUseV8GeoPositions(true)); } @Test @@ -108,14 +108,14 @@ public class ExportingTestCase extends AbstractExportingTestCase { } @Test - public void testRankExpression() throws IOException, ParseException { - assertCorrectDeriving("rankexpression"); + public void testRankingExpression() throws IOException, ParseException { + assertCorrectDeriving("rankingexpression"); } @Test public void testAvoidRenamingRankingExpression() throws IOException, ParseException { assertCorrectDeriving("renamedfeatures", "foo", - new TestProperties().setAvoidRenamingSummaryFeatures(true), + new TestProperties().setExperimentalSdParsing(true).setAvoidRenamingSummaryFeatures(true), new TestableDeployLogger()); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ImportedFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ImportedFieldsTestCase.java index 34354612d04..5dcb9e4ca01 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ImportedFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ImportedFieldsTestCase.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.derived; +import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -18,7 +19,16 @@ public class ImportedFieldsTestCase extends AbstractExportingTestCase { @Test public void configs_for_imported_struct_fields_are_derived() throws IOException, ParseException { - assertCorrectDeriving("imported_struct_fields", "child", new TestableDeployLogger()); + assertCorrectDeriving("imported_struct_fields", "child", + new TestProperties().setExperimentalSdParsing(false), + new TestableDeployLogger()); + } + + @Test + public void configs_for_imported_struct_fields_are_derived_new() throws IOException, ParseException { + assertCorrectDeriving("imported_struct_fields", "child", + new TestProperties().setExperimentalSdParsing(true), + new TestableDeployLogger()); } @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/MultipleSummariesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/MultipleSummariesTestCase.java index 0e6d7b8442f..b13e88f5f1f 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/MultipleSummariesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/MultipleSummariesTestCase.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.derived; +import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -14,6 +15,13 @@ import java.io.IOException; public class MultipleSummariesTestCase extends AbstractExportingTestCase { @Test public void testMultipleSummaries() throws IOException, ParseException { - assertCorrectDeriving("multiplesummaries"); + assertCorrectDeriving("multiplesummaries", + new TestProperties().setExperimentalSdParsing(false)); + } + + @Test + public void testMultipleSummariesNew() throws IOException, ParseException { + assertCorrectDeriving("multiplesummaries", + new TestProperties().setExperimentalSdParsing(true)); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/NameCollisionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/NameCollisionTestCase.java index 5fce5c06943..70f6187be12 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/NameCollisionTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/NameCollisionTestCase.java @@ -2,7 +2,12 @@ package com.yahoo.searchdefinition.derived; +import com.yahoo.config.model.deploy.TestProperties; +import com.yahoo.document.DocumentTypeManager; +import com.yahoo.searchdefinition.ApplicationBuilder; + import org.junit.Test; +import static org.junit.Assert.assertThrows; /** * Verifies that a struct in a document type is preferred over another document type @@ -14,7 +19,21 @@ public class NameCollisionTestCase extends AbstractExportingTestCase { @Test public void testNameCollision() throws Exception { - assertCorrectDeriving("namecollision", "collisionstruct", new TestableDeployLogger()); + var ex = assertThrows(IllegalArgumentException.class, () -> { + assertCorrectDeriving("namecollision", "collisionstruct", + new TestProperties().setExperimentalSdParsing(false), + new TestableDeployLogger()); + var docman = DocumentTypeManager.fromFile("temp/namecollision/documentmanager.cfg"); + }); + System.err.println("MSG 1: "+ex.getClass()+" -> "+ex.getMessage()); + var ey = assertThrows(IllegalArgumentException.class, () -> { + assertCorrectDeriving("namecollision", "collisionstruct", + new TestProperties().setExperimentalSdParsing(true), + new TestableDeployLogger()); + var docman = DocumentTypeManager.fromFile("temp/namecollision/documentmanager.cfg"); + }); + System.err.println("MSG 2: "+ey.getMessage()); + } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/parser/ConvertIntermediateTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/parser/ConvertIntermediateTestCase.java index 264481cb3ec..127f5184c4c 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/parser/ConvertIntermediateTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/parser/ConvertIntermediateTestCase.java @@ -26,7 +26,6 @@ public class ConvertIntermediateTestCase { var collection = new IntermediateCollection(); ParsedSchema schema = collection.addSchemaFromString(input); assertEquals("foo", schema.getDocument().name()); - collection.resolveInternalConnections(); var docMan = new DocumentTypeManager(); var converter = new ConvertSchemaCollection(collection, docMan); converter.convertTypes(); @@ -41,7 +40,6 @@ public class ConvertIntermediateTestCase { collection.addSchemaFromFile("src/test/derived/deriver/grandparent.sd"); collection.addSchemaFromFile("src/test/derived/deriver/parent.sd"); assertEquals(collection.getParsedSchemas().size(), 3); - collection.resolveInternalConnections(); var docMan = new DocumentTypeManager(); var converter = new ConvertSchemaCollection(collection, docMan); converter.convertTypes(); @@ -60,7 +58,6 @@ public class ConvertIntermediateTestCase { collection.addSchemaFromFile("src/test/converter/other.sd"); collection.addSchemaFromFile("src/test/converter/parent.sd"); collection.addSchemaFromFile("src/test/converter/grandparent.sd"); - collection.resolveInternalConnections(); var docMan = new DocumentTypeManager(); var converter = new ConvertSchemaCollection(collection, docMan); converter.convertTypes(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateCollectionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateCollectionTestCase.java index cd78f1faeb2..e29e4833856 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateCollectionTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateCollectionTestCase.java @@ -36,6 +36,20 @@ public class IntermediateCollectionTestCase { } @Test + public void names_may_differ() throws Exception { + String input = joinLines + ("schema foo_search {", + " document foo {", + " }", + "}"); + var collection = new IntermediateCollection(); + ParsedSchema schema = collection.addSchemaFromString(input); + assertEquals("foo_search", schema.name()); + assertTrue(schema.hasDocument()); + assertEquals("foo", schema.getDocument().name()); + } + + @Test public void can_add_schema_files() throws Exception { var collection = new IntermediateCollection(); collection.addSchemaFromFile("src/test/derived/deriver/child.sd"); @@ -127,16 +141,16 @@ public class IntermediateCollectionTestCase { public void bad_parse_throws() throws Exception { var collection = new IntermediateCollection(); var ex = assertThrows(ParseException.class, () -> - collection.addSchemaFromFile("src/test/examples/structoutsideofdocument.sd")); - assertTrue(ex.getMessage().startsWith("Failed parsing schema from src/test/examples/structoutsideofdocument.sd: Encountered")); + collection.addSchemaFromFile("src/test/examples/badparse.sd")); + assertTrue(ex.getMessage().startsWith("Failed parsing schema from src/test/examples/badparse.sd: Encountered")); ex = assertThrows(ParseException.class, () -> - collection.addSchemaFromReader(readerOf("src/test/examples/structoutsideofdocument.sd"))); - assertTrue(ex.getMessage().startsWith("Failed parsing schema from src/test/examples/structoutsideofdocument.sd: Encountered")); + collection.addSchemaFromReader(readerOf("src/test/examples/badparse.sd"))); + assertTrue(ex.getMessage().startsWith("Failed parsing schema from src/test/examples/badparse.sd: Encountered")); collection.addSchemaFromFile("src/test/derived/rankprofilemodularity/test.sd"); collection.addRankProfileFile("test", "src/test/derived/rankprofilemodularity/test/outside_schema1.profile"); ex = assertThrows(ParseException.class, () -> - collection.addRankProfileFile("test", "src/test/examples/structoutsideofdocument.sd")); - assertTrue(ex.getMessage().startsWith("Failed parsing rank-profile from src/test/examples/structoutsideofdocument.sd: Encountered")); + collection.addRankProfileFile("test", "src/test/examples/badparse.sd")); + assertTrue(ex.getMessage().startsWith("Failed parsing rank-profile from src/test/examples/badparse.sd: Encountered")); } @Test @@ -167,7 +181,7 @@ public class IntermediateCollectionTestCase { assertEquals(collection.getParsedSchemas().size(), 3); var ex = assertThrows(IllegalArgumentException.class, () -> collection.resolveInternalConnections()); - assertTrue(ex.getMessage().startsWith("Inheritance cycle for schemas: ")); + assertTrue(ex.getMessage().startsWith("Inheritance/reference cycle for schemas: ")); } @Test @@ -180,7 +194,7 @@ public class IntermediateCollectionTestCase { var ex = assertThrows(IllegalArgumentException.class, () -> collection.resolveInternalConnections()); System.err.println("ex: "+ex.getMessage()); - assertTrue(ex.getMessage().startsWith("Inheritance cycle for documents: ")); + assertTrue(ex.getMessage().startsWith("Inheritance/reference cycle for documents: ")); } @Test @@ -194,4 +208,30 @@ public class IntermediateCollectionTestCase { assertEquals("document foo inherits from unavailable document bar", ex.getMessage()); } + @Test + public void can_detect_document_reference_cycle() throws Exception { + var collection = new IntermediateCollection(); + collection.addSchemaFromString("schema foo { document foo { field oneref type reference<bar> {} } }"); + collection.addSchemaFromString("schema bar { document bar { field tworef type reference<foo> {} } }"); + assertEquals(collection.getParsedSchemas().size(), 2); + var ex = assertThrows(IllegalArgumentException.class, () -> + collection.resolveInternalConnections()); + System.err.println("ex: "+ex.getMessage()); + assertTrue(ex.getMessage().startsWith("Inheritance/reference cycle for documents: ")); + } + + @Test + public void can_detect_cycles_with_reference() throws Exception { + var collection = new IntermediateCollection(); + collection.addSchemaFromString("schema foo { document foodoc inherits bardoc {} }"); + collection.addSchemaFromString("schema bar { document bardoc { field myref type reference<qux> { } } }"); + collection.addSchemaFromString("schema qux inherits foo { document qux inherits foodoc {} }"); + assertEquals(collection.getParsedSchemas().size(), 3); + var ex = assertThrows(IllegalArgumentException.class, () -> + collection.resolveInternalConnections()); + System.err.println("ex: "+ex.getMessage()); + assertTrue(ex.getMessage().startsWith("Inheritance/reference cycle for documents: ")); + } + + } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java index 4e212ccd574..8bd04af8c54 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java @@ -22,8 +22,12 @@ public class IntermediateParserTestCase { var deployLogger = new BaseDeployLogger(); var modelProperties = new TestProperties(); var stream = new SimpleCharStream(input); - var parser = new IntermediateParser(stream, deployLogger, modelProperties); - return parser.schema(); + try { + var parser = new IntermediateParser(stream, deployLogger, modelProperties); + return parser.schema(); + } catch (ParseException pe) { + throw new ParseException(stream.formatException(pe.getMessage())); + } } ParsedSchema parseFile(String fileName) throws Exception { @@ -174,7 +178,7 @@ public class IntermediateParserTestCase { checkFileParses("src/test/derived/position_summary/position_summary.sd"); checkFileParses("src/test/derived/predicate_attribute/predicate_attribute.sd"); checkFileParses("src/test/derived/prefixexactattribute/prefixexactattribute.sd"); - checkFileParses("src/test/derived/rankexpression/rankexpression.sd"); + checkFileParses("src/test/derived/rankingexpression/rankexpression.sd"); checkFileParses("src/test/derived/rankprofileinheritance/child.sd"); checkFileParses("src/test/derived/rankprofileinheritance/parent1.sd"); checkFileParses("src/test/derived/rankprofileinheritance/parent2.sd"); @@ -208,9 +212,9 @@ public class IntermediateParserTestCase { checkFileParses("src/test/derived/uri_wset/uri_wset.sd"); checkFileParses("src/test/examples/arrays.sd"); checkFileParses("src/test/examples/arraysweightedsets.sd"); + checkFileParses("src/test/examples/attributeposition.sd"); checkFileParses("src/test/examples/attributesettings.sd"); checkFileParses("src/test/examples/attributesexactmatch.sd"); - checkFileParses("src/test/examples/badstruct.sd"); checkFileParses("src/test/examples/casing.sd"); checkFileParses("src/test/examples/comment.sd"); checkFileParses("src/test/examples/documentidinsummary.sd"); @@ -252,7 +256,6 @@ public class IntermediateParserTestCase { checkFileParses("src/test/examples/stemmingdefault.sd"); checkFileParses("src/test/examples/stemmingsetting.sd"); checkFileParses("src/test/examples/strange.sd"); - checkFileParses("src/test/examples/structanddocumentwithsamenames.sd"); checkFileParses("src/test/examples/struct.sd"); checkFileParses("src/test/examples/summaryfieldcollision.sd"); checkFileParses("src/test/examples/weightedset-summaryto.sd"); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/ml/OnnxModelProbeTest.java b/config-model/src/test/java/com/yahoo/vespa/model/ml/OnnxModelProbeTest.java deleted file mode 100644 index 6c4c919a229..00000000000 --- a/config-model/src/test/java/com/yahoo/vespa/model/ml/OnnxModelProbeTest.java +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.ml; - -import com.yahoo.config.application.api.ApplicationPackage; -import com.yahoo.config.model.application.provider.FilesApplicationPackage; -import com.yahoo.io.IOUtils; -import com.yahoo.path.Path; -import com.yahoo.tensor.TensorType; -import org.junit.Test; - -import java.io.IOException; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -public class OnnxModelProbeTest { - - @Test - public void testProbedOutputTypes() throws IOException { - - Path appDir = Path.fromString("src/test/cfg/application/onnx_probe"); - Path storedAppDir = appDir.append("copy"); - try { - FilesApplicationPackage app = FilesApplicationPackage.fromFile(appDir.toFile()); - Path modelPath = Path.fromString("files/dynamic_model.onnx"); - String output = "out"; - Map<String, TensorType> inputTypes = Map.of( - "input1", TensorType.fromSpec("tensor<float>(d0[1],d1[2])"), - "input2", TensorType.fromSpec("tensor<float>(d0[1],d1[2])")); - TensorType expected = TensorType.fromSpec("tensor<float>(d0[1],d1[2],d2[2])"); - - // Can't test model probing directly as 'vespa-analyze-onnx-model' is not available - TensorType outputType = OnnxModelProbe.probeModel(app, modelPath, output, inputTypes); - assertEquals(outputType, TensorType.empty); - - OnnxModelProbe.writeProbedOutputType(app, modelPath, output, inputTypes, expected); - - // Test loading from generated info - storedAppDir.toFile().mkdirs(); - IOUtils.copyDirectory(appDir.append(ApplicationPackage.MODELS_GENERATED_DIR).toFile(), - storedAppDir.append(ApplicationPackage.MODELS_GENERATED_DIR).toFile()); - app = FilesApplicationPackage.fromFile(storedAppDir.toFile()); - outputType = OnnxModelProbe.probeModel(app, modelPath, output, inputTypes); - assertEquals(outputType, expected); - - } finally { - IOUtils.recursiveDeleteDir(appDir.append(ApplicationPackage.MODELS_GENERATED_DIR).toFile()); - IOUtils.recursiveDeleteDir(storedAppDir.toFile()); - } - } - -} |