From 143be4cc3cb264a125a0272c796a438af281303a Mon Sep 17 00:00:00 2001 From: Or Ozeri Date: Tue, 28 Jul 2020 12:08:30 +0300 Subject: [PATCH] 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 --- src/test/librados_test_stub/TestMemIoCtxImpl.cc | 7 +++++++ src/test/librbd/image/test_mock_ValidatePoolRequest.cc | 1 + 2 files changed, 8 insertions(+) diff --git a/src/test/librados_test_stub/TestMemIoCtxImpl.cc b/src/test/librados_test_stub/TestMemIoCtxImpl.cc index d1f2f8cda5120..24b4ac559a3c4 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 7bb3ead9db92b..95e4028ec964f 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)); } -- 2.39.5