diff --git a/searchcore/src/tests/proton/documentdb/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/CMakeLists.txt index 8deea49faf5f..8a89347babea 100644 --- a/searchcore/src/tests/proton/documentdb/CMakeLists.txt +++ b/searchcore/src/tests/proton/documentdb/CMakeLists.txt @@ -26,7 +26,6 @@ vespa_add_test(NAME searchcore_documentdb_test_app COMMAND searchcore_documentdb vespa_add_executable(searchcore_proton_documentdb_vespatest_test_app TEST SOURCES vespatest_runner.cpp - documentdbconfig_test.cpp documentdbconfigscout_test.cpp job_tracked_maintenance_job_test.cpp maintenancecontroller_test.cpp @@ -49,6 +48,7 @@ vespa_add_executable(searchcore_proton_documentdb_gtest_test_app TEST document_scan_iterator_test.cpp document_subdbs_test.cpp documentbucketmover_test.cpp + documentdbconfig_test.cpp documentmover_test.cpp executor_threading_service_test.cpp feedview_test.cpp diff --git a/searchcore/src/tests/proton/documentdb/documentdbconfig_test.cpp b/searchcore/src/tests/proton/documentdb/documentdbconfig_test.cpp index fbbf6097b062..320952aaa1ba 100644 --- a/searchcore/src/tests/proton/documentdb/documentdbconfig_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdbconfig_test.cpp @@ -3,13 +3,13 @@ #include #include #include -#include -#include -#include #include #include #include #include +#include +#include +#include using namespace document; using namespace proton; @@ -26,7 +26,7 @@ using document::config_builder::Struct; using ConfigSP = shared_ptr; -namespace documentdbconfig_test { +inline namespace documentdbconfig_test { namespace { @@ -131,32 +131,40 @@ struct Fixture { ConfigSP fullCfg; ConfigSP replayCfg; ConfigSP nullCfg; - Fixture() - : basic_schema(make_shared()), - full_schema(make_shared()), - repo(make_shared()), - basicCfg(), - fullCfg(), - replayCfg(), - nullCfg() - { - basic_schema->addAttributeField(Schema::AttributeField("my_attribute", schema::DataType::INT32)); - full_schema->addAttributeField(Schema::AttributeField("my_attribute", schema::DataType::INT32)); - basicCfg = MyConfigBuilder(4, basic_schema, repo).addAttribute().addSummary(false, false).build(); - fullCfg = MyConfigBuilder(4, full_schema, repo).addAttribute(). - addRankProfile(). - addRankingConstant(). - addRankingExpression(). - addOnnxModel(). - addImportedField(). - addSummary(true, true). - build(); - replayCfg = DocumentDBConfig::makeReplayConfig(fullCfg); - } + Fixture(); + ~Fixture(); }; -TEST_F("require that makeReplayConfig() drops unneeded configs", Fixture) +Fixture::Fixture() + : basic_schema(make_shared()), + full_schema(make_shared()), + repo(make_shared()), + basicCfg(), + fullCfg(), + replayCfg(), + nullCfg() +{ + basic_schema->addAttributeField(Schema::AttributeField("my_attribute", schema::DataType::INT32)); + full_schema->addAttributeField(Schema::AttributeField("my_attribute", schema::DataType::INT32)); + basicCfg = MyConfigBuilder(4, basic_schema, repo).addAttribute().addSummary(false, false).build(); + fullCfg = MyConfigBuilder(4, full_schema, repo).addAttribute(). + addRankProfile(). + addRankingConstant(). + addRankingExpression(). + addOnnxModel(). + addImportedField(). + addSummary(true, true). + build(); + replayCfg = DocumentDBConfig::makeReplayConfig(fullCfg); +} + +Fixture::~Fixture() = default; + +} + +TEST(DocumentDBConfigTest, require_that_makeReplayConfig_drops_unneeded_configs) { + Fixture f; using DDBC = DocumentDBConfig; EXPECT_FALSE(*f.basicCfg == *f.fullCfg); EXPECT_TRUE(*f.basicCfg == *f.replayCfg); @@ -169,31 +177,15 @@ TEST_F("require that makeReplayConfig() drops unneeded configs", Fixture) EXPECT_TRUE(DDBC::preferOriginalConfig(f.nullCfg).get() == nullptr); } +inline namespace documentdbconfig_test { + struct DelayAttributeAspectFixture { std::shared_ptr schema; ConfigSP attrCfg; ConfigSP noAttrCfg; - explicit DelayAttributeAspectFixture(bool hasDocField) - : schema(make_shared()), - attrCfg(), - noAttrCfg() - { - attrCfg = MyConfigBuilder(4, schema, makeDocTypeRepo(true)).addAttribute(). - addRankProfile(). - addRankingConstant(). - addRankingExpression(). - addOnnxModel(). - addImportedField(). - addSummary(true, true). - build(); - noAttrCfg = MyConfigBuilder(4, schema, makeDocTypeRepo(hasDocField)).addRankProfile(). - addRankingConstant(). - addRankingExpression(). - addOnnxModel(). - addImportedField(). - addSummary(hasDocField, false). - build(); - } + + explicit DelayAttributeAspectFixture(bool hasDocField); + ~DelayAttributeAspectFixture(); void assertDelayedConfig(const DocumentDBConfig &testCfg) { EXPECT_FALSE(noAttrCfg->getAttributesConfig() == testCfg.getAttributesConfig()); @@ -211,16 +203,42 @@ struct DelayAttributeAspectFixture { } }; -TEST_F("require that makeDelayedAttributeAspectConfig works, field remains when attribute removed", DelayAttributeAspectFixture(true)) +DelayAttributeAspectFixture::DelayAttributeAspectFixture(bool hasDocField) + : schema(make_shared()), + attrCfg(), + noAttrCfg() { - auto delayedRemove = DocumentDBConfig::makeDelayedAttributeAspectConfig(f.noAttrCfg, *f.attrCfg); - TEST_DO(f.assertDelayedConfig(*delayedRemove)); + attrCfg = MyConfigBuilder(4, schema, makeDocTypeRepo(true)).addAttribute(). + addRankProfile(). + addRankingConstant(). + addRankingExpression(). + addOnnxModel(). + addImportedField(). + addSummary(true, true). + build(); + noAttrCfg = MyConfigBuilder(4, schema, makeDocTypeRepo(hasDocField)).addRankProfile(). + addRankingConstant(). + addRankingExpression(). + addOnnxModel(). + addImportedField(). + addSummary(hasDocField, false). + build(); +} + +DelayAttributeAspectFixture::~DelayAttributeAspectFixture() = default; + } -TEST_F("require that makeDelayedAttributeAspectConfig works, field removed with attribute", DelayAttributeAspectFixture(false)) +TEST(DocumentDBConfigTest, require_that_makeDelayedAttributeAspectConfig_works_field_remains_when_attribute_removed) { - auto removed = DocumentDBConfig::makeDelayedAttributeAspectConfig(f.noAttrCfg, *f.attrCfg); - TEST_DO(f.assertNotDelayedConfig(*removed)); + DelayAttributeAspectFixture f(true); + auto delayedRemove = DocumentDBConfig::makeDelayedAttributeAspectConfig(f.noAttrCfg, *f.attrCfg); + f.assertDelayedConfig(*delayedRemove); } +TEST(DocumentDBConfigTest, require_that_makeDelayedAttributeAspectConfig_works_field_removed_with_attribute) +{ + DelayAttributeAspectFixture f(false); + auto removed = DocumentDBConfig::makeDelayedAttributeAspectConfig(f.noAttrCfg, *f.attrCfg); + f.assertNotDelayedConfig(*removed); }