Reorganize scenario tests
Create protocol specific manager classes
where we can abstract away common code
to handle access rules and mount operations
and re-use these in the tests to get adequate
coverage to the three protocols we support
in these tests currently.
Change-Id: I7e63434e745cc1c2a5e8aaccc20f7c31404742d9
Closes-Bug: #1921369
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
diff --git a/manila_tempest_tests/tests/scenario/manager_share.py b/manila_tempest_tests/tests/scenario/manager_share.py
index 3f9e818..e828b0a 100644
--- a/manila_tempest_tests/tests/scenario/manager_share.py
+++ b/manila_tempest_tests/tests/scenario/manager_share.py
@@ -352,9 +352,10 @@
self.shares_v2_client, share_id, "active",
status_attr='access_rules_status')
- def provide_access_to_auxiliary_instance(self, instance, share=None,
- snapshot=None, access_level='rw',
- client=None):
+ def _provide_access_to_client_identified_by_ip(self, instance, share=None,
+ snapshot=None,
+ access_level='rw',
+ client=None):
share = share or self.share
client = client or self.shares_v2_client
if not CONF.share.multitenancy_enabled:
@@ -377,14 +378,14 @@
share['id'], instance=instance, cleanup=False,
snapshot=snapshot, access_level=access_level, client=client)
- def provide_access_to_client_identified_by_cephx(self, share=None,
- access_rule=None,
- access_level='rw',
- access_to=None,
- remote_client=None,
- locations=None,
- client=None,
- oc_size=20971520):
+ def _provide_access_to_client_identified_by_cephx(self, share=None,
+ access_rule=None,
+ access_level='rw',
+ access_to=None,
+ remote_client=None,
+ locations=None,
+ client=None,
+ oc_size=20971520):
"""Provide an access to a client identified by cephx authentication
:param: share: An existing share.
@@ -728,10 +729,67 @@
return ip, version
-class BaseShareCEPHFSTest(ShareScenarioTest):
+class BaseShareScenarioNFSTest(ShareScenarioTest):
+ protocol = "nfs"
+
+ @classmethod
+ def skip_checks(cls):
+ super(BaseShareScenarioNFSTest, cls).skip_checks()
+ if cls.protocol not in CONF.share.enable_ip_rules_for_protocols:
+ message = ("%s tests for access rules other than IP are disabled" %
+ cls.protocol)
+ raise cls.skipException(message)
+
+ def allow_access(self, access_level='rw', **kwargs):
+ snapshot = kwargs.get('snapshot')
+ return self._provide_access_to_client_identified_by_ip(
+ instance=kwargs['instance'], access_level=access_level,
+ snapshot=snapshot)
+
+ def mount_share(self, location, ssh_client, target_dir=None):
+
+ self.validate_ping_to_export_location(location, ssh_client)
+
+ target_dir = target_dir or "/mnt"
+ ssh_client.exec_command(
+ "sudo mount -vt nfs \"%s\" %s" % (location, target_dir)
+ )
+
+
+class BaseShareScenarioCIFSTest(ShareScenarioTest):
+ protocol = 'cifs'
+
+ @classmethod
+ def skip_checks(cls):
+ super(BaseShareScenarioCIFSTest, cls).skip_checks()
+ if cls.protocol not in CONF.share.enable_ip_rules_for_protocols:
+ message = ("%s tests for access rules other than IP are disabled" %
+ cls.protocol)
+ raise cls.skipException(message)
+
+ def allow_access(self, access_level='rw', **kwargs):
+ snapshot = kwargs.get('snapshot')
+ return self._provide_access_to_client_identified_by_ip(
+ instance=kwargs['instance'],
+ snapshot=snapshot,
+ access_level=access_level)
+
+ def mount_share(self, location, ssh_client, target_dir=None):
+
+ self.validate_ping_to_export_location(location, ssh_client)
+
+ location = location.replace("\\", "/")
+ target_dir = target_dir or "/mnt"
+ ssh_client.exec_command(
+ "sudo mount.cifs \"%s\" %s -o guest" % (location, target_dir)
+ )
+
+
+class BaseShareScenarioCEPHFSTest(ShareScenarioTest):
+ protocol = 'cephfs'
def allow_access(self, access_level='rw', access_rule=None, **kwargs):
- return self.provide_access_to_client_identified_by_cephx(
+ return self._provide_access_to_client_identified_by_cephx(
remote_client=kwargs['remote_client'],
locations=kwargs['locations'], access_level=access_level,
access_rule=access_rule)
@@ -762,4 +820,4 @@
if getattr(self, 'mount_client', None):
return remote_client.exec_command(
"sudo fusermount -uz %s" % target_dir)
- super(BaseShareCEPHFSTest, self).unmount_share(remote_client)
+ super(BaseShareScenarioCEPHFSTest, self).unmount_share(remote_client)
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 b7d894b..29fa9a8 100644
--- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
+++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
@@ -165,7 +165,7 @@
instance = self.boot_instance(wait_until="BUILD")
self.create_share()
- exports = self.get_user_export_locations(self.share)
+ export_location = self.get_user_export_locations(self.share)[0]
instance = self.wait_for_active_instance(instance["id"])
self.share = self.shares_admin_v2_client.get_share(self.share['id'])
@@ -181,9 +181,12 @@
dest_pool = dest_pool['name']
remote_client = self.init_remote_client(instance)
- self.provide_access_to_auxiliary_instance(instance)
- self.mount_share(exports[0], remote_client)
+ self.allow_access(instance=instance,
+ remote_client=remote_client,
+ locations=export_location)
+
+ self.mount_share(export_location, remote_client)
remote_client.exec_command("sudo mkdir -p /mnt/f1")
remote_client.exec_command("sudo mkdir -p /mnt/f2")
@@ -250,6 +253,10 @@
# 2 - Create share S1, ok, created
parent_share = self.create_share()
+ parent_share_export_location = self.get_user_export_locations(
+ parent_share)[0]
+
+ # Create a client User Virtual Machine
instance = self.wait_for_active_instance(instance["id"])
self.addCleanup(self.servers_client.delete_server, instance['id'])
@@ -257,14 +264,18 @@
remote_client = self.init_remote_client(instance)
# 4 - Provide RW access to S1, ok, provided
- self.provide_access_to_auxiliary_instance(instance, parent_share)
+ self.allow_access(instance=instance,
+ remote_client=remote_client,
+ locations=parent_share_export_location)
# 5 - Try mount S1 to UVM, ok, mounted
- user_export_location = self.get_user_export_locations(parent_share)[0]
+
parent_share_dir = "/mnt/parent"
remote_client.exec_command("sudo mkdir -p %s" % parent_share_dir)
- self.mount_share(user_export_location, remote_client, parent_share_dir)
+ self.mount_share(parent_share_export_location,
+ remote_client,
+ parent_share_dir)
self.addCleanup(self.unmount_share, remote_client, parent_share_dir)
# 6 - Create "file1", ok, created
@@ -282,21 +293,26 @@
# 10 - Try mount S2 - fail, access denied. We test that child share
# did not get access rules from parent share.
- user_export_location = self.get_user_export_locations(child_share)[0]
+ child_share_export_location = self.get_user_export_locations(
+ child_share)[0]
child_share_dir = "/mnt/child"
remote_client.exec_command("sudo mkdir -p %s" % child_share_dir)
self.assertRaises(
exceptions.SSHExecCommandFailed,
self.mount_share,
- user_export_location, remote_client, child_share_dir,
+ child_share_export_location, remote_client, child_share_dir,
)
# 11 - Provide RW access to S2, ok, provided
- self.provide_access_to_auxiliary_instance(instance, child_share)
+ self.allow_access(instance=instance,
+ remote_client=remote_client,
+ locations=child_share_export_location)
# 12 - Try mount S2, ok, mounted
- self.mount_share(user_export_location, remote_client, child_share_dir)
+ self.mount_share(child_share_export_location,
+ remote_client,
+ child_share_dir)
self.addCleanup(self.unmount_share, remote_client, child_share_dir)
# 13 - List files on S2, only "file1" exists
@@ -335,6 +351,9 @@
# 2 - Create share S1, ok, created
parent_share = self.create_share()
+ user_export_location = self.get_user_export_locations(parent_share)[0]
+
+ # Create client User Virtual Machine
instance = self.wait_for_active_instance(instance["id"])
self.addCleanup(self.servers_client.delete_server, instance['id'])
@@ -342,10 +361,11 @@
remote_client = self.init_remote_client(instance)
# 4 - Provide RW access to S1, ok, provided
- self.provide_access_to_auxiliary_instance(instance, parent_share)
+ self.allow_access(instance=instance,
+ remote_client=remote_client,
+ locations=user_export_location)
# 5 - Try mount S1 to UVM, ok, mounted
- user_export_location = self.get_user_export_locations(parent_share)[0]
parent_share_dir = "/mnt/parent"
snapshot_dir = "/mnt/snapshot_dir"
remote_client.exec_command("sudo mkdir -p %s" % parent_share_dir)
@@ -359,18 +379,21 @@
# 7 - Create snapshot SS1 from S1, ok, created
snapshot = self._create_snapshot(parent_share['id'])
+ snapshot_export_location = self.get_user_export_locations(
+ snapshot=snapshot)[0]
# 8 - Create "file2" in share S1 - ok, created. We expect that
# snapshot will not contain any data created after snapshot creation.
remote_client.exec_command("sudo touch %s/file2" % parent_share_dir)
# 9 - Allow access to SS1
- self.provide_access_to_auxiliary_instance(instance, snapshot=snapshot)
+ self.allow_access(instance=instance,
+ snapshot=snapshot,
+ remote_client=remote_client,
+ locations=snapshot_export_location)
# 10 - Mount SS1
- user_export_location = self.get_user_export_locations(
- snapshot=snapshot)[0]
- self.mount_share(user_export_location, remote_client, snapshot_dir)
+ self.mount_share(snapshot_export_location, remote_client, snapshot_dir)
self.addCleanup(self.unmount_share, remote_client, snapshot_dir)
# 11 - List files on SS1, only "file1" exists
@@ -387,54 +410,13 @@
"sudo touch %s/file3" % snapshot_dir)
-class TestShareBasicOpsNFS(ShareBasicOpsBase):
- protocol = "nfs"
-
- @classmethod
- def skip_checks(cls):
- super(TestShareBasicOpsNFS, cls).skip_checks()
- if cls.protocol not in CONF.share.enable_ip_rules_for_protocols:
- message = ("%s tests for access rules other than IP are disabled" %
- cls.protocol)
- raise cls.skipException(message)
-
- def allow_access(self, access_level='rw', **kwargs):
- return self.provide_access_to_auxiliary_instance(
- instance=kwargs['instance'], access_level=access_level)
-
- def mount_share(self, location, remote_client, target_dir=None):
-
- self.validate_ping_to_export_location(location, remote_client)
-
- target_dir = target_dir or "/mnt"
- remote_client.exec_command(
- "sudo mount -vt nfs \"%s\" %s" % (location, target_dir))
+class TestShareBasicOpsNFS(manager.BaseShareScenarioNFSTest,
+ ShareBasicOpsBase):
+ ip_version = 4
-class TestShareBasicOpsCIFS(ShareBasicOpsBase):
- protocol = "cifs"
-
- @classmethod
- def skip_checks(cls):
- super(TestShareBasicOpsCIFS, cls).skip_checks()
- if cls.protocol not in CONF.share.enable_ip_rules_for_protocols:
- message = ("%s tests for access rules other than IP are disabled" %
- cls.protocol)
- raise cls.skipException(message)
-
- def allow_access(self, access_level='rw', **kwargs):
- return self.provide_access_to_auxiliary_instance(
- instance=kwargs['instance'], access_level=access_level)
-
- def mount_share(self, location, remote_client, target_dir=None):
-
- self.validate_ping_to_export_location(location, remote_client)
-
- location = location.replace("\\", "/")
- target_dir = target_dir or "/mnt"
- remote_client.exec_command(
- "sudo mount.cifs \"%s\" %s -o guest" % (location, target_dir)
- )
+class TestShareBasicOpsCIFS(manager.BaseShareScenarioCIFSTest,
+ ShareBasicOpsBase):
@decorators.idempotent_id('4344a47a-d316-496b-97a4-12a59297950a')
@tc.attr(base.TAG_NEGATIVE, base.TAG_BACKEND)
@@ -456,26 +438,28 @@
raise self.skipException(msg)
-class TestShareBasicOpsCEPHFS(ShareBasicOpsBase, manager.BaseShareCEPHFSTest):
- protocol = "cephfs"
-
+class TestBaseShareBasicOpsScenarioCEPHFS(manager.BaseShareScenarioCEPHFSTest,
+ ShareBasicOpsBase):
@decorators.idempotent_id('9fb12879-45b3-4042-acac-82be338dbde1')
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
def test_mount_share_one_vm_with_ceph_fuse_client(self):
self.mount_client = 'fuse'
- super(TestShareBasicOpsCEPHFS, self).test_mount_share_one_vm()
+ super(TestBaseShareBasicOpsScenarioCEPHFS,
+ self).test_mount_share_one_vm()
@decorators.idempotent_id('a2a70b94-f5fc-438a-9dfa-53aa60ee3949')
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
def test_write_with_ro_access_with_ceph_fuse_client(self):
self.mount_client = 'fuse'
- super(TestShareBasicOpsCEPHFS, self).test_write_with_ro_access()
+ super(TestBaseShareBasicOpsScenarioCEPHFS,
+ self).test_write_with_ro_access()
@decorators.idempotent_id('c247f51f-0ffc-4a4f-894c-781647619faf')
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
def test_read_write_two_vms_with_ceph_fuse_client(self):
self.mount_client = 'fuse'
- super(TestShareBasicOpsCEPHFS, self).test_read_write_two_vms()
+ super(TestBaseShareBasicOpsScenarioCEPHFS,
+ self).test_read_write_two_vms()
class TestShareBasicOpsNFSIPv6(TestShareBasicOpsNFS):
diff --git a/manila_tempest_tests/tests/scenario/test_share_extend.py b/manila_tempest_tests/tests/scenario/test_share_extend.py
index f0f378b..e5ecf3b 100644
--- a/manila_tempest_tests/tests/scenario/test_share_extend.py
+++ b/manila_tempest_tests/tests/scenario/test_share_extend.py
@@ -146,65 +146,23 @@
raise
-class TestShareExtendNFS(ShareExtendBase):
- protocol = "nfs"
-
- @classmethod
- def skip_checks(cls):
- super(ShareExtendBase, cls).skip_checks()
- if cls.protocol not in CONF.share.enable_ip_rules_for_protocols:
- message = ("%s tests for access rules other than IP are disabled" %
- cls.protocol)
- raise cls.skipException(message)
-
- def allow_access(self, access_level='rw', **kwargs):
- return self.provide_access_to_auxiliary_instance(
- instance=kwargs['instance'], access_level=access_level)
-
- def mount_share(self, location, remote_client, target_dir=None):
-
- self.validate_ping_to_export_location(location, remote_client)
-
- target_dir = target_dir or "/mnt"
- remote_client.exec_command(
- "sudo mount -vt nfs \"%s\" %s" % (location, target_dir)
- )
+class TestShareExtendNFS(manager.BaseShareScenarioNFSTest, ShareExtendBase):
+ ip_version = 4
-class TestShareExtendCIFS(ShareExtendBase):
- protocol = "cifs"
-
- @classmethod
- def skip_checks(cls):
- super(ShareExtendBase, cls).skip_checks()
- if cls.protocol not in CONF.share.enable_ip_rules_for_protocols:
- message = ("%s tests for access rules other than IP are disabled" %
- cls.protocol)
- raise cls.skipException(message)
-
- def allow_access(self, access_level='rw', **kwargs):
- return self.provide_access_to_auxiliary_instance(
- instance=kwargs['instance'], access_level=access_level)
-
- def mount_share(self, location, remote_client, target_dir=None):
-
- self.validate_ping_to_export_location(location, remote_client)
-
- location = location.replace("\\", "/")
- target_dir = target_dir or "/mnt"
- remote_client.exec_command(
- "sudo mount.cifs \"%s\" %s -o guest" % (location, target_dir)
- )
+class TestShareExtendCIFS(manager.BaseShareScenarioCIFSTest, ShareExtendBase):
+ pass
-class TestShareExtendCEPHFS(ShareExtendBase, manager.BaseShareCEPHFSTest):
- protocol = "cephfs"
+class TestBaseShareExtendScenarioCEPHFS(manager.BaseShareScenarioCEPHFSTest,
+ ShareExtendBase):
@decorators.idempotent_id('9ca1e4a9-23e3-4da6-a63e-46e7919335e0')
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
def test_create_extend_and_write_with_ceph_fuse_client(self):
self.mount_client = 'fuse'
- super(TestShareExtendCEPHFS, self).test_create_extend_and_write()
+ super(TestBaseShareExtendScenarioCEPHFS,
+ self).test_create_extend_and_write()
class TestShareExtendNFSIPv6(TestShareExtendNFS):
diff --git a/manila_tempest_tests/tests/scenario/test_share_manage_unmanage.py b/manila_tempest_tests/tests/scenario/test_share_manage_unmanage.py
index 0c60184..65fce38 100644
--- a/manila_tempest_tests/tests/scenario/test_share_manage_unmanage.py
+++ b/manila_tempest_tests/tests/scenario/test_share_manage_unmanage.py
@@ -83,7 +83,7 @@
remote_client = self.init_remote_client(instance)
LOG.debug('Step 4 - provide access to instance')
- self.provide_access_to_auxiliary_instance(instance, share=share)
+ self._provide_access_to_client_identified_by_ip(instance, share=share)
if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"):
locations = share['export_locations']
@@ -136,7 +136,7 @@
self.shares_admin_v2_client, managed_share['id'], 'available')
LOG.debug('Step 11 - grant access again')
- self.provide_access_to_auxiliary_instance(
+ self._provide_access_to_client_identified_by_ip(
instance,
share=managed_share,
client=self.shares_admin_v2_client)
@@ -177,31 +177,14 @@
share_id=remanaged_share['id'])
-class ShareManageUnmanageNFS(ShareManageUnmanageBase):
- protocol = "nfs"
-
- def mount_share(self, location, remote_client, target_dir=None):
-
- self.validate_ping_to_export_location(location, remote_client)
-
- target_dir = target_dir or "/mnt"
- remote_client.exec_command(
- "sudo mount -vt nfs \"%s\" %s" % (location, target_dir)
- )
+class ShareManageUnmanageNFS(manager.BaseShareScenarioNFSTest,
+ ShareManageUnmanageBase):
+ ip_version = 4
-class ShareManageUnmanageCIFS(ShareManageUnmanageBase):
- protocol = "cifs"
-
- def mount_share(self, location, remote_client, target_dir=None):
-
- self.validate_ping_to_export_location(location, remote_client)
-
- location = location.replace("\\", "/")
- target_dir = target_dir or "/mnt"
- remote_client.exec_command(
- "sudo mount.cifs \"%s\" %s -o guest" % (location, target_dir)
- )
+class ShareManageUnmanageCIFS(manager.BaseShareScenarioCIFSTest,
+ ShareManageUnmanageBase):
+ pass
class ShareManageUnmanageNFSIPv6(ShareManageUnmanageNFS):
diff --git a/manila_tempest_tests/tests/scenario/test_share_shrink.py b/manila_tempest_tests/tests/scenario/test_share_shrink.py
index 2e1e44f..1ba860f 100644
--- a/manila_tempest_tests/tests/scenario/test_share_shrink.py
+++ b/manila_tempest_tests/tests/scenario/test_share_shrink.py
@@ -162,65 +162,22 @@
raise exceptions.TimeoutException(message)
-class TestShareShrinkNFS(ShareShrinkBase):
- protocol = "nfs"
-
- @classmethod
- def skip_checks(cls):
- super(ShareShrinkBase, cls).skip_checks()
- if cls.protocol not in CONF.share.enable_ip_rules_for_protocols:
- message = ("%s tests for access rules other than IP are disabled" %
- cls.protocol)
- raise cls.skipException(message)
-
- def allow_access(self, access_level='rw', **kwargs):
- return self.provide_access_to_auxiliary_instance(
- instance=kwargs['instance'], access_level=access_level)
-
- def mount_share(self, location, ssh_client, target_dir=None):
-
- self.validate_ping_to_export_location(location, ssh_client)
-
- target_dir = target_dir or "/mnt"
- ssh_client.exec_command(
- "sudo mount -vt nfs \"%s\" %s" % (location, target_dir)
- )
+class TestShareShrinkNFS(manager.BaseShareScenarioNFSTest, ShareShrinkBase):
+ ip_version = 4
-class TestShareShrinkCIFS(ShareShrinkBase):
- protocol = "cifs"
-
- @classmethod
- def skip_checks(cls):
- super(ShareShrinkBase, cls).skip_checks()
- if cls.protocol not in CONF.share.enable_ip_rules_for_protocols:
- message = ("%s tests for access rules other than IP are disabled" %
- cls.protocol)
- raise cls.skipException(message)
-
- def allow_access(self, access_level='rw', **kwargs):
- return self.provide_access_to_auxiliary_instance(
- instance=kwargs['instance'], access_level=access_level)
-
- def mount_share(self, location, ssh_client, target_dir=None):
-
- self.validate_ping_to_export_location(location, ssh_client)
-
- location = location.replace("\\", "/")
- target_dir = target_dir or "/mnt"
- ssh_client.exec_command(
- "sudo mount.cifs \"%s\" %s -o guest" % (location, target_dir)
- )
+class TestShareShrinkCIFS(manager.BaseShareScenarioCIFSTest, ShareShrinkBase):
+ pass
-class TestShareShrinkCEPHFS(ShareShrinkBase, manager.BaseShareCEPHFSTest):
- protocol = "cephfs"
-
+class TestBaseShareShrinkScenarioCEPHFS(manager.BaseShareScenarioCEPHFSTest,
+ ShareShrinkBase):
@decorators.idempotent_id('7fb324ed-7479-4bd9-b022-b3739dee9bcb')
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
def test_create_shrink_and_write_with_ceph_fuse_client(self):
self.mount_client = 'fuse'
- super(TestShareShrinkCEPHFS, self).test_create_shrink_and_write()
+ super(TestBaseShareShrinkScenarioCEPHFS,
+ self).test_create_shrink_and_write()
class TestShareShrinkNFSIPv6(TestShareShrinkNFS):