]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/librbd: migration supporting namespace tests
authorMykola Golub <mgolub@suse.com>
Fri, 2 Nov 2018 16:59:14 +0000 (18:59 +0200)
committerMykola Golub <mgolub@suse.com>
Sat, 3 Nov 2018 17:36:44 +0000 (19:36 +0200)
Signed-off-by: Mykola Golub <mgolub@suse.com>
qa/workunits/rbd/cli_generic.sh
src/test/librbd/test_Migration.cc

index 35a2e9507fe62eed55443782cdcb530f6906b4ce..d2066d9d9446d804fb8e8325f3fc92e9d291d179 100755 (executable)
@@ -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
index b9e0791b234faea315ee4aa4a855e4f6970b4ae2..77ac5aba13b6bfd5d1eeb523239e07f453a5467b 100644 (file)
@@ -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);