Merge "Return share_type UUID instead of name in Share API"
diff --git a/manila_tempest_tests/config.py b/manila_tempest_tests/config.py
index 0d9ffa3..616cb19 100644
--- a/manila_tempest_tests/config.py
+++ b/manila_tempest_tests/config.py
@@ -144,6 +144,9 @@
help="Defines whether to run consistency group tests or not. "
"Disable this feature if used driver doesn't support "
"it."),
+ cfg.BoolOpt("run_migration_tests",
+ default=False,
+ help="Enable or disable migration tests."),
cfg.StrOpt("image_with_share_tools",
default="manila-service-image",
help="Image name for vm booting with nfs/smb clients tool."),
@@ -160,7 +163,7 @@
default=1200,
help="Time to wait for share migration before "
"timing out (seconds)."),
- cfg.BoolOpt("migration_enabled",
- default=True,
- help="Enable or disable migration tests."),
+ cfg.StrOpt("default_share_type_name",
+ default=None,
+ help="Default share type name to use in tempest tests."),
]
diff --git a/manila_tempest_tests/tests/api/admin/test_migration.py b/manila_tempest_tests/tests/api/admin/test_migration.py
index 75b4ba7..517f43d 100644
--- a/manila_tempest_tests/tests/api/admin/test_migration.py
+++ b/manila_tempest_tests/tests/api/admin/test_migration.py
@@ -21,7 +21,7 @@
CONF = config.CONF
-class MigrationTest(base.BaseSharesAdminTest):
+class MigrationNFSTest(base.BaseSharesAdminTest):
"""Tests Share Migration.
Tests migration in multi-backend environment.
@@ -31,23 +31,23 @@
@classmethod
def resource_setup(cls):
- super(MigrationTest, cls).resource_setup()
+ super(MigrationNFSTest, 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_migration_tests:
+ raise cls.skipException("Migration tests disabled. Skipping.")
- @test.attr(type=["gate", "smoke", ])
+ @test.attr(type=["gate", ])
def test_migration_empty_v2_5(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.")
+ raise self.skipException("At least two different pool entries "
+ "are needed to run migration tests. "
+ "Skipping.")
+
share = self.create_share(self.protocol)
share = self.shares_client.get_share(share['id'])
@@ -55,6 +55,7 @@
None)
self.assertIsNotNone(dest_pool)
+ self.assertIsNotNone(dest_pool.get('name'))
dest_pool = dest_pool['name']
diff --git a/manila_tempest_tests/tests/api/admin/test_share_manage.py b/manila_tempest_tests/tests/api/admin/test_share_manage.py
index 1dd4b03..4100b2e 100644
--- a/manila_tempest_tests/tests/api/admin/test_share_manage.py
+++ b/manila_tempest_tests/tests/api/admin/test_share_manage.py
@@ -100,7 +100,7 @@
# Add managed share to cleanup queue
self.method_resources.insert(
- 0, {'type': 'share_type', 'id': share['id'],
+ 0, {'type': 'share', 'id': share['id'],
'client': self.shares_client})
# Wait for success
@@ -140,7 +140,7 @@
# Add managed share to cleanup queue
self.method_resources.insert(
- 0, {'type': 'share_type', 'id': share['id'],
+ 0, {'type': 'share', 'id': share['id'],
'client': self.shares_client})
# Wait for success
diff --git a/manila_tempest_tests/tests/scenario/manager_share.py b/manila_tempest_tests/tests/scenario/manager_share.py
index 00a2209..51e65ca 100644
--- a/manila_tempest_tests/tests/scenario/manager_share.py
+++ b/manila_tempest_tests/tests/scenario/manager_share.py
@@ -39,6 +39,8 @@
# Manila clients
cls.shares_client = clients_share.Manager().shares_client
cls.shares_admin_client = clients_share.AdminManager().shares_client
+ cls.shares_admin_v2_client = (
+ clients_share.AdminManager().shares_v2_client)
def _create_share(self, share_protocol=None, size=1, name=None,
snapshot_id=None, description=None, metadata=None,
@@ -62,7 +64,10 @@
description = description or "Tempest's share"
if not name:
name = data_utils.rand_name("manila-scenario")
- share_network_id = share_network_id or client.share_network_id or None
+ if CONF.share.multitenancy_enabled:
+ share_network_id = (share_network_id or client.share_network_id)
+ else:
+ share_network_id = None
metadata = metadata or {}
kwargs = {
'share_protocol': share_protocol,
@@ -184,7 +189,15 @@
return linux_client
def _migrate_share(self, share_id, dest_host, client=None):
- client = client or self.shares_client
+ client = client or self.shares_admin_v2_client
client.migrate_share(share_id, dest_host)
share = client.wait_for_migration_completed(share_id, dest_host)
return share
+
+ def _create_share_type(self, name, is_public=True, **kwargs):
+ share_type = self.shares_admin_v2_client.create_share_type(name,
+ is_public,
+ **kwargs)
+ self.addCleanup(self.shares_admin_v2_client.delete_share_type,
+ share_type['share_type']['id'])
+ return share_type
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 be07639..c26cbab 100644
--- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
+++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
@@ -62,16 +62,15 @@
image=self.image_ref, flavor=self.flavor_ref,
ssh_user=self.ssh_user))
- def boot_instance(self, network):
+ def boot_instance(self):
self.keypair = self.create_keypair()
security_groups = [{'name': self.security_group['name']}]
create_kwargs = {
- 'networks': [
- {'uuid': network['id']},
- ],
'key_name': self.keypair['name'],
'security_groups': security_groups,
}
+ if CONF.share.multitenancy_enabled:
+ create_kwargs['networks'] = [{'uuid': self.net['id']}, ]
instance = self.create_server(image=self.image_ref,
create_kwargs=create_kwargs,
flavor=self.flavor_ref)
@@ -118,7 +117,7 @@
def migrate_share(self, share_id, dest_host):
share = self._migrate_share(share_id, dest_host,
- self.shares_admin_client)
+ self.shares_admin_v2_client)
return share
def create_share_network(self):
@@ -133,9 +132,25 @@
neutron_subnet_id=self.subnet['id'],
name=data_utils.rand_name("sn-name"))
- def create_share(self, share_net_id):
- self.share = self._create_share(share_protocol=self.protocol,
- share_network_id=share_net_id)
+ def _get_share_type(self):
+ if CONF.share.default_share_type_name:
+ return self.shares_client.get_share_type(
+ CONF.share.default_share_type_name)['share_type']
+ return self._create_share_type(
+ data_utils.rand_name("share_type"),
+ extra_specs={
+ 'driver_handles_share_servers': CONF.share.multitenancy_enabled
+ },)['share_type']
+
+ def create_share(self):
+ kwargs = {
+ 'share_protocol': self.protocol,
+ 'share_type_id': self._get_share_type()['id'],
+ }
+ if CONF.share.multitenancy_enabled:
+ self.create_share_network()
+ kwargs.update({'share_network_id': self.share_net['id']})
+ self.share = self._create_share(**kwargs)
def allow_access_ip(self, share_id, ip=None, instance=None, cleanup=True):
if instance and not ip:
@@ -155,9 +170,8 @@
@test.services('compute', 'network')
def test_mount_share_one_vm(self):
self.security_group = self._create_security_group()
- self.create_share_network()
- self.create_share(self.share_net['id'])
- instance = self.boot_instance(self.net)
+ self.create_share()
+ instance = self.boot_instance()
self.allow_access_ip(self.share['id'], instance=instance)
ssh_client = self.init_ssh(instance)
for location in self.share['export_locations']:
@@ -170,11 +184,10 @@
"""Boots two vms and writes/reads data on it."""
test_data = "Some test data to write"
self.security_group = self._create_security_group()
- self.create_share_network()
- self.create_share(self.share_net['id'])
+ self.create_share()
# boot first VM and write data
- instance1 = self.boot_instance(self.net)
+ instance1 = self.boot_instance()
self.allow_access_ip(self.share['id'], instance=instance1)
ssh_client_inst1 = self.init_ssh(instance1)
first_location = self.share['export_locations'][0]
@@ -184,7 +197,7 @@
self.write_data(test_data, ssh_client_inst1)
# boot second VM and read
- instance2 = self.boot_instance(self.net)
+ instance2 = self.boot_instance()
self.allow_access_ip(self.share['id'], instance=instance2)
ssh_client_inst2 = self.init_ssh(instance2)
self.mount_share(first_location, ssh_client_inst2)
@@ -200,31 +213,31 @@
raise self.skipException("Test for CIFS protocol not supported "
"at this moment. Skipping.")
- if not CONF.share.migration_enabled:
+ if not CONF.share.run_migration_tests:
raise self.skipException("Migration tests disabled. Skipping.")
pools = self.shares_admin_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.")
+ raise self.skipException("At least two different pool entries "
+ "are needed to run migration tests. "
+ "Skipping.")
self.security_group = self._create_security_group()
- self.create_share_network()
- self.create_share(self.share_net['id'])
+ self.create_share()
share = self.shares_client.get_share(self.share['id'])
dest_pool = next((x for x in pools if x['name'] != share['host']),
None)
self.assertIsNotNone(dest_pool)
+ self.assertIsNotNone(dest_pool.get('name'))
dest_pool = dest_pool['name']
old_export_location = share['export_locations'][0]
- instance1 = self.boot_instance(self.net)
+ instance1 = self.boot_instance()
self.allow_access_ip(self.share['id'], instance=instance1,
cleanup=False)
ssh_client = self.init_ssh(instance1)