Enable share-replica tests in multitenancy enviroments

This patch enables share-replica tests to be executed in a multitenancy
environment, providing a share-network to be used by both shares and
share-replicas.

The multitenancy test for share-replicas will be enabled only for API
version equal or greater than 2.51.

Depends-On: I60bdb493ad5766f28408a0c877f960922fe44ad0
Change-Id: Icb93fc346b71edc7bb3ac989e9751899bb80fbe5
diff --git a/manila_tempest_tests/tests/api/admin/test_replication.py b/manila_tempest_tests/tests/api/admin/test_replication.py
index a0c0d84..a40c94f 100644
--- a/manila_tempest_tests/tests/api/admin/test_replication.py
+++ b/manila_tempest_tests/tests/api/admin/test_replication.py
@@ -20,6 +20,7 @@
 from manila_tempest_tests.common import constants
 from manila_tempest_tests import share_exceptions
 from manila_tempest_tests.tests.api import base
+from manila_tempest_tests import utils
 
 CONF = config.CONF
 _MIN_SUPPORTED_MICROVERSION = '2.11'
@@ -36,6 +37,8 @@
         cls.admin_client = cls.admin_shares_v2_client
         cls.member_client = cls.shares_v2_client
         cls.replication_type = CONF.share.backend_replication_type
+        cls.multitenancy_enabled = (
+            utils.replication_with_multitenancy_support())
 
         if cls.replication_type not in constants.REPLICATION_TYPE_CHOICES:
             raise share_exceptions.ShareReplicationTypeException(
@@ -45,6 +48,11 @@
         extra_specs = {"replication_type": cls.replication_type}
         cls.share_type = cls._create_share_type(extra_specs)
         cls.share_type_id = cls.share_type['id']
+        cls.sn_id = None
+        if cls.multitenancy_enabled:
+            cls.share_network = cls.shares_v2_client.get_share_network(
+                cls.shares_v2_client.share_network_id)
+            cls.sn_id = cls.share_network['id']
 
         cls.zones = cls.get_availability_zones_matching_share_type(
             cls.share_type, client=cls.admin_client)
@@ -54,6 +62,7 @@
         # Create share with above share_type
         cls.share = cls.create_share(share_type_id=cls.share_type_id,
                                      availability_zone=cls.share_zone,
+                                     share_network_id=cls.sn_id,
                                      client=cls.admin_client)
         cls.replica = cls.admin_client.list_share_replicas(
             share_id=cls.share['id'])[0]
@@ -74,7 +83,7 @@
                 msg % ','.join(constants.REPLICATION_PROMOTION_CHOICES))
         share = self.create_share(
             share_type_id=self.share_type_id, client=self.admin_client,
-            availability_zone=self.share_zone)
+            availability_zone=self.share_zone, share_network_id=self.sn_id)
         original_replica = self.admin_client.list_share_replicas(
             share_id=share['id'])[0]
 
diff --git a/manila_tempest_tests/tests/api/admin/test_replication_actions.py b/manila_tempest_tests/tests/api/admin/test_replication_actions.py
index a278751..b5b0f42 100644
--- a/manila_tempest_tests/tests/api/admin/test_replication_actions.py
+++ b/manila_tempest_tests/tests/api/admin/test_replication_actions.py
@@ -18,6 +18,7 @@
 from manila_tempest_tests.common import constants
 from manila_tempest_tests import share_exceptions
 from manila_tempest_tests.tests.api import base
+from manila_tempest_tests import utils
 
 CONF = config.CONF
 _MIN_SUPPORTED_MICROVERSION = '2.11'
@@ -37,6 +38,8 @@
         cls.admin_client = cls.admin_shares_v2_client
         cls.member_client = cls.shares_v2_client
         cls.replication_type = CONF.share.backend_replication_type
+        cls.multitenancy_enabled = (
+            utils.replication_with_multitenancy_support())
 
         if cls.replication_type not in constants.REPLICATION_TYPE_CHOICES:
             raise share_exceptions.ShareReplicationTypeException(
@@ -48,6 +51,12 @@
         cls.share_type = cls._create_share_type(extra_specs)
         cls.share_type_id = cls.share_type['id']
 
+        cls.sn_id = None
+        if cls.multitenancy_enabled:
+            cls.share_network = cls.shares_v2_client.get_share_network(
+                cls.shares_v2_client.share_network_id)
+            cls.sn_id = cls.share_network['id']
+
         cls.zones = cls.get_availability_zones_matching_share_type(
             cls.share_type, client=cls.admin_client)
         cls.share_zone = cls.zones[0]
@@ -57,6 +66,7 @@
         cls.share = cls.create_share(size=CONF.share.share_size + 1,
                                      share_type_id=cls.share_type_id,
                                      availability_zone=cls.share_zone,
+                                     share_network_id=cls.sn_id,
                                      client=cls.admin_client)
         cls.replica = cls.admin_client.list_share_replicas(
             share_id=cls.share['id'])[0]
@@ -93,6 +103,7 @@
         share = self.create_share(size=2,
                                   share_type_id=self.share_type_id,
                                   availability_zone=self.share_zone,
+                                  share_network_id=self.sn_id,
                                   cleanup_in_class=True,
                                   client=self.admin_client)
         share = self.admin_client.get_share(share["id"])
@@ -139,6 +150,7 @@
         """Unmanage a replication type share that does not have replica."""
         share = self.create_share(size=2,
                                   share_type_id=self.share_type_id,
+                                  share_network_id=self.sn_id,
                                   availability_zone=self.share_zone,
                                   client=self.admin_client)
         self.admin_client.unmanage_share(share['id'])
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index eca162a..113a669 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -756,7 +756,8 @@
     def create_share_replica(cls, share_id, availability_zone, client=None,
                              cleanup_in_class=False, cleanup=True):
         client = client or cls.shares_v2_client
-        replica = client.create_share_replica(share_id, availability_zone)
+        replica = client.create_share_replica(
+            share_id, availability_zone=availability_zone)
         resource = {
             "type": "share_replica",
             "id": replica["id"],
diff --git a/manila_tempest_tests/tests/api/test_replication.py b/manila_tempest_tests/tests/api/test_replication.py
index d827c8d..cfb5812 100644
--- a/manila_tempest_tests/tests/api/test_replication.py
+++ b/manila_tempest_tests/tests/api/test_replication.py
@@ -21,6 +21,7 @@
 from manila_tempest_tests.common import constants
 from manila_tempest_tests import share_exceptions
 from manila_tempest_tests.tests.api import base
+from manila_tempest_tests import utils
 
 CONF = config.CONF
 _MIN_SUPPORTED_MICROVERSION = '2.11'
@@ -41,6 +42,8 @@
         name = data_utils.rand_name(constants.TEMPEST_MANILA_PREFIX)
         cls.admin_client = cls.admin_shares_v2_client
         cls.replication_type = CONF.share.backend_replication_type
+        cls.multitenancy_enabled = (
+            utils.replication_with_multitenancy_support())
 
         if cls.replication_type not in constants.REPLICATION_TYPE_CHOICES:
             raise share_exceptions.ShareReplicationTypeException(
@@ -64,6 +67,13 @@
             'share_type_id': cls.share_type['id'],
             'availability_zone': cls.share_zone,
         }}
+        cls.sn_id = None
+        if cls.multitenancy_enabled:
+            cls.share_network = cls.shares_v2_client.get_share_network(
+                cls.shares_v2_client.share_network_id)
+            cls.creation_data['kwargs'].update({
+                'share_network_id': cls.share_network['id']})
+            cls.sn_id = cls.share_network['id']
 
         # Data for creating shares in parallel
         data = [cls.creation_data, cls.creation_data]
@@ -145,6 +155,28 @@
         self.delete_share_replica(share_replica["id"])
 
     @tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
+    @testtools.skipIf(
+        not CONF.share.multitenancy_enabled, "Only for multitenancy.")
+    @base.skip_if_microversion_not_supported("2.51")
+    def test_add_delete_share_replica_different_subnet(self):
+        # Create new subnet in replica az
+        subnet = utils.share_network_get_default_subnet(self.share_network)
+        data = {
+            'neutron_net_id': subnet.get('neutron_net_id'),
+            'neutron_subnet_id': subnet.get('neutron_subnet_id'),
+            'share_network_id': self.sn_id,
+            'availability_zone': self.replica_zone,
+        }
+        subnet = self.create_share_network_subnet(**data)
+        # Create the replica
+        share_replica = self._verify_create_replica()
+
+        # Delete the replica
+        self.delete_share_replica(share_replica["id"])
+        # Delete subnet
+        self.shares_v2_client.delete_subnet(self.sn_id, subnet['id'])
+
+    @tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
     def test_add_access_rule_create_replica_delete_rule(self):
         # Add access rule to the share
         access_type, access_to = self._get_access_rule_data_from_config()
@@ -260,7 +292,7 @@
 
         share = self.create_share(
             share_type_id=self.share_type['id'], cleanup_in_class=False,
-            availability_zone=self.share_zone)
+            availability_zone=self.share_zone, share_network_id=self.sn_id)
         share = self.shares_v2_client.get_share(share['id'])
         replica = self.create_share_replica(share['id'], self.replica_zone)
         replica = self.shares_v2_client.get_share_replica(replica['id'])
@@ -328,6 +360,8 @@
         name = data_utils.rand_name(constants.TEMPEST_MANILA_PREFIX)
         cls.admin_client = cls.admin_shares_v2_client
         cls.replication_type = CONF.share.backend_replication_type
+        cls.multitenancy_enabled = (
+            utils.replication_with_multitenancy_support())
 
         if cls.replication_type not in constants.REPLICATION_TYPE_CHOICES:
             raise share_exceptions.ShareReplicationTypeException(
@@ -352,6 +386,13 @@
             'availability_zone': cls.share_zone,
         }}
 
+        if cls.multitenancy_enabled:
+            cls.share_network = cls.shares_v2_client.get_share_network(
+                cls.shares_v2_client.share_network_id)
+            cls.creation_data['kwargs'].update({
+                'share_network_id': cls.share_network['id']})
+        cls.sn_id = (
+            cls.share_network['id'] if cls.multitenancy_enabled else None)
         # Data for creating shares in parallel
         data = [cls.creation_data, cls.creation_data]
         cls.shares = cls.create_shares(data)
diff --git a/manila_tempest_tests/tests/api/test_replication_export_locations.py b/manila_tempest_tests/tests/api/test_replication_export_locations.py
index 4313edb..165b40b 100644
--- a/manila_tempest_tests/tests/api/test_replication_export_locations.py
+++ b/manila_tempest_tests/tests/api/test_replication_export_locations.py
@@ -37,6 +37,8 @@
         name = data_utils.rand_name(constants.TEMPEST_MANILA_PREFIX)
         cls.admin_client = cls.admin_shares_v2_client
         cls.replication_type = CONF.share.backend_replication_type
+        cls.multitenancy_enabled = (
+            utils.replication_with_multitenancy_support())
 
         if cls.replication_type not in constants.REPLICATION_TYPE_CHOICES:
             raise share_exceptions.ShareReplicationTypeException(
@@ -48,6 +50,11 @@
             name,
             extra_specs=cls.extra_specs,
             client=cls.admin_client)
+        cls.sn_id = None
+        if cls.multitenancy_enabled:
+            cls.share_network = cls.shares_v2_client.get_share_network(
+                cls.shares_v2_client.share_network_id)
+            cls.sn_id = cls.share_network['id']
         cls.share_type = share_type["share_type"]
         cls.zones = cls.get_availability_zones_matching_share_type(
             cls.share_type)
@@ -60,7 +67,8 @@
 
     def _create_share_and_replica_get_exports(self, cleanup_replica=True):
         share = self.create_share(share_type_id=self.share_type['id'],
-                                  availability_zone=self.share_zone)
+                                  availability_zone=self.share_zone,
+                                  share_network_id=self.sn_id)
         replica = self.create_share_replica(share['id'], self.replica_zone,
                                             cleanup=cleanup_replica)
         replicas = self.shares_v2_client.list_share_replicas(
diff --git a/manila_tempest_tests/tests/api/test_replication_export_locations_negative.py b/manila_tempest_tests/tests/api/test_replication_export_locations_negative.py
index af2b1b3..64d2c2c 100644
--- a/manila_tempest_tests/tests/api/test_replication_export_locations_negative.py
+++ b/manila_tempest_tests/tests/api/test_replication_export_locations_negative.py
@@ -35,6 +35,8 @@
         name = data_utils.rand_name(constants.TEMPEST_MANILA_PREFIX)
         cls.admin_client = cls.admin_shares_v2_client
         cls.replication_type = CONF.share.backend_replication_type
+        cls.multitenancy_enabled = (
+            utils.replication_with_multitenancy_support())
 
         if cls.replication_type not in constants.REPLICATION_TYPE_CHOICES:
             raise share_exceptions.ShareReplicationTypeException(
@@ -47,6 +49,11 @@
             extra_specs=cls.extra_specs,
             client=cls.admin_client)
         cls.share_type = share_type["share_type"]
+        cls.sn_id = None
+        if cls.multitenancy_enabled:
+            cls.share_network = cls.shares_v2_client.get_share_network(
+                cls.shares_v2_client.share_network_id)
+            cls.sn_id = cls.share_network['id']
         cls.zones = cls.get_availability_zones_matching_share_type(
             cls.share_type)
         cls.share_zone = cls.zones[0]
@@ -61,7 +68,8 @@
     def test_get_share_export_location_for_secondary_replica(self):
         """Is NotFound raised with share el API for non-active replicas"""
         share = self.create_share(share_type_id=self.share_type['id'],
-                                  availability_zone=self.share_zone)
+                                  availability_zone=self.share_zone,
+                                  share_network_id=self.sn_id)
         replica = self.create_share_replica(share['id'], self.replica_zone)
         replica_exports = (
             self.shares_v2_client.list_share_replica_export_locations(
@@ -80,7 +88,8 @@
         # Create a share type with no support for replication
         share_type = self._create_share_type()
         share = self.create_share(share_type_id=share_type['id'],
-                                  availability_zone=self.share_zone)
+                                  availability_zone=self.share_zone,
+                                  share_network_id=self.sn_id)
         share_instances = self.admin_client.get_instances_of_share(share['id'])
         for instance in share_instances:
             self.assertRaises(
@@ -102,7 +111,8 @@
     def test_get_replica_export_location_for_invalid_export_id(self):
         """Is NotFound raised for invalid replica export location ID"""
         share = self.create_share(share_type_id=self.share_type['id'],
-                                  availability_zone=self.share_zone)
+                                  availability_zone=self.share_zone,
+                                  share_network_id=self.sn_id)
         replica = self.create_share_replica(share['id'], self.replica_zone)
         self.assertRaises(
             lib_exc.NotFound,
diff --git a/manila_tempest_tests/tests/api/test_replication_negative.py b/manila_tempest_tests/tests/api/test_replication_negative.py
index 8e20483..fd8bf4f 100644
--- a/manila_tempest_tests/tests/api/test_replication_negative.py
+++ b/manila_tempest_tests/tests/api/test_replication_negative.py
@@ -22,6 +22,7 @@
 from manila_tempest_tests.common import constants
 from manila_tempest_tests import share_exceptions
 from manila_tempest_tests.tests.api import base
+from manila_tempest_tests import utils
 
 CONF = config.CONF
 _MIN_SUPPORTED_MICROVERSION = '2.11'
@@ -37,6 +38,8 @@
         super(ReplicationNegativeTest, cls).resource_setup()
         cls.admin_client = cls.admin_shares_v2_client
         cls.replication_type = CONF.share.backend_replication_type
+        cls.multitenancy_enabled = (
+            utils.replication_with_multitenancy_support())
 
         if cls.replication_type not in constants.REPLICATION_TYPE_CHOICES:
             raise share_exceptions.ShareReplicationTypeException(
@@ -47,7 +50,11 @@
         extra_specs = {"replication_type": cls.replication_type}
         cls.share_type = cls._create_share_type(extra_specs)
         cls.share_type_id = cls.share_type['id']
-
+        cls.sn_id = None
+        if cls.multitenancy_enabled:
+            cls.share_network = cls.shares_v2_client.get_share_network(
+                cls.shares_v2_client.share_network_id)
+            cls.sn_id = cls.share_network['id']
         cls.zones = cls.get_availability_zones_matching_share_type(
             cls.share_type, client=cls.admin_client)
         cls.share_zone = cls.zones[0]
@@ -57,9 +64,11 @@
         cls.share1, cls.instance_id1 = cls._create_share_get_instance()
 
     @classmethod
-    def _create_share_get_instance(cls):
+    def _create_share_get_instance(cls, share_network_id=None):
+        sn_id = share_network_id if share_network_id else cls.sn_id
         share = cls.create_share(share_type_id=cls.share_type_id,
-                                 availability_zone=cls.share_zone)
+                                 availability_zone=cls.share_zone,
+                                 share_network_id=sn_id)
         share_instances = cls.admin_client.get_instances_of_share(
             share["id"], version=_MIN_SUPPORTED_MICROVERSION
         )
@@ -80,7 +89,8 @@
             data_utils.rand_name(constants.TEMPEST_MANILA_PREFIX),
             extra_specs=self.add_extra_specs_to_dict(),
             client=self.admin_client)["share_type"]
-        share = self.create_share(share_type_id=share_type["id"])
+        share = self.create_share(share_type_id=share_type["id"],
+                                  share_network_id=self.sn_id)
         self.assertRaises(lib_exc.BadRequest,
                           self.create_share_replica,
                           share['id'],
@@ -207,6 +217,26 @@
                           self.share1['id'],
                           self.replica_zone)
 
+    @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+    @testtools.skipIf(
+        not CONF.share.multitenancy_enabled, "Only for multitenancy.")
+    @base.skip_if_microversion_lt("2.51")
+    def test_try_add_replica_nonexistent_subnet(self):
+        # Create a new share network only for a specific az
+        data = self.generate_share_network_data()
+        subnet = utils.share_network_get_default_subnet(self.share_network)
+        data['neutron_net_id'] = subnet['neutron_net_id']
+        data['neutron_subnet_id'] = subnet['neutron_subnet_id']
+        data['availability_zone'] = self.share_zone
+        share_net = self.shares_v2_client.create_share_network(**data)
+        share, instance_id = self._create_share_get_instance(
+            share_network_id=share_net['id'])
+
+        self.assertRaises(lib_exc.BadRequest,
+                          self.create_share_replica,
+                          share['id'],
+                          self.replica_zone)
+
 
 @testtools.skipUnless(CONF.share.run_replication_tests,
                       'Replication tests are disabled.')
diff --git a/manila_tempest_tests/tests/api/test_replication_snapshots.py b/manila_tempest_tests/tests/api/test_replication_snapshots.py
index e1902f7..40bf365 100644
--- a/manila_tempest_tests/tests/api/test_replication_snapshots.py
+++ b/manila_tempest_tests/tests/api/test_replication_snapshots.py
@@ -20,6 +20,7 @@
 from manila_tempest_tests.common import constants
 from manila_tempest_tests import share_exceptions
 from manila_tempest_tests.tests.api import base
+from manila_tempest_tests import utils
 
 CONF = config.CONF
 _MIN_SUPPORTED_MICROVERSION = '2.11'
@@ -37,6 +38,8 @@
         super(ReplicationSnapshotTest, cls).resource_setup()
         cls.admin_client = cls.admin_shares_v2_client
         cls.replication_type = CONF.share.backend_replication_type
+        cls.multitenancy_enabled = (
+            utils.replication_with_multitenancy_support())
 
         if cls.replication_type not in constants.REPLICATION_TYPE_CHOICES:
             raise share_exceptions.ShareReplicationTypeException(
@@ -47,6 +50,11 @@
         extra_specs = {"replication_type": cls.replication_type}
         cls.share_type = cls._create_share_type(extra_specs)
         cls.share_type_id = cls.share_type['id']
+        cls.sn_id = None
+        if cls.multitenancy_enabled:
+            cls.share_network = cls.shares_v2_client.get_share_network(
+                cls.shares_v2_client.share_network_id)
+            cls.sn_id = cls.share_network['id']
 
         cls.zones = cls.get_availability_zones_matching_share_type(
             cls.share_type, client=cls.admin_client)
@@ -62,7 +70,8 @@
         creating a share from that snapshot.
         """
         share = self.create_share(share_type_id=self.share_type_id,
-                                  availability_zone=self.share_zone)
+                                  availability_zone=self.share_zone,
+                                  share_network_id=self.sn_id)
         original_replica = self.shares_v2_client.list_share_replicas(
             share["id"])[0]
 
@@ -83,7 +92,8 @@
 
         if CONF.share.capability_create_share_from_snapshot_support:
             self.create_share(share_type_id=self.share_type_id,
-                              snapshot_id=snapshot['id'])
+                              snapshot_id=snapshot['id'],
+                              share_network_id=self.sn_id)
 
     @tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
     def test_snapshot_before_share_replica(self):
@@ -94,7 +104,8 @@
         Verify snapshot by creating share from the snapshot.
         """
         share = self.create_share(share_type_id=self.share_type_id,
-                                  availability_zone=self.share_zone)
+                                  availability_zone=self.share_zone,
+                                  share_network_id=self.sn_id)
         snapshot = self.create_snapshot_wait_for_active(share["id"])
 
         original_replica = self.shares_v2_client.list_share_replicas(
@@ -119,7 +130,8 @@
 
         if CONF.share.capability_create_share_from_snapshot_support:
             self.create_share(share_type_id=self.share_type_id,
-                              snapshot_id=snapshot['id'])
+                              snapshot_id=snapshot['id'],
+                              share_network_id=self.sn_id)
 
     @tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
     def test_snapshot_before_and_after_share_replica(self):
@@ -130,7 +142,8 @@
         Verify snapshots by creating share from the snapshots.
         """
         share = self.create_share(share_type_id=self.share_type_id,
-                                  availability_zone=self.share_zone)
+                                  availability_zone=self.share_zone,
+                                  share_network_id=self.sn_id)
         snapshot1 = self.create_snapshot_wait_for_active(share["id"])
 
         original_replica = self.shares_v2_client.list_share_replicas(
@@ -163,9 +176,11 @@
 
         if CONF.share.capability_create_share_from_snapshot_support:
             self.create_share(share_type_id=self.share_type_id,
-                              snapshot_id=snapshot1['id'])
+                              snapshot_id=snapshot1['id'],
+                              share_network_id=self.sn_id)
             self.create_share(share_type_id=self.share_type_id,
-                              snapshot_id=snapshot2['id'])
+                              snapshot_id=snapshot2['id'],
+                              share_network_id=self.sn_id)
 
     @tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
     def test_delete_snapshot_after_adding_replica(self):
@@ -176,7 +191,8 @@
         """
 
         share = self.create_share(share_type_id=self.share_type_id,
-                                  availability_zone=self.share_zone)
+                                  availability_zone=self.share_zone,
+                                  share_network_id=self.sn_id)
         share_replica = self.create_share_replica(share["id"],
                                                   self.replica_zone)
         self.shares_v2_client.wait_for_share_replica_status(
@@ -195,10 +211,12 @@
         """Test replica for a share that was created from snapshot."""
 
         share = self.create_share(share_type_id=self.share_type_id,
-                                  availability_zone=self.share_zone)
+                                  availability_zone=self.share_zone,
+                                  share_network_id=self.sn_id)
         orig_snapshot = self.create_snapshot_wait_for_active(share["id"])
         snap_share = self.create_share(share_type_id=self.share_type_id,
-                                       snapshot_id=orig_snapshot['id'])
+                                       snapshot_id=orig_snapshot['id'],
+                                       share_network_id=self.sn_id)
         original_replica = self.shares_v2_client.list_share_replicas(
             snap_share["id"])[0]
         share_replica = self.create_share_replica(snap_share["id"],
diff --git a/manila_tempest_tests/tests/api/test_revert_to_snapshot.py b/manila_tempest_tests/tests/api/test_revert_to_snapshot.py
index c4b72a0..c862c0b 100644
--- a/manila_tempest_tests/tests/api/test_revert_to_snapshot.py
+++ b/manila_tempest_tests/tests/api/test_revert_to_snapshot.py
@@ -22,6 +22,7 @@
 from manila_tempest_tests.common import constants
 from manila_tempest_tests import share_exceptions
 from manila_tempest_tests.tests.api import base
+from manila_tempest_tests import utils
 
 CONF = config.CONF
 
@@ -48,6 +49,8 @@
     def resource_setup(cls):
         super(RevertToSnapshotTest, cls).resource_setup()
         cls.admin_client = cls.admin_shares_v2_client
+        cls.replication_multitenancy = (
+            utils.replication_with_multitenancy_support())
         pools = cls.admin_client.list_pools(detail=True)['pools']
         revert_support = [
             pool['capabilities'][constants.REVERT_TO_SNAPSHOT_SUPPORT]
@@ -91,6 +94,11 @@
                 cls.replicated_share_type, client=cls.admin_client)
             cls.share_zone = cls.zones[0]
             cls.replica_zone = cls.zones[-1]
+            cls.sn_id = None
+            if cls.replication_multitenancy:
+                cls.share_network = cls.shares_v2_client.get_share_network(
+                    cls.shares_v2_client.share_network_id)
+                cls.sn_id = cls.share_network['id']
 
     @tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
     @ddt.data(
@@ -139,7 +147,8 @@
         """Test reverting to a replicated snapshot."""
         share = self.create_share(
             share_type_id=self.replicated_share_type['id'],
-            availability_zone=self.share_zone
+            availability_zone=self.share_zone,
+            share_network_id=self.sn_id
         )
 
         share_replica = self.create_share_replica(share["id"],