diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-01-31 15:12:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-31 15:12:58 +0100 |
commit | dead1465fd37719c03ed27fdb91736a8fb9742e1 (patch) | |
tree | 302e87625dcd258bc90c2f0600e33df0dc397830 /searchcore/src/tests | |
parent | f8777b88ff970fb036cd01c7f709e8021feb649f (diff) | |
parent | 395627362aec1f0ee7dc6b5115789f96fbc86dce (diff) |
Merge pull request #4814 from vespa-engine/balder/compute-summary-cache-automatically-in-backend
Balder/compute summary cache automatically in backend
Diffstat (limited to 'searchcore/src/tests')
6 files changed, 55 insertions, 15 deletions
diff --git a/searchcore/src/tests/proton/docsummary/docsummary.cpp b/searchcore/src/tests/proton/docsummary/docsummary.cpp index dae50fcc860..ff393682f9b 100644 --- a/searchcore/src/tests/proton/docsummary/docsummary.cpp +++ b/searchcore/src/tests/proton/docsummary/docsummary.cpp @@ -208,7 +208,7 @@ public: std::make_shared<ProtonConfig>(), std::make_shared<FiledistributorrpcConfig>(), std::make_shared<BucketspacesConfig>(), - _tuneFileDocumentDB); + _tuneFileDocumentDB, _hwInfo); _configMgr.forwardConfig(b); _configMgr.nextGeneration(0); if (! FastOS_File::MakeDirectory((std::string("tmpdb/") + docTypeName).c_str())) { abort(); } diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp index e655ae0d739..e39fd1fe28a 100644 --- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp +++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp @@ -284,7 +284,7 @@ struct MyConfigSnapshot std::make_shared<ProtonConfig>(), std::make_shared<FiledistributorrpcConfig>(), std::make_shared<BucketspacesConfig>(), - tuneFileDocumentDB); + tuneFileDocumentDB, HwInfo()); config::DirSpec spec(cfgDir); DocumentDBConfigHelper mgr(spec, "searchdocument"); mgr.forwardConfig(_bootstrap); diff --git a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp index f93930d189b..9f6eb0ea4e1 100644 --- a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp @@ -99,7 +99,7 @@ Fixture::Fixture() std::make_shared<ProtonConfig>(), std::make_shared<FiledistributorrpcConfig>(), std::make_shared<BucketspacesConfig>(), - tuneFileDocumentDB)); + tuneFileDocumentDB, HwInfo())); mgr.forwardConfig(b); mgr.nextGeneration(0); _db.reset(new DocumentDB(".", mgr.getConfig(), "tcp/localhost:9014", _queryLimiter, _clock, DocTypeName("typea"), diff --git a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp index 6b1031fe558..dd35d823b99 100644 --- a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp +++ b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp @@ -40,13 +40,12 @@ makeBaseConfigSnapshot() DBCM dbcm(spec, "test"); DocumenttypesConfigSP dtcfg(config::ConfigGetter<DocumenttypesConfig>::getConfig("", spec).release()); - BootstrapConfig::SP b(new BootstrapConfig(1, - dtcfg, + BootstrapConfig::SP b(new BootstrapConfig(1, dtcfg, DocumentTypeRepo::SP(new DocumentTypeRepo(*dtcfg)), std::make_shared<ProtonConfig>(), std::make_shared<FiledistributorrpcConfig>(), std::make_shared<BucketspacesConfig>(), - std::make_shared<TuneFileDocumentDB>())); + std::make_shared<TuneFileDocumentDB>(), HwInfo())); dbcm.forwardConfig(b); dbcm.nextGeneration(0); DocumentDBConfig::SP snap = dbcm.getConfig(); 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 37e4dfc486d..96f742a172c 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 @@ -14,12 +14,12 @@ #include <vespa/searchcore/proton/server/proton_config_fetcher.h> #include <vespa/searchcore/proton/server/proton_config_snapshot.h> #include <vespa/searchcore/proton/server/i_proton_configurer.h> +#include <vespa/searchcore/proton/common/hw_info.h> #include <vespa/searchsummary/config/config-juniperrc.h> #include <vespa/searchcore/config/config-ranking-constants.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/varholder.h> #include <vespa/config-bucketspaces.h> -#include <mutex> using namespace config; using namespace proton; @@ -146,14 +146,15 @@ struct ConfigTestFixture { documenttypesBuilder == bootstrapConfig->getDocumenttypesConfig()); } - BootstrapConfig::SP getBootstrapConfig(int64_t generation) const { + BootstrapConfig::SP getBootstrapConfig(int64_t generation, const HwInfo & hwInfo) const { return BootstrapConfig::SP(new BootstrapConfig(generation, - BootstrapConfig::DocumenttypesConfigSP(new DocumenttypesConfig(documenttypesBuilder)), - DocumentTypeRepo::SP(new DocumentTypeRepo(documenttypesBuilder)), - BootstrapConfig::ProtonConfigSP(new ProtonConfig(protonBuilder)), + std::make_shared<DocumenttypesConfig>(documenttypesBuilder), + std::make_shared<DocumentTypeRepo>(documenttypesBuilder), + std::make_shared<ProtonConfig>(protonBuilder), std::make_shared<FiledistributorrpcConfig>(), std::make_shared<BucketspacesConfig>(bucketspacesBuilder), - std::make_shared<TuneFileDocumentDB>())); + std::make_shared<TuneFileDocumentDB>(), + hwInfo)); } void reload() { context->reload(); } @@ -232,14 +233,20 @@ TEST_FFF("require that bootstrap config manager updates config", ConfigTestFixtu } DocumentDBConfig::SP -getDocumentDBConfig(ConfigTestFixture &f, DocumentDBConfigManager &mgr) +getDocumentDBConfig(ConfigTestFixture &f, DocumentDBConfigManager &mgr, const HwInfo & hwInfo) { ConfigRetriever retriever(mgr.createConfigKeySet(), f.context); - mgr.forwardConfig(f.getBootstrapConfig(1)); + mgr.forwardConfig(f.getBootstrapConfig(1, hwInfo)); mgr.update(retriever.getBootstrapConfigs()); // Cheating, but we only need the configs return mgr.getConfig(); } +DocumentDBConfig::SP +getDocumentDBConfig(ConfigTestFixture &f, DocumentDBConfigManager &mgr) +{ + return getDocumentDBConfig(f, mgr, HwInfo()); +} + TEST_FF("require that documentdb config manager subscribes for config", ConfigTestFixture("search"), DocumentDBConfigManager(f1.configId + "/typea", "typea")) { @@ -351,4 +358,38 @@ TEST_FF("require that prune removed documents interval can be set based on age", EXPECT_EQUAL(20, config->getMaintenanceConfigSP()->getPruneRemovedDocumentsConfig().getInterval()); } +TEST_FF("require that docstore config computes cachesize automatically if unset", + ConfigTestFixture("test"), + DocumentDBConfigManager(f1.configId + "/test", "test")) +{ + HwInfo hwInfo(HwInfo::Disk(1, false, false), HwInfo::Memory(1000000), HwInfo::Cpu(1)); + f1.addDocType("test"); + f1.protonBuilder.summary.cache.maxbytes = 2000; + auto config = getDocumentDBConfig(f1, f2, hwInfo); + EXPECT_EQUAL(2000ul, config->getStoreConfig().getMaxCacheBytes()); + + f1.protonBuilder.summary.cache.maxbytes = -7; + config = getDocumentDBConfig(f1, f2, hwInfo); + EXPECT_EQUAL(70000ul, config->getStoreConfig().getMaxCacheBytes()); + + f1.protonBuilder.summary.cache.maxbytes = -700; + config = getDocumentDBConfig(f1, f2, hwInfo); + EXPECT_EQUAL(500000ul, config->getStoreConfig().getMaxCacheBytes()); +} + +TEST("test HwInfo equality") { + EXPECT_TRUE(HwInfo::Cpu(1) == HwInfo::Cpu(1)); + EXPECT_FALSE(HwInfo::Cpu(1) == HwInfo::Cpu(2)); + EXPECT_TRUE(HwInfo::Memory(1) == HwInfo::Memory(1)); + EXPECT_FALSE(HwInfo::Memory(1) == HwInfo::Memory(2)); + EXPECT_TRUE(HwInfo::Disk(1, false, false) == HwInfo::Disk(1, false,false)); + EXPECT_FALSE(HwInfo::Disk(1, false, false) == HwInfo::Disk(1, false,true)); + EXPECT_FALSE(HwInfo::Disk(1, false, false) == HwInfo::Disk(1, true,false)); + EXPECT_FALSE(HwInfo::Disk(1, false, false) == HwInfo::Disk(2, false,false)); + EXPECT_TRUE(HwInfo(HwInfo::Disk(1, false, false), 1ul, 1ul) == HwInfo(HwInfo::Disk(1, false,false), 1ul, 1ul)); + EXPECT_FALSE(HwInfo(HwInfo::Disk(1, false, false), 1ul, 1ul) == HwInfo(HwInfo::Disk(1, false,false), 1ul, 2ul)); + EXPECT_FALSE(HwInfo(HwInfo::Disk(1, false, false), 1ul, 1ul) == HwInfo(HwInfo::Disk(1, false,false), 2ul, 1ul)); + EXPECT_FALSE(HwInfo(HwInfo::Disk(1, false, false), 1ul, 1ul) == HwInfo(HwInfo::Disk(2, false,false), 1ul, 1ul)); +} + TEST_MAIN() { TEST_RUN_ALL(); } 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 a8336e29f9f..d59a67d73bb 100644 --- a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp +++ b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp @@ -171,7 +171,7 @@ struct ConfigFixture { BootstrapConfig::ProtonConfigSP(new ProtonConfig(_protonBuilder)), std::make_shared<FiledistributorrpcConfig>(), std::make_shared<BucketspacesConfig>(_bucketspacesBuilder), - std::make_shared<TuneFileDocumentDB>())); + std::make_shared<TuneFileDocumentDB>(), HwInfo())); } std::shared_ptr<ProtonConfigSnapshot> getConfigSnapshot() |