Skip to content

Commit 0701324

Browse files
committed
test/crimson/seastore/test_omap_manager: add monotonic inc UT
Signed-off-by: Chanyoung Park <[email protected]>
1 parent bc26409 commit 0701324

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/test/crimson/seastore/test_omap_manager.cc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,46 @@ TEST_P(omap_manager_test_t, heavy_update)
915915
});
916916
}
917917

918+
TEST_P(omap_manager_test_t, monotonic_inc)
919+
{
920+
// This test simulate a real-world common pattern of inserting
921+
// monotonically increasing new keys and sequentially deleting
922+
// the oldest keys. The goal is to detect any abnormal splits
923+
// (imbalances) that may occur during right-skewed growth, and
924+
// then repeatedly delete the oldest keys to trigger left-skewed
925+
// deletions, checking for bugs in repeated left-side rebalancing.
926+
run_async([this] {
927+
omap_root_t omap_root = initialize();
928+
929+
auto monotonic_inc = []() {
930+
static uint64_t counter = 0;
931+
char buf[32];
932+
snprintf(buf, sizeof(buf), "%16lu", counter++);
933+
return std::string(buf);
934+
};
935+
936+
while (omap_root.get_depth() < 3) {
937+
auto t = create_mutate_transaction();
938+
for (int i = 0; i < 128; i++) {
939+
auto key = monotonic_inc();
940+
auto val = rand_buffer(512);
941+
set_key(omap_root, *t, key, val);
942+
}
943+
submit_transaction(std::move(t));
944+
}
945+
check_mappings(omap_root);
946+
947+
while (test_omap_mappings.size() > 128) {
948+
auto t = create_mutate_transaction();
949+
auto first = test_omap_mappings.begin()->first;
950+
auto last = std::next(test_omap_mappings.begin(), 128)->first;
951+
rm_key_range(omap_root, *t, first, last);
952+
submit_transaction(std::move(t));
953+
}
954+
check_mappings(omap_root);
955+
});
956+
}
957+
918958
INSTANTIATE_TEST_SUITE_P(
919959
omap_manager_test,
920960
omap_manager_test_t,

0 commit comments

Comments
 (0)