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
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
#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"
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,
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);