]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/crimson/seastore: improve test_seastore zero() coverage
authorSamuel Just <sjust@redhat.com>
Thu, 7 Apr 2022 20:48:38 +0000 (20:48 +0000)
committerchunmei-liu <chunmei.liu@intel.com>
Wed, 13 Apr 2022 00:48:45 +0000 (17:48 -0700)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/test/crimson/seastore/test_seastore.cc

index 7b827e5395ce1507127a1970934c1202c8ea0664..c6471998d9cc7ee3ef7f384e6de83521146eb065 100644 (file)
@@ -790,24 +790,57 @@ TEST_F(seastore_test_t, sparse_read)
 TEST_F(seastore_test_t, zero)
 {
   run_async([this] {
-    auto &test_obj = get_object(make_oid(0));
-    test_obj.write(
-      *seastore,
-      1024,
-      1024,
-      'a');
-    test_obj.read(
-      *seastore,
-      1024,
-      1024);
-    test_obj.check_size(*seastore);
-    test_obj.zero(*seastore, 1124, 200);
-    test_obj.read(
-      *seastore,
-      1024,
-      1024);
-    test_obj.check_size(*seastore);
+    auto test_zero = [this](
+      // [(off, len, repeat)]
+      std::vector<std::tuple<uint64_t, uint64_t, uint64_t>> writes,
+      uint64_t zero_off, uint64_t zero_len) {
+
+      // Test zero within a block
+      auto &test_obj = get_object(make_oid(0));
+      uint64_t size = 0;
+      for (auto &[off, len, repeat]: writes) {
+       for (decltype(repeat) i = 0; i < repeat; ++i) {
+         test_obj.write(*seastore, off + (len * repeat), len, 'a');
+       }
+       size = off + (len * (repeat + 1));
+      }
+      test_obj.read(
+       *seastore,
+       0,
+       size);
+      test_obj.check_size(*seastore);
+      test_obj.zero(*seastore, zero_off, zero_len);
+      test_obj.read(
+       *seastore,
+       0,
+       size);
+      test_obj.check_size(*seastore);
+      remove_object(test_obj);
+    };
 
-    remove_object(test_obj);
+    const uint64_t BS = 4<<10;
+
+    // Test zero within a block
+    test_zero(
+      {{1<<10, 1<<10, 1}},
+      1124, 200);
+
+    // Multiple writes, partial on left, partial on right.
+    test_zero(
+      {{BS, BS, 10}},
+      BS + 128,
+      BS * 4);
+
+    // Single large write, block boundary on right, partial on left.
+    test_zero(
+      {{BS, BS * 10, 1}},
+      BS + 128,
+      (BS * 4) - 128);
+
+    // Multiple writes, block boundary on left, partial on right.
+    test_zero(
+      {{BS, BS, 10}},
+      BS,
+      (BS * 4) + 128);
   });
 }