diff options
author | junxiang Mu <1948535941@qq.com> | 2024-09-11 05:06:18 +0200 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2025-01-22 09:55:34 +0100 |
commit | a5c9a884ac3dc10b02e319a3f528969cd9fd932e (patch) | |
tree | a54ecb27559e1fdad06095180cadd12454d8997a /src/test/librbd/test_Migration.cc | |
parent | Merge pull request #59485 from mcv21/cephadm_image_warn (diff) | |
download | ceph-a5c9a884ac3dc10b02e319a3f528969cd9fd932e.tar.xz ceph-a5c9a884ac3dc10b02e319a3f528969cd9fd932e.zip |
test/librbd: add unit test for flatten migration
Fixes: https://tracker.ceph.com/issues/65743
Co-authored-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: junxiang Mu <1948535941@qq.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to '')
-rw-r--r-- | src/test/librbd/test_Migration.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/librbd/test_Migration.cc b/src/test/librbd/test_Migration.cc index 8c0f4b61b21..000cae6de86 100644 --- a/src/test/librbd/test_Migration.cc +++ b/src/test/librbd/test_Migration.cc @@ -330,6 +330,16 @@ struct TestMigration : public TestFixture { ASSERT_EQ(0, m_ictx->operations->resize(size, true, no_op)); } + void test_children(bool have, std::string initial_image_name) { + std::vector<librbd::linked_image_spec_t> images; + librbd::ImageCtx *initial_ictx = nullptr; + open_image(m_ioctx, initial_image_name, &initial_ictx); + EXPECT_EQ(0, librbd::api::Image<>::snap_set( + initial_ictx, cls::rbd::UserSnapshotNamespace(), "snap")); + ASSERT_EQ(0, librbd::api::Image<>::list_children(initial_ictx, &images)); + ASSERT_EQ(have, !images.empty()); + } + void test_no_snaps() { uint64_t len = (1 << m_ictx->order) * 2 + 1; write(0 * len, len, '1'); @@ -1051,16 +1061,41 @@ TEST_F(TestMigration, CloneUpdateAfterPrepare) { REQUIRE_FEATURE(RBD_FEATURE_LAYERING); + auto initial_image_name = m_image_name; + + write(0, 10, 'X'); + snap_create("snap"); + clone("snap"); + + migration_prepare(m_ioctx, m_image_name); + + write(0, 1, 'Y'); + + test_children(true, initial_image_name); + migration_execute(m_ioctx, m_image_name); + migration_commit(m_ioctx, m_image_name); + test_children(true, initial_image_name); +} + +TEST_F(TestMigration, CloneFlatten) +{ + REQUIRE_FEATURE(RBD_FEATURE_LAYERING); + + auto initial_image_name = m_image_name; + write(0, 10, 'X'); snap_create("snap"); clone("snap"); + ASSERT_EQ(0, m_opts.set(RBD_IMAGE_OPTION_FLATTEN, 1)); migration_prepare(m_ioctx, m_image_name); write(0, 1, 'Y'); + test_children(true, initial_image_name); migration_execute(m_ioctx, m_image_name); migration_commit(m_ioctx, m_image_name); + test_children(false, initial_image_name); } TEST_F(TestMigration, TriggerAssertSnapcSeq) |