X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftest%2Flibrados_test_stub%2FMockTestMemRadosClient.h;fp=src%2Fceph%2Fsrc%2Ftest%2Flibrados_test_stub%2FMockTestMemRadosClient.h;h=5fd0aa9fed988e342abb4839b70e7e1f628f6831;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/test/librados_test_stub/MockTestMemRadosClient.h b/src/ceph/src/test/librados_test_stub/MockTestMemRadosClient.h new file mode 100644 index 0000000..5fd0aa9 --- /dev/null +++ b/src/ceph/src/test/librados_test_stub/MockTestMemRadosClient.h @@ -0,0 +1,66 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef LIBRADOS_TEST_STUB_MOCK_TEST_MEM_RADOS_CLIENT_H +#define LIBRADOS_TEST_STUB_MOCK_TEST_MEM_RADOS_CLIENT_H + +#include "test/librados_test_stub/TestMemRadosClient.h" +#include "test/librados_test_stub/MockTestMemIoCtxImpl.h" +#include "gmock/gmock.h" + +namespace librados { + +class TestMemCluster; + +class MockTestMemRadosClient : public TestMemRadosClient { +public: + MockTestMemRadosClient(CephContext *cct, TestMemCluster *test_mem_cluster) + : TestMemRadosClient(cct, test_mem_cluster) { + default_to_dispatch(); + } + + MOCK_METHOD2(create_ioctx, TestIoCtxImpl *(int64_t pool_id, + const std::string &pool_name)); + TestIoCtxImpl *do_create_ioctx(int64_t pool_id, + const std::string &pool_name) { + return new ::testing::NiceMock( + this, this, pool_id, pool_name, + get_mem_cluster()->get_pool(pool_name)); + } + + MOCK_METHOD2(blacklist_add, int(const std::string& client_address, + uint32_t expire_seconds)); + int do_blacklist_add(const std::string& client_address, + uint32_t expire_seconds) { + return TestMemRadosClient::blacklist_add(client_address, expire_seconds); + } + + MOCK_METHOD3(service_daemon_register, + int(const std::string&, + const std::string&, + const std::map&)); + int do_service_daemon_register(const std::string& service, + const std::string& name, + const std::map& metadata) { + return TestMemRadosClient::service_daemon_register(service, name, metadata); + } + + MOCK_METHOD1(service_daemon_update_status, + int(const std::map&)); + int do_service_daemon_update_status(const std::map& status) { + return TestMemRadosClient::service_daemon_update_status(status); + } + + void default_to_dispatch() { + using namespace ::testing; + + ON_CALL(*this, create_ioctx(_, _)).WillByDefault(Invoke(this, &MockTestMemRadosClient::do_create_ioctx)); + ON_CALL(*this, blacklist_add(_, _)).WillByDefault(Invoke(this, &MockTestMemRadosClient::do_blacklist_add)); + ON_CALL(*this, service_daemon_register(_, _, _)).WillByDefault(Invoke(this, &MockTestMemRadosClient::do_service_daemon_register)); + ON_CALL(*this, service_daemon_update_status(_)).WillByDefault(Invoke(this, &MockTestMemRadosClient::do_service_daemon_update_status)); + } +}; + +} // namespace librados + +#endif // LIBRADOS_TEST_STUB_MOCK_TEST_MEM_RADOS_CLIENT_H