Skip to content

Commit d16a12b

Browse files
authored
Merge pull request ceph#64998 from chanyoung/monotonic
test/crimson/seastore/test_omap_manager: add monotonic inc UT Reviewed-by: Samuel Just <[email protected]>
2 parents 50342c1 + 0701324 commit d16a12b

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
@@ -840,6 +840,46 @@ TEST_P(omap_manager_test_t, heavy_update)
840840
});
841841
}
842842

843+
TEST_P(omap_manager_test_t, monotonic_inc)
844+
{
845+
// This test simulate a real-world common pattern of inserting
846+
// monotonically increasing new keys and sequentially deleting
847+
// the oldest keys. The goal is to detect any abnormal splits
848+
// (imbalances) that may occur during right-skewed growth, and
849+
// then repeatedly delete the oldest keys to trigger left-skewed
850+
// deletions, checking for bugs in repeated left-side rebalancing.
851+
run_async([this] {
852+
omap_root_t omap_root = initialize();
853+
854+
auto monotonic_inc = []() {
855+
static uint64_t counter = 0;
856+
char buf[32];
857+
snprintf(buf, sizeof(buf), "%16lu", counter++);
858+
return std::string(buf);
859+
};
860+
861+
while (omap_root.get_depth() < 3) {
862+
auto t = create_mutate_transaction();
863+
for (int i = 0; i < 128; i++) {
864+
auto key = monotonic_inc();
865+
auto val = rand_buffer(512);
866+
set_key(omap_root, *t, key, val);
867+
}
868+
submit_transaction(std::move(t));
869+
}
870+
check_mappings(omap_root);
871+
872+
while (test_omap_mappings.size() > 128) {
873+
auto t = create_mutate_transaction();
874+
auto first = test_omap_mappings.begin()->first;
875+
auto last = std::next(test_omap_mappings.begin(), 128)->first;
876+
rm_key_range(omap_root, *t, first, last);
877+
submit_transaction(std::move(t));
878+
}
879+
check_mappings(omap_root);
880+
});
881+
}
882+
843883
INSTANTIATE_TEST_SUITE_P(
844884
omap_manager_test,
845885
omap_manager_test_t,

0 commit comments

Comments
 (0)