]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph_test_objectstore: extends SimpleObjectTest with the case where write happens...
authorIgor Fedotov <ifedotov@mirantis.com>
Fri, 27 May 2016 14:19:59 +0000 (17:19 +0300)
committerSage Weil <sage@redhat.com>
Wed, 1 Jun 2016 15:40:49 +0000 (11:40 -0400)
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
src/test/objectstore/store_test.cc

index 388d97beb204353a47eb64149c7507dacaf1238f..df60875f243199d0d21c8bf5bcfc7eda0d7ff0f9 100644 (file)
@@ -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);