From b0981b3391512a4bad9dd4cb84d358756cf8c6c6 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Fri, 27 May 2016 17:19:59 +0300 Subject: [PATCH] ceph_test_objectstore: extends SimpleObjectTest with the case where write happens for neighboring csum blocks to verify for potential alignment issue Signed-off-by: Igor Fedotov --- src/test/objectstore/store_test.cc | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 388d97beb20..df60875f243 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -821,6 +821,57 @@ TEST_P(StoreTest, SimpleObjectTest) { in.hexdump(cout); ASSERT_TRUE(in.contents_equal(bl)); } + { + //verifying unaligned csums + std::string s1("1"), s2(0x1000, '2'), s3("00"); + { + ObjectStore::Transaction t; + bufferlist bl; + bl.append(s1); + bl.append(s2); + t.truncate(cid, hoid, 0); + t.write(cid, hoid, 0x1000-1, bl.length(), bl); + cerr << "Write unaligned csum, stage 1" << std::endl; + r = apply_transaction(store, &osr, std::move(t)); + ASSERT_EQ(r, 0); + } + + bufferlist in, exp1, exp2, exp3; + exp1.append(s1); + exp2.append(s2); + exp3.append(s3); + r = store->read(cid, hoid, 0x1000-1, 1, in); + ASSERT_EQ(1, r); + ASSERT_TRUE(in.contents_equal(exp1)); + in.clear(); + r = store->read(cid, hoid, 0x1000, 0x1000, in); + ASSERT_EQ(0x1000, r); + ASSERT_TRUE(in.contents_equal(exp2)); + + { + ObjectStore::Transaction t; + bufferlist bl; + bl.append(s3); + t.write(cid, hoid, 1, bl.length(), bl); + cerr << "Write unaligned csum, stage 2" << std::endl; + r = apply_transaction(store, &osr, std::move(t)); + ASSERT_EQ(r, 0); + } + in.clear(); + r = store->read(cid, hoid, 1, 2, in); + ASSERT_EQ(2, r); + ASSERT_TRUE(in.contents_equal(exp3)); + in.clear(); + r = store->read(cid, hoid, 0x1000-1, 1, in); + ASSERT_EQ(1, r); + ASSERT_TRUE(in.contents_equal(exp1)); + in.clear(); + r = store->read(cid, hoid, 0x1000, 0x1000, in); + ASSERT_EQ(0x1000, r); + ASSERT_TRUE(in.contents_equal(exp2)); + + } + { ObjectStore::Transaction t; t.remove(cid, hoid); -- 2.39.5