]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: fix misc fiemap testing 18240/head
authorNing Yao <yaoning@unitedstack.com>
Thu, 7 Sep 2017 10:52:55 +0000 (10:52 +0000)
committerKefu Chai <kchai@redhat.com>
Wed, 11 Oct 2017 08:11:15 +0000 (16:11 +0800)
1) Different filesystem will have different behavior to
allocate extents. Therefore, even if write 4000 extents,
the filesystem may not really allocate 4000 extents.

2) kstore always return [0, xxx] even if offset ~= 0. Therefore,
the whole non-zero offset FiemapHoles test should be skipped

3) enable fiemap test for filestore, bluestore, memstore again

Fixes: http://tracker.ceph.com/issues/21716
Signed-off-by: Ning Yao <yaoning@unitedstack.com>
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/test/objectstore/store_test.cc

index 3fffab0e569fbbe89d7085eaf54191ec231095d1..d549007b96b7244a295f1f40b09186ee7b429142 100644 (file)
@@ -471,39 +471,39 @@ TEST_P(StoreTest, FiemapHoles) {
     cout << " got " << m << std::endl;
     ASSERT_TRUE(!m.empty());
     ASSERT_GE(m[0], 3u);
-    bool extents_exist = true;
-    if (m.size() == MAX_EXTENTS) {
-      for (uint64_t i = 0; i < MAX_EXTENTS; i++)
-        extents_exist = extents_exist && m.count(SKIP_STEP*i);
+    auto last = m.crbegin();
+    if (m.size() == 1) {
+      ASSERT_EQ(0u, last->first);
+    } else if (m.size() == MAX_EXTENTS) {
+      for (uint64_t i = 0; i < MAX_EXTENTS; i++) {
+        ASSERT_TRUE(m.count(SKIP_STEP * i));
+      }
     }
-    ASSERT_TRUE((m.size() == 1 &&
-                m[0] > SKIP_STEP * (MAX_EXTENTS - 1)) ||
-                (m.size() == MAX_EXTENTS && extents_exist));
-
+    ASSERT_GT(last->first + last->second, SKIP_STEP * (MAX_EXTENTS - 1));
+  }
+  {
     // fiemap test from SKIP_STEP to SKIP_STEP * (MAX_EXTENTS - 2) + 3
-    // reset bufferlist and map
-    bl.clear();
-    m.clear();
-    e.clear();
+    bufferlist bl;
     store->fiemap(cid, oid, SKIP_STEP, SKIP_STEP * (MAX_EXTENTS - 2) + 3, bl);
-    p = bl.begin();
+    map<uint64_t,uint64_t> m, e;
+    auto p = bl.begin();
     ::decode(m, p);
     cout << " got " << m << std::endl;
     ASSERT_TRUE(!m.empty());
-
-    // kstore always return [0, object_size] regardless of offset and length
+    // kstore always returns [0, object_size] regardless of offset and length
     // FIXME: if fiemap logic in kstore is refined
     if (string(GetParam()) != "kstore") {
       ASSERT_GE(m[SKIP_STEP], 3u);
+      auto last = m.crbegin();
+      if (m.size() == 1) {
+        ASSERT_EQ(SKIP_STEP, last->first);
+      } else if (m.size() == MAX_EXTENTS - 2) {
+        for (uint64_t i = 1; i < MAX_EXTENTS - 1; i++) {
+         ASSERT_TRUE(m.count(SKIP_STEP*i));
+       }
+      }
+      ASSERT_GT(last->first + last->second, SKIP_STEP * (MAX_EXTENTS - 1));
     }
-    extents_exist = true;
-    if (m.size() == (MAX_EXTENTS - 2)) {
-      for (uint64_t i = 1; i < MAX_EXTENTS - 1; i++)
-       extents_exist = extents_exist && m.count(SKIP_STEP*i);
-    }
-    ASSERT_TRUE((m.size() == 1 &&
-                m[SKIP_STEP] > SKIP_STEP * (MAX_EXTENTS - 2)) ||
-                (m.size() == (MAX_EXTENTS - 1) && extents_exist));
   }
   {
     ObjectStore::Transaction t;
@@ -6730,7 +6730,7 @@ int main(int argc, char **argv) {
   g_ceph_context->_conf->set_val("filestore_index_retry_probability", "0.5");
   g_ceph_context->_conf->set_val("filestore_op_thread_timeout", "1000");
   g_ceph_context->_conf->set_val("filestore_op_thread_suicide_timeout", "10000");
-  //g_ceph_context->_conf->set_val("filestore_fiemap", "true");
+  g_ceph_context->_conf->set_val("filestore_fiemap", "true");
   g_ceph_context->_conf->set_val("bluestore_fsck_on_mount", "true");
   g_ceph_context->_conf->set_val("bluestore_fsck_on_umount", "true");
   g_ceph_context->_conf->set_val("bluestore_debug_misc", "true");