]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librados/aio_cxx: Fix PoolEIOFlag test
authorMatan Breizman <mbreizma@redhat.com>
Wed, 23 Nov 2022 13:20:01 +0000 (13:20 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 23 Nov 2022 13:20:01 +0000 (13:20 +0000)
* wait_for_complete is added before getting the return value.

* for loop iteration limit is added to avoid infinite run.

Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/test/librados/aio_cxx.cc

index 31914ff1b56ea453b855966bc910dae54d8f4c58..1f3d6c4b85b73061af3f86bd1fdb4025ed355e2c 100644 (file)
@@ -2267,6 +2267,10 @@ void pool_io_callback(completion_t cb, void *arg /* Actually AioCompletion* */)
 {
   io_info *info = (io_info *)arg;
   unsigned long i = info->i;
+  {
+    TestAlarm alarm;
+    ASSERT_EQ(0, info->c->wait_for_complete());
+  }
   int r = info->c->get_return_value();
   //cout << "finish " << i << " r = " << r << std::endl;
 
@@ -2294,7 +2298,7 @@ TEST(LibRadosAio, PoolEIOFlag) {
   unsigned max = 100;
   unsigned long i = 1;
   my_lock.lock();
-  for (; min_failed == 0; ++i) {
+  for (; min_failed == 0 && i <= max; ++i) {
     io_info *info = new io_info;
     info->i = i;
     info->c = Rados::aio_create_completion();
@@ -2309,14 +2313,13 @@ TEST(LibRadosAio, PoolEIOFlag) {
       t = new std::thread(
        [&] {
          bufferlist empty;
-         int r = test_data.m_cluster.mon_command(
+         ASSERT_EQ(0, test_data.m_cluster.mon_command(
            "{\"prefix\": \"osd pool set\", \"pool\": \"" + test_data.m_pool_name +
-           "\", \"var\": \"eio\", \"val\": \"true\"}", empty, nullptr, nullptr);
-         ceph_assert(r == 0);
+           "\", \"var\": \"eio\", \"val\": \"true\"}", empty, nullptr, nullptr));
        });
     }
 
-    std::this_thread::sleep_for(10'000us);
+    std::this_thread::sleep_for(10ms);
     my_lock.lock();
     if (r < 0) {
       inflight.erase(i);