diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-01-31 18:42:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-31 18:42:15 +0100 |
commit | 01dcc51225aed6e017d54875a0c924f0fab7aef1 (patch) | |
tree | f538eb6f83f8a0c0d5df4a0c4d383985a92725ab /searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp | |
parent | 2b42b7abba86daa12dbc5691d1873bec14a94d00 (diff) |
Revert "Revert "Balder/compute summary cache automatically in backend""
Diffstat (limited to 'searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp')
-rw-r--r-- | searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp | 57 |
1 files changed, 49 insertions, 8 deletions
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(); } |