From: Mykola Golub Date: Mon, 22 Feb 2021 12:53:38 +0000 (+0000) Subject: test/librbd: extend TestLibRBD.RenameViaLockOwner X-Git-Tag: v17.1.0~2865^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=2d2e04e86bcc666e3abaceeeef7e1598dcc9fb94;p=ceph.git test/librbd: extend TestLibRBD.RenameViaLockOwner To cover the following case: - Client A has image opened but does not owns the lock. - Client B renames the image (client A is not aware of it). - Client A becomes the lock owner. - Client B requests rename, which is proxied to the client A. Signed-off-by: Mykola Golub --- diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc index e7233f0f376f2..11b2cf1cfa6d9 100644 --- a/src/test/librbd/test_librbd.cc +++ b/src/test/librbd/test_librbd.cc @@ -5068,14 +5068,22 @@ TEST_F(TestLibRBD, RenameViaLockOwner) librbd::Image image1; ASSERT_EQ(0, rbd.open(ioctx, image1, name.c_str(), NULL)); + bool lock_owner; + ASSERT_EQ(0, image1.is_exclusive_lock_owner(&lock_owner)); + ASSERT_FALSE(lock_owner); + + std::string new_name = get_temp_image_name(); + ASSERT_EQ(0, rbd.rename(ioctx, name.c_str(), new_name.c_str())); + ASSERT_EQ(0, image1.is_exclusive_lock_owner(&lock_owner)); + ASSERT_FALSE(lock_owner); + bufferlist bl; ASSERT_EQ(0, image1.write(0, 0, bl)); - - bool lock_owner; ASSERT_EQ(0, image1.is_exclusive_lock_owner(&lock_owner)); ASSERT_TRUE(lock_owner); - std::string new_name = get_temp_image_name(); + name = new_name; + new_name = get_temp_image_name(); ASSERT_EQ(0, rbd.rename(ioctx, name.c_str(), new_name.c_str())); ASSERT_EQ(0, image1.is_exclusive_lock_owner(&lock_owner)); ASSERT_TRUE(lock_owner);