From 472abc2ed96738d265d592a99d35b24d988ce30a Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Fri, 2 Nov 2018 18:59:14 +0200 Subject: [PATCH] test/librbd: migration supporting namespace tests Signed-off-by: Mykola Golub --- qa/workunits/rbd/cli_generic.sh | 22 ++++++++++++++++++++++ src/test/librbd/test_Migration.cc | 28 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/qa/workunits/rbd/cli_generic.sh b/qa/workunits/rbd/cli_generic.sh index 35a2e9507fe..d2066d9d944 100755 --- a/qa/workunits/rbd/cli_generic.sh +++ b/qa/workunits/rbd/cli_generic.sh @@ -724,6 +724,18 @@ test_migration() { rbd rm rbd2/test1 && exit 1 || true rbd migration commit test1 + # Migration to other namespace + rbd namespace create rbd2 ns1 + rbd namespace create rbd2 ns2 + rbd migration prepare rbd2/test1 rbd2/ns1/test1 + test "$(get_migration_state rbd2/ns1/test1)" = prepared + rbd migration execute rbd2/test1 + test "$(get_migration_state rbd2/ns1/test1)" = executed + rbd migration commit rbd2/test1 + rbd migration prepare rbd2/ns1/test1 rbd2/ns2/test1 + rbd migration execute rbd2/ns2/test1 + rbd migration commit rbd2/ns2/test1 + # Enable data pool rbd create -s 128M test1 rbd migration prepare test1 --data-pool rbd2 @@ -769,6 +781,16 @@ test_migration() { rbd migration abort rbd2/test2 rbd bench --io-type write --io-size 1024 --io-total 1024 test2 rbd rm test2 + + test $format = 1 && continue + + # Abort migration to other namespace + rbd create -s 128M --image-format ${format} test2 + rbd migration prepare test2 rbd2/ns1/test3 + rbd bench --io-type write --io-size 1024 --io-total 1024 rbd2/ns1/test3 + rbd migration abort test2 + rbd bench --io-type write --io-size 1024 --io-total 1024 test2 + rbd rm test2 done remove_images diff --git a/src/test/librbd/test_Migration.cc b/src/test/librbd/test_Migration.cc index b9e0791b234..77ac5aba13b 100644 --- a/src/test/librbd/test_Migration.cc +++ b/src/test/librbd/test_Migration.cc @@ -10,6 +10,7 @@ #include "librbd/api/Image.h" #include "librbd/api/Migration.h" #include "librbd/api/Mirror.h" +#include "librbd/api/Namespace.h" #include "librbd/internal.h" #include "librbd/io/ImageRequestWQ.h" #include "librbd/io/ReadResult.h" @@ -500,6 +501,18 @@ TEST_F(TestMigration, OtherPool) ASSERT_EQ(_other_pool_ioctx.get_id(), m_ictx->md_ctx.get_id()); } +TEST_F(TestMigration, OtherNamespace) +{ + ASSERT_EQ(0, librbd::api::Namespace<>::create(_other_pool_ioctx, "ns1")); + _other_pool_ioctx.set_namespace("ns1"); + + migrate(_other_pool_ioctx, m_image_name); + + ASSERT_EQ(_other_pool_ioctx.get_id(), m_ictx->md_ctx.get_id()); + ASSERT_EQ(_other_pool_ioctx.get_namespace(), m_ictx->md_ctx.get_namespace()); + _other_pool_ioctx.set_namespace(""); +} + TEST_F(TestMigration, DataPool) { ASSERT_EQ(0, m_opts.set(RBD_IMAGE_OPTION_DATA_POOL, @@ -544,6 +557,21 @@ TEST_F(TestMigration, OtherPoolAbortAfterExecute) migration_abort(_other_pool_ioctx, m_image_name); } +TEST_F(TestMigration, OtherNamespaceAbortAfterExecute) +{ + ASSERT_EQ(0, librbd::api::Namespace<>::create(_other_pool_ioctx, "ns2")); + _other_pool_ioctx.set_namespace("ns2"); + + migration_prepare(_other_pool_ioctx, m_image_name); + migration_status(RBD_IMAGE_MIGRATION_STATE_PREPARED); + migration_execute(_other_pool_ioctx, m_image_name); + migration_status(RBD_IMAGE_MIGRATION_STATE_EXECUTED); + migration_abort(_other_pool_ioctx, m_image_name); + + _other_pool_ioctx.set_namespace(""); + ASSERT_EQ(0, librbd::api::Namespace<>::remove(_other_pool_ioctx, "ns2")); +} + TEST_F(TestMigration, MirroringSamePool) { REQUIRE_FEATURE(RBD_FEATURE_JOURNALING); -- 2.39.5