From 8dfcc72071d63c7867a5a59abe871cf5db673a0a Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 23 Jun 2015 14:20:16 -0400 Subject: [PATCH] tests: verify that image shrink properly handles flush op Signed-off-by: Jason Dillaman --- src/test/librbd/test_internal.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/test/librbd/test_internal.cc b/src/test/librbd/test_internal.cc index 757802392b7b1..0d909497953f5 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(); +} -- 2.39.5