From: xinxin shu Date: Mon, 15 Jun 2015 00:05:26 +0000 (+0800) Subject: extend clone test to mock clone operation X-Git-Tag: v9.1.0~515^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b7e9fe13271f3a0f7b0e92821dbc7c84e3355d42;p=ceph.git extend clone test to mock clone operation 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 --- diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 77097f4a29e2d..cae47afacdd01 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -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;