]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librbd: extend TestLibRBD.RenameViaLockOwner
authorMykola Golub <mgolub@suse.com>
Mon, 22 Feb 2021 12:53:38 +0000 (12:53 +0000)
committerMykola Golub <mgolub@suse.com>
Fri, 5 Mar 2021 17:04:34 +0000 (19:04 +0200)
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 <mgolub@suse.com>
(cherry picked from commit 2d2e04e86bcc666e3abaceeeef7e1598dcc9fb94)

src/test/librbd/test_librbd.cc

index d5943cc369f4af11d00410aba047deb31724c78d..f64572958c3b9b5dea2a19adc79bafabf5e58440 100644 (file)
@@ -4900,14 +4900,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);