]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/objectstore: make store_test also run collection_list_legacy
authorMykola Golub <mgolub@suse.com>
Thu, 20 Aug 2020 11:24:42 +0000 (12:24 +0100)
committerMykola Golub <mgolub@suse.com>
Wed, 9 Sep 2020 09:13:51 +0000 (12:13 +0300)
Signed-off-by: Mykola Golub <mgolub@suse.com>
(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

src/os/ObjectStore.h
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/test/objectstore/store_test.cc

index 8014411db3598d8bb4f4b01fbe2696bf88a6e3e3..a3b2982b22f13e03393409b1f8450728c3273c6a 100644 (file)
@@ -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<ghobject_t> *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,
index d283da321a1c1431eb89687c9d71e07e2b84489a..accc4388e51dc7883e1d6754e93188c81edf48e9 100644 (file)
@@ -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<ghobject_t> *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<ghobject_t> *ls, ghobject_t *pnext)
index 0d031ab1b0186aa1b21ba340c6702393b16c3f94..e1e90feb3675a8879806fe1eda2a8d95f6e185f1 100644 (file)
@@ -2446,6 +2446,12 @@ public:
                      int max,
                      vector<ghobject_t> *ls, ghobject_t *next) override;
 
+  int collection_list_legacy(const coll_t& cid,
+                             const ghobject_t& start,
+                             const ghobject_t& end,
+                             int max,
+                             vector<ghobject_t> *ls,
+                             ghobject_t *next) override;
   int collection_list_legacy(CollectionHandle &c,
                              const ghobject_t& start,
                              const ghobject_t& end,
index bfa2dbc55bc5b3955eb7867489f822a12ddae00b..efc6864aa94d5ff4a04385e763ba3252d840d324 100644 (file)
@@ -100,6 +100,16 @@ int apply_transaction(
   }
 }
 
+template <typename T>
+int collection_list(T &store, const coll_t& cid, const ghobject_t& start,
+                    const ghobject_t& end, int max, vector<ghobject_t> *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<ghobject_t> &in) {
   ghobject_t start;
@@ -2468,9 +2478,8 @@ TEST_P(StoreTest, SimpleListTest) {
     vector<ghobject_t> 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<ghobject_t> 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<ghobject_t> 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<ghobject_t>::iterator p = objects.begin(); p != objects.end();
@@ -3276,7 +3285,8 @@ TEST_P(StoreTest, ManyObjectTest) {
 
   set<ghobject_t> listed, listed2;
   vector<ghobject_t> 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<ghobject_t> 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<ghobject_t> 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<ghobject_t> 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<ghobject_t>::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<ghobject_t> 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<ghobject_t> 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<ghobject_t> 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<ghobject_t> 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<ghobject_t> 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<ghobject_t>::iterator i = objects.begin();
@@ -5247,8 +5259,8 @@ void colsplittest(
 
   ObjectStore::Transaction t;
   vector<ghobject_t> 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<ghobject_t>::iterator i = objects.begin();
@@ -5544,8 +5556,8 @@ TEST_P(StoreTest, BigRGWObjectName) {
 
   {
     vector<ghobject_t> 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);