Merge "Enable share-replica tests in multitenancy enviroments"

This commit is contained in:
Zuul 2019-09-21 01:02:59 +00:00 committed by Gerrit Code Review
commit 171241eb94
10 changed files with 165 additions and 22 deletions

View File

@ -20,6 +20,7 @@ from testtools import testcase as tc
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 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
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 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
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 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
# 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 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
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]

View File

@ -18,6 +18,7 @@ from testtools import testcase as tc
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 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
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 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
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 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
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 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
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 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
"""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'])

View File

@ -767,7 +767,8 @@ class BaseSharesTest(test.BaseTestCase):
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"],

View File

@ -21,6 +21,7 @@ from testtools import testcase as tc
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 @@ class ReplicationTest(base.BaseSharesMixedTest):
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 @@ class ReplicationTest(base.BaseSharesMixedTest):
'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]
@ -144,6 +154,28 @@ class ReplicationTest(base.BaseSharesMixedTest):
# Delete the replica
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
@ -260,7 +292,7 @@ class ReplicationTest(base.BaseSharesMixedTest):
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 @@ class ReplicationActionsTest(base.BaseSharesMixedTest):
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 @@ class ReplicationActionsTest(base.BaseSharesMixedTest):
'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)

View File

@ -37,6 +37,8 @@ class ReplicationExportLocationsTest(base.BaseSharesMixedTest):
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 @@ class ReplicationExportLocationsTest(base.BaseSharesMixedTest):
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 @@ class ReplicationExportLocationsTest(base.BaseSharesMixedTest):
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(

View File

@ -35,6 +35,8 @@ class ReplicationExportLocationsNegativeTest(base.BaseSharesMixedTest):
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 @@ class ReplicationExportLocationsNegativeTest(base.BaseSharesMixedTest):
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 @@ class ReplicationExportLocationsNegativeTest(base.BaseSharesMixedTest):
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 @@ class ReplicationExportLocationsNegativeTest(base.BaseSharesMixedTest):
# 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 @@ class ReplicationExportLocationsNegativeTest(base.BaseSharesMixedTest):
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,

View File

@ -22,6 +22,7 @@ from testtools import testcase as tc
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 @@ class ReplicationNegativeTest(base.BaseSharesMixedTest):
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 @@ class ReplicationNegativeTest(base.BaseSharesMixedTest):
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 @@ class ReplicationNegativeTest(base.BaseSharesMixedTest):
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 @@ class ReplicationNegativeTest(base.BaseSharesMixedTest):
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 @@ class ReplicationNegativeTest(base.BaseSharesMixedTest):
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.')

View File

@ -20,6 +20,7 @@ from testtools import testcase as tc
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 @@ class ReplicationSnapshotTest(base.BaseSharesMixedTest):
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 @@ class ReplicationSnapshotTest(base.BaseSharesMixedTest):
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 @@ class ReplicationSnapshotTest(base.BaseSharesMixedTest):
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 @@ class ReplicationSnapshotTest(base.BaseSharesMixedTest):
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 @@ class ReplicationSnapshotTest(base.BaseSharesMixedTest):
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 @@ class ReplicationSnapshotTest(base.BaseSharesMixedTest):
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 @@ class ReplicationSnapshotTest(base.BaseSharesMixedTest):
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 @@ class ReplicationSnapshotTest(base.BaseSharesMixedTest):
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 @@ class ReplicationSnapshotTest(base.BaseSharesMixedTest):
"""
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 @@ class ReplicationSnapshotTest(base.BaseSharesMixedTest):
"""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"],

View File

@ -22,6 +22,7 @@ from testtools import testcase as tc
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 @@ class RevertToSnapshotTest(base.BaseSharesMixedTest):
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 @@ class RevertToSnapshotTest(base.BaseSharesMixedTest):
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 @@ class RevertToSnapshotTest(base.BaseSharesMixedTest):
"""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"],

View File

@ -171,6 +171,11 @@ def get_configured_extra_specs(variation=None):
return extra_specs
def replication_with_multitenancy_support():
return (share_network_subnets_are_supported() and
CONF.share.multitenancy_enabled)
def skip_if_manage_not_supported_for_version(
version=CONF.share.max_api_microversion):
if (is_microversion_lt(version, "2.49")