#include "librbd/internal.h"
#include "tools/rbd_mirror/ClusterWatcher.h"
#include "tools/rbd_mirror/types.h"
+#include "test/rbd_mirror/test_fixture.h"
#include "test/librados/test.h"
#include "gtest/gtest.h"
#include <boost/scope_exit.hpp>
void register_test_cluster_watcher() {
}
-class TestClusterWatcher : public ::testing::Test {
+class TestClusterWatcher : public ::rbd::mirror::TestFixture {
public:
TestClusterWatcher() : m_lock("TestClusterWatcherLock")
#include "include/rados/librados.hpp"
#include "include/rbd/librbd.hpp"
#include "include/stringify.h"
+#include "test/rbd_mirror/test_fixture.h"
#include "cls/journal/cls_journal_types.h"
#include "cls/journal/cls_journal_client.h"
#include "cls/rbd/cls_rbd_types.h"
#define TEST_IO_SIZE 512
#define TEST_IO_COUNT 11
-class TestImageReplayer : public ::testing::Test {
+class TestImageReplayer : public ::rbd::mirror::TestFixture {
public:
struct C_WatchCtx : public librados::WatchCtx2 {
TestImageReplayer *test;
#include "include/rados/librados.hpp"
#include "include/rbd/librbd.hpp"
#include "include/stringify.h"
+#include "test/rbd_mirror/test_fixture.h"
#include "cls/rbd/cls_rbd_types.h"
#include "cls/rbd/cls_rbd_client.h"
#include "include/rbd_types.h"
void register_test_pool_watcher() {
}
-class TestPoolWatcher : public ::testing::Test {
+class TestPoolWatcher : public ::rbd::mirror::TestFixture {
public:
TestPoolWatcher() : m_lock("TestPoolWatcherLock"),
std::string TestFixture::_remote_pool_name;
std::shared_ptr<librados::Rados> TestFixture::_rados;
uint64_t TestFixture::_image_number = 0;
+std::string TestFixture::_data_pool;
TestFixture::TestFixture() {
}
_remote_pool_name = get_temp_pool_name("test-rbd-mirror-");
ASSERT_EQ(0, _rados->pool_create(_remote_pool_name.c_str()));
+
+ ASSERT_EQ(0, create_image_data_pool(_data_pool));
+ if (!_data_pool.empty()) {
+ printf("using image data pool: %s\n", _data_pool.c_str());
+ }
}
void TestFixture::TearDownTestCase() {
+ if (!_data_pool.empty()) {
+ ASSERT_EQ(0, _rados->pool_delete(_data_pool.c_str()));
+ }
+
ASSERT_EQ(0, _rados->pool_delete(_remote_pool_name.c_str()));
ASSERT_EQ(0, _rados->pool_delete(_local_pool_name.c_str()));
_rados->shutdown();
return "image" + stringify(_image_number);
}
+int TestFixture::create_image_data_pool(std::string &data_pool) {
+ std::string pool;
+ int r = _rados->conf_get("rbd_default_data_pool", pool);
+ if (r != 0) {
+ return r;
+ } else if (pool.empty()) {
+ return 0;
+ }
+
+ r = _rados->pool_create(pool.c_str());
+ if (r == 0) {
+ data_pool = pool;
+ return 0;
+ }
+
+ return r;
+}
+
} // namespace mirror
} // namespace rbd
Threads *m_threads = nullptr;
+
int create_image(librbd::RBD &rbd, librados::IoCtx &ioctx,
const std::string &name, uint64_t size);
int open_image(librados::IoCtx &io_ctx, const std::string &image_name,
librados::snap_t *snap_id = nullptr);
static std::string get_temp_image_name();
+ static int create_image_data_pool(std::string &data_pool);
static std::string _local_pool_name;
static std::string _remote_pool_name;
static std::shared_ptr<librados::Rados> _rados;
static uint64_t _image_number;
+ static std::string _data_pool;
};
} // namespace mirror