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_LIBRBD_MOCK_JOURNAL_H
5 #define CEPH_TEST_LIBRBD_MOCK_JOURNAL_H
7 #include "gmock/gmock.h"
8 #include "librbd/Journal.h"
9 #include "librbd/journal/Types.h"
14 namespace librados { class IoCtx; }
19 namespace io { struct ObjectRequestHandle; }
22 typedef std::list<io::ObjectRequestHandle *> ObjectRequests;
24 static MockJournal *s_instance;
25 static MockJournal *get_instance() {
26 assert(s_instance != nullptr);
30 template <typename ImageCtxT>
31 static int is_tag_owner(ImageCtxT *image_ctx, bool *is_tag_owner) {
32 return get_instance()->is_tag_owner(is_tag_owner);
35 static void get_tag_owner(librados::IoCtx &,
36 const std::string &global_image_id,
37 std::string *tag_owner, ContextWQ *work_queue,
39 get_instance()->get_tag_owner(global_image_id, tag_owner,
40 work_queue, on_finish);
47 MOCK_CONST_METHOD0(is_journal_ready, bool());
48 MOCK_CONST_METHOD0(is_journal_replaying, bool());
49 MOCK_CONST_METHOD0(is_journal_appending, bool());
51 MOCK_METHOD1(wait_for_journal_ready, void(Context *));
53 MOCK_METHOD4(get_tag_owner, void(const std::string &,
54 std::string *, ContextWQ *,
57 MOCK_CONST_METHOD0(is_tag_owner, bool());
58 MOCK_CONST_METHOD1(is_tag_owner, int(bool *));
59 MOCK_METHOD3(allocate_tag, void(const std::string &mirror_uuid,
60 const journal::TagPredecessor &predecessor,
63 MOCK_METHOD1(open, void(Context *));
64 MOCK_METHOD1(close, void(Context *));
66 MOCK_CONST_METHOD0(get_tag_tid, uint64_t());
67 MOCK_CONST_METHOD0(get_tag_data, journal::TagData());
69 MOCK_METHOD0(allocate_op_tid, uint64_t());
71 MOCK_METHOD5(append_write_event, uint64_t(uint64_t, size_t,
73 const ObjectRequests &, bool));
74 MOCK_METHOD5(append_io_event_mock, uint64_t(const journal::EventEntry&,
75 const ObjectRequests &,
76 uint64_t, size_t, bool));
77 uint64_t append_io_event(journal::EventEntry &&event_entry,
78 const ObjectRequests &requests,
79 uint64_t offset, size_t length,
81 // googlemock doesn't support move semantics
82 return append_io_event_mock(event_entry, requests, offset, length,
86 MOCK_METHOD3(append_op_event_mock, void(uint64_t, const journal::EventEntry&,
88 void append_op_event(uint64_t op_tid, journal::EventEntry &&event_entry,
90 // googlemock doesn't support move semantics
91 append_op_event_mock(op_tid, event_entry, on_safe);
94 MOCK_METHOD2(flush_event, void(uint64_t, Context *));
95 MOCK_METHOD2(wait_event, void(uint64_t, Context *));
97 MOCK_METHOD3(commit_op_event, void(uint64_t, int, Context *));
98 MOCK_METHOD2(replay_op_ready, void(uint64_t, Context *));
100 MOCK_METHOD1(add_listener, void(journal::Listener *));
101 MOCK_METHOD1(remove_listener, void(journal::Listener *));
103 MOCK_METHOD1(is_resync_requested, int(bool *));
106 } // namespace librbd
108 #endif // CEPH_TEST_LIBRBD_MOCK_JOURNAL_H