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: v12.2.14~2^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b97386785e5f0080a7f03da4009a2bf29344ca10;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/os/ObjectStore.h, src/os/bluestore/BlueStore.cc, src/os/bluestore/BlueStore.h: add collection_list_legacy with "old" signature src/test/objectstore/store_test.cc: "old" collection_list signature, different collection_list arguments in SyntheticWorkloadState::shutdown, missing related code --- diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 8014411db3598..a3b2982b22f13 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -1925,6 +1925,13 @@ public: return collection_list(c->get_cid(), start, end, max, ls, next); } + virtual int collection_list_legacy(const coll_t& c, + const ghobject_t& start, + const ghobject_t& end, int max, + vector *ls, + ghobject_t *next) { + return collection_list(c, start, end, max, ls, next); + } virtual int collection_list_legacy(CollectionHandle &c, const ghobject_t& start, const ghobject_t& end, int max, diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index d283da321a1c1..accc4388e51dc 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7901,6 +7901,16 @@ int BlueStore::collection_list( return r; } +int BlueStore::collection_list_legacy( + const coll_t& cid, const ghobject_t& start, const ghobject_t& end, int max, + vector *ls, ghobject_t *pnext) +{ + CollectionHandle c = _get_collection(cid); + if (!c) + return -ENOENT; + return collection_list_legacy(c, start, end, max, ls, pnext); +} + int BlueStore::collection_list_legacy( CollectionHandle &c_, const ghobject_t& start, const ghobject_t& end, int max, vector *ls, ghobject_t *pnext) diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 0d031ab1b0186..e1e90feb3675a 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2446,6 +2446,12 @@ public: int max, vector *ls, ghobject_t *next) override; + int collection_list_legacy(const coll_t& cid, + const ghobject_t& start, + const ghobject_t& end, + int max, + vector *ls, + ghobject_t *next) override; int collection_list_legacy(CollectionHandle &c, const ghobject_t& start, const ghobject_t& end, diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index bfa2dbc55bc5b..efc6864aa94d5 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -100,6 +100,16 @@ int apply_transaction( } } +template +int collection_list(T &store, const coll_t& cid, 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(cid, start, end, max, ls, pnext); + } else { + return store->collection_list_legacy(cid, start, end, max, ls, pnext); + } +} bool sorted(const vector &in) { ghobject_t start; @@ -2468,9 +2478,8 @@ TEST_P(StoreTest, SimpleListTest) { vector objects; ghobject_t next, current; while (!next.is_max()) { - int r = store->collection_list(cid, current, ghobject_t::get_max(), - 50, - &objects, &next); + int r = collection_list(store, cid, current, ghobject_t::get_max(), 50, + &objects, &next); ASSERT_EQ(r, 0); ASSERT_TRUE(sorted(objects)); cout << " got " << objects.size() << " next " << next << std::endl; @@ -2533,8 +2542,8 @@ TEST_P(StoreTest, ListEndTest) { end.hobj.pool = 1; vector objects; ghobject_t next; - int r = store->collection_list(cid, ghobject_t(), end, 500, - &objects, &next); + int r = collection_list(store, cid, ghobject_t(), end, 500, &objects, + &next); ASSERT_EQ(r, 0); for (auto &p : objects) { ASSERT_NE(p, end); @@ -2613,8 +2622,8 @@ TEST_P(StoreTest, MultipoolListTest) { vector objects; ghobject_t next, current; while (!next.is_max()) { - int r = store->collection_list(cid, current, ghobject_t::get_max(), 50, - &objects, &next); + int r = collection_list(store, cid, 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(); @@ -3276,7 +3285,8 @@ TEST_P(StoreTest, ManyObjectTest) { set listed, listed2; vector objects; - r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0); + r = collection_list(store, cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, + &objects, 0); ASSERT_EQ(r, 0); cerr << "objects.size() is " << objects.size() << std::endl; @@ -3290,7 +3300,8 @@ TEST_P(StoreTest, ManyObjectTest) { ghobject_t start, next; objects.clear(); - r = store->collection_list( + r = collection_list( + store, cid, ghobject_t::get_max(), ghobject_t::get_max(), @@ -3305,10 +3316,8 @@ TEST_P(StoreTest, ManyObjectTest) { listed.clear(); ghobject_t start2, next2; while (1) { - r = store->collection_list(cid, start, ghobject_t::get_max(), - 50, - &objects, - &next); + r = collection_list(store, cid, start, ghobject_t::get_max(), 50, &objects, + &next); ASSERT_TRUE(sorted(objects)); ASSERT_EQ(r, 0); listed.insert(objects.begin(), objects.end()); @@ -3532,8 +3541,8 @@ public: void shutdown() { while (1) { vector objects; - int r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), - 10, &objects, 0); + int r = collection_list(store, cid, ghobject_t(), ghobject_t::get_max(), + 10, &objects, 0); assert(r >= 0); if (objects.empty()) break; @@ -4143,8 +4152,8 @@ public: ghobject_t next, current; while (1) { //cerr << "scanning..." << std::endl; - int r = store->collection_list(cid, current, ghobject_t::get_max(), 100, - &objects, &next); + int r = collection_list(store, cid, current, ghobject_t::get_max(), 100, + &objects, &next); ASSERT_EQ(r, 0); ASSERT_TRUE(sorted(objects)); objects_set.insert(objects.begin(), objects.end()); @@ -4177,8 +4186,8 @@ public: ASSERT_GT(available_objects.count(*i), (unsigned)0); } - int r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), - INT_MAX, &objects, 0); + int r = collection_list(store, cid, 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()); @@ -4561,7 +4570,8 @@ TEST_P(StoreTest, HashCollisionTest) { } } vector objects; - r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0); + r = collection_list(store, cid, 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; @@ -4570,8 +4580,8 @@ TEST_P(StoreTest, HashCollisionTest) { listed.clear(); ghobject_t current, next; while (1) { - r = store->collection_list(cid, current, ghobject_t::get_max(), 60, - &objects, &next); + r = collection_list(store, cid, current, ghobject_t::get_max(), 60, + &objects, &next); ASSERT_EQ(r, 0); ASSERT_TRUE(sorted(objects)); for (vector::iterator i = objects.begin(); @@ -4611,6 +4621,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}; @@ -4666,8 +4678,8 @@ TEST_P(StoreTest, HashCollisionSorting) { } vector objects; - r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, - &objects, 0); + r = collection_list(store, cid, 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(); @@ -4682,9 +4694,8 @@ TEST_P(StoreTest, HashCollisionSorting) { std::set created_sub(i, j); objects.clear(); ghobject_t next; - r = store->collection_list(cid, *i, ghobject_t::get_max(), - created_sub.size(), - &objects, &next); + r = collection_list(store, cid, *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(); @@ -4706,7 +4717,8 @@ TEST_P(StoreTest, HashCollisionSorting) { std::set created_sub(i, j); objects.clear(); ghobject_t next; - r = store->collection_list(cid, *i, *j, INT_MAX, &objects, &next); + r = collection_list(store, cid, *i, *j, INT_MAX, &objects, &next, + disable_legacy); ASSERT_EQ(r, 0); ASSERT_EQ(created_sub.size(), objects.size()); it = objects.begin(); @@ -4772,8 +4784,8 @@ TEST_P(StoreTest, ScrubTest) { } vector objects; - r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), - INT_MAX, &objects, 0); + r = collection_list(store, cid, 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; @@ -4782,8 +4794,8 @@ TEST_P(StoreTest, ScrubTest) { listed.clear(); ghobject_t current, next; while (1) { - r = store->collection_list(cid, current, ghobject_t::get_max(), 60, - &objects, &next); + r = collection_list(store, cid, current, ghobject_t::get_max(), 60, + &objects, &next); ASSERT_EQ(r, 0); ASSERT_TRUE(sorted(objects)); for (vector::iterator i = objects.begin(); @@ -5247,8 +5259,8 @@ void colsplittest( ObjectStore::Transaction t; vector objects; - r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), - INT_MAX, &objects, 0); + r = collection_list(store, cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, + &objects, 0); ASSERT_EQ(r, 0); ASSERT_EQ(objects.size(), num_objects); unsigned size = 0; @@ -5266,8 +5278,8 @@ void colsplittest( } objects.clear(); - r = store->collection_list(tid, ghobject_t(), ghobject_t::get_max(), - INT_MAX, &objects, 0); + r = collection_list(store, tid, 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(); @@ -5544,8 +5556,8 @@ TEST_P(StoreTest, BigRGWObjectName) { { vector objects; - r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), - INT_MAX, &objects, 0); + r = collection_list(store, cid, ghobject_t(), ghobject_t::get_max(), + INT_MAX, &objects, 0); ASSERT_EQ(r, 0); ASSERT_EQ(objects.size(), 1u); ASSERT_EQ(objects[0], oid2);