From: John Spray Date: Mon, 17 Aug 2015 18:40:00 +0000 (-0400) Subject: test: tests for new-style pgls X-Git-Tag: v10.0.3~215^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5555f9f41fad755c526a099b13e3425f4a0d4aa4;p=ceph.git test: tests for new-style pgls Signed-off-by: John Spray Signed-off-by: Sage Weil --- diff --git a/src/test/librados/list.cc b/src/test/librados/list.cc index 0e6aa5b3b63..4f7897f1772 100644 --- a/src/test/librados/list.cc +++ b/src/test/librados/list.cc @@ -6,6 +6,7 @@ #include "test/librados/TestCase.h" #include "include/types.h" +#include "common/hobject.h" #include "gtest/gtest.h" #include #include @@ -34,6 +35,7 @@ TEST_F(LibRadosList, ListObjects) { rados_objects_list_close(ctx); } + #pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" @@ -665,5 +667,129 @@ TEST_F(LibRadosListECPP, ListObjectsStartPP) { } } + +TEST_F(LibRadosList, EnumerateObjects) { + char buf[128]; + memset(buf, 0xcc, sizeof(buf)); + bufferlist bl; + bl.append(buf, sizeof(buf)); + + const uint32_t n_objects = 16; + for (unsigned i=0; i saw_obj; + rados_enumerate_cursor c = rados_enumerate_objects_begin(ioctx); + rados_enumerate_cursor end = rados_enumerate_objects_end(ioctx); + while(!rados_enumerate_objects_is_end(ioctx, c)) + { + rados_enumerate_item results[12]; + memset(results, 0, sizeof(rados_enumerate_item) * 12); + int r = rados_enumerate_objects(ioctx, + c, rados_enumerate_objects_end(ioctx), + 12, results, &c); + ASSERT_GE(r, 0); + for (int i = 0; i < r; ++i) { + std::string oid(results[i].oid, results[i].oid_length); + if (saw_obj.count(oid)) { + std::cerr << "duplicate obj " << oid << std::endl; + } + ASSERT_FALSE(saw_obj.count(oid)); + saw_obj.insert(oid); + } + rados_enumerate_objects_free(12, results); + } + rados_enumerate_cursor_free(ioctx, c); + rados_enumerate_cursor_free(ioctx, end); + + for (unsigned i=0; i saw_obj; + for (unsigned n = 0; n < m; ++n) { + rados_enumerate_cursor shard_start = rados_enumerate_objects_begin(ioctx);; + rados_enumerate_cursor shard_end = rados_enumerate_objects_end(ioctx);; + + rados_enumerate_objects_split( + ioctx, + begin, + end, + n, + m, + &shard_start, + &shard_end); + std::cout << "split " << n << "/" << m << " -> " + << *(hobject_t*)shard_start << " " + << *(hobject_t*)shard_end << std::endl; + + rados_enumerate_cursor c = shard_start; + //while(c < shard_end) + while(rados_enumerate_cursor_cmp(ioctx, c, shard_end) == -1) + { + rados_enumerate_item results[12]; + memset(results, 0, sizeof(rados_enumerate_item) * 12); + int r = rados_enumerate_objects(ioctx, + c, shard_end, + 12, results, &c); + ASSERT_GE(r, 0); + for (int i = 0; i < r; ++i) { + std::string oid(results[i].oid, results[i].oid_length); + if (saw_obj.count(oid)) { + std::cerr << "duplicate obj " << oid << std::endl; + } + ASSERT_FALSE(saw_obj.count(oid)); + saw_obj.insert(oid); + } + rados_enumerate_objects_free(12, results); + } + rados_enumerate_cursor_free(ioctx, shard_start); + rados_enumerate_cursor_free(ioctx, shard_end); + } + + rados_enumerate_cursor_free(ioctx, begin); + rados_enumerate_cursor_free(ioctx, end); + + for (unsigned i=0; i