]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados_test_stub: additional definitions and mock functions
authorJason Dillaman <dillaman@redhat.com>
Mon, 7 Dec 2015 21:11:27 +0000 (16:11 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 15 Dec 2015 01:30:51 +0000 (20:30 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/librados_test_stub/LibradosTestStub.cc
src/test/librados_test_stub/MockTestMemIoCtxImpl.h
src/test/librados_test_stub/MockTestMemRadosClient.h

index 220a0ea94e11a45d288dd35086a28d5624f0ae72..99a8f444be2ded5ed1b062af1d1b0fcfca5cffbe 100644 (file)
@@ -661,6 +661,19 @@ void ObjectReadOperation::list_snaps(snap_set_t *out_snaps, int *prval) {
   o->ops.push_back(op);
 }
 
+void ObjectReadOperation::list_watchers(std::list<obj_watch_t> *out_watchers,
+                                        int *prval) {
+  TestObjectOperationImpl *o = reinterpret_cast<TestObjectOperationImpl*>(impl);
+
+  ObjectOperationTestImpl op = boost::bind(&TestIoCtxImpl::list_watchers, _1,
+                                           _2, out_watchers);
+  if (prval != NULL) {
+    op = boost::bind(save_operation_result,
+                     boost::bind(op, _1, _2, _3, _4), prval);
+  }
+  o->ops.push_back(op);
+}
+
 void ObjectReadOperation::read(size_t off, uint64_t len, bufferlist *pbl,
                                int *prval) {
   TestObjectOperationImpl *o = reinterpret_cast<TestObjectOperationImpl*>(impl);
index 596436b33e727462672cdcc4896b778eb7e02e41..b0a481b56708b03044953264c8409c22196c5e5e 100644 (file)
@@ -48,6 +48,13 @@ public:
                                   snapc);
   }
 
+  MOCK_METHOD2(list_watchers, int(const std::string& o,
+                                  std::list<obj_watch_t> *out_watchers));
+  int do_list_watchers(const std::string& o,
+                       std::list<obj_watch_t> *out_watchers) {
+    return TestMemIoCtxImpl::list_watchers(o, out_watchers);
+  }
+
   MOCK_METHOD4(read, int(const std::string& oid,
                          size_t len,
                          uint64_t off,
@@ -92,6 +99,7 @@ public:
     using namespace ::testing;
 
     ON_CALL(*this, exec(_, _, _, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_exec));
+    ON_CALL(*this, list_watchers(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_list_watchers));
     ON_CALL(*this, read(_, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_read));
     ON_CALL(*this, remove(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_remove));
     ON_CALL(*this, selfmanaged_snap_create(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_selfmanaged_snap_create));
index 1d0b994afa6296e58906c9885d744900b5699a04..9afde338f62fd49303c9b77ec1a28b04ee163d81 100644 (file)
@@ -24,10 +24,18 @@ public:
       this, this, pool_id, pool_name, 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);
+  }
+
   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));
   }
 };