From: Igor Fedotov Date: Mon, 16 May 2016 17:55:55 +0000 (+0300) Subject: test/objectstore: Adds trivial test case to verify buffer cache use in bluestore X-Git-Tag: v11.0.0~359^2~70 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d0acbd08ae7310b9654d86ed7f357691a50eee06;p=ceph.git test/objectstore: Adds trivial test case to verify buffer cache use in bluestore Signed-off-by: Igor Fedotov --- diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index dcd2c1400f87..855c8ac3b0cd 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -532,6 +532,68 @@ TEST_P(StoreTest, SmallBlockWrites) { } } +TEST_P(StoreTest, BufferCacheReadTest) { + ObjectStore::Sequencer osr("test"); + int r; + coll_t cid; + ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP))); + { + bufferlist in; + r = store->read(cid, hoid, 0, 5, in); + ASSERT_EQ(-ENOENT, r); + } + { + ObjectStore::Transaction t; + t.create_collection(cid, 0); + cerr << "Creating collection " << cid << std::endl; + r = apply_transaction(store, &osr, std::move(t)); + ASSERT_EQ(r, 0); + } + { + bool exists = store->exists(cid, hoid); + ASSERT_TRUE(!exists); + + ObjectStore::Transaction t; + t.touch(cid, hoid); + cerr << "Creating object " << hoid << std::endl; + r = apply_transaction(store, &osr, std::move(t)); + ASSERT_EQ(r, 0); + + exists = store->exists(cid, hoid); + ASSERT_EQ(true, exists); + } + { + ObjectStore::Transaction t; + bufferlist bl, newdata; + bl.append("abcde"); + t.write(cid, hoid, 0, 5, bl); + t.write(cid, hoid, 10, 5, bl); + cerr << "TwinWrite" << std::endl; + r = apply_transaction(store, &osr, std::move(t)); + ASSERT_EQ(r, 0); + + newdata.clear(); + r = store->read(cid, hoid, 0, 5, newdata); + ASSERT_EQ(r, 5); + ASSERT_TRUE(newdata.contents_equal(bl)); + + newdata.clear(); + r = store->read(cid, hoid, 10, 15, newdata); + ASSERT_EQ(r, 5); + ASSERT_TRUE(newdata.contents_equal(bl)); + newdata.clear(); + r = store->read(cid, hoid, 0, 15, newdata); + ASSERT_EQ(r, 15); + { + bufferlist expected; + expected.append(bl); + expected.append_zero(5); + expected.append(bl); + ASSERT_TRUE(newdata.contents_equal(expected)); + } + } +} + TEST_P(StoreTest, SimpleObjectTest) { ObjectStore::Sequencer osr("test"); int r; @@ -1379,6 +1441,7 @@ TEST_P(StoreTest, SimpleCloneTest) { r = apply_transaction(store, &osr, std::move(t)); ASSERT_EQ(r, 0); } + ghobject_t hoid2(hobject_t(sobject_t("Object 2", CEPH_NOSNAP), "key", 123, -1, "")); {