]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: verify that image shrink properly handles flush op 5063/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 23 Jun 2015 18:20:16 +0000 (14:20 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 23 Jun 2015 21:55:09 +0000 (17:55 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/librbd/test_internal.cc

index 757802392b7b171e98d3db5503d686facdfe728f..0d909497953f57a4e16c5ffc20554e7a7e34457b 100644 (file)
@@ -604,3 +604,27 @@ TEST_F(TestInternal, DiscardCopyup)
   }
 }
 
+TEST_F(TestInternal, ShrinkFlushesCache) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  {
+    RWLock::WLocker owner_locker(ictx->owner_lock);
+    ASSERT_EQ(0, ictx->image_watcher->try_lock());
+  }
+
+  std::string buffer(4096, '1');
+  C_SaferCond cond_ctx;
+  librbd::AioCompletion *c =
+    librbd::aio_create_completion_internal(&cond_ctx, librbd::rbd_ctx_cb);
+  c->get();
+  aio_write(ictx, 0, buffer.size(), buffer.c_str(), c, 0);
+
+  librbd::NoOpProgressContext no_op;
+  ASSERT_EQ(0, librbd::resize(ictx, m_image_size >> 1, no_op));
+
+  ASSERT_TRUE(c->is_complete());
+  ASSERT_EQ(0, c->wait_for_complete());
+  ASSERT_EQ(0, cond_ctx.wait());
+  c->put();
+}