]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_test_objectstore: test collection_list end bound
authorSage Weil <sage@redhat.com>
Thu, 3 Nov 2016 18:14:07 +0000 (14:14 -0400)
committerSage Weil <sage@redhat.com>
Thu, 3 Nov 2016 18:14:07 +0000 (14:14 -0400)
Ensure that it is not included in the result!

Signed-off-by: Sage Weil <sage@redhat.com>
src/test/objectstore/store_test.cc

index 0bf4b1585f0205ee753eaf159b1005820ad3d08e..c659a27ed09faa12ea9a666621c174d5743e94a4 100644 (file)
@@ -2364,6 +2364,58 @@ TEST_P(StoreTest, SimpleListTest) {
   }
 }
 
+TEST_P(StoreTest, ListEndTest) {
+  ObjectStore::Sequencer osr("test");
+  int r;
+  coll_t cid(spg_t(pg_t(0, 1), shard_id_t(1)));
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    cerr << "Creating collection " << cid << std::endl;
+    r = apply_transaction(store, &osr, std::move(t));
+    ASSERT_EQ(r, 0);
+  }
+  set<ghobject_t, ghobject_t::BitwiseComparator> all;
+  {
+    ObjectStore::Transaction t;
+    for (int i=0; i<200; ++i) {
+      string name("object_");
+      name += stringify(i);
+      ghobject_t hoid(hobject_t(sobject_t(name, CEPH_NOSNAP)),
+                     ghobject_t::NO_GEN, shard_id_t(1));
+      hoid.hobj.pool = 1;
+      all.insert(hoid);
+      t.touch(cid, hoid);
+      cerr << "Creating object " << hoid << std::endl;
+    }
+    r = apply_transaction(store, &osr, std::move(t));
+    ASSERT_EQ(r, 0);
+  }
+  {
+    ghobject_t end(hobject_t(sobject_t("object_100", CEPH_NOSNAP)),
+                  ghobject_t::NO_GEN, shard_id_t(1));
+    end.hobj.pool = 1;
+    vector<ghobject_t> objects;
+    ghobject_t next;
+    int r = store->collection_list(cid, ghobject_t(), end,
+                                  true, 500,
+                                  &objects, &next);
+    ASSERT_EQ(r, 0);
+    for (auto &p : objects) {
+      ASSERT_NE(p, end);
+    }
+  }
+  {
+    ObjectStore::Transaction t;
+    for (set<ghobject_t, ghobject_t::BitwiseComparator>::iterator p = all.begin(); p != all.end(); ++p)
+      t.remove(cid, *p);
+    t.remove_collection(cid);
+    cerr << "Cleaning" << std::endl;
+    r = apply_transaction(store, &osr, std::move(t));
+    ASSERT_EQ(r, 0);
+  }
+}
+
 TEST_P(StoreTest, Sort) {
   {
     hobject_t a(sobject_t("a", CEPH_NOSNAP));