summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-02-11 22:03:17 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-02-11 22:03:17 +0000
commitdce83e882bfe1f8a183b03994f5c53f297ad1b5a (patch)
treea05cbea6ec7118d21e028af8ffc2f833fd172a36 /searchcore
parent6f529be6a611d26aefc04fa0a924718c5c80f74b (diff)
Add unit test for capping
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/server/memory_flush_config_updater/memory_flush_config_updater_test.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/searchcore/src/tests/proton/server/memory_flush_config_updater/memory_flush_config_updater_test.cpp b/searchcore/src/tests/proton/server/memory_flush_config_updater/memory_flush_config_updater_test.cpp
index 716b369d928..ff64d614169 100644
--- a/searchcore/src/tests/proton/server/memory_flush_config_updater/memory_flush_config_updater_test.cpp
+++ b/searchcore/src/tests/proton/server/memory_flush_config_updater/memory_flush_config_updater_test.cpp
@@ -42,6 +42,7 @@ belowLimit()
}
const HwInfo::Memory defaultMemory(8ul * 1024ul * 1024ul * 1024ul);
+constexpr size_t ONE_G = 1024ul * 1024ul * 1024ul;;
struct Fixture
{
@@ -74,6 +75,29 @@ TEST_F("require that strategy is updated when setting new config", Fixture)
TEST_DO(f.assertStrategyConfig(6, 3, 30));
}
+TEST("require that we use configured memory limits") {
+ auto cfg = MemoryFlushConfigUpdater::convertConfig(getConfig(6, 3, 30), defaultMemory);
+ EXPECT_EQUAL(cfg.maxGlobalMemory, 6u);
+ EXPECT_EQUAL(cfg.maxMemoryGain, 3);
+}
+
+TEST("require that we cap configured limits based on available memory") {
+ const uint64_t LIMIT = defaultMemory.sizeBytes()/4;
+ constexpr uint64_t MEM_4G = 4 * ONE_G;
+ auto cfg = MemoryFlushConfigUpdater::convertConfig(getConfig(MEM_4G, MEM_4G, 30), defaultMemory);
+ EXPECT_EQUAL(cfg.maxGlobalMemory, LIMIT);
+ EXPECT_EQUAL(uint64_t(cfg.maxMemoryGain), LIMIT);
+}
+
+TEST("require that we cap configured limits based on the absolute 16G limit") {
+ constexpr uint64_t LIMIT_16G = 16 * ONE_G;
+ constexpr uint64_t MEM_64G = 64 * ONE_G;
+ const HwInfo::Memory largeMemory(512 * ONE_G);
+ auto cfg = MemoryFlushConfigUpdater::convertConfig(getConfig(MEM_64G, MEM_64G, 30), largeMemory);
+ EXPECT_EQUAL(cfg.maxGlobalMemory, LIMIT_16G);
+ EXPECT_EQUAL(uint64_t(cfg.maxMemoryGain), LIMIT_16G);
+}
+
TEST_F("require that strategy is updated with normal values if no limits are reached", Fixture)
{
f.updater.notifyDiskMemUsage(DiskMemUsageState());