From a1d8013abc3bedfedbd05052d53ac7cdc3f3ba46 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Thu, 11 Aug 2011 10:40:29 -0700 Subject: [PATCH] test/rados-api/test.cc: add create_one_pool_pp,etc Signed-off-by: Colin McCabe --- src/test/rados-api/test.cc | 47 ++++++++++++++++++++++++++++++++++++++ src/test/rados-api/test.h | 5 +++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/test/rados-api/test.cc b/src/test/rados-api/test.cc index 72cce23ca5474..5e37fac037b5f 100644 --- a/src/test/rados-api/test.cc +++ b/src/test/rados-api/test.cc @@ -1,4 +1,5 @@ #include "include/rados/librados.h" +#include "include/rados/librados.hpp" #include "test/rados-api/test.h" #include @@ -6,6 +7,8 @@ #include #include +using namespace librados; + std::string get_temp_pool_name() { char out[17]; @@ -50,6 +53,39 @@ std::string create_one_pool(const std::string &pool_name, rados_t *cluster) return ""; } +std::string create_one_pool_pp(const std::string &pool_name, Rados &cluster) +{ + int ret; + ret = cluster.init(NULL); + if (ret) { + std::ostringstream oss; + oss << "cluster.init failed with error " << ret; + return oss.str(); + } + ret = cluster.conf_read_file(NULL); + if (ret) { + cluster.shutdown(); + std::ostringstream oss; + oss << "cluster.conf_read_file failed with error " << ret; + return oss.str(); + } + ret = cluster.connect(); + if (ret) { + cluster.shutdown(); + std::ostringstream oss; + oss << "cluster.connect failed with error " << ret; + return oss.str(); + } + ret = cluster.pool_create(pool_name.c_str()); + if (ret) { + cluster.shutdown(); + std::ostringstream oss; + oss << "cluster.pool_create(" << pool_name << ") failed with error " << ret; + return oss.str(); + } + return ""; +} + int destroy_one_pool(const std::string &pool_name, rados_t *cluster) { int ret = rados_pool_delete(*cluster, pool_name.c_str()); @@ -60,3 +96,14 @@ int destroy_one_pool(const std::string &pool_name, rados_t *cluster) rados_shutdown(*cluster); return 0; } + +int destroy_one_pool_pp(const std::string &pool_name, Rados &cluster) +{ + int ret = cluster.pool_delete(pool_name.c_str()); + if (ret) { + cluster.shutdown(); + return ret; + } + cluster.shutdown(); + return 0; +} diff --git a/src/test/rados-api/test.h b/src/test/rados-api/test.h index 01022b8a03fe5..8e22d87105bc2 100644 --- a/src/test/rados-api/test.h +++ b/src/test/rados-api/test.h @@ -16,6 +16,7 @@ #define CEPH_TEST_RADOS_API_TEST_H #include "include/rados/librados.h" +#include "include/rados/librados.hpp" #include #include @@ -23,8 +24,10 @@ std::string get_temp_pool_name(); std::string create_one_pool(const std::string &pool_name, rados_t *cluster); - +std::string create_one_pool_pp(const std::string &pool_name, + librados::Rados &cluster); int destroy_one_pool(const std::string &pool_name, rados_t *cluster); +int destroy_one_pool_pp(const std::string &pool_name, librados::Rados &cluster); class TestAlarm { -- 2.39.5