From: Mykola Golub Date: Fri, 4 Dec 2020 17:02:17 +0000 (+0000) Subject: test/librbd: fix race in TestLibRBD.ConcurentOperations X-Git-Tag: v17.0.0~407^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3f8c63175d9364b98747d7b21f92599cff0d5bb9;p=ceph-ci.git test/librbd: fix race in TestLibRBD.ConcurentOperations 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 --- diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc index 96543cf4497..fe7fe1a5ff6 100644 --- a/src/test/librbd/test_librbd.cc +++ b/src/test/librbd/test_librbd.cc @@ -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();