]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/libradosstriper/TestCase.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / test / libradosstriper / TestCase.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_RADOS_TESTCASE_H
5 #define CEPH_TEST_RADOS_TESTCASE_H
6
7 #include "include/rados/librados.h"
8 #include "include/rados/librados.hpp"
9 #include "include/radosstriper/libradosstriper.h"
10 #include "include/radosstriper/libradosstriper.hpp"
11 #include "gtest/gtest.h"
12
13 #include <string>
14
15 /**
16 * These test cases create a temporary pool that lives as long as the
17 * test case. Each test within a test case gets a new ioctx and striper
18 * set to a unique namespace within the pool.
19 *
20 * Since pool creation and deletion is slow, this allows many tests to
21 * run faster.
22 */
23 class StriperTest : public ::testing::Test {
24 public:
25 StriperTest() {}
26 ~StriperTest() override {}
27 protected:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 static rados_t s_cluster;
31 static std::string pool_name;
32
33 void SetUp() override;
34 void TearDown() override;
35 rados_t cluster;
36 rados_ioctx_t ioctx;
37 rados_striper_t striper;
38 };
39
40 class StriperTestPP : public ::testing::Test {
41 public:
42 StriperTestPP() : cluster(s_cluster) {}
43 ~StriperTestPP() override {}
44 static void SetUpTestCase();
45 static void TearDownTestCase();
46 protected:
47 static librados::Rados s_cluster;
48 static std::string pool_name;
49
50 void SetUp() override;
51 librados::Rados &cluster;
52 librados::IoCtx ioctx;
53 libradosstriper::RadosStriper striper;
54 };
55
56 struct TestData {
57 uint32_t stripe_unit;
58 uint32_t stripe_count;
59 uint32_t object_size;
60 size_t size;
61 };
62 // this is pure copy and paste from previous class
63 // but for the inheritance from TestWithParam
64 // with gtest >= 1.6, we couldd avoid this by using
65 // inheritance from WithParamInterface
66 class StriperTestParam : public ::testing::TestWithParam<TestData> {
67 public:
68 StriperTestParam() : cluster(s_cluster) {}
69 ~StriperTestParam() override {}
70 static void SetUpTestCase();
71 static void TearDownTestCase();
72 protected:
73 static librados::Rados s_cluster;
74 static std::string pool_name;
75
76 void SetUp() override;
77 librados::Rados &cluster;
78 librados::IoCtx ioctx;
79 libradosstriper::RadosStriper striper;
80 };
81
82 #endif