]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: update librbd AIO tests to remove result code
authorJason Dillaman <dillaman@redhat.com>
Thu, 9 Apr 2015 01:55:36 +0000 (21:55 -0400)
committerKen Dreyer <kdreyer@redhat.com>
Wed, 24 Jun 2015 16:41:21 +0000 (10:41 -0600)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 948b15eb52fd5d9ce842fa12ee0cecda17353b01)
(cherry picked from commit 272df2aed79a95dd9c45db4e0953e9b321f7b0f5)

src/test/librbd/test_ImageWatcher.cc
src/test/librbd/test_internal.cc
src/test/librbd/test_librbd.cc

index ed514946c82a5fa2cfffdf8eab7cb86058937680..fccc90d140d4c6113155efb7e090f925130bb7e3 100644 (file)
@@ -170,13 +170,13 @@ public:
     if (!ictx->image_watcher->is_lock_owner() &&
         (m_expected_aio_restarts == 0 ||
         m_aio_completion_restarts < m_expected_aio_restarts)) {
-      EXPECT_EQ(0, ictx->image_watcher->request_lock(
+      ictx->image_watcher->request_lock(
         boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
-       aio_completion));
+       aio_completion);
     } else {
       {
        Mutex::Locker l2(aio_completion->lock);
-       aio_completion->complete();
+       aio_completion->complete(ictx->cct);
       }
 
       m_aio_completions.erase(aio_completion);
@@ -531,12 +531,12 @@ TEST_F(TestImageWatcher, RequestLock) {
 
   {
     RWLock::WLocker l(ictx->owner_lock);
-    ASSERT_EQ(0, ictx->image_watcher->request_lock(
+    ictx->image_watcher->request_lock(
       boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
-      create_aio_completion(*ictx)));
-    ASSERT_EQ(0, ictx->image_watcher->request_lock(
+      create_aio_completion(*ictx));
+    ictx->image_watcher->request_lock(
       boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
-      create_aio_completion(*ictx)));
+      create_aio_completion(*ictx));
   }
 
   ASSERT_TRUE(wait_for_notifies(*ictx));
@@ -581,9 +581,9 @@ TEST_F(TestImageWatcher, RequestLockTimedOut) {
 
   {
     RWLock::WLocker l(ictx->owner_lock);
-    ASSERT_EQ(0, ictx->image_watcher->request_lock(
+    ictx->image_watcher->request_lock(
       boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
-      create_aio_completion(*ictx)));
+      create_aio_completion(*ictx));
   }
 
   ASSERT_TRUE(wait_for_notifies(*ictx));
@@ -608,9 +608,9 @@ TEST_F(TestImageWatcher, RequestLockTryLockRace) {
 
   {
     RWLock::WLocker l(ictx->owner_lock);
-    ASSERT_EQ(0, ictx->image_watcher->request_lock(
+    ictx->image_watcher->request_lock(
       boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
-      create_aio_completion(*ictx)));
+      create_aio_completion(*ictx));
   }
 
   ASSERT_TRUE(wait_for_notifies(*ictx));
@@ -643,9 +643,9 @@ TEST_F(TestImageWatcher, RequestLockPreTryLockFailed) {
 
   {
     RWLock::WLocker l(ictx->owner_lock);
-    ASSERT_EQ(0, ictx->image_watcher->request_lock(
+    ictx->image_watcher->request_lock(
       boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
-      create_aio_completion(*ictx)));
+      create_aio_completion(*ictx));
   }
   ASSERT_TRUE(wait_for_aio_completions(*ictx));
 }
@@ -665,9 +665,9 @@ TEST_F(TestImageWatcher, RequestLockPostTryLockFailed) {
   m_expected_aio_restarts = 1;
   {
     RWLock::WLocker l(ictx->owner_lock);
-    ASSERT_EQ(0, ictx->image_watcher->request_lock(
+    ictx->image_watcher->request_lock(
       boost::bind(&TestImageWatcher::handle_restart_aio, this, ictx, _1),
-      create_aio_completion(*ictx)));
+      create_aio_completion(*ictx));
   }
 
   ASSERT_TRUE(wait_for_notifies(*ictx));
index a6d1bcf529f21443b6f59c71d9bad1a6e5d444dd..082d1dc54a63422f3c09e3c2c96ec51dbda11bc3 100644 (file)
@@ -256,12 +256,14 @@ TEST_F(TestInternal, AioWriteRequestsLock) {
   DummyContext *ctx = new DummyContext();
   librbd::AioCompletion *c =
     librbd::aio_create_completion_internal(ctx, librbd::rbd_ctx_cb);
-  ASSERT_EQ(0, aio_write(ictx, 0, buffer.size(), buffer.c_str(), c, 0));
+  c->get();
+  aio_write(ictx, 0, buffer.size(), buffer.c_str(), c, 0);
 
   bool is_owner;
   ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner));
   ASSERT_FALSE(is_owner);
   ASSERT_FALSE(c->is_complete());
+  c->put();
 }
 
 TEST_F(TestInternal, AioDiscardRequestsLock) {
@@ -274,12 +276,14 @@ TEST_F(TestInternal, AioDiscardRequestsLock) {
   DummyContext *ctx = new DummyContext();
   librbd::AioCompletion *c =
     librbd::aio_create_completion_internal(ctx, librbd::rbd_ctx_cb);
-  ASSERT_EQ(0, aio_discard(ictx, 0, 256, c));
+  c->get();
+  aio_discard(ictx, 0, 256, c);
 
   bool is_owner;
   ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner));
   ASSERT_FALSE(is_owner);
   ASSERT_FALSE(c->is_complete());
+  c->put();
 }
 
 TEST_F(TestInternal, CancelAsyncResize) {
index cf76c67c7b645c4914014adb1631cc86ba556d72..d13e15b8eb194dd57c50cb892ca2fd8c0108e6a9 100644 (file)
@@ -827,8 +827,16 @@ TEST_F(TestLibRBD, TestIO)
   ASSERT_EQ(10, rbd_write(image, info.size - 10, 100, test_data));
 
   rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
-  ASSERT_EQ(-EINVAL, rbd_aio_write(image, info.size, 1, test_data, comp));
-  ASSERT_EQ(-EINVAL, rbd_aio_read(image, info.size, 1, test_data, comp));
+  ASSERT_EQ(0, rbd_aio_write(image, info.size, 1, test_data, comp));
+  ASSERT_EQ(0, rbd_aio_wait_for_complete(comp));
+  ASSERT_EQ(-EINVAL, rbd_aio_get_return_value(comp));
+  rbd_aio_release(comp);
+
+  rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
+  ASSERT_EQ(0, rbd_aio_read(image, info.size, 1, test_data, comp));
+  ASSERT_EQ(0, rbd_aio_wait_for_complete(comp));
+  ASSERT_EQ(-EINVAL, rbd_aio_get_return_value(comp));
+  rbd_aio_release(comp);
 
   ASSERT_PASSED(validate_object_map, image);
   ASSERT_EQ(0, rbd_close(image));
@@ -903,15 +911,16 @@ TEST_F(TestLibRBD, TestIOWithIOHint)
                            LIBRADOS_OP_FLAG_FADVISE_DONTNEED));
 
   rbd_aio_create_completion(NULL, (rbd_callback_t) simple_read_cb, &comp);
-  ASSERT_EQ(-EINVAL, rbd_aio_write(image, info.size, 1, test_data, comp));
-  ASSERT_EQ(-EINVAL, rbd_aio_read2(image, info.size, 1, test_data, comp,
-                                   LIBRADOS_OP_FLAG_FADVISE_DONTNEED));
+  ASSERT_EQ(0, rbd_aio_read2(image, info.size, 1, test_data, comp,
+                            LIBRADOS_OP_FLAG_FADVISE_DONTNEED));
+  ASSERT_EQ(0, rbd_aio_wait_for_complete(comp));
+  ASSERT_EQ(-EINVAL, rbd_aio_get_return_value(comp));
+  rbd_aio_release(comp);
 
   ASSERT_PASSED(validate_object_map, image);
   ASSERT_EQ(0, rbd_close(image));
 
   rados_ioctx_destroy(ioctx);
-
 }
 
 TEST_F(TestLibRBD, TestEmptyDiscard)