From: Jason Dillaman Date: Tue, 23 Jun 2015 18:20:16 +0000 (-0400) Subject: tests: verify that image shrink properly handles flush op X-Git-Tag: v9.0.2~10^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F5063%2Fhead;p=ceph.git tests: verify that image shrink properly handles flush op Signed-off-by: Jason Dillaman --- diff --git a/src/test/librbd/test_internal.cc b/src/test/librbd/test_internal.cc index 757802392b7b..0d909497953f 100644 --- a/src/test/librbd/test_internal.cc +++ b/src/test/librbd/test_internal.cc @@ -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(); +}