summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2021-04-14 15:24:27 +0200
committerTor Egge <Tor.Egge@online.no>2021-04-14 15:24:27 +0200
commitbd1164656ebb3af3e5e5bfb6ed3c71531c12d5dd (patch)
tree88d698f5a92c51dbe0c832eb4014bb3954c2b834 /vespalib
parentc5280110e891376661211bf2bf6c29b9c516d4e9 (diff)
Add explicit unit test for compact_worst_shard().
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp b/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp
index da9bc1284fa..67195ecd8dd 100644
--- a/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp
+++ b/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp
@@ -277,4 +277,17 @@ TEST_F(DataStoreShardedHashTest, normalize_values_works)
}
}
+TEST_F(DataStoreShardedHashTest, compact_worst_shard_works)
+{
+ populate_sample_data();
+ for (uint32_t i = 10; i < 50; ++i) {
+ remove(i);
+ }
+ commit();
+ auto usage_before = _hash_map.get_memory_usage();
+ _hash_map.compact_worst_shard();
+ auto usage_after = _hash_map.get_memory_usage();
+ EXPECT_GT(usage_before.deadBytes(), usage_after.deadBytes());
+}
+
GTEST_MAIN_RUN_ALL_TESTS()