]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_test_objectstore: test many small writes
authorSage Weil <sage@redhat.com>
Tue, 28 Apr 2015 16:30:32 +0000 (09:30 -0700)
committerSage Weil <sage@redhat.com>
Wed, 19 Aug 2015 21:03:57 +0000 (17:03 -0400)
This exercises the overlay code better.

Signed-off-by: Sage Weil <sage@redhat.com>
src/test/objectstore/store_test.cc

index cc45ee8e4e446f09fa6e04dbe3d19987d66e9599..e6b4d8f55c72154254a56675c00c9e5219f3cf0c 100644 (file)
@@ -402,6 +402,45 @@ TEST_P(StoreTest, SimpleObjectTest) {
   }
 }
 
+TEST_P(StoreTest, ManySmallWrite) {
+  int r;
+  coll_t cid;
+  ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+  ghobject_t b(hobject_t(sobject_t("Object 2", CEPH_NOSNAP)));
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    cerr << "Creating collection " << cid << std::endl;
+    r = store->apply_transaction(t);
+    ASSERT_EQ(r, 0);
+  }
+  bufferlist bl;
+  bufferptr bp(4096);
+  bp.zero();
+  bl.append(bp);
+  for (int i=0; i<100; ++i) {
+    ObjectStore::Transaction t;
+    t.write(cid, a, i*4096, 4096, bl, 0);
+    r = store->apply_transaction(t);
+    ASSERT_EQ(r, 0);
+  }
+  for (int i=0; i<100; ++i) {
+    ObjectStore::Transaction t;
+    t.write(cid, b, (rand() % 1024)*4096, 4096, bl, 0);
+    r = store->apply_transaction(t);
+    ASSERT_EQ(r, 0);
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, a);
+    t.remove(cid, b);
+    t.remove_collection(cid);
+    cerr << "Cleaning" << std::endl;
+    r = store->apply_transaction(t);
+    ASSERT_EQ(r, 0);
+  }
+}
+
 TEST_P(StoreTest, SimpleAttrTest) {
   int r;
   coll_t cid;