summaryrefslogtreecommitdiff
path: root/src/test/librados/list.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/librados/list.cc')
-rw-r--r--src/test/librados/list.cc87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/test/librados/list.cc b/src/test/librados/list.cc
index fca0ad40395..d2aeec25e96 100644
--- a/src/test/librados/list.cc
+++ b/src/test/librados/list.cc
@@ -3,6 +3,7 @@
#include "include/stringify.h"
#include "test/librados/test.h"
+#include "include/types.h"
#include "gtest/gtest.h"
#include <errno.h>
#include <string>
@@ -214,3 +215,89 @@ TEST(LibRadosList, ListObjectsManyPP) {
ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
}
+
+
+TEST(LibRadosList, ListObjectsStart) {
+ rados_t cluster;
+ rados_ioctx_t ioctx;
+ std::string pool_name = get_temp_pool_name();
+ ASSERT_EQ("", create_one_pool(pool_name, &cluster));
+ rados_ioctx_create(cluster, pool_name.c_str(), &ioctx);
+
+ char buf[128];
+ memset(buf, 0xcc, sizeof(buf));
+
+ for (int i=0; i<16; ++i) {
+ string n = stringify(i);
+ ASSERT_EQ((int)sizeof(buf), rados_write(ioctx, n.c_str(), buf, sizeof(buf), 0));
+ }
+
+ rados_list_ctx_t ctx;
+ ASSERT_EQ(0, rados_objects_list_open(ioctx, &ctx));
+ std::map<int, std::set<std::string> > pg_to_obj;
+ const char *entry;
+ while (rados_objects_list_next(ctx, &entry, NULL) == 0) {
+ uint32_t pos = rados_objects_list_get_pg_hash_position(ctx);
+ std::cout << entry << " " << pos << std::endl;
+ pg_to_obj[pos].insert(entry);
+ }
+ rados_objects_list_close(ctx);
+
+ std::map<int, std::set<std::string> >::reverse_iterator p =
+ pg_to_obj.rbegin();
+ ASSERT_EQ(0, rados_objects_list_open(ioctx, &ctx));
+ while (p != pg_to_obj.rend()) {
+ ASSERT_EQ((uint32_t)p->first, rados_objects_list_seek(ctx, p->first));
+ ASSERT_EQ(0, rados_objects_list_next(ctx, &entry, NULL));
+ std::cout << "have " << entry << " expect one of " << p->second << std::endl;
+ ASSERT_TRUE(p->second.count(entry));
+
+ ++p;
+ if (p == pg_to_obj.rend())
+ break;
+ }
+ rados_objects_list_close(ctx);
+ rados_ioctx_destroy(ioctx);
+ ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
+}
+
+TEST(LibRadosList, ListObjectsStartPP) {
+ std::string pool_name = get_temp_pool_name();
+ Rados cluster;
+ ASSERT_EQ("", create_one_pool_pp(pool_name, cluster));
+ IoCtx ioctx;
+ cluster.ioctx_create(pool_name.c_str(), ioctx);
+
+ char buf[128];
+ memset(buf, 0xcc, sizeof(buf));
+ bufferlist bl;
+ bl.append(buf, sizeof(buf));
+
+ for (int i=0; i<16; ++i) {
+ ASSERT_EQ((int)sizeof(buf), ioctx.write(stringify(i), bl, bl.length(), 0));
+ }
+
+ librados::ObjectIterator it = ioctx.objects_begin();
+ std::map<int, std::set<std::string> > pg_to_obj;
+ for (; it != ioctx.objects_end(); ++it) {
+ std::cout << it->first << " " << it.get_pg_hash_position() << std::endl;
+ pg_to_obj[it.get_pg_hash_position()].insert(it->first);
+ }
+
+ std::map<int, std::set<std::string> >::reverse_iterator p =
+ pg_to_obj.rbegin();
+ it = ioctx.objects_begin(p->first);
+ while (p != pg_to_obj.rend()) {
+ std::cout << "have " << it->first << " expect one of " << p->second << std::endl;
+ ASSERT_TRUE(p->second.count(it->first));
+
+ ++p;
+ if (p == pg_to_obj.rend())
+ break;
+ ASSERT_EQ((uint32_t)p->first, it.seek(p->first));
+ }
+
+ ioctx.close();
+ ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
+}
+