Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / 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 <boost/shared_ptr.hpp>
11 #include <gmock/gmock.h>
12 #include "include/assert.h"
13
14 namespace librados {
15 class TestRadosClient;
16 class MockTestMemIoCtxImpl;
17 class MockTestMemRadosClient;
18 }
19
20 namespace librbd {
21 class MockImageCtx;
22 }
23
24 ACTION_P(CompleteContext, r) {
25   arg0->complete(r);
26 }
27
28 ACTION_P2(CompleteContext, wq, r) {
29   ContextWQ *context_wq = reinterpret_cast<ContextWQ *>(wq);
30   context_wq->queue(arg0, r);
31 }
32
33 MATCHER_P(ContentsEqual, bl, "") {
34   // TODO fix const-correctness of bufferlist
35   return const_cast<bufferlist &>(arg).contents_equal(
36     const_cast<bufferlist &>(bl));
37 }
38
39 namespace rbd {
40 namespace mirror {
41
42 class TestMockFixture : public TestFixture {
43 public:
44   typedef boost::shared_ptr<librados::TestCluster> TestClusterRef;
45
46   static void SetUpTestCase();
47   static void TearDownTestCase();
48
49   void TearDown() override;
50
51   void expect_test_features(librbd::MockImageCtx &mock_image_ctx);
52
53 private:
54   static TestClusterRef s_test_cluster;
55 };
56
57 } // namespace mirror
58 } // namespace rbd
59
60 #endif // CEPH_TEST_RBD_MIRROR_TEST_MOCK_FIXTURE_H