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: v14.2.12~81^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c1ffc64ed55c3fc47e1767fa7da4d43f45ecbda6;p=ceph.git test/objectstore: make store_test also run collection_list_legacy Signed-off-by: Mykola Golub (cherry picked from commit 08fab7a8a9103f87935c685c0a66d28e361bc9f5) Conflicts: src/test/objectstore/store_test.cc: different collection_list arguments in SyntheticWorkloadState::shutdown --- diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 0b11913847a..db1ff9d7dc8 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -103,6 +103,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; @@ -2733,9 +2744,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; @@ -2798,8 +2808,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); @@ -2878,8 +2887,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(); @@ -3545,7 +3554,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; @@ -3559,7 +3569,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(), @@ -3574,10 +3585,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()); @@ -3802,8 +3811,8 @@ public: void shutdown() { while (1) { vector objects; - int r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), - 10, &objects, 0); + int r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), + 10, &objects, 0); ceph_assert(r >= 0); if (objects.empty()) break; @@ -4413,8 +4422,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()); @@ -4447,8 +4456,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()); @@ -4862,7 +4871,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; @@ -4871,8 +4881,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(); @@ -4912,6 +4922,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}; @@ -4964,8 +4976,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(); @@ -4980,9 +4992,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(); @@ -5004,7 +5015,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(); @@ -5070,8 +5082,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; @@ -5080,8 +5092,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(); @@ -5547,8 +5559,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(); @@ -5558,8 +5570,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(); @@ -5580,8 +5592,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; @@ -5718,8 +5730,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)); @@ -6027,8 +6039,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);