Improve Share Migration tempest tests
Improve coverage by adding tests that validate the share-type
change while also changing the driver mode.
Closes-bug: #1620800
Change-Id: I924c34aa69591754b437d75f43db91d77e73fb07
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index a36f391..6b48348 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -268,7 +268,8 @@
@classmethod
@network_synchronized
def provide_share_network(cls, shares_client, networks_client,
- isolated_creds_client=None):
+ isolated_creds_client=None,
+ ignore_multitenancy_config=False):
"""Used for finding/creating share network for multitenant driver.
This method creates/gets entity share-network for one tenant. This
@@ -279,6 +280,8 @@
:param isolated_creds_client: DynamicCredentialProvider instance
If provided, then its networking will be used if needed.
If not provided, then common network will be used if needed.
+ :param ignore_multitenancy_config: provide a share network regardless
+ of 'multitenancy_enabled' configuration value.
:returns: str -- share network id for shares_client tenant
:returns: None -- if single-tenant driver used
"""
@@ -287,83 +290,87 @@
search_word = "reusable"
sn_name = "autogenerated_by_tempest_%s" % search_word
- if not CONF.share.multitenancy_enabled:
+ if (not ignore_multitenancy_config and
+ not CONF.share.multitenancy_enabled):
# Assumed usage of a single-tenant driver
share_network_id = None
- elif sc.share_network_id:
- # Share-network already exists, use it
- share_network_id = sc.share_network_id
- elif not CONF.share.create_networks_when_multitenancy_enabled:
- share_network_id = None
-
- # Try get suitable share-network
- share_networks = sc.list_share_networks_with_detail()
- for sn in share_networks:
- if (sn["neutron_net_id"] is None and
- sn["neutron_subnet_id"] is None and
- sn["name"] and search_word in sn["name"]):
- share_network_id = sn["id"]
- break
-
- # Create new share-network if one was not found
- if share_network_id is None:
- sn_desc = "This share-network was created by tempest"
- sn = sc.create_share_network(name=sn_name, description=sn_desc)
- share_network_id = sn["id"]
else:
- net_id = subnet_id = share_network_id = None
-
- if not isolated_creds_client:
- # Search for networks, created in previous runs
- service_net_name = "share-service"
- networks = networks_client.list_networks()
- if "networks" in networks.keys():
- networks = networks["networks"]
- for network in networks:
- if (service_net_name in network["name"] and
- sc.tenant_id == network['tenant_id']):
- net_id = network["id"]
- if len(network["subnets"]) > 0:
- subnet_id = network["subnets"][0]
- break
-
- # Create suitable network
- if (net_id is None or subnet_id is None):
- ic = dynamic_creds.DynamicCredentialProvider(
- identity_version=CONF.identity.auth_version,
- name=service_net_name,
- admin_role=CONF.identity.admin_role,
- admin_creds=(
- common_creds.get_configured_admin_credentials()))
- net_data = ic._create_network_resources(sc.tenant_id)
- network, subnet, router = net_data
- net_id = network["id"]
- subnet_id = subnet["id"]
+ if sc.share_network_id:
+ # Share-network already exists, use it
+ share_network_id = sc.share_network_id
+ elif not CONF.share.create_networks_when_multitenancy_enabled:
+ share_network_id = None
# Try get suitable share-network
share_networks = sc.list_share_networks_with_detail()
for sn in share_networks:
- if (net_id == sn["neutron_net_id"] and
- subnet_id == sn["neutron_subnet_id"] and
+ if (sn["neutron_net_id"] is None and
+ sn["neutron_subnet_id"] is None and
sn["name"] and search_word in sn["name"]):
share_network_id = sn["id"]
break
- else:
- sn_name = "autogenerated_by_tempest_for_isolated_creds"
- # Use precreated network and subnet from isolated creds
- net_id = isolated_creds_client.get_credentials(
- isolated_creds_client.type_of_creds).network['id']
- subnet_id = isolated_creds_client.get_credentials(
- isolated_creds_client.type_of_creds).subnet['id']
- # Create suitable share-network
- if share_network_id is None:
- sn_desc = "This share-network was created by tempest"
- sn = sc.create_share_network(name=sn_name,
- description=sn_desc,
- neutron_net_id=net_id,
- neutron_subnet_id=subnet_id)
- share_network_id = sn["id"]
+ # Create new share-network if one was not found
+ if share_network_id is None:
+ sn_desc = "This share-network was created by tempest"
+ sn = sc.create_share_network(name=sn_name,
+ description=sn_desc)
+ share_network_id = sn["id"]
+ else:
+ net_id = subnet_id = share_network_id = None
+
+ if not isolated_creds_client:
+ # Search for networks, created in previous runs
+ service_net_name = "share-service"
+ networks = networks_client.list_networks()
+ if "networks" in networks.keys():
+ networks = networks["networks"]
+ for network in networks:
+ if (service_net_name in network["name"] and
+ sc.tenant_id == network['tenant_id']):
+ net_id = network["id"]
+ if len(network["subnets"]) > 0:
+ subnet_id = network["subnets"][0]
+ break
+
+ # Create suitable network
+ if net_id is None or subnet_id is None:
+ ic = dynamic_creds.DynamicCredentialProvider(
+ identity_version=CONF.identity.auth_version,
+ name=service_net_name,
+ admin_role=CONF.identity.admin_role,
+ admin_creds=(
+ common_creds.
+ get_configured_admin_credentials()))
+ net_data = ic._create_network_resources(sc.tenant_id)
+ network, subnet, router = net_data
+ net_id = network["id"]
+ subnet_id = subnet["id"]
+
+ # Try get suitable share-network
+ share_networks = sc.list_share_networks_with_detail()
+ for sn in share_networks:
+ if (net_id == sn["neutron_net_id"] and
+ subnet_id == sn["neutron_subnet_id"] and
+ sn["name"] and search_word in sn["name"]):
+ share_network_id = sn["id"]
+ break
+ else:
+ sn_name = "autogenerated_by_tempest_for_isolated_creds"
+ # Use precreated network and subnet from isolated creds
+ net_id = isolated_creds_client.get_credentials(
+ isolated_creds_client.type_of_creds).network['id']
+ subnet_id = isolated_creds_client.get_credentials(
+ isolated_creds_client.type_of_creds).subnet['id']
+
+ # Create suitable share-network
+ if share_network_id is None:
+ sn_desc = "This share-network was created by tempest"
+ sn = sc.create_share_network(name=sn_name,
+ description=sn_desc,
+ neutron_net_id=net_id,
+ neutron_subnet_id=subnet_id)
+ share_network_id = sn["id"]
return share_network_id