]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: fix misc fiemap testing 20143/head
authorNing Yao <yaoning@unitedstack.com>
Thu, 7 Sep 2017 10:52:55 +0000 (10:52 +0000)
committerNathan Cutler <ncutler@suse.com>
Sat, 27 Jan 2018 08:34:16 +0000 (09:34 +0100)
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>
(cherry picked from commit 87f33376d977962ab7438c46873ea9b6292390d1)

Conflicts:
    src/test/objectstore/store_test.cc (master does not set
       filestore_op_thread_suicide_timeout; trivial resolution)

src/test/objectstore/store_test.cc

index 50940164c64c1ab4dc4308543bded31650051d99..72936dfbb8329f9f0fab101d0c864d2742a353c8 100644 (file)
@@ -288,39 +288,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;
@@ -3710,7 +3710,7 @@ int main(int argc, char **argv) {
   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_debug_disable_sharded_check", "true");
-  //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");