From: Mykola Golub Date: Thu, 23 Jul 2020 14:38:45 +0000 (+0100) Subject: test/immutable_object_cache: remove lookup_object mock workaround X-Git-Tag: v15.2.9~122^2~92^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4d8d089f549133eff290b54d5b8fae6d001f9fd7;p=ceph.git test/immutable_object_cache: remove lookup_object mock workaround gmock already supports move. Signed-off-by: Mykola Golub (cherry picked from commit 48066e322297bf53365d4c1d72c88712120e954a) --- diff --git a/src/test/immutable_object_cache/MockCacheDaemon.h b/src/test/immutable_object_cache/MockCacheDaemon.h index 71fd062650b5..3773e87ea9a2 100644 --- a/src/test/immutable_object_cache/MockCacheDaemon.h +++ b/src/test/immutable_object_cache/MockCacheDaemon.h @@ -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*)); }; diff --git a/src/test/librbd/cache/test_mock_ParentCacheObjectDispatch.cc b/src/test/librbd/cache/test_mock_ParentCacheObjectDispatch.cc index aa5dcf9235ce..a4f033f32d04 100644 --- a/src/test/librbd/cache/test_mock_ParentCacheObjectDispatch.cc +++ b/src/test/librbd/cache/test_mock_ParentCacheObjectDispatch.cc @@ -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();