]> git.proxmox.com Git - ceph.git/blame - ceph/src/test/librbd/test_fixture.h
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / test / librbd / test_fixture.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3#include "include/int_types.h"
4#include "include/rados/librados.h"
5#include "include/rbd/librbd.hpp"
6#include "librbd/ImageCtx.h"
7#include "gtest/gtest.h"
8#include <set>
9#include <string>
10
11using namespace ceph;
12
13class TestFixture : public ::testing::Test {
14public:
15
16 TestFixture();
17
18 static void SetUpTestCase();
19 static void TearDownTestCase();
20
21 static std::string get_temp_image_name();
22
23 void SetUp() override;
24 void TearDown() override;
25
26 int open_image(const std::string &image_name, librbd::ImageCtx **ictx);
27 void close_image(librbd::ImageCtx *ictx);
28
29 int snap_create(librbd::ImageCtx &ictx, const std::string &snap_name);
30 int snap_protect(librbd::ImageCtx &ictx, const std::string &snap_name);
31
32 int flatten(librbd::ImageCtx &ictx, librbd::ProgressContext &prog_ctx);
b32b8144 33 int resize(librbd::ImageCtx *ictx, uint64_t size);
7c673cae
FG
34
35 int lock_image(librbd::ImageCtx &ictx, ClsLockType lock_type,
36 const std::string &cookie);
37 int unlock_image();
38
f67539c2
TL
39 int flush_writeback_cache(librbd::ImageCtx *image_ctx);
40
7c673cae
FG
41 int acquire_exclusive_lock(librbd::ImageCtx &ictx);
42
43 static std::string _pool_name;
44 static librados::Rados _rados;
45 static rados_t _cluster;
46 static uint64_t _image_number;
47 static std::string _data_pool;
48
11fdf7f2 49 CephContext* m_cct = nullptr;
7c673cae
FG
50 librados::IoCtx m_ioctx;
51 librbd::RBD m_rbd;
52
53 std::string m_image_name;
54 uint64_t m_image_size;
55
56 std::set<librbd::ImageCtx *> m_ictxs;
57
58 std::string m_lock_object;
59 std::string m_lock_cookie;
60};