From 87f33376d977962ab7438c46873ea9b6292390d1 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 --- 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 3fffab0e569fb..d549007b96b72 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -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 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"); -- 2.39.5