]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge branch 'wip-librados-tests'
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 17 Aug 2011 17:55:39 +0000 (10:55 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 17 Aug 2011 18:00:58 +0000 (11:00 -0700)
1  2 
src/Makefile.am
src/include/rados/librados.h
src/include/rados/librados.hpp
src/librados.cc
src/test/rados-api/stat.cc

diff --cc src/Makefile.am
Simple merge
Simple merge
Simple merge
diff --cc src/librados.cc
Simple merge
index 0000000000000000000000000000000000000000,d2f482675c4fffcd9462e1010de2eb48899259d6..6a3c3ca0fd8e105f2895dc2c34946489ad21e0f4
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,99 +1,99 @@@
 -  std::map<std::string,pool_stat_t> stats;
+ #include "include/rados/librados.h"
+ #include "include/rados/librados.hpp"
+ #include "test/rados-api/test.h"
+ #include <algorithm>
+ #include <errno.h>
+ #include "gtest/gtest.h"
+ using namespace librados;
+ TEST(LibRadosStat, Stat) {
+   char buf[128];
+   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);
+   memset(buf, 0xcc, sizeof(buf));
+   ASSERT_EQ((int)sizeof(buf), rados_write(ioctx, "foo", buf, sizeof(buf), 0));
+   uint64_t size;
+   time_t mtime;
+   ASSERT_EQ(0, rados_stat(ioctx, "foo", &size, &mtime));
+   ASSERT_EQ(sizeof(buf), size);
+   ASSERT_EQ(-ENOENT, rados_stat(ioctx, "nonexistent", &size, &mtime));
+   rados_ioctx_destroy(ioctx);
+   ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
+ }
+ TEST(LibRadosStat, StatPP) {
+   char buf[128];
+   Rados cluster;
+   std::string pool_name = get_temp_pool_name();
+   ASSERT_EQ("", create_one_pool_pp(pool_name, cluster));
+   IoCtx ioctx;
+   cluster.ioctx_create(pool_name.c_str(), ioctx);
+   memset(buf, 0xcc, sizeof(buf));
+   bufferlist bl;
+   bl.append(buf, sizeof(buf));
+   ASSERT_EQ((int)sizeof(buf), ioctx.write("foo", bl, sizeof(buf), 0));
+   uint64_t size;
+   time_t mtime;
+   ASSERT_EQ(0, ioctx.stat("foo", &size, &mtime));
+   ASSERT_EQ(sizeof(buf), size);
+   ASSERT_EQ(-ENOENT, ioctx.stat("nonexistent", &size, &mtime));
+   ioctx.close();
+   ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
+ }
+ TEST(LibRadosStat, ClusterStat) {
+   rados_t cluster;
+   std::string pool_name = get_temp_pool_name();
+   ASSERT_EQ("", create_one_pool(pool_name, &cluster));
+   struct rados_cluster_stat_t result;
+   ASSERT_EQ(0, rados_cluster_stat(cluster, &result));
+   ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
+ }
+ TEST(LibRadosStat, ClusterStatPP) {
+   Rados cluster;
+   cluster_stat_t cstat;
+   std::string pool_name = get_temp_pool_name();
+   ASSERT_EQ("", create_one_pool_pp(pool_name, cluster));
+   ASSERT_EQ(0, cluster.cluster_stat(cstat));
+   ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
+ }
+ TEST(LibRadosStat, PoolStat) {
+   char buf[128];
+   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);
+   memset(buf, 0xff, sizeof(buf));
+   ASSERT_EQ((int)sizeof(buf), rados_write(ioctx, "foo", buf, sizeof(buf), 0));
+   struct rados_pool_stat_t stats;
+   memset(&stats, 0, sizeof(stats));
+   ASSERT_EQ(0, rados_ioctx_pool_stat(ioctx, &stats));
+   rados_ioctx_destroy(ioctx);
+   ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
+ }
+ TEST(LibRadosStat, PoolStatPP) {
+   Rados cluster;
+   std::string pool_name = get_temp_pool_name();
+   ASSERT_EQ("", create_one_pool_pp(pool_name, cluster));
+   IoCtx ioctx;
+   cluster.ioctx_create(pool_name.c_str(), ioctx);
+   char buf[128];
+   memset(buf, 0xff, sizeof(buf));
+   bufferlist bl1;
+   bl1.append(buf, sizeof(buf));
+   ASSERT_EQ((int)sizeof(buf), ioctx.write("foo", bl1, sizeof(buf), 0));
+   std::list<std::string> v;
++  std::map<std::string,stats_map> stats;
+   ASSERT_EQ(0, cluster.get_pool_stats(v, stats));
+   ioctx.close();
+   ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
+ }