From: Mykola Golub Date: Thu, 20 Aug 2020 11:24:42 +0000 (+0100) Subject: test/objectstore: make store_test also run collection_list_legacy X-Git-Tag: v15.2.9~122^2~43^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7c26c0b5e9ea835652b1f524503ab78d1ff1ea64;p=ceph.git test/objectstore: make store_test also run collection_list_legacy Signed-off-by: Mykola Golub (cherry picked from commit 08fab7a8a9103f87935c685c0a66d28e361bc9f5) --- diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 40610e86f0a..c8aba223127 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -101,6 +101,17 @@ int queue_transaction( } } +template +int collection_list(T &store, ObjectStore::CollectionHandle &c, + const ghobject_t& start, const ghobject_t& end, int max, + vector *ls, ghobject_t *pnext, + bool disable_legacy = false) { + if (disable_legacy || rand() % 2) { + return store->collection_list(c, start, end, max, ls, pnext); + } else { + return store->collection_list_legacy(c, start, end, max, ls, pnext); + } +} bool sorted(const vector &in) { ghobject_t start; @@ -2836,9 +2847,8 @@ TEST_P(StoreTest, SimpleListTest) { vector objects; ghobject_t next, current; while (!next.is_max()) { - int r = store->collection_list(ch, current, ghobject_t::get_max(), - 50, - &objects, &next); + int r = collection_list(store, ch, current, ghobject_t::get_max(), 50, + &objects, &next); ASSERT_EQ(r, 0); ASSERT_TRUE(sorted(objects)); cout << " got " << objects.size() << " next " << next << std::endl; @@ -2901,8 +2911,7 @@ TEST_P(StoreTest, ListEndTest) { end.hobj.pool = 1; vector objects; ghobject_t next; - int r = store->collection_list(ch, ghobject_t(), end, 500, - &objects, &next); + int r = collection_list(store, ch, ghobject_t(), end, 500, &objects, &next); ASSERT_EQ(r, 0); for (auto &p : objects) { ASSERT_NE(p, end); @@ -2981,8 +2990,8 @@ TEST_P(StoreTest, MultipoolListTest) { vector objects; ghobject_t next, current; while (!next.is_max()) { - int r = store->collection_list(ch, current, ghobject_t::get_max(), 50, - &objects, &next); + int r = collection_list(store, ch, current, ghobject_t::get_max(), 50, + &objects, &next); ASSERT_EQ(r, 0); cout << " got " << objects.size() << " next " << next << std::endl; for (vector::iterator p = objects.begin(); p != objects.end(); @@ -3648,7 +3657,8 @@ TEST_P(StoreTest, ManyObjectTest) { set listed, listed2; vector objects; - r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0); + r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, + &objects, 0); ASSERT_EQ(r, 0); cerr << "objects.size() is " << objects.size() << std::endl; @@ -3662,7 +3672,8 @@ TEST_P(StoreTest, ManyObjectTest) { ghobject_t start, next; objects.clear(); - r = store->collection_list( + r = collection_list( + store, ch, ghobject_t::get_max(), ghobject_t::get_max(), @@ -3677,10 +3688,8 @@ TEST_P(StoreTest, ManyObjectTest) { listed.clear(); ghobject_t start2, next2; while (1) { - r = store->collection_list(ch, start, ghobject_t::get_max(), - 50, - &objects, - &next); + r = collection_list(store, ch, start, ghobject_t::get_max(), 50, &objects, + &next); ASSERT_TRUE(sorted(objects)); ASSERT_EQ(r, 0); listed.insert(objects.begin(), objects.end()); @@ -3907,8 +3916,8 @@ public: ghobject_t next; while (1) { vector objects; - int r = store->collection_list(ch, next, ghobject_t::get_max(), - 10, &objects, &next); + int r = collection_list(store, ch, next, ghobject_t::get_max(), 10, + &objects, &next); ceph_assert(r >= 0); if (objects.size() == 0) break; @@ -4559,8 +4568,8 @@ public: ghobject_t next, current; while (1) { //cerr << "scanning..." << std::endl; - int r = store->collection_list(ch, current, ghobject_t::get_max(), 100, - &objects, &next); + int r = collection_list(store, ch, current, ghobject_t::get_max(), 100, + &objects, &next); ASSERT_EQ(r, 0); ASSERT_TRUE(sorted(objects)); objects_set.insert(objects.begin(), objects.end()); @@ -4593,8 +4602,8 @@ public: ASSERT_GT(available_objects.count(*i), (unsigned)0); } - int r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), - INT_MAX, &objects, 0); + int r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), + INT_MAX, &objects, 0); ASSERT_EQ(r, 0); objects_set2.insert(objects.begin(), objects.end()); ASSERT_EQ(objects_set2.size(), available_objects.size()); @@ -5008,7 +5017,8 @@ TEST_P(StoreTest, HashCollisionTest) { } } vector objects; - r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0); + r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, + &objects, 0); ASSERT_EQ(r, 0); set listed(objects.begin(), objects.end()); cerr << "listed.size() is " << listed.size() << " and created.size() is " << created.size() << std::endl; @@ -5017,8 +5027,8 @@ TEST_P(StoreTest, HashCollisionTest) { listed.clear(); ghobject_t current, next; while (1) { - r = store->collection_list(ch, current, ghobject_t::get_max(), 60, - &objects, &next); + r = collection_list(store, ch, current, ghobject_t::get_max(), 60, &objects, + &next); ASSERT_EQ(r, 0); ASSERT_TRUE(sorted(objects)); for (vector::iterator i = objects.begin(); @@ -5058,6 +5068,8 @@ TEST_P(StoreTest, HashCollisionTest) { } TEST_P(StoreTest, HashCollisionSorting) { + bool disable_legacy = (string(GetParam()) == "bluestore"); + char buf121664318_1[] = {18, -119, -121, -111, 0}; char buf121664318_2[] = {19, 127, -121, 32, 0}; char buf121664318_3[] = {19, -118, 15, 19, 0}; @@ -5110,8 +5122,8 @@ TEST_P(StoreTest, HashCollisionSorting) { } vector objects; - int r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), - INT_MAX, &objects, 0); + int r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), + INT_MAX, &objects, 0, disable_legacy); ASSERT_EQ(r, 0); ASSERT_EQ(created.size(), objects.size()); auto it = objects.begin(); @@ -5126,9 +5138,8 @@ TEST_P(StoreTest, HashCollisionSorting) { std::set created_sub(i, j); objects.clear(); ghobject_t next; - r = store->collection_list(ch, *i, ghobject_t::get_max(), - created_sub.size(), - &objects, &next); + r = collection_list(store, ch, *i, ghobject_t::get_max(), + created_sub.size(), &objects, &next, disable_legacy); ASSERT_EQ(r, 0); ASSERT_EQ(created_sub.size(), objects.size()); it = objects.begin(); @@ -5150,7 +5161,8 @@ TEST_P(StoreTest, HashCollisionSorting) { std::set created_sub(i, j); objects.clear(); ghobject_t next; - r = store->collection_list(ch, *i, *j, INT_MAX, &objects, &next); + r = collection_list(store, ch, *i, *j, INT_MAX, &objects, &next, + disable_legacy); ASSERT_EQ(r, 0); ASSERT_EQ(created_sub.size(), objects.size()); it = objects.begin(); @@ -5216,8 +5228,8 @@ TEST_P(StoreTest, ScrubTest) { } vector objects; - r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), - INT_MAX, &objects, 0); + r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, + &objects, 0); ASSERT_EQ(r, 0); set listed(objects.begin(), objects.end()); cerr << "listed.size() is " << listed.size() << " and created.size() is " << created.size() << std::endl; @@ -5226,8 +5238,8 @@ TEST_P(StoreTest, ScrubTest) { listed.clear(); ghobject_t current, next; while (1) { - r = store->collection_list(ch, current, ghobject_t::get_max(), 60, - &objects, &next); + r = collection_list(store, ch, current, ghobject_t::get_max(), 60, &objects, + &next); ASSERT_EQ(r, 0); ASSERT_TRUE(sorted(objects)); for (vector::iterator i = objects.begin(); @@ -5691,8 +5703,8 @@ void colsplittest( // check vector objects; - r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), - INT_MAX, &objects, 0); + r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, + &objects, 0); ASSERT_EQ(r, 0); ASSERT_EQ(objects.size(), num_objects); for (vector::iterator i = objects.begin(); @@ -5702,8 +5714,8 @@ void colsplittest( } objects.clear(); - r = store->collection_list(tch, ghobject_t(), ghobject_t::get_max(), - INT_MAX, &objects, 0); + r = collection_list(store, tch, ghobject_t(), ghobject_t::get_max(), INT_MAX, + &objects, 0); ASSERT_EQ(r, 0); ASSERT_EQ(objects.size(), num_objects); for (vector::iterator i = objects.begin(); @@ -5724,8 +5736,8 @@ void colsplittest( ObjectStore::Transaction t; { vector objects; - r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), - INT_MAX, &objects, 0); + r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, + &objects, 0); ASSERT_EQ(r, 0); ASSERT_EQ(objects.size(), num_objects * 2); // both halves unsigned size = 0; @@ -5862,8 +5874,8 @@ void test_merge_skewed(ObjectStore *store, // verify { vector got; - store->collection_list(cha, ghobject_t(), ghobject_t::get_max(), INT_MAX, - &got, 0); + collection_list(store, cha, ghobject_t(), ghobject_t::get_max(), INT_MAX, + &got, 0); set gotset; for (auto& o : got) { ASSERT_TRUE(aobjects.count(o) || bobjects.count(o)); @@ -6171,8 +6183,8 @@ TEST_P(StoreTest, BigRGWObjectName) { { vector objects; - r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), - INT_MAX, &objects, 0); + r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, + &objects, 0); ASSERT_EQ(r, 0); ASSERT_EQ(objects.size(), 1u); ASSERT_EQ(objects[0], oid2);