From bd463863532ca75214271db1ccb3b1e39344b911 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Mon, 10 Sep 2012 21:47:09 -0700 Subject: [PATCH] test/store_test: add simple tests for collection_split Signed-off-by: Samuel Just --- src/test/filestore/store_test.cc | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/test/filestore/store_test.cc b/src/test/filestore/store_test.cc index 3a41fa10e4c..e1e1491c53e 100644 --- a/src/test/filestore/store_test.cc +++ b/src/test/filestore/store_test.cc @@ -732,6 +732,72 @@ TEST_F(StoreTest, XattrTest) { ASSERT_TRUE(bl2 == attrs["attr3"]); } +void colsplittest( + ObjectStore *store, + unsigned num_objects, + unsigned common_suffix_size + ) { + coll_t cid("from"); + coll_t tid("to"); + int r = 0; + { + ObjectStore::Transaction t; + t.create_collection(cid); + r = store->apply_transaction(t); + ASSERT_EQ(r, 0); + } + { + ObjectStore::Transaction t; + for (uint32_t i = 0; i < 2*num_objects; ++i) { + stringstream objname; + objname << "obj" << i; + t.touch(cid, hobject_t( + objname.str(), + "", + CEPH_NOSNAP, + i<apply_transaction(t); + ASSERT_EQ(r, 0); + } + { + ObjectStore::Transaction t; + t.split_collection(cid, common_suffix_size+1, 0, tid); + r = store->apply_transaction(t); + ASSERT_EQ(r, 0); + } + vector objects; + r = store->collection_list(cid, objects); + ASSERT_EQ(r, 0); + ASSERT_EQ(objects.size(), num_objects); + for (vector::iterator i = objects.begin(); + i != objects.end(); + ++i) { + ASSERT_EQ(!(i->hash & (1<collection_list(tid, objects); + ASSERT_EQ(r, 0); + ASSERT_EQ(objects.size(), num_objects); + for (vector::iterator i = objects.begin(); + i != objects.end(); + ++i) { + ASSERT_EQ(i->hash & (1< args; argv_to_vec(argc, (const char **)argv, args);