#include "include/rbd/librbd.h"
#include "include/rbd/librbd.hpp"
-#include "global/global_context.h"
-#include "global/global_init.h"
-#include "common/ceph_argparse.h"
-#include "common/config.h"
#include "common/Thread.h"
#include "gtest/gtest.h"
{
if (old_format) {
// ensure old-format tests actually use the old format
- CephContext *cct = reinterpret_cast<CephContext*>(rados_ioctx_cct(ioctx));
- cct->_conf->set_val_or_die("rbd_default_format", "1");
-
+ int r = rados_conf_set(rados_ioctx_get_cluster(ioctx),
+ "rbd_default_format", "1");
+ if (r < 0) {
+ return r;
+ }
return rbd_create(ioctx, name, size, order);
} else if ((features & RBD_FEATURE_STRIPINGV2) != 0) {
return rbd_create3(ioctx, name, size, features, order, 65536, 16);
if (r < 0)
return r;
if (old_format) {
- // ensure old-format tests actually use the old format
- CephContext *cct = reinterpret_cast<CephContext*>(ioctx.cct());
- cct->_conf->set_val_or_die("rbd_default_format", "1");
-
+ librados::Rados rados(ioctx);
+ int r = rados.conf_set("rbd_default_format", "1");
+ if (r < 0) {
+ return r;
+ }
return rbd.create(ioctx, name, size, order);
} else {
return rbd.create2(ioctx, name, size, features, order);
TEST_F(TestLibRBD, TestCoR)
{
- if (!g_conf->rbd_clone_copy_on_read) {
+ std::string config_value;
+ ASSERT_EQ(0, _rados.conf_get("rbd_clone_copy_on_read", config_value));
+ if (config_value == "false") {
std::cout << "SKIPPING due to disabled rbd_copy_on_read" << std::endl;
return;
}
TEST_F(TestLibRBD, LargeCacheRead)
{
- if (!g_conf->rbd_cache) {
+ std::string config_value;
+ ASSERT_EQ(0, _rados.conf_get("rbd_cache", config_value));
+ if (config_value == "false") {
std::cout << "SKIPPING due to disabled cache" << std::endl;
return;
}
rados_ioctx_t ioctx;
rados_ioctx_create(_cluster, m_pool_name.c_str(), &ioctx);
- uint64_t orig_cache_size = g_conf->rbd_cache_size;
- g_conf->set_val("rbd_cache_size", "16777216");
+ uint32_t new_cache_size = 16777216;
+ std::string orig_cache_size;
+ ASSERT_EQ(0, _rados.conf_get("rbd_cache_size", orig_cache_size));
+ ASSERT_EQ(0, _rados.conf_set("rbd_cache_size",
+ stringify(new_cache_size).c_str()));
+ ASSERT_EQ(0, _rados.conf_get("rbd_cache_size", config_value));
+ ASSERT_EQ(stringify(new_cache_size), config_value);
BOOST_SCOPE_EXIT( (orig_cache_size) ) {
- g_conf->set_val("rbd_cache_size", stringify(orig_cache_size).c_str());
+ ASSERT_EQ(0, _rados.conf_set("rbd_cache_size", orig_cache_size.c_str()));
} BOOST_SCOPE_EXIT_END;
- ASSERT_EQ(16777216, g_conf->rbd_cache_size);
rbd_image_t image;
int order = 0;
const char *name = "testimg";
- uint64_t size = g_conf->rbd_cache_size + 1;
+ uint64_t size = new_cache_size + 1;
ASSERT_EQ(0, create_image(ioctx, name, size, &order));
ASSERT_EQ(0, rbd_open(ioctx, name, &image, NULL));
int order = 18;
ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order));
- CephContext *cct = reinterpret_cast<CephContext*>(ioctx.cct());
- cct->_conf->set_val_or_die("rbd_non_blocking_aio", "0");
+ ASSERT_EQ(0, _rados.conf_set("rbd_non_blocking_aio", "0"));
librbd::Image image;
ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));
// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
-#include "gtest/gtest.h"
-#include "common/ceph_argparse.h"
-#include "common/config.h"
+#include "include/rados/librados.hpp"
#include "global/global_context.h"
-#include "global/global_init.h"
-#include <vector>
+#include "test/librados/test.h"
+#include "gtest/gtest.h"
+#include <iostream>
+#include <string>
extern void register_test_librbd();
#ifdef TEST_LIBRBD_INTERNALS
::testing::InitGoogleTest(&argc, argv);
- vector<const char*> args;
- argv_to_vec(argc, (const char **)argv, args);
+ librados::Rados rados;
+ std::string result = connect_cluster_pp(rados);
+ if (result != "" ) {
+ std::cerr << result << std::endl;
+ return 1;
+ }
- global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
- g_conf->set_val("lockdep", "true");
- common_init_finish(g_ceph_context);
+#ifdef TEST_LIBRBD_INTERNALS
+ g_ceph_context = reinterpret_cast<CephContext*>(rados.cct());
+#endif // TEST_LIBRBD_INTERNALS
- int r = RUN_ALL_TESTS();
- g_ceph_context->put();
- return r;
+ int r = rados.conf_set("lockdep", "true");
+ if (r < 0) {
+ std::cerr << "failed to enable lockdep" << std::endl;
+ return -r;
+ }
+ return RUN_ALL_TESTS();
}