Skip to content

Commit 470e980

Browse files
authored
Merge pull request ceph#64522 from chanyoung/cleanup-test-variable-sizes
test/crimson/seastore/test_omap_manager: redesign test variable sizes Reviewed-by: Samuel Just <[email protected]>
2 parents f94666b + f858759 commit 470e980

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

src/test/crimson/seastore/test_omap_manager.cc

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,14 @@ struct omap_manager_test_t :
9595

9696
std::string set_random_key(
9797
omap_root_t &omap_root,
98-
Transaction &t) {
99-
auto key = rand_name(STR_LEN);
100-
set_key(
101-
omap_root,
102-
t,
103-
key,
104-
rand_buffer(STR_LEN));
98+
Transaction &t,
99+
bool variable_length = false) {
100+
// Generates a random number in the range [4, 128].
101+
auto randu = []() -> int { return 4 + (std::rand() % 125); };
102+
auto key = rand_name(variable_length ? randu() : STR_LEN);
103+
set_key(omap_root, t, key,
104+
rand_buffer(variable_length ? randu() : STR_LEN));
105+
105106
return key;
106107
}
107108

@@ -725,31 +726,20 @@ TEST_P(omap_manager_test_t, replay)
725726
});
726727
}
727728

728-
TEST_P(omap_manager_test_t, internal_force_split_to_root)
729+
TEST_P(omap_manager_test_t, variable_key_value_sizes)
729730
{
730731
run_async([this] {
731732
omap_root_t omap_root = initialize();
732733

733-
logger().debug("set big keys");
734-
for (unsigned i = 0; i < 53; i++) {
734+
while (omap_root.get_depth() < 2) {
735735
auto t = create_mutate_transaction();
736-
737-
for (unsigned j = 0; j < 8; ++j) {
738-
set_random_key(omap_root, *t);
736+
for (unsigned i = 0; i < 128; ++i) {
737+
set_random_key(omap_root, *t, true /* variable sizes */);
739738
}
740-
logger().debug("submitting transaction i = {}", i);
739+
check_mappings(omap_root, *t);
741740
submit_transaction(std::move(t));
741+
check_mappings(omap_root);
742742
}
743-
logger().debug("set small keys");
744-
for (unsigned i = 0; i < 100; i++) {
745-
auto t = create_mutate_transaction();
746-
for (unsigned j = 0; j < 8; ++j) {
747-
set_random_key(omap_root, *t);
748-
}
749-
logger().debug("submitting transaction last");
750-
submit_transaction(std::move(t));
751-
}
752-
check_mappings(omap_root);
753743
});
754744
}
755745

0 commit comments

Comments
 (0)