]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/omap: add tests to range list
authorXinyu Huang <xinyu.huang@intel.com>
Fri, 9 Sep 2022 15:46:15 +0000 (15:46 +0000)
committerXinyu Huang <xinyu.huang@intel.com>
Tue, 13 Dec 2022 09:49:55 +0000 (09:49 +0000)
Signed-off-by: Xinyu Huang <xinyu.huang@intel.com>
src/test/crimson/seastore/test_omap_manager.cc

index c6e4601a2c8f2616c7cd1b9bb5a297ed99013797..a571500e4c92d4ecd10b827f39fb035faeb58f50 100644 (file)
@@ -391,14 +391,21 @@ TEST_F(omap_manager_test_t, force_split_listkeys_list_clear)
   run_async([this] {
     omap_root_t omap_root = initialize();
 
-    string temp;
+    string first, last;
     for (unsigned i = 0; i < 40; i++) {
       auto t = create_mutate_transaction();
       logger().debug("opened transaction");
       for (unsigned j = 0; j < 10; ++j) {
         auto key = set_random_key(omap_root, *t);
-        if (i == 10)
-          temp = key;
+        if (i == 10) {
+          first = key;
+       }
+       if (i == 30) {
+         last = key;
+         if (first > last) {
+           std::swap(first, last);
+         }
+       }
         if ((i % 20 == 0) && (j == 5)) {
           check_mappings(omap_root, *t);
         }
@@ -408,19 +415,41 @@ TEST_F(omap_manager_test_t, force_split_listkeys_list_clear)
       check_mappings(omap_root);
     }
 
+    std::optional<std::string> first_temp;
+    std::optional<std::string> last_temp;
+    {
+      auto t = create_read_transaction();
+      first_temp = std::nullopt;
+      last_temp = std::nullopt;
+      list(omap_root, *t, first_temp, last_temp);
+    }
+
+    {
+      auto t = create_read_transaction();
+      first_temp = first;
+      last_temp = std::nullopt;
+      list(omap_root, *t, first_temp, last_temp, 100);
+    }
+
     {
       auto t = create_read_transaction();
-      list(omap_root, *t, std::nullopt, std::nullopt);
+      first_temp = first;
+      last_temp = std::nullopt;
+      list(omap_root, *t, first_temp, last_temp, 100, true);
     }
 
     {
       auto t = create_read_transaction();
-      list(omap_root, *t, temp, std::nullopt, 100);
+      first_temp = std::nullopt;
+      last_temp = last;
+      list(omap_root, *t, first_temp, last_temp, 10240);
     }
 
     {
       auto t = create_read_transaction();
-      list(omap_root, *t, temp, std::nullopt, 100, true);
+      first_temp = first;
+      last_temp = last;
+      list(omap_root, *t, first_temp, last_temp, 10240, true);
     }
 
     {
@@ -436,29 +465,54 @@ TEST_F(omap_manager_test_t, force_inner_node_split_list)
   run_async([this] {
     omap_root_t omap_root = initialize();
 
-    string temp = "";
+    string first = "";
+    string last;
     while (cache->get_omap_tree_depth() < 3) {
       for (unsigned i = 0; i < 40; i++) {
        auto t = create_mutate_transaction();
        logger().debug("opened transaction");
        for (unsigned j = 0; j < 10; ++j) {
          auto key = set_random_key(omap_root, *t);
-         if (key.compare(temp) < 0 || !temp.length())
-           temp = key;
+         if (key.compare(first) < 0 || !first.length()) {
+           first = key;
+         }
+         if (i == 10) {
+           last = key;
+         }
        }
        logger().debug("force split submit transaction i = {}", i);
        submit_transaction(std::move(t));
       }
     }
 
+    std::optional<std::string> first_temp;
+    std::optional<std::string> last_temp;
+    {
+      auto t = create_read_transaction();
+      first_temp = first;
+      last_temp = std::nullopt;
+      list(omap_root, *t, first_temp, last_temp, 10240);
+    }
+
+    {
+      auto t = create_read_transaction();
+      first_temp = first;
+      last_temp = std::nullopt;
+      list(omap_root, *t, first_temp, last_temp, 10240, true);
+    }
+
     {
       auto t = create_read_transaction();
-      list(omap_root, *t, temp, std::nullopt, 10240);
+      first_temp = std::nullopt;
+      last_temp = last;
+      list(omap_root, *t, first_temp, last_temp, 10240);
     }
 
     {
       auto t = create_read_transaction();
-      list(omap_root, *t, temp, std::nullopt, 10240, true);
+      first_temp = first;
+      last_temp = last;
+      list(omap_root, *t, first_temp, last_temp, 10240, true);
     }
 
     {