From: Mykola Golub Date: Tue, 7 May 2019 05:34:47 +0000 (+0100) Subject: librados_test_stub: pass snap context to "create" method X-Git-Tag: v15.1.0~2678^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=599247701350dbabe9ece6803e9e912608d99901;p=ceph-ci.git librados_test_stub: pass snap context to "create" method Signed-off-by: Mykola Golub --- diff --git a/src/test/librados_test_stub/LibradosTestStub.cc b/src/test/librados_test_stub/LibradosTestStub.cc index 2b3cce60652..11db4308b1b 100644 --- a/src/test/librados_test_stub/LibradosTestStub.cc +++ b/src/test/librados_test_stub/LibradosTestStub.cc @@ -510,7 +510,8 @@ void IoCtx::close() { int IoCtx::create(const std::string& oid, bool exclusive) { TestIoCtxImpl *ctx = reinterpret_cast(io_ctx_impl); return ctx->execute_operation( - oid, boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive)); + oid, boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive, + ctx->get_snap_context())); } void IoCtx::dup(const IoCtx& rhs) { @@ -914,7 +915,7 @@ void ObjectWriteOperation::append(const bufferlist &bl) { void ObjectWriteOperation::create(bool exclusive) { TestObjectOperationImpl *o = reinterpret_cast(impl); - o->ops.push_back(boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive)); + o->ops.push_back(boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive, _4)); } void ObjectWriteOperation::omap_set(const std::map &map) { @@ -1204,7 +1205,7 @@ WatchCtx2::~WatchCtx2() { int cls_cxx_create(cls_method_context_t hctx, bool exclusive) { librados::TestClassHandler::MethodContext *ctx = reinterpret_cast(hctx); - return ctx->io_ctx_impl->create(ctx->oid, exclusive); + return ctx->io_ctx_impl->create(ctx->oid, exclusive, ctx->snapc); } int cls_cxx_remove(cls_method_context_t hctx) { diff --git a/src/test/librados_test_stub/MockTestMemIoCtxImpl.h b/src/test/librados_test_stub/MockTestMemIoCtxImpl.h index 0ef52d3863f..e9d2bcabe49 100644 --- a/src/test/librados_test_stub/MockTestMemIoCtxImpl.h +++ b/src/test/librados_test_stub/MockTestMemIoCtxImpl.h @@ -61,9 +61,10 @@ public: return TestMemIoCtxImpl::assert_exists(oid); } - MOCK_METHOD2(create, int(const std::string&, bool)); - int do_create(const std::string& oid, bool exclusive) { - return TestMemIoCtxImpl::create(oid, exclusive); + MOCK_METHOD3(create, int(const std::string&, bool, const SnapContext &)); + int do_create(const std::string& oid, bool exclusive, + const SnapContext &snapc) { + return TestMemIoCtxImpl::create(oid, exclusive, snapc); } MOCK_METHOD3(cmpext, int(const std::string&, uint64_t, bufferlist&)); @@ -200,7 +201,7 @@ public: ON_CALL(*this, aio_watch(_, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_aio_watch)); ON_CALL(*this, aio_unwatch(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_aio_unwatch)); ON_CALL(*this, assert_exists(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_assert_exists)); - ON_CALL(*this, create(_,_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_create)); + ON_CALL(*this, create(_, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_create)); ON_CALL(*this, cmpext(_,_,_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_cmpext)); ON_CALL(*this, exec(_, _, _, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_exec)); ON_CALL(*this, get_instance_id()).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_get_instance_id)); diff --git a/src/test/librados_test_stub/TestIoCtxImpl.cc b/src/test/librados_test_stub/TestIoCtxImpl.cc index 0788d9f5b30..aa6f0dcce2f 100644 --- a/src/test/librados_test_stub/TestIoCtxImpl.cc +++ b/src/test/librados_test_stub/TestIoCtxImpl.cc @@ -278,7 +278,7 @@ int TestIoCtxImpl::tmap_update(const std::string& oid, bufferlist& cmdbl) { uint64_t size = 0; int r = stat(oid, &size, NULL); if (r == -ENOENT) { - r = create(oid, false); + r = create(oid, false, m_snapc); } if (r < 0) { return r; diff --git a/src/test/librados_test_stub/TestIoCtxImpl.h b/src/test/librados_test_stub/TestIoCtxImpl.h index e92d7dfa505..ad79a2986c7 100644 --- a/src/test/librados_test_stub/TestIoCtxImpl.h +++ b/src/test/librados_test_stub/TestIoCtxImpl.h @@ -99,7 +99,8 @@ public: const SnapContext &snapc) = 0; virtual int assert_exists(const std::string &oid) = 0; - virtual int create(const std::string& oid, bool exclusive) = 0; + virtual int create(const std::string& oid, bool exclusive, + const SnapContext &snapc) = 0; virtual int exec(const std::string& oid, TestClassHandler *handler, const char *cls, const char *method, bufferlist& inbl, bufferlist* outbl, diff --git a/src/test/librados_test_stub/TestMemIoCtxImpl.cc b/src/test/librados_test_stub/TestMemIoCtxImpl.cc index 4f60e435987..3f135954394 100644 --- a/src/test/librados_test_stub/TestMemIoCtxImpl.cc +++ b/src/test/librados_test_stub/TestMemIoCtxImpl.cc @@ -99,7 +99,8 @@ int TestMemIoCtxImpl::assert_exists(const std::string &oid) { return 0; } -int TestMemIoCtxImpl::create(const std::string& oid, bool exclusive) { +int TestMemIoCtxImpl::create(const std::string& oid, bool exclusive, + const SnapContext &snapc) { if (get_snap_read() != CEPH_NOSNAP) { return -EROFS; } else if (m_client->is_blacklisted()) { @@ -107,7 +108,7 @@ int TestMemIoCtxImpl::create(const std::string& oid, bool exclusive) { } RWLock::WLocker l(m_pool->file_lock); - get_file(oid, true, get_snap_context()); + get_file(oid, true, snapc); return 0; } diff --git a/src/test/librados_test_stub/TestMemIoCtxImpl.h b/src/test/librados_test_stub/TestMemIoCtxImpl.h index f083230c89e..22e4fc7eb88 100644 --- a/src/test/librados_test_stub/TestMemIoCtxImpl.h +++ b/src/test/librados_test_stub/TestMemIoCtxImpl.h @@ -28,7 +28,8 @@ public: int assert_exists(const std::string &oid) override; - int create(const std::string& oid, bool exclusive) override; + int create(const std::string& oid, bool exclusive, + const SnapContext &snapc) override; int list_snaps(const std::string& o, snap_set_t *out_snaps) override; int omap_get_vals(const std::string& oid, const std::string& start_after, diff --git a/src/test/librbd/io/test_mock_ObjectRequest.cc b/src/test/librbd/io/test_mock_ObjectRequest.cc index 2f1d8777e0b..3459ac49c41 100644 --- a/src/test/librbd/io/test_mock_ObjectRequest.cc +++ b/src/test/librbd/io/test_mock_ObjectRequest.cc @@ -273,7 +273,7 @@ struct TestMockIoObjectRequest : public TestMockFixture { } void expect_create(MockTestImageCtx &mock_image_ctx, bool exclusive) { - EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, exclusive)) + EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, exclusive, _)) .Times(1); } @@ -998,7 +998,8 @@ TEST_F(TestMockIoObjectRequest, DiscardTruncateAssertExists) { expect_assert_exists(mock_image_ctx, 0); expect_truncate(mock_image_ctx, 0, 0); - EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, _)).Times(0); + EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, _, _)) + .Times(0); C_SaferCond ctx; auto req = MockObjectDiscardRequest::create_discard( @@ -1033,7 +1034,8 @@ TEST_F(TestMockIoObjectRequest, DiscardTruncate) { expect_object_map_update(mock_image_ctx, 0, 1, OBJECT_EXISTS, {}, false, 0); expect_truncate(mock_image_ctx, 1, 0); - EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, _)).Times(0); + EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, _, _)) + .Times(0); C_SaferCond ctx; auto req = MockObjectDiscardRequest::create_discard( diff --git a/src/test/rbd_mirror/image_deleter/test_mock_TrashWatcher.cc b/src/test/rbd_mirror/image_deleter/test_mock_TrashWatcher.cc index 034c3e5497d..df78edd2db3 100644 --- a/src/test/rbd_mirror/image_deleter/test_mock_TrashWatcher.cc +++ b/src/test/rbd_mirror/image_deleter/test_mock_TrashWatcher.cc @@ -151,7 +151,7 @@ public: } void expect_create_trash(librados::IoCtx &io_ctx, int r) { - EXPECT_CALL(get_mock_io_ctx(io_ctx), create(RBD_TRASH, false)) + EXPECT_CALL(get_mock_io_ctx(io_ctx), create(RBD_TRASH, false, _)) .WillOnce(Return(r)); }