]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
StoreTest: Add clone xattr test
authorHaomai Wang <haomaiwang@gmail.com>
Mon, 13 Oct 2014 01:39:32 +0000 (09:39 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Mon, 13 Oct 2014 02:01:59 +0000 (10:01 +0800)
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/test/objectstore/store_test.cc

index 38c7b30cf24dd969516edc723728739be529ee2a..6922b5bbf4d6a5c6fc26e8ff8fbf84a68be45081 100644 (file)
@@ -217,6 +217,47 @@ TEST_P(StoreTest, SimpleObjectTest) {
   }
 }
 
+TEST_P(StoreTest, SimpleCloneTest) {
+  int r;
+  coll_t cid = coll_t("coll");
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid);
+    cerr << "Creating collection " << cid << std::endl;
+    r = store->apply_transaction(t);
+    ASSERT_EQ(r, 0);
+  }
+  ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+  bufferlist small;
+  small.append("small");
+  {
+    ObjectStore::Transaction t;
+    t.touch(cid, hoid);
+    t.setattr(cid, hoid, "attr1", small);
+    cerr << "Creating object and set attr " << hoid << std::endl;
+    r = store->apply_transaction(t);
+    ASSERT_EQ(r, 0);
+  }
+  ghobject_t hoid2(hobject_t(sobject_t("Object 2", CEPH_NOSNAP)));
+  {
+    ObjectStore::Transaction t;
+    t.clone(cid, hoid, hoid2);
+    t.rmattr(cid, hoid, "attr1");
+    cerr << "Clone object and rm attr" << std::endl;
+    r = store->apply_transaction(t);
+    ASSERT_EQ(r, 0);
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, hoid);
+    t.remove(cid, hoid2);
+    t.remove_collection(cid);
+    cerr << "Cleaning" << std::endl;
+    r = store->apply_transaction(t);
+    ASSERT_EQ(r, 0);
+  }
+}
+
 TEST_P(StoreTest, SimpleObjectLongnameTest) {
   int r;
   coll_t cid = coll_t("coll");