From: Or Ozeri Date: Tue, 28 Jul 2020 09:08:30 +0000 (+0300) Subject: test/librados_test_stub: handle exclusive create X-Git-Tag: v16.1.0~1569^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F36317%2Fhead;p=ceph.git test/librados_test_stub: handle exclusive create The exclusive boolean of the create method was unused so far. This commit adds the proper handling by checking if an object already exists, and returning EEXISTS appropriately. Signed-off-by: Or Ozeri --- diff --git a/src/test/librados_test_stub/TestMemIoCtxImpl.cc b/src/test/librados_test_stub/TestMemIoCtxImpl.cc index d1f2f8cda51..24b4ac559a3 100644 --- a/src/test/librados_test_stub/TestMemIoCtxImpl.cc +++ b/src/test/librados_test_stub/TestMemIoCtxImpl.cc @@ -108,6 +108,13 @@ int TestMemIoCtxImpl::create(const std::string& oid, bool exclusive, } std::unique_lock l{m_pool->file_lock}; + if (exclusive) { + TestMemCluster::SharedFile file = get_file(oid, false, CEPH_NOSNAP, {}); + if (file != NULL && file->exists) { + return -EEXIST; + } + } + get_file(oid, true, CEPH_NOSNAP, snapc); return 0; } diff --git a/src/test/librbd/image/test_mock_ValidatePoolRequest.cc b/src/test/librbd/image/test_mock_ValidatePoolRequest.cc index 7bb3ead9db9..95e4028ec96 100644 --- a/src/test/librbd/image/test_mock_ValidatePoolRequest.cc +++ b/src/test/librbd/image/test_mock_ValidatePoolRequest.cc @@ -39,6 +39,7 @@ public: void SetUp() override { TestMockFixture::SetUp(); + m_ioctx.remove(RBD_INFO); ASSERT_EQ(0, open_image(m_image_name, &image_ctx)); }