From 16a900edb0a78b01a20b1071ba9811ae912c519f Mon Sep 17 00:00:00 2001 From: Ning Yao Date: Thu, 7 Sep 2017 10:52:55 +0000 Subject: [PATCH] test: fix misc fiemap testing 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 Signed-off-by: Kefu Chai (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 | 48 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 50940164c64c1..72936dfbb8329 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -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 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"); -- 2.39.5