Merge "Share migration Newton improvements"
diff --git a/manila_tempest_tests/config.py b/manila_tempest_tests/config.py
index ec9a204..f0c8dc7 100644
--- a/manila_tempest_tests/config.py
+++ b/manila_tempest_tests/config.py
@@ -34,7 +34,7 @@
                help="The minimum api microversion is configured to be the "
                     "value of the minimum microversion supported by Manila."),
     cfg.StrOpt("max_api_microversion",
-               default="2.21",
+               default="2.22",
                help="The maximum api microversion is configured to be the "
                     "value of the latest microversion supported by Manila."),
     cfg.StrOpt("region",
@@ -173,9 +173,14 @@
                 help="Defines whether to run multiple replicas creation test "
                      "or not. Enable this if the driver can create more than "
                      "one replica for a share."),
-    cfg.BoolOpt("run_migration_tests",
+    cfg.BoolOpt("run_host_assisted_migration_tests",
+                deprecated_name="run_migration_tests",
                 default=False,
-                help="Enable or disable migration tests."),
+                help="Enable or disable host-assisted migration tests."),
+    cfg.BoolOpt("run_driver_assisted_migration_tests",
+                deprecated_name="run_migration_tests",
+                default=False,
+                help="Enable or disable driver-assisted migration tests."),
     cfg.BoolOpt("run_manage_unmanage_tests",
                 default=False,
                 help="Defines whether to run manage/unmanage tests or not. "
diff --git a/manila_tempest_tests/services/share/v2/json/shares_client.py b/manila_tempest_tests/services/share/v2/json/shares_client.py
index 2887904..b5a745e 100755
--- a/manila_tempest_tests/services/share/v2/json/shares_client.py
+++ b/manila_tempest_tests/services/share/v2/json/shares_client.py
@@ -1017,22 +1017,24 @@
 
 ###############
 
-    def migrate_share(self, share_id, host, notify,
-                      version=LATEST_MICROVERSION, action_name=None):
-        if action_name is None:
-            if utils.is_microversion_lt(version, "2.7"):
-                action_name = 'os-migrate_share'
-            elif utils.is_microversion_lt(version, "2.15"):
-                action_name = 'migrate_share'
-            else:
-                action_name = 'migration_start'
-        post_body = {
-            action_name: {
+    def migrate_share(self, share_id, host,
+                      force_host_assisted_migration=False,
+                      new_share_network_id=None, writable=False,
+                      preserve_metadata=False, nondisruptive=False,
+                      version=LATEST_MICROVERSION):
+
+        body = {
+            'migration_start': {
                 'host': host,
-                'notify': notify,
+                'force_host_assisted_migration': force_host_assisted_migration,
+                'new_share_network_id': new_share_network_id,
+                'writable': writable,
+                'preserve_metadata': preserve_metadata,
+                'nondisruptive': nondisruptive,
             }
         }
-        body = json.dumps(post_body)
+
+        body = json.dumps(body)
         return self.post('shares/%s/action' % share_id, body,
                          headers=EXPERIMENTAL, extra_headers=True,
                          version=version)
@@ -1063,9 +1065,10 @@
             action_name: None,
         }
         body = json.dumps(post_body)
-        return self.post('shares/%s/action' % share_id, body,
-                         headers=EXPERIMENTAL, extra_headers=True,
-                         version=version)
+        result = self.post('shares/%s/action' % share_id, body,
+                           headers=EXPERIMENTAL, extra_headers=True,
+                           version=version)
+        return json.loads(result[1])
 
     def reset_task_state(
             self, share_id, task_state, version=LATEST_MICROVERSION,
diff --git a/manila_tempest_tests/tests/api/admin/test_admin_actions.py b/manila_tempest_tests/tests/api/admin/test_admin_actions.py
index 40b2460..ac862d4 100644
--- a/manila_tempest_tests/tests/api/admin/test_admin_actions.py
+++ b/manila_tempest_tests/tests/api/admin/test_admin_actions.py
@@ -30,7 +30,7 @@
         super(AdminActionsTest, cls).resource_setup()
         cls.states = ["error", "available"]
         cls.task_states = ["migration_starting", "data_copying_in_progress",
-                           "migration_success"]
+                           "migration_success", None]
         cls.bad_status = "error_deleting"
         cls.sh = cls.create_share()
         cls.sh_instance = (
@@ -120,7 +120,7 @@
         self.shares_v2_client.wait_for_resource_deletion(snapshot_id=sn["id"])
 
     @test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND])
-    @base.skip_if_microversion_lt("2.15")
+    @base.skip_if_microversion_lt("2.22")
     def test_reset_share_task_state(self):
         for task_state in self.task_states:
             self.shares_v2_client.reset_task_state(self.sh["id"], task_state)
diff --git a/manila_tempest_tests/tests/api/admin/test_admin_actions_negative.py b/manila_tempest_tests/tests/api/admin/test_admin_actions_negative.py
index 67444de..735c65d 100644
--- a/manila_tempest_tests/tests/api/admin/test_admin_actions_negative.py
+++ b/manila_tempest_tests/tests/api/admin/test_admin_actions_negative.py
@@ -13,6 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import ddt
 from tempest import config
 from tempest.lib import exceptions as lib_exc
 from tempest import test
@@ -124,20 +125,14 @@
                           self.sh['id'])
 
     @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
-    @base.skip_if_microversion_lt("2.15")
-    def test_reset_task_state_empty(self):
-        self.assertRaises(
-            lib_exc.BadRequest, self.admin_client.reset_task_state,
-            self.sh['id'], None)
-
-    @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
-    @base.skip_if_microversion_lt("2.15")
+    @base.skip_if_microversion_lt("2.22")
     def test_reset_task_state_invalid_state(self):
         self.assertRaises(
             lib_exc.BadRequest, self.admin_client.reset_task_state,
             self.sh['id'], 'fake_state')
 
 
+@ddt.ddt
 class AdminActionsAPIOnlyNegativeTest(base.BaseSharesMixedTest):
 
     @classmethod
@@ -153,7 +148,7 @@
                           self.member_client.list_share_instances)
 
     @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
-    @base.skip_if_microversion_lt("2.15")
+    @base.skip_if_microversion_lt("2.22")
     def test_reset_task_state_share_not_found(self):
         self.assertRaises(
             lib_exc.NotFound, self.admin_client.reset_task_state,
@@ -196,3 +191,20 @@
     def test_reset_nonexistent_snapshot_state(self):
         self.assertRaises(lib_exc.NotFound, self.admin_client.reset_state,
                           "fake", s_type="snapshots")
+
+    @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
+    @ddt.data('migrate_share', 'migration_complete', 'reset_task_state',
+              'migration_get_progress', 'migration_cancel')
+    def test_migration_API_invalid_microversion(self, method_name):
+        if method_name == 'migrate_share':
+            self.assertRaises(
+                lib_exc.NotFound, getattr(self.shares_v2_client, method_name),
+                'fake_share', 'fake_host', version='2.21')
+        elif method_name == 'reset_task_state':
+            self.assertRaises(
+                lib_exc.NotFound, getattr(self.shares_v2_client, method_name),
+                'fake_share', 'fake_task_state', version='2.21')
+        else:
+            self.assertRaises(
+                lib_exc.NotFound, getattr(self.shares_v2_client, method_name),
+                'fake_share', version='2.21')
diff --git a/manila_tempest_tests/tests/api/admin/test_migration.py b/manila_tempest_tests/tests/api/admin/test_migration.py
index c5fef44..ed643ff 100644
--- a/manila_tempest_tests/tests/api/admin/test_migration.py
+++ b/manila_tempest_tests/tests/api/admin/test_migration.py
@@ -13,6 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import ddt
 from tempest import config
 from tempest import test
 
@@ -23,10 +24,27 @@
 CONF = config.CONF
 
 
+@ddt.ddt
 class MigrationNFSTest(base.BaseSharesAdminTest):
-    """Tests Share Migration.
+    """Tests Share Migration for NFS shares.
 
     Tests share migration in multi-backend environment.
+
+    This class covers:
+    1) Driver-assisted migration: force_host_assisted_migration, nondisruptive,
+    writable and preserve-metadata are False.
+    2) Host-assisted migration: force_host_assisted_migration is True,
+    nondisruptive, writable and preserve-metadata are False.
+    3) 2-phase migration of both Host-assisted and Driver-assisted.
+
+    No need to test with writable, preserve-metadata and non-disruptive as
+    True, values are supplied to the driver which decides what to do. Test
+    should be positive, so not being writable, not preserving metadata and
+    being disruptive is less restrictive for drivers, which would abort if they
+    cannot handle them.
+
+    Drivers that implement driver-assisted migration should enable the
+    configuration flag to be tested.
     """
 
     protocol = "nfs"
@@ -35,80 +53,89 @@
     def resource_setup(cls):
         super(MigrationNFSTest, cls).resource_setup()
         if cls.protocol not in CONF.share.enable_protocols:
-            message = "%s tests are disabled" % cls.protocol
+            message = "%s tests are disabled." % cls.protocol
             raise cls.skipException(message)
-        if not CONF.share.run_migration_tests:
+        if not (CONF.share.run_host_assisted_migration_tests or
+                CONF.share.run_driver_assisted_migration_tests):
             raise cls.skipException("Share migration tests are disabled.")
 
     @test.attr(type=[base.TAG_POSITIVE, base.TAG_BACKEND])
-    @base.skip_if_microversion_lt("2.15")
-    def test_migration_cancel(self):
+    @base.skip_if_microversion_lt("2.22")
+    @ddt.data(True, False)
+    def test_migration_cancel(self, force_host_assisted):
+
+        self._check_migration_enabled(force_host_assisted)
 
         share, dest_pool = self._setup_migration()
 
         old_exports = self.shares_v2_client.list_share_export_locations(
-            share['id'], version='2.15')
+            share['id'])
         self.assertNotEmpty(old_exports)
         old_exports = [x['path'] for x in old_exports
                        if x['is_admin_only'] is False]
         self.assertNotEmpty(old_exports)
 
-        task_states = (constants.TASK_STATE_DATA_COPYING_COMPLETED,
-                       constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE)
+        task_state = (constants.TASK_STATE_DATA_COPYING_COMPLETED
+                      if force_host_assisted
+                      else constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE)
 
         share = self.migrate_share(
-            share['id'], dest_pool, version='2.15', notify=False,
-            wait_for_status=task_states)
+            share['id'], dest_pool, wait_for_status=task_state,
+            force_host_assisted_migration=force_host_assisted)
 
         self._validate_migration_successful(
-            dest_pool, share, task_states, '2.15', notify=False)
+            dest_pool, share, task_state, complete=False)
 
         share = self.migration_cancel(share['id'], dest_pool)
 
         self._validate_migration_successful(
             dest_pool, share, constants.TASK_STATE_MIGRATION_CANCELLED,
-            '2.15', notify=False)
+            complete=False)
 
     @test.attr(type=[base.TAG_POSITIVE, base.TAG_BACKEND])
-    @base.skip_if_microversion_lt("2.5")
-    def test_migration_empty_v2_5(self):
+    @base.skip_if_microversion_lt("2.22")
+    @ddt.data(True, False)
+    def test_migration_2phase(self, force_host_assisted):
 
-        share, dest_pool = self._setup_migration()
-
-        share = self.migrate_share(share['id'], dest_pool, version='2.5')
-
-        self._validate_migration_successful(
-            dest_pool, share, constants.TASK_STATE_MIGRATION_SUCCESS,
-            version='2.5')
-
-    @test.attr(type=[base.TAG_POSITIVE, base.TAG_BACKEND])
-    @base.skip_if_microversion_lt("2.15")
-    def test_migration_completion_empty_v2_15(self):
+        self._check_migration_enabled(force_host_assisted)
 
         share, dest_pool = self._setup_migration()
 
         old_exports = self.shares_v2_client.list_share_export_locations(
-            share['id'], version='2.15')
+            share['id'])
         self.assertNotEmpty(old_exports)
         old_exports = [x['path'] for x in old_exports
                        if x['is_admin_only'] is False]
         self.assertNotEmpty(old_exports)
 
-        task_states = (constants.TASK_STATE_DATA_COPYING_COMPLETED,
-                       constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE)
+        task_state = (constants.TASK_STATE_DATA_COPYING_COMPLETED
+                      if force_host_assisted
+                      else constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE)
+
+        old_share_network_id = share['share_network_id']
+        new_share_network_id = self._create_secondary_share_network(
+            old_share_network_id)
 
         share = self.migrate_share(
-            share['id'], dest_pool, version='2.15', notify=False,
-            wait_for_status=task_states)
+            share['id'], dest_pool,
+            force_host_assisted_migration=force_host_assisted,
+            wait_for_status=task_state,
+            new_share_network_id=new_share_network_id)
 
         self._validate_migration_successful(
-            dest_pool, share, task_states, '2.15', notify=False)
+            dest_pool, share, task_state,
+            complete=False, share_network_id=old_share_network_id)
 
-        share = self.migration_complete(share['id'], dest_pool, version='2.15')
+        progress = self.shares_v2_client.migration_get_progress(share['id'])
+
+        self.assertEqual(task_state, progress['task_state'])
+        self.assertEqual(100, progress['total_progress'])
+
+        share = self.migration_complete(share['id'], dest_pool)
 
         self._validate_migration_successful(
             dest_pool, share, constants.TASK_STATE_MIGRATION_SUCCESS,
-            version='2.15')
+            complete=True, share_network_id=new_share_network_id)
 
     def _setup_migration(self):
 
@@ -145,28 +172,59 @@
 
         return share, dest_pool
 
-    def _validate_migration_successful(self, dest_pool, share,
-                                       status_to_wait, version, notify=True):
+    def _validate_migration_successful(self, dest_pool, share, status_to_wait,
+                                       version=CONF.share.max_api_microversion,
+                                       complete=True, share_network_id=None):
 
         statuses = ((status_to_wait,)
                     if not isinstance(status_to_wait, (tuple, list, set))
                     else status_to_wait)
 
-        if utils.is_microversion_lt(version, '2.9'):
-            new_exports = share['export_locations']
-            self.assertNotEmpty(new_exports)
-        else:
-            new_exports = self.shares_v2_client.list_share_export_locations(
-                share['id'], version='2.9')
-            self.assertNotEmpty(new_exports)
-            new_exports = [x['path'] for x in new_exports if
-                           x['is_admin_only'] is False]
-            self.assertNotEmpty(new_exports)
+        new_exports = self.shares_v2_client.list_share_export_locations(
+            share['id'], version=version)
+        self.assertNotEmpty(new_exports)
+        new_exports = [x['path'] for x in new_exports if
+                       x['is_admin_only'] is False]
+        self.assertNotEmpty(new_exports)
+
+        self.assertIn(share['task_state'], statuses)
+        if share_network_id:
+            self.assertEqual(share_network_id, share['share_network_id'])
 
         # Share migrated
-        if notify:
+        if complete:
             self.assertEqual(dest_pool, share['host'])
+            self.shares_v2_client.delete_share(share['id'])
+            self.shares_v2_client.wait_for_resource_deletion(
+                share_id=share['id'])
         # Share not migrated yet
         else:
             self.assertNotEqual(dest_pool, share['host'])
-        self.assertIn(share['task_state'], statuses)
+
+    def _check_migration_enabled(self, force_host_assisted):
+
+        if force_host_assisted:
+            if not CONF.share.run_host_assisted_migration_tests:
+                raise self.skipException(
+                    "Host-assisted migration tests are disabled.")
+        else:
+            if not CONF.share.run_driver_assisted_migration_tests:
+                raise self.skipException(
+                    "Driver-assisted migration tests are disabled.")
+
+    def _create_secondary_share_network(self, old_share_network_id):
+        if (utils.is_microversion_ge(
+                CONF.share.max_api_microversion, "2.22") and
+                CONF.share.multitenancy_enabled):
+
+            old_share_network = self.shares_v2_client.get_share_network(
+                old_share_network_id)
+
+            new_share_network = self.create_share_network(
+                cleanup_in_class=True,
+                neutron_net_id=old_share_network['neutron_net_id'],
+                neutron_subnet_id=old_share_network['neutron_subnet_id'])
+
+            return new_share_network['id']
+        else:
+            return None
diff --git a/manila_tempest_tests/tests/api/admin/test_migration_negative.py b/manila_tempest_tests/tests/api/admin/test_migration_negative.py
index 3dfc31a..94450d2 100644
--- a/manila_tempest_tests/tests/api/admin/test_migration_negative.py
+++ b/manila_tempest_tests/tests/api/admin/test_migration_negative.py
@@ -26,7 +26,7 @@
 CONF = config.CONF
 
 
-class MigrationNFSTest(base.BaseSharesAdminTest):
+class MigrationTest(base.BaseSharesAdminTest):
     """Tests Share Migration.
 
     Tests share migration in multi-backend environment.
@@ -36,8 +36,12 @@
 
     @classmethod
     def resource_setup(cls):
-        super(MigrationNFSTest, cls).resource_setup()
-        if not CONF.share.run_migration_tests:
+        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)
+        if not (CONF.share.run_host_assisted_migration_tests or
+                CONF.share.run_driver_assisted_migration_tests):
             raise cls.skipException("Share migration tests are disabled.")
 
         pools = cls.shares_client.list_pools(detail=True)['pools']
@@ -62,56 +66,112 @@
         cls.dest_pool = dest_pool['name']
 
     @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
-    @base.skip_if_microversion_lt("2.15")
+    @base.skip_if_microversion_lt("2.22")
     def test_migration_cancel_invalid(self):
         self.assertRaises(
             lib_exc.BadRequest, self.shares_v2_client.migration_cancel,
             self.share['id'])
 
     @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
-    @base.skip_if_microversion_lt("2.15")
-    def test_migration_get_progress_invalid(self):
+    @base.skip_if_microversion_lt("2.22")
+    def test_migration_get_progress_None(self):
+        self.shares_v2_client.reset_task_state(self.share["id"], None)
+        self.shares_v2_client.wait_for_share_status(
+            self.share["id"], None, 'task_state')
         self.assertRaises(
             lib_exc.BadRequest, self.shares_v2_client.migration_get_progress,
             self.share['id'])
 
     @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
-    @base.skip_if_microversion_lt("2.15")
+    @base.skip_if_microversion_lt("2.22")
     def test_migration_complete_invalid(self):
         self.assertRaises(
             lib_exc.BadRequest, self.shares_v2_client.migration_complete,
             self.share['id'])
 
     @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
-    @base.skip_if_microversion_lt("2.5")
+    @base.skip_if_microversion_lt("2.22")
+    def test_migration_cancel_not_found(self):
+        self.assertRaises(
+            lib_exc.NotFound, self.shares_v2_client.migration_cancel,
+            'invalid_share_id')
+
+    @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
+    @base.skip_if_microversion_lt("2.22")
+    def test_migration_get_progress_not_found(self):
+        self.assertRaises(
+            lib_exc.NotFound, self.shares_v2_client.migration_get_progress,
+            'invalid_share_id')
+
+    @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
+    @base.skip_if_microversion_lt("2.22")
+    def test_migration_complete_not_found(self):
+        self.assertRaises(
+            lib_exc.NotFound, self.shares_v2_client.migration_complete,
+            'invalid_share_id')
+
+    @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
+    @base.skip_if_microversion_lt("2.22")
     @testtools.skipUnless(CONF.share.run_snapshot_tests,
                           "Snapshot tests are disabled.")
-    def test_migrate_share_with_snapshot_v2_5(self):
+    def test_migrate_share_with_snapshot(self):
         snap = self.create_snapshot_wait_for_active(self.share['id'])
         self.assertRaises(
             lib_exc.BadRequest, self.shares_v2_client.migrate_share,
-            self.share['id'], self.dest_pool, True, version='2.5')
+            self.share['id'], self.dest_pool)
         self.shares_client.delete_snapshot(snap['id'])
         self.shares_client.wait_for_resource_deletion(snapshot_id=snap["id"])
 
     @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
-    @base.skip_if_microversion_lt("2.5")
-    def test_migrate_share_same_host_v2_5(self):
+    @base.skip_if_microversion_lt("2.22")
+    def test_migrate_share_same_host(self):
         self.assertRaises(
             lib_exc.BadRequest, self.shares_v2_client.migrate_share,
-            self.share['id'], self.share['host'], True, version='2.5')
+            self.share['id'], self.share['host'])
 
     @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
-    @base.skip_if_microversion_lt("2.5")
-    def test_migrate_share_not_available_v2_5(self):
-        self.shares_client.reset_state(
-            self.share['id'], constants.STATUS_ERROR)
+    @base.skip_if_microversion_lt("2.22")
+    def test_migrate_share_host_invalid(self):
+        self.assertRaises(
+            lib_exc.NotFound, self.shares_v2_client.migrate_share,
+            self.share['id'], 'invalid_host')
+
+    @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
+    @base.skip_if_microversion_lt("2.22")
+    def test_migrate_share_host_assisted_not_allowed(self):
+        self.shares_v2_client.migrate_share(
+            self.share['id'], self.dest_pool,
+            force_host_assisted_migration=True, writable=True,
+            preserve_metadata=True)
+        self.shares_v2_client.wait_for_migration_status(
+            self.share['id'], self.dest_pool, 'migration_error')
+
+    @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
+    @base.skip_if_microversion_lt("2.22")
+    def test_migrate_share_not_found(self):
+        self.assertRaises(
+            lib_exc.NotFound, self.shares_v2_client.migrate_share,
+            'invalid_share_id', self.dest_pool)
+
+    @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
+    @base.skip_if_microversion_lt("2.22")
+    def test_migrate_share_not_available(self):
+        self.shares_client.reset_state(self.share['id'],
+                                       constants.STATUS_ERROR)
         self.shares_client.wait_for_share_status(self.share['id'],
                                                  constants.STATUS_ERROR)
         self.assertRaises(
             lib_exc.BadRequest, self.shares_v2_client.migrate_share,
-            self.share['id'], self.dest_pool, True, version='2.5')
+            self.share['id'], self.dest_pool)
         self.shares_client.reset_state(self.share['id'],
                                        constants.STATUS_AVAILABLE)
         self.shares_client.wait_for_share_status(self.share['id'],
                                                  constants.STATUS_AVAILABLE)
+
+    @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
+    @base.skip_if_microversion_lt("2.22")
+    def test_migrate_share_invalid_share_network(self):
+        self.assertRaises(
+            lib_exc.NotFound, self.shares_v2_client.migrate_share,
+            self.share['id'], self.dest_pool,
+            new_share_network_id='invalid_net_id')
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index 82135bf..6d0eb25 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -401,13 +401,19 @@
         return share
 
     @classmethod
-    def migrate_share(cls, share_id, dest_host, client=None, notify=True,
-                      wait_for_status='migration_success', **kwargs):
+    def migrate_share(
+            cls, share_id, dest_host, wait_for_status, client=None,
+            force_host_assisted_migration=False, new_share_network_id=None,
+            **kwargs):
         client = client or cls.shares_v2_client
-        client.migrate_share(share_id, dest_host, notify, **kwargs)
+        client.migrate_share(
+            share_id, dest_host,
+            force_host_assisted_migration=force_host_assisted_migration,
+            new_share_network_id=new_share_network_id,
+            writable=False, preserve_metadata=False, nondisruptive=False,
+            **kwargs)
         share = client.wait_for_migration_status(
-            share_id, dest_host, wait_for_status,
-            version=kwargs.get('version'))
+            share_id, dest_host, wait_for_status, **kwargs)
         return share
 
     @classmethod
@@ -415,8 +421,7 @@
         client = client or cls.shares_v2_client
         client.migration_complete(share_id, **kwargs)
         share = client.wait_for_migration_status(
-            share_id, dest_host, 'migration_success',
-            version=kwargs.get('version'))
+            share_id, dest_host, 'migration_success', **kwargs)
         return share
 
     @classmethod
diff --git a/manila_tempest_tests/tests/scenario/manager_share.py b/manila_tempest_tests/tests/scenario/manager_share.py
index 972654b..14fb34d 100644
--- a/manila_tempest_tests/tests/scenario/manager_share.py
+++ b/manila_tempest_tests/tests/scenario/manager_share.py
@@ -21,6 +21,7 @@
 from tempest.lib.common.utils import data_utils
 from tempest.scenario import manager
 
+from manila_tempest_tests.common import constants
 from manila_tempest_tests.services.share.json import shares_client
 from manila_tempest_tests.services.share.v2.json import (
     shares_client as shares_v2_client)
@@ -196,11 +197,19 @@
 
         return linux_client
 
-    def _migrate_share(self, share_id, dest_host, client=None):
+    def _migrate_share(self, share_id, dest_host, status, client=None):
         client = client or self.shares_admin_v2_client
-        client.migrate_share(share_id, dest_host, True)
-        share = client.wait_for_migration_status(share_id, dest_host,
-                                                 'migration_success')
+        client.migrate_share(share_id, dest_host, writable=False,
+                             preserve_metadata=False, nondisruptive=False)
+        share = client.wait_for_migration_status(share_id, dest_host, status)
+        return share
+
+    def _migration_complete(self, share_id, dest_host, client=None, **kwargs):
+        client = client or self.shares_admin_v2_client
+        client.migration_complete(share_id, **kwargs)
+        share = client.wait_for_migration_status(
+            share_id, dest_host, constants.TASK_STATE_MIGRATION_SUCCESS,
+            **kwargs)
         return share
 
     def _create_share_type(self, name, is_public=True, **kwargs):
diff --git a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
index b52fe07..532ddd5 100644
--- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
+++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
@@ -125,9 +125,10 @@
         data = ssh_client.exec_command("sudo cat /mnt/t1")
         return data.rstrip()
 
-    def migrate_share(self, share_id, dest_host):
-        share = self._migrate_share(share_id, dest_host,
+    def migrate_share(self, share_id, dest_host, status):
+        share = self._migrate_share(share_id, dest_host, status,
                                     self.shares_admin_v2_client)
+        share = self._migration_complete(share['id'], dest_host)
         return share
 
     def create_share_network(self):
@@ -246,12 +247,13 @@
 
     @test.services('compute', 'network')
     @test.attr(type=[base.TAG_POSITIVE, base.TAG_BACKEND])
-    @testtools.skipUnless(CONF.share.run_migration_tests,
+    @testtools.skipUnless(CONF.share.run_host_assisted_migration_tests or
+                          CONF.share.run_driver_assisted_migration_tests,
                           "Share migration tests are disabled.")
     def test_migration_files(self):
 
-        if self.protocol == "CIFS":
-            raise self.skipException("Test for CIFS protocol not supported "
+        if self.protocol != "NFS":
+            raise self.skipException("Only NFS protocol supported "
                                      "at this moment.")
 
         pools = self.shares_admin_v2_client.list_pools(detail=True)['pools']
@@ -276,18 +278,20 @@
 
         dest_pool = dest_pool['name']
 
-        self.allow_access_ip(self.share['id'], instance=instance,
-                             cleanup=False)
+        self.allow_access_ip(
+            self.share['id'], instance=instance, cleanup=False)
         ssh_client = self.init_ssh(instance)
 
         if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"):
-            locations = self.share['export_locations']
+            exports = self.share['export_locations']
         else:
             exports = self.shares_v2_client.list_share_export_locations(
                 self.share['id'])
-            locations = [x['path'] for x in exports]
+            self.assertNotEmpty(exports)
+            exports = [x['path'] for x in exports]
+            self.assertNotEmpty(exports)
 
-        self.mount_share(locations[0], ssh_client)
+        self.mount_share(exports[0], ssh_client)
 
         ssh_client.exec_command("mkdir -p /mnt/f1")
         ssh_client.exec_command("mkdir -p /mnt/f2")
@@ -310,22 +314,27 @@
 
         self.umount_share(ssh_client)
 
-        self.share = self.migrate_share(self.share['id'], dest_pool)
+        task_state = (constants.TASK_STATE_DATA_COPYING_COMPLETED,
+                      constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE)
+
+        self.share = self.migrate_share(
+            self.share['id'], dest_pool, task_state)
+
         if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"):
-            new_locations = self.share['export_locations']
+            new_exports = self.share['export_locations']
+            self.assertNotEmpty(new_exports)
         else:
             new_exports = self.shares_v2_client.list_share_export_locations(
                 self.share['id'])
-            new_locations = [x['path'] for x in new_exports]
+            self.assertNotEmpty(new_exports)
+            new_exports = [x['path'] for x in new_exports]
+            self.assertNotEmpty(new_exports)
 
         self.assertEqual(dest_pool, self.share['host'])
-        locations.sort()
-        new_locations.sort()
-        self.assertNotEqual(locations, new_locations)
         self.assertEqual(constants.TASK_STATE_MIGRATION_SUCCESS,
                          self.share['task_state'])
 
-        self.mount_share(new_locations[0], ssh_client)
+        self.mount_share(new_exports[0], ssh_client)
 
         output = ssh_client.exec_command("ls -lRA --ignore=lost+found /mnt")