]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/rbd_mirror/test_mock_fixture.h
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / test / rbd_mirror / test_mock_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_MOCK_FIXTURE_H
5 #define CEPH_TEST_RBD_MIRROR_TEST_MOCK_FIXTURE_H
6
7 #include "test/rbd_mirror/test_fixture.h"
8 #include "test/librados_test_stub/LibradosTestStub.h"
9 #include "common/WorkQueue.h"
10 #include "librbd/asio/ContextWQ.h"
11 #include <boost/shared_ptr.hpp>
12 #include <gmock/gmock.h>
13 #include "include/ceph_assert.h"
14
15 namespace librados {
16 class TestRadosClient;
17 class MockTestMemCluster;
18 class MockTestMemIoCtxImpl;
19 class MockTestMemRadosClient;
20 }
21
22 namespace librbd {
23 class MockImageCtx;
24 }
25
26 ACTION_P(CopyInBufferlist, str) {
27 arg0->append(str);
28 }
29
30 ACTION_P(CompleteContext, r) {
31 arg0->complete(r);
32 }
33
34 ACTION_P2(CompleteContext, wq, r) {
35 auto context_wq = reinterpret_cast<librbd::asio::ContextWQ *>(wq);
36 context_wq->queue(arg0, r);
37 }
38
39 ACTION_P(GetReference, ref_object) {
40 ref_object->get();
41 }
42
43 MATCHER_P(ContentsEqual, bl, "") {
44 // TODO fix const-correctness of bufferlist
45 return const_cast<bufferlist &>(arg).contents_equal(
46 const_cast<bufferlist &>(bl));
47 }
48
49 namespace rbd {
50 namespace mirror {
51
52 class TestMockFixture : public TestFixture {
53 public:
54 typedef boost::shared_ptr<librados::TestCluster> TestClusterRef;
55
56 static void SetUpTestCase();
57 static void TearDownTestCase();
58
59 void TearDown() override;
60
61 void expect_test_features(librbd::MockImageCtx &mock_image_ctx);
62
63 librados::MockTestMemCluster& get_mock_cluster();
64
65 private:
66 static TestClusterRef s_test_cluster;
67 };
68
69 } // namespace mirror
70 } // namespace rbd
71
72 #endif // CEPH_TEST_RBD_MIRROR_TEST_MOCK_FIXTURE_H