Merge pull request #24009 from trociny/wip-test-migration-other-pool

test/librbd: migration tests did not delete additional pool

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
Jason Dillaman 2018-09-11 20:46:02 -04:00 committed by GitHub
commit bd97964b0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,9 +18,25 @@ void register_test_migration() {
}
struct TestMigration : public TestFixture {
static void SetUpTestCase() {
TestFixture::SetUpTestCase();
_other_pool_name = get_temp_pool_name("test-librbd-");
ASSERT_EQ(0, _rados.pool_create(_other_pool_name.c_str()));
}
static void TearDownTestCase() {
ASSERT_EQ(0, _rados.pool_delete(_other_pool_name.c_str()));
TestFixture::TearDownTestCase();
}
void SetUp() override {
TestFixture::SetUp();
ASSERT_EQ(0, _rados.ioctx_create(_other_pool_name.c_str(),
_other_pool_ioctx));
open_image(m_ioctx, m_image_name, &m_ictx);
m_image_id = m_ictx->id;
@ -40,24 +56,11 @@ struct TestMigration : public TestFixture {
close_image(m_ictx);
}
m_other_pool_ioctx.close();
_other_pool_ioctx.close();
TestFixture::TearDown();
}
void require_other_pool() {
std::string pool_name = get_temp_pool_name("test-librbd-");
ASSERT_EQ("", create_one_pool_pp(pool_name, m_other_pool_rados));
ASSERT_EQ(0, m_other_pool_rados.ioctx_create(pool_name.c_str(),
m_other_pool_ioctx));
}
bool is_librados_test_stub() {
std::string fsid;
EXPECT_EQ(0, _rados.cluster_fsid(&fsid));
return fsid == "00000000-1111-2222-3333-444444444444";
}
void compare(const std::string &description = "") {
vector<librbd::snap_info_t> src_snaps, dst_snaps;
@ -454,15 +457,19 @@ struct TestMigration : public TestFixture {
migration_commit(m_ioctx, m_image_name);
}
static std::string _other_pool_name;
static librados::IoCtx _other_pool_ioctx;
std::string m_image_id;
librbd::ImageCtx *m_ictx = nullptr;
librados::IoCtx m_ref_ioctx;
librbd::ImageCtx *m_ref_ictx = nullptr;
librbd::ImageOptions m_opts;
librados::Rados m_other_pool_rados;
librados::IoCtx m_other_pool_ioctx;
};
std::string TestMigration::_other_pool_name;
librados::IoCtx TestMigration::_other_pool_ioctx;
TEST_F(TestMigration, Empty)
{
uint64_t features = m_ictx->features ^ RBD_FEATURE_LAYERING;
@ -484,23 +491,19 @@ TEST_F(TestMigration, OtherName)
TEST_F(TestMigration, OtherPool)
{
require_other_pool();
migrate(_other_pool_ioctx, m_image_name);
migrate(m_other_pool_ioctx, m_image_name);
ASSERT_EQ(m_other_pool_ioctx.get_id(), m_ictx->md_ctx.get_id());
ASSERT_EQ(_other_pool_ioctx.get_id(), m_ictx->md_ctx.get_id());
}
TEST_F(TestMigration, DataPool)
{
require_other_pool();
ASSERT_EQ(0, m_opts.set(RBD_IMAGE_OPTION_DATA_POOL,
m_other_pool_ioctx.get_pool_name().c_str()));
_other_pool_ioctx.get_pool_name().c_str()));
migrate(m_ioctx, m_image_name);
ASSERT_EQ(m_other_pool_ioctx.get_id(), m_ictx->data_ctx.get_id());
ASSERT_EQ(_other_pool_ioctx.get_id(), m_ictx->data_ctx.get_id());
}
TEST_F(TestMigration, AbortAfterPrepare)
@ -530,13 +533,11 @@ TEST_F(TestMigration, AbortAfterExecute)
TEST_F(TestMigration, OtherPoolAbortAfterExecute)
{
require_other_pool();
migration_prepare(m_other_pool_ioctx, m_image_name);
migration_prepare(_other_pool_ioctx, m_image_name);
migration_status(RBD_IMAGE_MIGRATION_STATE_PREPARED);
migration_execute(m_other_pool_ioctx, m_image_name);
migration_execute(_other_pool_ioctx, m_image_name);
migration_status(RBD_IMAGE_MIGRATION_STATE_EXECUTED);
migration_abort(m_other_pool_ioctx, m_image_name);
migration_abort(_other_pool_ioctx, m_image_name);
}
TEST_F(TestMigration, MirroringSamePool)
@ -582,8 +583,6 @@ TEST_F(TestMigration, MirroringOtherPoolDisabled)
{
REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
require_other_pool();
ASSERT_EQ(0, librbd::api::Mirror<>::mode_set(m_ioctx, RBD_MIRROR_MODE_IMAGE));
ASSERT_EQ(0, librbd::api::Mirror<>::image_enable(m_ictx, false));
@ -591,7 +590,7 @@ TEST_F(TestMigration, MirroringOtherPoolDisabled)
ASSERT_EQ(0, librbd::api::Mirror<>::image_get_info(m_ictx, &info));
ASSERT_EQ(RBD_MIRROR_IMAGE_ENABLED, info.state);
migrate(m_other_pool_ioctx, m_image_name);
migrate(_other_pool_ioctx, m_image_name);
ASSERT_EQ(0, librbd::api::Mirror<>::image_get_info(m_ictx, &info));
ASSERT_EQ(RBD_MIRROR_IMAGE_DISABLED, info.state);
@ -601,10 +600,8 @@ TEST_F(TestMigration, MirroringOtherPoolEnabled)
{
REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
require_other_pool();
ASSERT_EQ(0, librbd::api::Mirror<>::mode_set(m_ioctx, RBD_MIRROR_MODE_IMAGE));
ASSERT_EQ(0, librbd::api::Mirror<>::mode_set(m_other_pool_ioctx,
ASSERT_EQ(0, librbd::api::Mirror<>::mode_set(_other_pool_ioctx,
RBD_MIRROR_MODE_IMAGE));
ASSERT_EQ(0, librbd::api::Mirror<>::image_enable(m_ictx, false));
@ -612,7 +609,7 @@ TEST_F(TestMigration, MirroringOtherPoolEnabled)
ASSERT_EQ(0, librbd::api::Mirror<>::image_get_info(m_ictx, &info));
ASSERT_EQ(RBD_MIRROR_IMAGE_ENABLED, info.state);
migrate(m_other_pool_ioctx, m_image_name);
migrate(_other_pool_ioctx, m_image_name);
ASSERT_EQ(0, librbd::api::Mirror<>::image_get_info(m_ictx, &info));
ASSERT_EQ(RBD_MIRROR_IMAGE_ENABLED, info.state);
@ -622,15 +619,13 @@ TEST_F(TestMigration, MirroringPool)
{
REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
require_other_pool();
ASSERT_EQ(0, librbd::api::Mirror<>::mode_set(m_other_pool_ioctx,
ASSERT_EQ(0, librbd::api::Mirror<>::mode_set(_other_pool_ioctx,
RBD_MIRROR_MODE_POOL));
librbd::mirror_image_info_t info;
ASSERT_EQ(0, librbd::api::Mirror<>::image_get_info(m_ictx, &info));
ASSERT_EQ(RBD_MIRROR_IMAGE_DISABLED, info.state);
migrate(m_other_pool_ioctx, m_image_name);
migrate(_other_pool_ioctx, m_image_name);
ASSERT_EQ(0, librbd::api::Mirror<>::image_get_info(m_ictx, &info));
ASSERT_EQ(RBD_MIRROR_IMAGE_ENABLED, info.state);
@ -696,23 +691,19 @@ TEST_F(TestMigration, NoSnapsOtherPool)
{
test_no_snaps();
require_other_pool();
test_no_snaps();
migrate(m_other_pool_ioctx, m_image_name);
migrate(_other_pool_ioctx, m_image_name);
}
TEST_F(TestMigration, NoSnapsDataPool)
{
test_no_snaps();
require_other_pool();
ASSERT_EQ(0, m_opts.set(RBD_IMAGE_OPTION_DATA_POOL,
m_other_pool_ioctx.get_pool_name().c_str()));
_other_pool_ioctx.get_pool_name().c_str()));
migrate(m_ioctx, m_image_name);
EXPECT_EQ(m_other_pool_ioctx.get_id(), m_ictx->data_ctx.get_id());
EXPECT_EQ(_other_pool_ioctx.get_id(), m_ictx->data_ctx.get_id());
}
TEST_F(TestMigration, NoSnapsShrinkAfterPrepare)
@ -791,25 +782,21 @@ TEST_F(TestMigration, SnapsOtherPool)
{
test_snaps();
require_other_pool();
test_no_snaps();
migrate(m_other_pool_ioctx, m_image_name);
migrate(_other_pool_ioctx, m_image_name);
EXPECT_EQ(m_other_pool_ioctx.get_id(), m_ictx->md_ctx.get_id());
EXPECT_EQ(_other_pool_ioctx.get_id(), m_ictx->md_ctx.get_id());
}
TEST_F(TestMigration, SnapsDataPool)
{
test_snaps();
require_other_pool();
ASSERT_EQ(0, m_opts.set(RBD_IMAGE_OPTION_DATA_POOL,
m_other_pool_ioctx.get_pool_name().c_str()));
_other_pool_ioctx.get_pool_name().c_str()));
migrate(m_ioctx, m_image_name);
EXPECT_EQ(m_other_pool_ioctx.get_id(), m_ictx->data_ctx.get_id());
EXPECT_EQ(_other_pool_ioctx.get_id(), m_ictx->data_ctx.get_id());
}
TEST_F(TestMigration, SnapsShrinkAfterPrepare)