#include "gtest/gtest.h"
/* cluster info */
-//int rados_cluster_stat(rados_t cluster, struct rados_cluster_stat_t *result);
-//
-//int rados_ioctx_pool_stat(rados_ioctx_t io, struct rados_pool_stat_t *stats);
-TEST(LibRadosIo, Stat) {
+TEST(LibRadosStat, Stat) {
char buf[128];
rados_t cluster;
rados_ioctx_t ioctx;
rados_ioctx_destroy(ioctx);
ASSERT_EQ(0, destroy_one_pool(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, 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));
+ ASSERT_EQ(stats.num_objects, 1u);
+ rados_ioctx_destroy(ioctx);
+ ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
+}