From 08fab7a8a9103f87935c685c0a66d28e361bc9f5 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Thu, 20 Aug 2020 12:24:42 +0100 Subject: [PATCH] test/objectstore: make store_test also run collection_list_legacy Signed-off-by: Mykola Golub --- src/test/objectstore/store_test.cc | 96 +++++++++++++++++------------- 1 file changed, 54 insertions(+), 42 deletions(-) diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 0458347e217..c382c3ac1f8 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; @@ -2840,9 +2851,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; @@ -2905,8 +2915,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); @@ -2985,8 +2994,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(); @@ -3652,7 +3661,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; @@ -3666,7 +3676,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(), @@ -3681,10 +3692,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()); @@ -3911,8 +3920,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; @@ -4563,8 +4572,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()); @@ -4597,8 +4606,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()); @@ -4977,7 +4986,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; @@ -4986,8 +4996,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(); @@ -5027,6 +5037,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}; @@ -5079,8 +5091,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(); @@ -5095,9 +5107,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(); @@ -5119,7 +5130,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(); @@ -5185,8 +5197,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; @@ -5195,8 +5207,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(); @@ -5660,8 +5672,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(); @@ -5671,8 +5683,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(); @@ -5693,8 +5705,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; @@ -5831,8 +5843,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)); @@ -6140,8 +6152,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); -- 2.39.5