]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/librados_test_stub: handle exclusive create
authorOr Ozeri <oro@il.ibm.com>
Tue, 28 Jul 2020 09:08:30 +0000 (12:08 +0300)
committerOr Ozeri <oro@il.ibm.com>
Wed, 29 Jul 2020 11:39:08 +0000 (14:39 +0300)
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 <oro@il.ibm.com>
src/test/librados_test_stub/TestMemIoCtxImpl.cc
src/test/librbd/image/test_mock_ValidatePoolRequest.cc

index d1f2f8cda512010ad22edf9dc63da21eec2799b2..24b4ac559a3c48814454f00b6212d9206371e621 100644 (file)
@@ -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;
 }
index 7bb3ead9db92b6d266f927bd0e60f90ce71aefbf..95e4028ec964fa726c8ca681d4a18dc84e7bebe5 100644 (file)
@@ -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));
   }