]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/immutable_object_cache: remove lookup_object mock workaround
authorMykola Golub <mgolub@suse.com>
Thu, 23 Jul 2020 14:38:45 +0000 (15:38 +0100)
committerJason Dillaman <dillaman@redhat.com>
Thu, 27 Aug 2020 17:56:04 +0000 (13:56 -0400)
gmock already supports move.

Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit 48066e322297bf53365d4c1d72c88712120e954a)

src/test/immutable_object_cache/MockCacheDaemon.h
src/test/librbd/cache/test_mock_ParentCacheObjectDispatch.cc

index 71fd062650b54deb3f3688715d364c4304c99360..3773e87ea9a2fcc10f4f7d86eeffc8c02a070f02 100644 (file)
@@ -24,14 +24,8 @@ class MockCacheClient {
   MOCK_METHOD0(stop, void());
   MOCK_METHOD0(connect, int());
   MOCK_METHOD1(connect, void(Context*));
-  void lookup_object(std::string pool_nspace, uint64_t pool_id, uint64_t snap_id,
-              std::string oid, CacheGenContextURef&& on_finish) {
-    // gmock don't support move
-    internal_lookup(pool_nspace, pool_id, snap_id, oid);
-  };
-  MOCK_METHOD4(internal_lookup, void(std::string pool_nspace,
-                uint64_t pool_id, uint64_t snap_id, 
-                std::string oid));
+  MOCK_METHOD5(lookup_object, void(std::string, uint64_t, uint64_t, std::string,
+                                   CacheGenContextURef));
   MOCK_METHOD1(register_client, int(Context*));
 };
 
index aa5dcf9235ce3c86d002aa1a858b68cf93646e34..a4f033f32d048a60d05d393e1a4d69bc0d3b4b1f 100644 (file)
@@ -93,13 +93,13 @@ public :
    }
 
   void expect_cache_lookup_object(MockParentImageCache& mparent_image_cache,
-                                  Context* on_finish) {
-    auto& expect = EXPECT_CALL(*(mparent_image_cache.get_cache_client()),
-                               internal_lookup(_, _, _, _));
-
-     expect.WillOnce(WithArg<3>(Invoke([on_finish](std::string oid) {
-       on_finish->complete(0);
-     })));
+                                  const std::string &cache_path) {
+    EXPECT_CALL(*(mparent_image_cache.get_cache_client()),
+                lookup_object(_, _, _, _, _))
+      .WillOnce(WithArg<4>(Invoke([cache_path](CacheGenContextURef on_finish) {
+        auto ack = new ObjectCacheReadReplyData(RBDSC_READ_REPLY, 0, cache_path);
+        on_finish.release()->complete(ack);
+      })));
   }
 
   void expect_cache_close(MockParentImageCache& mparent_image_cache, int ret_val) {
@@ -321,17 +321,18 @@ TEST_F(TestMockParentCacheObjectDispatch, test_read) {
   expect_cache_session_state(*mock_parent_image_cache, true);
   ASSERT_EQ(mock_parent_image_cache->get_cache_client()->is_session_work(), true);
 
-  C_SaferCond cond;
-  Context* on_finish = &cond;
-
   auto& expect = EXPECT_CALL(*(mock_parent_image_cache->get_cache_client()), is_session_work());
   expect.WillOnce(Return(true));
 
-  expect_cache_lookup_object(*mock_parent_image_cache, on_finish);
+  expect_cache_lookup_object(*mock_parent_image_cache, "/dev/null");
 
-  mock_parent_image_cache->read(0, 0, 4096, CEPH_NOSNAP, 0, {},
-                        nullptr, nullptr, nullptr, nullptr, &on_finish, nullptr);
-  ASSERT_EQ(0, cond.wait());
+  C_SaferCond on_dispatched;
+  io::DispatchResult dispatch_result;
+  ceph::bufferlist read_data;
+  mock_parent_image_cache->read(0, 0, 4096, CEPH_NOSNAP, 0, {}, &read_data,
+                                nullptr, nullptr, &dispatch_result, nullptr,
+                                &on_dispatched);
+  ASSERT_EQ(0, on_dispatched.wait());
 
   mock_parent_image_cache->get_cache_client()->close();
   mock_parent_image_cache->get_cache_client()->stop();