]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/rbd_mirror/test_fixture.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / test / rbd_mirror / test_fixture.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_TEST_RBD_MIRROR_TEST_FIXTURE_H
5 #define CEPH_TEST_RBD_MIRROR_TEST_FIXTURE_H
6
7 #include "include/int_types.h"
8 #include "include/rados/librados.hpp"
9 #include <gtest/gtest.h>
10 #include <set>
11
12 namespace librbd {
13 class ImageCtx;
14 class RBD;
15 }
16
17 namespace rbd {
18 namespace mirror {
19
20 template <typename> class Threads;
21
22 class TestFixture : public ::testing::Test {
23 public:
24 TestFixture();
25
26 static void SetUpTestCase();
27 static void TearDownTestCase();
28
29 void SetUp() override;
30 void TearDown() override;
31
32 librados::IoCtx m_local_io_ctx;
33 librados::IoCtx m_remote_io_ctx;
34
35 std::string m_image_name;
36 uint64_t m_image_size = 1 << 24;
37
38 std::set<librbd::ImageCtx *> m_image_ctxs;
39
40 Threads<librbd::ImageCtx> *m_threads = nullptr;
41
42
43 int create_image(librbd::RBD &rbd, librados::IoCtx &ioctx,
44 const std::string &name, uint64_t size);
45 int open_image(librados::IoCtx &io_ctx, const std::string &image_name,
46 librbd::ImageCtx **image_ctx);
47
48 int create_snap(librbd::ImageCtx *image_ctx, const char* snap_name,
49 librados::snap_t *snap_id = nullptr);
50
51 static std::string get_temp_image_name();
52 static int create_image_data_pool(std::string &data_pool);
53
54 static std::string _local_pool_name;
55 static std::string _remote_pool_name;
56 static std::shared_ptr<librados::Rados> _rados;
57 static uint64_t _image_number;
58 static std::string _data_pool;
59 };
60
61 } // namespace mirror
62 } // namespace rbd
63
64 #endif // CEPH_TEST_RBD_MIRROR_TEST_FIXTURE_H