test: new librbd flatten test case

AIO operations after a flatten operation were previously
hanging during the close of the parent image.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
Jason Dillaman 2016-02-02 10:54:53 -05:00
parent 63e671a979
commit 5b3a4d2cbc

View File

@ -2939,6 +2939,52 @@ TEST_F(TestLibRBD, TestPendingAio)
rados_ioctx_destroy(ioctx);
}
TEST_F(TestLibRBD, Flatten)
{
REQUIRE_FEATURE(RBD_FEATURE_LAYERING);
librados::IoCtx ioctx;
ASSERT_EQ(0, _rados.ioctx_create(m_pool_name.c_str(), ioctx));
librbd::RBD rbd;
std::string parent_name = get_temp_image_name();
uint64_t size = 2 << 20;
int order = 0;
ASSERT_EQ(0, create_image_pp(rbd, ioctx, parent_name.c_str(), size, &order));
librbd::Image parent_image;
ASSERT_EQ(0, rbd.open(ioctx, parent_image, parent_name.c_str(), NULL));
bufferlist bl;
bl.append(std::string(4096, '1'));
ASSERT_EQ(bl.length(), parent_image.write(0, bl.length(), bl));
ASSERT_EQ(0, parent_image.snap_create("snap1"));
ASSERT_EQ(0, parent_image.snap_protect("snap1"));
uint64_t features;
ASSERT_EQ(0, parent_image.features(&features));
std::string clone_name = get_temp_image_name();
EXPECT_EQ(0, rbd.clone(ioctx, parent_name.c_str(), "snap1", ioctx,
clone_name.c_str(), features, &order));
librbd::Image clone_image;
ASSERT_EQ(0, rbd.open(ioctx, clone_image, clone_name.c_str(), NULL));
ASSERT_EQ(0, clone_image.flatten());
librbd::RBD::AioCompletion *read_comp =
new librbd::RBD::AioCompletion(NULL, NULL);
bufferlist read_bl;
clone_image.aio_read(0, bl.length(), read_bl, read_comp);
ASSERT_EQ(0, read_comp->wait_for_complete());
ASSERT_EQ(bl.length(), read_comp->get_return_value());
read_comp->release();
ASSERT_TRUE(bl.contents_equal(read_bl));
ASSERT_PASSED(validate_object_map, clone_image);
}
TEST_F(TestLibRBD, RebuildObjectMapViaLockOwner)
{
REQUIRE_FEATURE(RBD_FEATURE_EXCLUSIVE_LOCK | RBD_FEATURE_OBJECT_MAP);