Add Share Migration tempest functional tests
This patch adds functional tests for Share Migration,
running on generic driver DHSS = true mode.
Implements: blueprint share-migration
Change-Id: I64b0a3ee77b27278cc294f72702408a27888e0e9
diff --git a/manila_tempest_tests/tests/api/admin/test_migration.py b/manila_tempest_tests/tests/api/admin/test_migration.py
new file mode 100644
index 0000000..4c6bacf
--- /dev/null
+++ b/manila_tempest_tests/tests/api/admin/test_migration.py
@@ -0,0 +1,67 @@
+# Copyright 2015 Hitachi Data Systems.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest import config # noqa
+from tempest import test # noqa
+
+from manila_tempest_tests.tests.api import base
+
+CONF = config.CONF
+
+
+class MigrationTest(base.BaseSharesAdminTest):
+ """Tests Share Migration.
+
+ Tests migration in multi-backend environment.
+ """
+
+ protocol = "nfs"
+
+ @classmethod
+ def resource_setup(cls):
+ super(MigrationTest, cls).resource_setup()
+ if cls.protocol not in CONF.share.enable_protocols:
+ message = "%s tests are disabled" % cls.protocol
+ raise cls.skipException(message)
+
+ @test.attr(type=["gate", "smoke", ])
+ def test_migration_empty(self):
+
+ if not CONF.share.migration_enabled:
+ raise self.skipException("Migration tests disabled. Skipping.")
+
+ pools = self.shares_client.list_pools()['pools']
+
+ if len(pools) < 2:
+ raise self.skipException("At least two different running "
+ "manila-share services are needed to "
+ "run migration tests. Skipping.")
+ share = self.create_share(self.protocol)
+ share = self.shares_client.get_share(share['id'])
+
+ dest_pool = next((x for x in pools if x['name'] != share['host']),
+ None)
+
+ self.assertIsNotNone(dest_pool)
+
+ dest_pool = dest_pool['name']
+
+ old_export_location = share['export_locations'][0]
+
+ share = self.migrate_share(share['id'], dest_pool)
+
+ self.assertEqual(dest_pool, share['host'])
+ self.assertNotEqual(old_export_location, share['export_locations'][0])
+ self.assertEqual('migration_success', share['task_state'])
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index 554ba35..6444ccc 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -304,6 +304,13 @@
return share
@classmethod
+ def migrate_share(cls, share_id, dest_host, client=None):
+ client = client or cls.shares_client
+ client.migrate_share(share_id, dest_host)
+ share = client.wait_for_migration_completed(share_id, dest_host)
+ return share
+
+ @classmethod
def create_share(cls, *args, **kwargs):
"""Create one share and wait for available state. Retry if allowed."""
result = cls.create_shares([{"args": args, "kwargs": kwargs}])