From 3a4df233f6e4815ac356509ddfa0bc9076bb0376 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Tue, 2 Feb 2021 15:34:28 +0100 Subject: Improve handling of changed alloc config. --- .../common/alloc_config/alloc_config_test.cpp | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 searchcore/src/tests/proton/common/alloc_config/alloc_config_test.cpp (limited to 'searchcore/src/tests/proton/common/alloc_config/alloc_config_test.cpp') diff --git a/searchcore/src/tests/proton/common/alloc_config/alloc_config_test.cpp b/searchcore/src/tests/proton/common/alloc_config/alloc_config_test.cpp new file mode 100644 index 00000000000..2c2e03dcfd0 --- /dev/null +++ b/searchcore/src/tests/proton/common/alloc_config/alloc_config_test.cpp @@ -0,0 +1,35 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include +#include +#include + +using proton::AllocConfig; +using proton::AllocStrategy; +using proton::SubDbType; +using search::CompactionStrategy; +using search::GrowStrategy; + +namespace { + +CompactionStrategy baseline_compaction_strategy(0.2, 0.25); + +GrowStrategy make_grow_strategy(uint32_t initial_docs) { + return GrowStrategy(initial_docs, 0.1, 1, 0.15); +} + +AllocStrategy make_alloc_strategy(uint32_t initial_docs) { + return AllocStrategy(make_grow_strategy(initial_docs), baseline_compaction_strategy, 10000); +} + +}; + +TEST(AllocConfigTest, hello_world) +{ + AllocConfig config(make_alloc_strategy(10000000), 5, 2); + EXPECT_EQ(make_alloc_strategy(20000000), config.make_alloc_strategy(SubDbType::READY)); + EXPECT_EQ(make_alloc_strategy(100000), config.make_alloc_strategy(SubDbType::REMOVED)); + EXPECT_EQ(make_alloc_strategy(30000000), config.make_alloc_strategy(SubDbType::NOTREADY)); +} + +GTEST_MAIN_RUN_ALL_TESTS() -- cgit v1.2.3