summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2020-08-31 10:32:50 +0000
committerHåvard Pettersen <havardpe@oath.com>2020-09-01 12:45:13 +0000
commit3440f424ab11d8d8810b6f9785e6a8fad7271fe1 (patch)
treeb769b0acf1485b4b18fd51efe556c8a6b583c7bf /searchcore/src/tests
parent3b8f7fdff4872bd010286753f6072ec492f14a48 (diff)
handle onnx models config
Diffstat (limited to 'searchcore/src/tests')
-rw-r--r--searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp2
-rw-r--r--searchcore/src/tests/proton/documentdb/documentdbconfig/documentdbconfig_test.cpp9
-rw-r--r--searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp6
-rw-r--r--searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp15
-rw-r--r--searchcore/src/tests/proton/matching/matching_test.cpp2
-rw-r--r--searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp5
-rw-r--r--searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp9
7 files changed, 45 insertions, 3 deletions
diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp
index 1da35c9f5c3..b2903f00226 100644
--- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp
@@ -646,6 +646,7 @@ TEST("require that maintenance controller should change if some config has chang
TEST_DO(assertMaintenanceControllerShouldChange(CCR().setRankProfilesChanged(true)));
TEST_DO(assertMaintenanceControllerShouldChange(CCR().setRankingConstantsChanged(true)));
+ TEST_DO(assertMaintenanceControllerShouldChange(CCR().setOnnxModelsChanged(true)));
TEST_DO(assertMaintenanceControllerShouldChange(CCR().setIndexschemaChanged(true)));
TEST_DO(assertMaintenanceControllerShouldChange(CCR().setAttributesChanged(true)));
TEST_DO(assertMaintenanceControllerShouldChange(CCR().setSummaryChanged(true)));
@@ -692,6 +693,7 @@ TEST("require that subdbs should change if relevant config changed")
TEST_DO(assertSubDbsShouldChange(CCR().setVisibilityDelayChanged(true)));
TEST_DO(assertSubDbsShouldChange(CCR().setRankProfilesChanged(true)));
TEST_DO(assertSubDbsShouldChange(CCR().setRankingConstantsChanged(true)));
+ TEST_DO(assertSubDbsShouldChange(CCR().setOnnxModelsChanged(true)));
TEST_DO(assertSubDbsShouldChange(CCR().setSchemaChanged(true)));
}
diff --git a/searchcore/src/tests/proton/documentdb/documentdbconfig/documentdbconfig_test.cpp b/searchcore/src/tests/proton/documentdb/documentdbconfig/documentdbconfig_test.cpp
index a2b824b88ba..aed01ca0192 100644
--- a/searchcore/src/tests/proton/documentdb/documentdbconfig/documentdbconfig_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/documentdbconfig/documentdbconfig_test.cpp
@@ -17,6 +17,7 @@ using namespace search::index;
using namespace search;
using namespace vespa::config::search;
using proton::matching::RankingConstants;
+using proton::matching::OnnxModels;
using std::make_shared;
using std::shared_ptr;
using document::config_builder::DocumenttypesConfigBuilderHelper;
@@ -68,6 +69,11 @@ public:
_builder.rankingConstants(make_shared<RankingConstants>(constants));
return *this;
}
+ MyConfigBuilder &addOnnxModel() {
+ OnnxModels::Vector models = {{"my_model_name", "my_model_file"}};
+ _builder.onnxModels(make_shared<OnnxModels>(models));
+ return *this;
+ }
MyConfigBuilder &addImportedField() {
ImportedFieldsConfigBuilder builder;
builder.attribute.resize(1);
@@ -132,6 +138,7 @@ struct Fixture {
fullCfg = MyConfigBuilder(4, schema, repo).addAttribute().
addRankProfile().
addRankingConstant().
+ addOnnxModel().
addImportedField().
addSummary(true).
addSummarymap().
@@ -166,12 +173,14 @@ struct DelayAttributeAspectFixture {
attrCfg = MyConfigBuilder(4, schema, makeDocTypeRepo(true)).addAttribute().
addRankProfile().
addRankingConstant().
+ addOnnxModel().
addImportedField().
addSummary(true).
addSummarymap().
build();
noAttrCfg = MyConfigBuilder(4, schema, makeDocTypeRepo(hasDocField)).addRankProfile().
addRankingConstant().
+ addOnnxModel().
addImportedField().
addSummary(hasDocField).
build();
diff --git a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp
index 2782117d8ae..2352fda65a0 100644
--- a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp
@@ -28,6 +28,7 @@ using namespace vespa::config::search;
using namespace std::chrono_literals;
using vespa::config::content::core::BucketspacesConfig;
using proton::matching::RankingConstants;
+using proton::matching::OnnxModels;
typedef DocumentDBConfigHelper DBCM;
typedef DocumentDBConfig::DocumenttypesConfigSP DocumenttypesConfigSP;
@@ -77,7 +78,9 @@ assertEqualSnapshot(const DocumentDBConfig &exp, const DocumentDBConfig &act)
{
EXPECT_TRUE(exp.getRankProfilesConfig() == act.getRankProfilesConfig());
EXPECT_TRUE(exp.getRankingConstants() == act.getRankingConstants());
+ EXPECT_TRUE(exp.getOnnxModels() == act.getOnnxModels());
EXPECT_EQUAL(0u, exp.getRankingConstants().size());
+ EXPECT_EQUAL(0u, exp.getOnnxModels().size());
EXPECT_TRUE(exp.getIndexschemaConfig() == act.getIndexschemaConfig());
EXPECT_TRUE(exp.getAttributesConfig() == act.getAttributesConfig());
EXPECT_TRUE(exp.getSummaryConfig() == act.getSummaryConfig());
@@ -105,6 +108,9 @@ addConfigsThatAreNotSavedToDisk(const DocumentDBConfig &cfg)
RankingConstants::Vector constants = {{"my_name", "my_type", "my_path"}};
builder.rankingConstants(std::make_shared<RankingConstants>(constants));
+ OnnxModels::Vector models = {{"my_model_name", "my_model_file"}};
+ builder.onnxModels(std::make_shared<OnnxModels>(models));
+
ImportedFieldsConfigBuilder importedFields;
importedFields.attribute.resize(1);
importedFields.attribute.back().name = "my_name";
diff --git a/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp b/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp
index 932ab6f4d14..508a60480d0 100644
--- a/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp
+++ b/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp
@@ -14,6 +14,13 @@ using search::index::schema::DataType;
using vespalib::eval::ConstantValue;
using SIAF = Schema::ImportedAttributeField;
+OnnxModels make_models() {
+ OnnxModels::Vector list;
+ list.emplace_back("model1", "path1");
+ list.emplace_back("model2", "path2");
+ return OnnxModels(list);
+}
+
struct MyConstantValueRepo : public IConstantValueRepo {
virtual ConstantValue::UP getConstant(const vespalib::string &) const override {
return ConstantValue::UP();
@@ -42,7 +49,7 @@ struct Fixture {
Fixture(Schema::UP schema_)
: repo(),
schema(std::move(schema_)),
- env(7, *schema, Properties(), repo)
+ env(7, *schema, Properties(), repo, make_models())
{
}
const FieldInfo *assertField(size_t idx,
@@ -97,4 +104,10 @@ TEST_F("require that imported attribute fields are extracted in index environmen
EXPECT_EQUAL("[documentmetastore]", f.env.getField(2)->name());
}
+TEST_F("require that onnx model paths can be obtained", Fixture(buildEmptySchema())) {
+ EXPECT_EQUAL(f1.env.getOnnxModelFullPath("model1").value(), vespalib::string("path1"));
+ EXPECT_EQUAL(f1.env.getOnnxModelFullPath("model2").value(), vespalib::string("path2"));
+ EXPECT_FALSE(f1.env.getOnnxModelFullPath("model3").has_value());
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp
index 9d5b67af81c..0ea63bce859 100644
--- a/searchcore/src/tests/proton/matching/matching_test.cpp
+++ b/searchcore/src/tests/proton/matching/matching_test.cpp
@@ -278,7 +278,7 @@ struct MyWorld {
}
Matcher::SP createMatcher() {
- return std::make_shared<Matcher>(schema, config, clock, queryLimiter, constantValueRepo, 0);
+ return std::make_shared<Matcher>(schema, config, clock, queryLimiter, constantValueRepo, OnnxModels(), 0);
}
struct MySearchHandler : ISearchHandler {
diff --git a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp
index a947074a917..1e64a8f4ecb 100644
--- a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp
+++ b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp
@@ -8,6 +8,7 @@
#include <vespa/searchcore/proton/server/i_proton_configurer.h>
#include <vespa/searchcore/proton/common/hw_info.h>
#include <vespa/searchcore/config/config-ranking-constants.h>
+#include <vespa/searchcore/config/config-onnx-models.h>
#include <vespa/searchsummary/config/config-juniperrc.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/fileacquirer/config-filedistributorrpc.h>
@@ -45,6 +46,7 @@ struct DoctypeFixture {
AttributesConfigBuilder attributesBuilder;
RankProfilesConfigBuilder rankProfilesBuilder;
RankingConstantsConfigBuilder rankingConstantsBuilder;
+ OnnxModelsConfigBuilder onnxModelsBuilder;
IndexschemaConfigBuilder indexschemaBuilder;
SummaryConfigBuilder summaryBuilder;
SummarymapConfigBuilder summarymapBuilder;
@@ -100,6 +102,7 @@ struct ConfigTestFixture {
set.addBuilder(db.configid, &fixture->attributesBuilder);
set.addBuilder(db.configid, &fixture->rankProfilesBuilder);
set.addBuilder(db.configid, &fixture->rankingConstantsBuilder);
+ set.addBuilder(db.configid, &fixture->onnxModelsBuilder);
set.addBuilder(db.configid, &fixture->indexschemaBuilder);
set.addBuilder(db.configid, &fixture->summaryBuilder);
set.addBuilder(db.configid, &fixture->summarymapBuilder);
@@ -253,7 +256,7 @@ TEST_FF("require that documentdb config manager subscribes for config",
DocumentDBConfigManager(f1.configId + "/typea", "typea")) {
f1.addDocType("typea");
const ConfigKeySet keySet(f2.createConfigKeySet());
- ASSERT_EQUAL(8u, keySet.size());
+ ASSERT_EQUAL(9u, keySet.size());
ASSERT_TRUE(f1.configEqual("typea", getDocumentDBConfig(f1, f2)));
}
diff --git a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp
index 83706d966ae..6190177ac9d 100644
--- a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp
+++ b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp
@@ -19,6 +19,7 @@
#include <vespa/searchcore/proton/server/i_proton_disk_layout.h>
#include <vespa/searchsummary/config/config-juniperrc.h>
#include <vespa/searchcore/config/config-ranking-constants.h>
+#include <vespa/searchcore/config/config-onnx-models.h>
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/searchcommon/common/schemaconfigurer.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
@@ -44,12 +45,14 @@ using std::map;
using search::index::Schema;
using search::index::SchemaBuilder;
using proton::matching::RankingConstants;
+using proton::matching::OnnxModels;
struct DBConfigFixture {
using UP = std::unique_ptr<DBConfigFixture>;
AttributesConfigBuilder _attributesBuilder;
RankProfilesConfigBuilder _rankProfilesBuilder;
RankingConstantsConfigBuilder _rankingConstantsBuilder;
+ OnnxModelsConfigBuilder _onnxModelsBuilder;
IndexschemaConfigBuilder _indexschemaBuilder;
SummaryConfigBuilder _summaryBuilder;
SummarymapConfigBuilder _summarymapBuilder;
@@ -70,6 +73,11 @@ struct DBConfigFixture {
return std::make_shared<RankingConstants>();
}
+ OnnxModels::SP buildOnnxModels()
+ {
+ return std::make_shared<OnnxModels>();
+ }
+
DocumentDBConfig::SP getConfig(int64_t generation,
std::shared_ptr<DocumenttypesConfig> documentTypes,
std::shared_ptr<const DocumentTypeRepo> repo,
@@ -80,6 +88,7 @@ struct DBConfigFixture {
(generation,
std::make_shared<RankProfilesConfig>(_rankProfilesBuilder),
buildRankingConstants(),
+ buildOnnxModels(),
std::make_shared<IndexschemaConfig>(_indexschemaBuilder),
std::make_shared<AttributesConfig>(_attributesBuilder),
std::make_shared<SummaryConfig>(_summaryBuilder),