diff options
Diffstat (limited to 'src/test/librbd/mock/io')
-rw-r--r-- | src/test/librbd/mock/io/MockImageRequestWQ.h | 25 | ||||
-rw-r--r-- | src/test/librbd/mock/io/MockObjectDispatch.h | 121 | ||||
-rw-r--r-- | src/test/librbd/mock/io/MockObjectDispatcher.h | 42 |
3 files changed, 188 insertions, 0 deletions
diff --git a/src/test/librbd/mock/io/MockImageRequestWQ.h b/src/test/librbd/mock/io/MockImageRequestWQ.h new file mode 100644 index 00000000..ab080452 --- /dev/null +++ b/src/test/librbd/mock/io/MockImageRequestWQ.h @@ -0,0 +1,25 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_TEST_LIBRBD_MOCK_IO_IMAGE_REQUEST_WQ_H +#define CEPH_TEST_LIBRBD_MOCK_IO_IMAGE_REQUEST_WQ_H + +#include "gmock/gmock.h" +#include "librbd/io/Types.h" + +class Context; + +namespace librbd { +namespace io { + +struct MockImageRequestWQ { + MOCK_METHOD1(block_writes, void(Context *)); + MOCK_METHOD0(unblock_writes, void()); + + MOCK_METHOD2(set_require_lock, void(Direction, bool)); +}; + +} // namespace io +} // namespace librbd + +#endif // CEPH_TEST_LIBRBD_MOCK_IO_IMAGE_REQUEST_WQ_H diff --git a/src/test/librbd/mock/io/MockObjectDispatch.h b/src/test/librbd/mock/io/MockObjectDispatch.h new file mode 100644 index 00000000..5f308dab --- /dev/null +++ b/src/test/librbd/mock/io/MockObjectDispatch.h @@ -0,0 +1,121 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_TEST_LIBRBD_MOCK_IO_OBJECT_DISPATCH_H +#define CEPH_TEST_LIBRBD_MOCK_IO_OBJECT_DISPATCH_H + +#include "gmock/gmock.h" +#include "librbd/io/ObjectDispatchInterface.h" +#include "librbd/io/Types.h" + +class Context; + +namespace librbd { +namespace io { + +struct MockObjectDispatch : public ObjectDispatchInterface { +public: + RWLock lock; + + MockObjectDispatch() : lock("MockObjectDispatch::lock", true, false) { + } + + MOCK_CONST_METHOD0(get_object_dispatch_layer, ObjectDispatchLayer()); + + MOCK_METHOD1(shut_down, void(Context*)); + + MOCK_METHOD8(execute_read, + bool(uint64_t, uint64_t, uint64_t, librados::snap_t, + ceph::bufferlist*, ExtentMap*, DispatchResult*, Context*)); + bool read( + const std::string& oid, uint64_t object_no, uint64_t object_off, + uint64_t object_len, librados::snap_t snap_id, int op_flags, + const ZTracer::Trace& parent_trace, ceph::bufferlist* read_data, + ExtentMap* extent_map, int* dispatch_flags, + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { + return execute_read(object_no, object_off, object_len, snap_id, read_data, + extent_map, dispatch_result, on_dispatched); + } + + MOCK_METHOD9(execute_discard, + bool(uint64_t, uint64_t, uint64_t, const ::SnapContext &, int, + int*, uint64_t*, DispatchResult*, Context*)); + bool discard( + const std::string &oid, uint64_t object_no, uint64_t object_off, + uint64_t object_len, const ::SnapContext &snapc, int discard_flags, + const ZTracer::Trace &parent_trace, int* dispatch_flags, + uint64_t* journal_tid, DispatchResult* dispatch_result, + Context** on_finish, Context* on_dispatched) { + return execute_discard(object_no, object_off, object_len, snapc, + discard_flags, dispatch_flags, journal_tid, + dispatch_result, on_dispatched); + } + + MOCK_METHOD8(execute_write, + bool(uint64_t, uint64_t, const ceph::bufferlist&, + const ::SnapContext &, int*, uint64_t*, DispatchResult*, + Context *)); + bool write( + const std::string &oid, uint64_t object_no, uint64_t object_off, + ceph::bufferlist&& data, const ::SnapContext &snapc, int op_flags, + const ZTracer::Trace &parent_trace, int* dispatch_flags, + uint64_t* journal_tid, DispatchResult* dispatch_result, + Context** on_finish, Context* on_dispatched) override { + return execute_write(object_no, object_off, data, snapc, dispatch_flags, + journal_tid, dispatch_result, on_dispatched); + } + + MOCK_METHOD10(execute_write_same, + bool(uint64_t, uint64_t, uint64_t, const Extents&, + const ceph::bufferlist&, const ::SnapContext &, int*, + uint64_t*, DispatchResult*, Context *)); + bool write_same( + const std::string &oid, uint64_t object_no, uint64_t object_off, + uint64_t object_len, Extents&& buffer_extents, ceph::bufferlist&& data, + const ::SnapContext &snapc, int op_flags, + const ZTracer::Trace &parent_trace, int* dispatch_flags, + uint64_t* journal_tid, DispatchResult* dispatch_result, + Context* *on_finish, Context* on_dispatched) override { + return execute_write_same(object_no, object_off, object_len, buffer_extents, + data, snapc, dispatch_flags, journal_tid, + dispatch_result, on_dispatched); + } + + MOCK_METHOD9(execute_compare_and_write, + bool(uint64_t, uint64_t, const ceph::bufferlist&, + const ceph::bufferlist&, uint64_t*, int*, uint64_t*, + DispatchResult*, Context *)); + bool compare_and_write( + const std::string &oid, uint64_t object_no, uint64_t object_off, + ceph::bufferlist&& cmp_data, ceph::bufferlist&& write_data, + const ::SnapContext &snapc, int op_flags, + const ZTracer::Trace &parent_trace, uint64_t* mismatch_offset, + int* dispatch_flags, uint64_t* journal_tid, + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override { + return execute_compare_and_write(object_no, object_off, cmp_data, + write_data, mismatch_offset, + dispatch_flags, journal_tid, + dispatch_result, on_dispatched); + } + + MOCK_METHOD3(execute_flush, bool(FlushSource, DispatchResult*, + Context*)); + bool flush(FlushSource flush_source, const ZTracer::Trace &parent_trace, + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { + return execute_flush(flush_source, dispatch_result, on_dispatched); + } + + MOCK_METHOD1(invalidate_cache, bool(Context*)); + MOCK_METHOD1(reset_existence_cache, bool(Context*)); + + MOCK_METHOD5(extent_overwritten, void(uint64_t, uint64_t, uint64_t, uint64_t, + uint64_t)); +}; + +} // namespace io +} // namespace librbd + +#endif // CEPH_TEST_LIBRBD_MOCK_IO_OBJECT_DISPATCH_H diff --git a/src/test/librbd/mock/io/MockObjectDispatcher.h b/src/test/librbd/mock/io/MockObjectDispatcher.h new file mode 100644 index 00000000..271c3010 --- /dev/null +++ b/src/test/librbd/mock/io/MockObjectDispatcher.h @@ -0,0 +1,42 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_TEST_LIBRBD_MOCK_IO_OBJECT_DISPATCHER_H +#define CEPH_TEST_LIBRBD_MOCK_IO_OBJECT_DISPATCHER_H + +#include "gmock/gmock.h" +#include "include/Context.h" +#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatchSpec.h" +#include "librbd/io/Types.h" + +class Context; + +namespace librbd { +namespace io { + +struct ObjectDispatchInterface; + +struct MockObjectDispatcher : public ObjectDispatcherInterface { +public: + MOCK_METHOD1(shut_down, void(Context*)); + + MOCK_METHOD1(register_object_dispatch, void(ObjectDispatchInterface*)); + MOCK_METHOD2(shut_down_object_dispatch, void(ObjectDispatchLayer, Context*)); + + MOCK_METHOD2(flush, void(FlushSource, Context*)); + + MOCK_METHOD1(invalidate_cache, void(Context*)); + MOCK_METHOD1(reset_existance_cache, void(Context*)); + + MOCK_METHOD5(extent_overwritten, void(uint64_t, uint64_t, uint64_t, uint64_t, + uint64_t)); + + MOCK_METHOD1(send, void(ObjectDispatchSpec*)); + +}; + +} // namespace io +} // namespace librbd + +#endif // CEPH_TEST_LIBRBD_MOCK_IO_OBJECT_DISPATCHER_H |