]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/librados/TestCase.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_TEST_RADOS_TESTCASE_H
5 #define CEPH_TEST_RADOS_TESTCASE_H
7 #include "include/rados/librados.h"
8 #include "gtest/gtest.h"
13 * These test cases create a temporary pool that lives as long as the
14 * test case. We initially use the default namespace and assume
15 * test will whatever namespaces it wants. After each test all objects
18 * Since pool creation and deletion is slow, this allows many tests to
21 class RadosTestNS
: public ::testing::Test
{
23 RadosTestNS(bool c
=false) : cleanup(c
) {}
24 ~RadosTestNS() override
{}
26 static void SetUpTestCase();
27 static void TearDownTestCase();
28 static void cleanup_all_objects(rados_ioctx_t ioctx
);
29 static rados_t s_cluster
;
30 static std::string pool_name
;
32 void SetUp() override
;
33 void TearDown() override
;
34 rados_t cluster
= nullptr;
35 rados_ioctx_t ioctx
= nullptr;
39 struct RadosTestNSCleanup
: public RadosTestNS
{
40 RadosTestNSCleanup() : RadosTestNS(true) {}
43 class RadosTestECNS
: public RadosTestNS
{
45 RadosTestECNS(bool c
=false) : cleanup(c
) {}
46 ~RadosTestECNS() override
{}
48 static void SetUpTestCase();
49 static void TearDownTestCase();
50 static rados_t s_cluster
;
51 static std::string pool_name
;
53 void SetUp() override
;
54 void TearDown() override
;
55 rados_t cluster
= nullptr;
56 rados_ioctx_t ioctx
= nullptr;
57 uint64_t alignment
= 0;
61 struct RadosTestECNSCleanup
: public RadosTestECNS
{
62 RadosTestECNSCleanup() : RadosTestECNS(true) {}
66 * These test cases create a temporary pool that lives as long as the
67 * test case. Each test within a test case gets a new ioctx set to a
68 * unique namespace within the pool.
70 * Since pool creation and deletion is slow, this allows many tests to
73 class RadosTest
: public ::testing::Test
{
75 RadosTest(bool c
=false) : cleanup(c
) {}
76 ~RadosTest() override
{}
78 static void SetUpTestCase();
79 static void TearDownTestCase();
80 static void cleanup_default_namespace(rados_ioctx_t ioctx
);
81 static void cleanup_namespace(rados_ioctx_t ioctx
, std::string ns
);
82 static rados_t s_cluster
;
83 static std::string pool_name
;
85 void SetUp() override
;
86 void TearDown() override
;
87 rados_t cluster
= nullptr;
88 rados_ioctx_t ioctx
= nullptr;
93 class RadosTestEC
: public RadosTest
{
95 RadosTestEC(bool c
=false) : cleanup(c
) {}
96 ~RadosTestEC() override
{}
98 static void SetUpTestCase();
99 static void TearDownTestCase();
100 static rados_t s_cluster
;
101 static std::string pool_name
;
103 void SetUp() override
;
104 void TearDown() override
;
105 rados_t cluster
= nullptr;
106 rados_ioctx_t ioctx
= nullptr;
109 uint64_t alignment
= 0;
113 * Test case without creating a temporary pool in advance.
114 * This is necessary for scenarios such that we need to
115 * manually create a pool, start some long-runing tasks and
116 * then the related pool is suddenly gone.
118 class RadosTestNP
: public ::testing::Test
{
121 ~RadosTestNP() override
{}