]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/librbd: fix race in TestLibRBD.ConcurentOperations
authorMykola Golub <mgolub@suse.com>
Fri, 4 Dec 2020 17:02:17 +0000 (17:02 +0000)
committerMykola Golub <mgolub@suse.com>
Fri, 4 Dec 2020 17:02:17 +0000 (17:02 +0000)
It was possible that before image1 was closed, both quiesce2 and
quiesce3 requests were received and the test got stuck on
create_snap1.join() waiting for the image1 to be closed, while
the close was waiting for quiesce3 to be completed.

Signed-off-by: Mykola Golub <mgolub@suse.com>
src/test/librbd/test_librbd.cc

index 96543cf449752708f4799f9d951882b818e6cc39..fe7fe1a5ff6735aabbf313eb308d490d86438c32 100644 (file)
@@ -8888,10 +8888,12 @@ TEST_F(TestLibRBD, ConcurentOperations)
     uint64_t handle;
     ASSERT_EQ(0, image2.quiesce_watch(&watcher, &handle));
 
-    std::thread create_snap1([&image1]() {
+    auto close1_comp = new librbd::RBD::AioCompletion(NULL, NULL);
+
+    std::thread create_snap1([&image1, close1_comp]() {
       int r = image1.snap_create("snap1");
       ceph_assert(r == 0);
-      r = image1.close();
+      r = image1.aio_close(close1_comp);
       ceph_assert(r == 0);
     });
 
@@ -8908,15 +8910,18 @@ TEST_F(TestLibRBD, ConcurentOperations)
     });
 
     image2.quiesce_complete(handle, 0);
+    create_snap1.join();
 
     ASSERT_TRUE(watcher.wait_for_quiesce(2));
     image2.quiesce_complete(handle, 0);
 
-    create_snap1.join();
-
     ASSERT_TRUE(watcher.wait_for_quiesce(3));
     image2.quiesce_complete(handle, 0);
 
+    ASSERT_EQ(0, close1_comp->wait_for_complete());
+    ASSERT_EQ(1, close1_comp->is_complete());
+    ASSERT_EQ(0, close1_comp->get_return_value());
+
     create_snap2.join();
     create_snap3.join();