]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
extend clone test to mock clone operation 4958/head
authorxinxin shu <xinxin.shu@intel.com>
Mon, 15 Jun 2015 00:05:26 +0000 (08:05 +0800)
committerxinxin shu <xinxin.shu@intel.com>
Tue, 14 Jul 2015 16:58:47 +0000 (00:58 +0800)
ops for clone:

{
            "op_num": 3,
            "op_name": "clone",
            "collection": "0.a_head",
            "src_oid": "573db18a\/rbd_data.100c6b8b4567.0000000000000000\/head\/\/0",
            "dst_oid": "573db18a\/rbd_data.100c6b8b4567.0000000000000000\/2\/\/0"
        },
        {
            "op_num": 4,
            "op_name": "setattr",
            "collection": "0.a_head",
            "oid": "573db18a\/rbd_data.100c6b8b4567.0000000000000000\/2\/\/0",
            "name": "_",
            "length": 258
        },
        {
            "op_num": 5,
            "op_name": "rmattr",
            "collection": "0.a_head",
            "oid": "573db18a\/rbd_data.100c6b8b4567.0000000000000000\/2\/\/0",
            "name": "snapset"
        },
        {
            "op_num": 6,
            "op_name": "op_setallochint",
            "collection": "0.a_head",
            "oid": "573db18a\/rbd_data.100c6b8b4567.0000000000000000\/head\/\/0",
            "expected_object_size": "4194304",
            "expected_write_size": "4194304"
        },
        {
            "op_num": 7,
            "op_name": "write",
            "collection": "0.a_head",
            "oid": "573db18a\/rbd_data.100c6b8b4567.0000000000000000\/head\/\/0",
            "length": 4096,
            "offset": 4024,
            "bufferlist length": 4096
        },
        {
            "op_num": 8,
            "op_name": "setattr",
            "collection": "0.a_head",
            "oid": "573db18a\/rbd_data.100c6b8b4567.0000000000000000\/head\/\/0",
            "name": "_",
            "length": 273
        },
        {
            "op_num": 9,
            "op_name": "setattr",
            "collection": "0.a_head",
            "oid": "573db18a\/rbd_data.100c6b8b4567.0000000000000000\/head\/\/0",
            "name": "snapset",
            "length": 91
        }
    ]
}

Signed-off-by: xinxin shu <xinxin.shu@intel.com>
src/test/objectstore/store_test.cc

index 77097f4a29e2d7864e46198d2afe44b1fd6f7a1b..cae47afacdd015655b449746f36def72f9a2c366 100644 (file)
@@ -399,12 +399,17 @@ TEST_P(StoreTest, SimpleCloneTest) {
     ASSERT_EQ(r, 0);
   }
   ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
-  bufferlist small;
+  bufferlist small, large, xlarge, newdata, attr;
   small.append("small");
+  large.append("large");
+  xlarge.append("xlarge");
   {
     ObjectStore::Transaction t;
     t.touch(cid, hoid);
     t.setattr(cid, hoid, "attr1", small);
+    t.setattr(cid, hoid, "attr2", large);
+    t.setattr(cid, hoid, "attr3", xlarge);
+    t.write(cid, hoid, 10, small.length(), small);
     cerr << "Creating object and set attr " << hoid << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -413,10 +418,32 @@ TEST_P(StoreTest, SimpleCloneTest) {
   {
     ObjectStore::Transaction t;
     t.clone(cid, hoid, hoid2);
-    t.rmattr(cid, hoid, "attr1");
+    t.setattr(cid, hoid2, "attr2", small);
+    t.rmattr(cid, hoid2, "attr1");
+    t.write(cid, hoid, 10, large.length(), large);
+    t.setattr(cid, hoid, "attr1", large);
+    t.setattr(cid, hoid, "attr2", small);
     cerr << "Clone object and rm attr" << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
+    r = store->read(cid, hoid, 10, 5, newdata);
+    ASSERT_EQ(r, 5);
+    ASSERT_TRUE(newdata.contents_equal(large));
+    newdata.clear();
+    r = store->read(cid, hoid2, 10, 5, newdata);
+    ASSERT_EQ(r, 5);
+    ASSERT_TRUE(newdata.contents_equal(small));
+    r = store->getattr(cid, hoid2, "attr2", attr);
+    ASSERT_EQ(r, 5);
+    ASSERT_TRUE(attr.contents_equal(small));
+    attr.clear();
+    r = store->getattr(cid, hoid2, "attr3", attr);
+    ASSERT_EQ(r, 6);
+    ASSERT_TRUE(attr.contents_equal(xlarge));
+    attr.clear();
+    r = store->getattr(cid, hoid, "attr1", attr);
+    ASSERT_EQ(r, 5);
+    ASSERT_TRUE(attr.contents_equal(small));
   }
   {
     ObjectStore::Transaction t;