]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: verify that image shrink properly handles flush op 5318/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 23 Jun 2015 18:20:16 +0000 (14:20 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 29 Jul 2015 17:41:40 +0000 (13:41 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 8dfcc72071d63c7867a5a59abe871cf5db673a0a)

src/test/librbd/test_internal.cc

index 2df917d5a05c29ea99e59c287b129b02a6bcb568..4aef7ae66f6fef0e9d348b51fc077c32f573a7f1 100644 (file)
@@ -365,3 +365,28 @@ TEST_F(TestInternal, MultipleResize) {
   ASSERT_EQ(0, librbd::get_size(ictx, &size));
   ASSERT_EQ(0U, size);
 }
+
+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();
+}