From 7f9209c7d49b1c20cdb6a7626a95172d6df85be2 Mon Sep 17 00:00:00 2001 From: Pranav Date: Tue, 28 Jul 2020 13:48:30 +0530 Subject: [Libfix] Move NFS Ganesha support to GlusterBaseClass Problem: NFS-Ganesha Tests inherits 'NfsGaneshaClusterSetupClass' whereas the other tests inherits 'GlusterBaseClass'. This causes a cyclic dependency when trying to run other modules with Nfs-Ganesha. Fix: 1. Move the Nfs-Ganesha dependencies to GlusterBaseClass 2. Modify the Nfs-Ganesha tests to inherit from GlusterBaseClass 3. Remove setup_nfs_ganesha method call from existing Ganesha tests as its invoked by default from GlusterBaseClass.SetUpClass Change-Id: I1e382fdb2b29585c097dfd0fea0b45edafb6442b Signed-off-by: Pranav --- .../glustolibs/gluster/gluster_base_class.py | 46 +++- .../glustolibs/gluster/nfs_ganesha_libs.py | 259 ++++++++------------- .../root-squash/test_nfs_ganesha_root_squash.py | 32 +-- .../test_root_squash_with_glusterd_restart.py | 30 +-- tests/functional/nfs_ganesha/test_cthon.py | 11 +- .../nfs_ganesha/test_ganesha_add_brick.py | 16 +- .../nfs_ganesha/test_ganesha_remove_brick.py | 16 +- .../nfs_ganesha/test_ganesha_replace_brick.py | 16 +- .../test_new_mount_while_io_in_progress.py | 16 +- .../test_new_volume_while_io_in_progress.py | 17 +- .../nfs_ganesha/test_nfs_ganesha_acls.py | 25 +- .../test_nfs_ganesha_run_io_multiple_clients.py | 16 +- .../nfs_ganesha/test_nfs_ganesha_sanity.py | 25 +- .../nfs_ganesha/test_nfs_ganesha_volume_exports.py | 61 +---- 14 files changed, 185 insertions(+), 401 deletions(-) mode change 100644 => 100755 glustolibs-gluster/glustolibs/gluster/gluster_base_class.py mode change 100644 => 100755 glustolibs-gluster/glustolibs/gluster/nfs_ganesha_libs.py diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py old mode 100644 new mode 100755 index 0acfa59ed..b43318fe4 --- a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py +++ b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py @@ -60,6 +60,8 @@ from glustolibs.gluster.volume_ops import ( set_volume_options, volume_reset, volume_start) from glustolibs.io.utils import log_mounts_info from glustolibs.gluster.geo_rep_libs import setup_master_and_slave_volumes +from glustolibs.gluster.nfs_ganesha_ops import ( + teardown_nfs_ganesha_cluster) from glustolibs.misc.misc_libs import kill_process @@ -279,7 +281,7 @@ class GlusterBaseClass(TestCase): process_ids=out.strip().split('\n')) if not ret: g.log.error("Unable to kill process {}".format( - out.strip().split('\n'))) + out.strip().split('\n'))) return False if not shared_storage_mounted: cmd_list = ( @@ -986,8 +988,8 @@ class GlusterBaseClass(TestCase): mount_dict['volname'] = cls.slave_volume mount_dict['server'] = cls.mnode_slave mount_dict['mountpoint'] = path_join( - "/mnt", '_'.join([cls.slave_volname, - cls.mount_type])) + "/mnt", '_'.join([cls.slave_volname, + cls.mount_type])) cls.slave_mounts = create_mount_objs(slave_mount_dict_list) # Defining clients from mounts. @@ -1027,6 +1029,30 @@ class GlusterBaseClass(TestCase): datetime.now().strftime('%H_%M_%d_%m_%Y')) cls.glustotest_run_id = g.config['glustotest_run_id'] + if cls.enable_nfs_ganesha: + g.log.info("Setup NFS_Ganesha") + cls.num_of_nfs_ganesha_nodes = int(cls.num_of_nfs_ganesha_nodes) + cls.servers_in_nfs_ganesha_cluster = ( + cls.servers[:cls.num_of_nfs_ganesha_nodes]) + cls.vips_in_nfs_ganesha_cluster = ( + cls.vips[:cls.num_of_nfs_ganesha_nodes]) + + # Obtain hostname of servers in ganesha cluster + cls.ganesha_servers_hostname = [] + for ganesha_server in cls.servers_in_nfs_ganesha_cluster: + ret, hostname, _ = g.run(ganesha_server, "hostname") + if ret: + raise ExecutionError("Failed to obtain hostname of %s" + % ganesha_server) + hostname = hostname.strip() + g.log.info("Obtained hostname: IP- %s, hostname- %s", + ganesha_server, hostname) + cls.ganesha_servers_hostname.append(hostname) + from glustolibs.gluster.nfs_ganesha_libs import setup_nfs_ganesha + ret = setup_nfs_ganesha(cls) + if not ret: + raise ExecutionError("Failed to setup nfs ganesha") + msg = "Setupclass: %s : %s" % (cls.__name__, cls.glustotest_run_id) g.log.info(msg) cls.inject_msg_in_gluster_logs(msg) @@ -1065,3 +1091,17 @@ class GlusterBaseClass(TestCase): GlusterBaseClass.error_or_failure_exists) g.log.info(ret) return cls.get_super_method(cls, 'doClassCleanups')() + + @classmethod + def delete_nfs_ganesha_cluster(cls): + ret = teardown_nfs_ganesha_cluster( + cls.servers_in_nfs_ganesha_cluster) + if not ret: + g.log.error("Teardown got failed. Hence, cleaning up " + "nfs-ganesha cluster forcefully") + ret = teardown_nfs_ganesha_cluster( + cls.servers_in_nfs_ganesha_cluster, force=True) + if not ret: + raise ExecutionError("Force cleanup of nfs-ganesha " + "cluster failed") + g.log.info("Teardown nfs ganesha cluster succeeded") diff --git a/glustolibs-gluster/glustolibs/gluster/nfs_ganesha_libs.py b/glustolibs-gluster/glustolibs/gluster/nfs_ganesha_libs.py old mode 100644 new mode 100755 index 92d22a8a4..cda79a5e6 --- a/glustolibs-gluster/glustolibs/gluster/nfs_ganesha_libs.py +++ b/glustolibs-gluster/glustolibs/gluster/nfs_ganesha_libs.py @@ -32,180 +32,121 @@ from glustolibs.gluster.nfs_ganesha_ops import ( create_nfs_ganesha_cluster, configure_ports_on_clients, ganesha_client_firewall_settings) -from glustolibs.gluster.gluster_base_class import GlusterBaseClass -from glustolibs.gluster.exceptions import ExecutionError, ConfigError from glustolibs.gluster.volume_libs import is_volume_exported -class NfsGaneshaClusterSetupClass(GlusterBaseClass): - """Creates nfs ganesha cluster +def setup_nfs_ganesha(cls): """ - @classmethod - def setUpClass(cls): - """ - Setup variable for nfs-ganesha tests. - """ - # pylint: disable=too-many-statements, too-many-branches - super(NfsGaneshaClusterSetupClass, cls).setUpClass() - - # Check if enable_nfs_ganesha is set in config file - if not cls.enable_nfs_ganesha: - raise ConfigError("Please enable nfs ganesha in config") - - # Read num_of_nfs_ganesha_nodes from config file and create - # nfs ganesha cluster accordingly - cls.num_of_nfs_ganesha_nodes = int(cls.num_of_nfs_ganesha_nodes) - cls.servers_in_nfs_ganesha_cluster = ( - cls.servers[:cls.num_of_nfs_ganesha_nodes]) - cls.vips_in_nfs_ganesha_cluster = ( - cls.vips[:cls.num_of_nfs_ganesha_nodes]) - - # Obtain hostname of servers in ganesha cluster - cls.ganesha_servers_hostname = [] - for ganesha_server in cls.servers_in_nfs_ganesha_cluster: - ret, hostname, _ = g.run(ganesha_server, "hostname") - if ret: - raise ExecutionError("Failed to obtain hostname of %s" - % ganesha_server) - hostname = hostname.strip() - g.log.info("Obtained hostname: IP- %s, hostname- %s", - ganesha_server, hostname) - cls.ganesha_servers_hostname.append(hostname) - - @classmethod - def setup_nfs_ganesha(cls): - """ - Create nfs-ganesha cluster if not exists - Set client configurations for nfs-ganesha - - Returns: - True(bool): If setup is successful - False(bool): If setup is failure - """ - # pylint: disable = too-many-statements, too-many-branches - # pylint: disable = too-many-return-statements - cluster_exists = is_nfs_ganesha_cluster_exists( + Create nfs-ganesha cluster if not exists + Set client configurations for nfs-ganesha + + Returns: + True(bool): If setup is successful + False(bool): If setup is failure + """ + # pylint: disable = too-many-statements, too-many-branches + # pylint: disable = too-many-return-statements + cluster_exists = is_nfs_ganesha_cluster_exists( + cls.servers_in_nfs_ganesha_cluster[0]) + if cluster_exists: + is_healthy = is_nfs_ganesha_cluster_in_healthy_state( cls.servers_in_nfs_ganesha_cluster[0]) - if cluster_exists: - is_healthy = is_nfs_ganesha_cluster_in_healthy_state( - cls.servers_in_nfs_ganesha_cluster[0]) - - if is_healthy: - g.log.info("Nfs-ganesha Cluster exists and is in healthy " - "state. Skipping cluster creation...") - else: - g.log.info("Nfs-ganesha Cluster exists and is not in " - "healthy state.") - g.log.info("Tearing down existing cluster which is not in " - "healthy state") - ganesha_ha_file = ("/var/run/gluster/shared_storage/" - "nfs-ganesha/ganesha-ha.conf") - g_node = cls.servers_in_nfs_ganesha_cluster[0] - - g.log.info("Collecting server details of existing " - "nfs ganesha cluster") - - # Check whether ganesha ha file exists - cmd = "[ -f {} ]".format(ganesha_ha_file) - ret, _, _ = g.run(g_node, cmd) - if ret: - g.log.error("Unable to locate %s", ganesha_ha_file) - return False - - # Read contents of ganesha_ha_file - cmd = "cat {}".format(ganesha_ha_file) - ret, ganesha_ha_contents, _ = g.run(g_node, cmd) - if ret: - g.log.error("Failed to read %s", ganesha_ha_file) - return False - - servers_in_existing_cluster = re.findall(r'VIP_(.*)\=.*', - ganesha_ha_contents) - - ret = teardown_nfs_ganesha_cluster( - servers_in_existing_cluster, force=True) - if not ret: - g.log.error("Failed to teardown unhealthy ganesha " - "cluster") - return False - - g.log.info("Existing unhealthy cluster got teardown " - "successfully") - - if (not cluster_exists) or (not is_healthy): - g.log.info("Creating nfs-ganesha cluster of %s nodes" - % str(cls.num_of_nfs_ganesha_nodes)) - g.log.info("Nfs-ganesha cluster node info: %s" - % cls.servers_in_nfs_ganesha_cluster) - g.log.info("Nfs-ganesha cluster vip info: %s" - % cls.vips_in_nfs_ganesha_cluster) - - ret = create_nfs_ganesha_cluster( - cls.ganesha_servers_hostname, - cls.vips_in_nfs_ganesha_cluster) + + if is_healthy: + g.log.info("Nfs-ganesha Cluster exists and is in healthy " + "state. Skipping cluster creation...") + else: + g.log.info("Nfs-ganesha Cluster exists and is not in " + "healthy state.") + g.log.info("Tearing down existing cluster which is not in " + "healthy state") + ganesha_ha_file = ("/var/run/gluster/shared_storage/" + "nfs-ganesha/ganesha-ha.conf") + g_node = cls.servers_in_nfs_ganesha_cluster[0] + + g.log.info("Collecting server details of existing " + "nfs ganesha cluster") + + # Check whether ganesha ha file exists + cmd = "[ -f {} ]".format(ganesha_ha_file) + ret, _, _ = g.run(g_node, cmd) + if ret: + g.log.error("Unable to locate %s", ganesha_ha_file) + return False + + # Read contents of ganesha_ha_file + cmd = "cat {}".format(ganesha_ha_file) + ret, ganesha_ha_contents, _ = g.run(g_node, cmd) + if ret: + g.log.error("Failed to read %s", ganesha_ha_file) + return False + + servers_in_existing_cluster = re.findall(r'VIP_(.*)\=.*', + ganesha_ha_contents) + + ret = teardown_nfs_ganesha_cluster( + servers_in_existing_cluster, force=True) if not ret: - g.log.error("Creation of nfs-ganesha cluster failed") + g.log.error("Failed to teardown unhealthy ganesha " + "cluster") return False - if not is_nfs_ganesha_cluster_in_healthy_state( - cls.servers_in_nfs_ganesha_cluster[0]): - g.log.error("Nfs-ganesha cluster is not healthy") - return False - g.log.info("Nfs-ganesha Cluster exists is in healthy state") + g.log.info("Existing unhealthy cluster got teardown " + "successfully") - ret = configure_ports_on_clients(cls.clients) - if not ret: - g.log.error("Failed to configure ports on clients") - return False + if (not cluster_exists) or (not is_healthy): + g.log.info("Creating nfs-ganesha cluster of %s nodes" + % str(cls.num_of_nfs_ganesha_nodes)) + g.log.info("Nfs-ganesha cluster node info: %s" + % cls.servers_in_nfs_ganesha_cluster) + g.log.info("Nfs-ganesha cluster vip info: %s" + % cls.vips_in_nfs_ganesha_cluster) - ret = ganesha_client_firewall_settings(cls.clients) + ret = create_nfs_ganesha_cluster( + cls.ganesha_servers_hostname, + cls.vips_in_nfs_ganesha_cluster) if not ret: - g.log.error("Failed to do firewall setting in clients") + g.log.error("Creation of nfs-ganesha cluster failed") return False - for server in cls.servers: - for client in cls.clients: - cmd = ("if [ -z \"$(grep -R \"%s\" /etc/hosts)\" ]; then " - "echo \"%s %s\" >> /etc/hosts; fi" - % (client, socket.gethostbyname(client), client)) - ret, _, _ = g.run(server, cmd) - if ret != 0: - g.log.error("Failed to add entry of client %s in " - "/etc/hosts of server %s" - % (client, server)) + if not is_nfs_ganesha_cluster_in_healthy_state( + cls.servers_in_nfs_ganesha_cluster[0]): + g.log.error("Nfs-ganesha cluster is not healthy") + return False + g.log.info("Nfs-ganesha Cluster exists is in healthy state") + + ret = configure_ports_on_clients(cls.clients) + if not ret: + g.log.error("Failed to configure ports on clients") + return False + ret = ganesha_client_firewall_settings(cls.clients) + if not ret: + g.log.error("Failed to do firewall setting in clients") + return False + + for server in cls.servers: for client in cls.clients: - for server in cls.servers: - cmd = ("if [ -z \"$(grep -R \"%s\" /etc/hosts)\" ]; then " - "echo \"%s %s\" >> /etc/hosts; fi" - % (server, socket.gethostbyname(server), server)) - ret, _, _ = g.run(client, cmd) - if ret != 0: - g.log.error("Failed to add entry of server %s in " - "/etc/hosts of client %s" - % (server, client)) - return True - - @classmethod - def tearDownClass(cls, delete_nfs_ganesha_cluster=True): - """Teardown nfs ganesha cluster. - """ - super(NfsGaneshaClusterSetupClass, cls).tearDownClass() - - if delete_nfs_ganesha_cluster: - ret = teardown_nfs_ganesha_cluster( - cls.servers_in_nfs_ganesha_cluster) - if not ret: - g.log.error("Teardown got failed. Hence, cleaning up " - "nfs-ganesha cluster forcefully") - ret = teardown_nfs_ganesha_cluster( - cls.servers_in_nfs_ganesha_cluster, force=True) - if not ret: - raise ExecutionError("Force cleanup of nfs-ganesha " - "cluster failed") - g.log.info("Teardown nfs ganesha cluster succeeded") - else: - g.log.info("Skipping teardown nfs-ganesha cluster...") + cmd = ("if [ -z \"$(grep -R \"%s\" /etc/hosts)\" ]; then " + "echo \"%s %s\" >> /etc/hosts; fi" + % (client, socket.gethostbyname(client), client)) + ret, _, _ = g.run(server, cmd) + if ret != 0: + g.log.error("Failed to add entry of client %s in " + "/etc/hosts of server %s" + % (client, server)) + + for client in cls.clients: + for server in cls.servers: + cmd = ("if [ -z \"$(grep -R \"%s\" /etc/hosts)\" ]; then " + "echo \"%s %s\" >> /etc/hosts; fi" + % (server, socket.gethostbyname(server), server)) + ret, _, _ = g.run(client, cmd) + if ret != 0: + g.log.error("Failed to add entry of server %s in " + "/etc/hosts of client %s" + % (server, client)) + return True def wait_for_nfs_ganesha_volume_to_get_exported(mnode, volname, timeout=120): diff --git a/tests/functional/nfs_ganesha/root-squash/test_nfs_ganesha_root_squash.py b/tests/functional/nfs_ganesha/root-squash/test_nfs_ganesha_root_squash.py index 67add4514..1f91b33d0 100644 --- a/tests/functional/nfs_ganesha/root-squash/test_nfs_ganesha_root_squash.py +++ b/tests/functional/nfs_ganesha/root-squash/test_nfs_ganesha_root_squash.py @@ -20,20 +20,19 @@ """ from glusto.core import Glusto as g from glustolibs.gluster.exceptions import ExecutionError -from glustolibs.gluster.gluster_base_class import runs_on +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass from glustolibs.gluster.nfs_ganesha_libs import ( - NfsGaneshaClusterSetupClass, - wait_for_nfs_ganesha_volume_to_get_unexported) + wait_for_nfs_ganesha_volume_to_get_unexported) from glustolibs.io.utils import validate_io_procs, get_mounts_stat from glustolibs.gluster.nfs_ganesha_ops import ( - set_root_squash, - unexport_nfs_ganesha_volume) + set_root_squash, + unexport_nfs_ganesha_volume) @runs_on([['replicated', 'distributed', 'distributed-replicated', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestNfsGaneshaRootSquash(NfsGaneshaClusterSetupClass): +class TestNfsGaneshaRootSquash(GlusterBaseClass): """ Tests to verify Nfs Ganesha v3/v4 rootsquash stability Steps: @@ -45,20 +44,6 @@ class TestNfsGaneshaRootSquash(NfsGaneshaClusterSetupClass): 6. Check for owner and group for any file 7. Edit file created by root user """ - @classmethod - def setUpClass(cls): - """ - Setup nfs-ganesha if not exists. - """ - cls.get_super_method(cls, 'setUpClass')() - - # Setup nfs-ganesha - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster" - "ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - def setUp(self): """ Setup Volume @@ -146,7 +131,7 @@ class TestNfsGaneshaRootSquash(NfsGaneshaClusterSetupClass): for mount_obj in self.mounts: cmd = ("echo hello > %s/file10" % mount_obj.mountpoint) ret, _, _ = g.run(mount_obj.client_system, cmd) - self.assertEqual(ret, 1, "nfsnobody user editing file created by " + self.assertEqual(ret, 1, "nfsnobody user editing file created by " "root user should FAIL") g.log.info("nfsnobody user failed to edit file " "created by root user") @@ -175,8 +160,3 @@ class TestNfsGaneshaRootSquash(NfsGaneshaClusterSetupClass): g.log.info("Successfull unmount and cleanup of volume") else: raise ExecutionError("Failed to unmount and cleanup volume") - - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) diff --git a/tests/functional/nfs_ganesha/root-squash/test_root_squash_with_glusterd_restart.py b/tests/functional/nfs_ganesha/root-squash/test_root_squash_with_glusterd_restart.py index 9e2a1197a..5ed925400 100644 --- a/tests/functional/nfs_ganesha/root-squash/test_root_squash_with_glusterd_restart.py +++ b/tests/functional/nfs_ganesha/root-squash/test_root_squash_with_glusterd_restart.py @@ -20,14 +20,13 @@ """ from glusto.core import Glusto as g from glustolibs.gluster.exceptions import ExecutionError -from glustolibs.gluster.gluster_base_class import runs_on +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass from glustolibs.gluster.nfs_ganesha_libs import ( - NfsGaneshaClusterSetupClass, - wait_for_nfs_ganesha_volume_to_get_unexported) + wait_for_nfs_ganesha_volume_to_get_unexported) from glustolibs.io.utils import get_mounts_stat from glustolibs.gluster.nfs_ganesha_ops import ( - set_root_squash, - unexport_nfs_ganesha_volume) + set_root_squash, + unexport_nfs_ganesha_volume) from glustolibs.gluster.gluster_init import ( is_glusterd_running, restart_glusterd) from glustolibs.gluster.peer_ops import wait_for_peers_to_connect @@ -38,21 +37,7 @@ from glustolibs.gluster.glusterfile import set_file_permissions @runs_on([['replicated', 'distributed', 'distributed-replicated', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestNfsGaneshaRootSquash(NfsGaneshaClusterSetupClass): - @classmethod - def setUpClass(cls): - """ - Setup nfs-ganesha if not exists. - """ - cls.get_super_method(cls, 'setUpClass')() - - # Setup nfs-ganesha - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster " - "ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - +class TestNfsGaneshaRootSquash(GlusterBaseClass): def setUp(self): """ Setup Volume @@ -183,8 +168,3 @@ class TestNfsGaneshaRootSquash(NfsGaneshaClusterSetupClass): g.log.info("Successful unmount and cleanup of volume") else: raise ExecutionError("Failed to unmount and cleanup volume") - - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) diff --git a/tests/functional/nfs_ganesha/test_cthon.py b/tests/functional/nfs_ganesha/test_cthon.py index 9b950fe59..78232fdac 100644 --- a/tests/functional/nfs_ganesha/test_cthon.py +++ b/tests/functional/nfs_ganesha/test_cthon.py @@ -20,8 +20,7 @@ """ from glusto.core import Glusto as g -from glustolibs.gluster.gluster_base_class import runs_on -from glustolibs.gluster.nfs_ganesha_libs import NfsGaneshaClusterSetupClass +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass from glustolibs.gluster.exceptions import ExecutionError from glustolibs.io.utils import run_cthon from glustolibs.misc.misc_libs import git_clone_and_compile @@ -30,7 +29,7 @@ from glustolibs.misc.misc_libs import git_clone_and_compile @runs_on([['replicated', 'distributed', 'distributed-replicated', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestCthon(NfsGaneshaClusterSetupClass): +class TestCthon(GlusterBaseClass): """ Cthon test on NFS Ganesha v4.0, v4.1 """ @@ -42,12 +41,6 @@ class TestCthon(NfsGaneshaClusterSetupClass): """ cls.get_super_method(cls, 'setUpClass')() - # Setup nfs-ganesha if not exists. - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - # Cloning the cthon test repo cls.dir_name = "repo_dir" link = 'git://linux-nfs.org/~steved/cthon04.git' diff --git a/tests/functional/nfs_ganesha/test_ganesha_add_brick.py b/tests/functional/nfs_ganesha/test_ganesha_add_brick.py index 946b64c3b..e3fc6adc9 100644 --- a/tests/functional/nfs_ganesha/test_ganesha_add_brick.py +++ b/tests/functional/nfs_ganesha/test_ganesha_add_brick.py @@ -16,8 +16,7 @@ from glusto.core import Glusto as g -from glustolibs.gluster.nfs_ganesha_libs import NfsGaneshaClusterSetupClass -from glustolibs.gluster.gluster_base_class import runs_on +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass from glustolibs.gluster.exceptions import ExecutionError from glustolibs.misc.misc_libs import upload_scripts from glustolibs.io.utils import validate_io_procs, get_mounts_stat @@ -31,7 +30,7 @@ from glustolibs.gluster.volume_libs import ( @runs_on([['distributed-replicated', 'replicated', 'distributed', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestGaneshaAddBrick(NfsGaneshaClusterSetupClass): +class TestGaneshaAddBrick(GlusterBaseClass): """ Test cases to validate add-brick and rebalance functionality on volumes exported through nfs-ganesha @@ -45,12 +44,6 @@ class TestGaneshaAddBrick(NfsGaneshaClusterSetupClass): """ cls.get_super_method(cls, 'setUpClass')() - # Setup nfs-ganesha if not exists. - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - # Upload IO scripts for running IO on mounts g.log.info("Upload io scripts to clients %s for running IO on " "mounts", cls.clients) @@ -177,8 +170,3 @@ class TestGaneshaAddBrick(NfsGaneshaClusterSetupClass): if not ret: raise ExecutionError("Failed to cleanup volume") g.log.info("Cleanup volume %s completed successfully", self.volname) - - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) diff --git a/tests/functional/nfs_ganesha/test_ganesha_remove_brick.py b/tests/functional/nfs_ganesha/test_ganesha_remove_brick.py index efa731041..9e9cf39c2 100644 --- a/tests/functional/nfs_ganesha/test_ganesha_remove_brick.py +++ b/tests/functional/nfs_ganesha/test_ganesha_remove_brick.py @@ -15,8 +15,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from glusto.core import Glusto as g -from glustolibs.gluster.nfs_ganesha_libs import NfsGaneshaClusterSetupClass -from glustolibs.gluster.gluster_base_class import runs_on +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass from glustolibs.gluster.exceptions import ExecutionError from glustolibs.misc.misc_libs import upload_scripts from glustolibs.io.utils import validate_io_procs, get_mounts_stat @@ -28,7 +27,7 @@ from glustolibs.gluster.volume_libs import ( @runs_on([['distributed', 'distributed-arbiter', 'distributed-replicated', 'distributed-dispersed'], ['nfs']]) -class TestGaneshaRemoveBrick(NfsGaneshaClusterSetupClass): +class TestGaneshaRemoveBrick(GlusterBaseClass): """ This test case validates remove brick functionality on volumes exported through nfs-ganesha @@ -42,12 +41,6 @@ class TestGaneshaRemoveBrick(NfsGaneshaClusterSetupClass): """ cls.get_super_method(cls, 'setUpClass')() - # Setup nfs-ganesha if not exists. - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - # Upload IO scripts for running IO on mounts cls.script_upload_path = ("/usr/share/glustolibs/io/scripts/" "file_dir_ops.py") @@ -145,8 +138,3 @@ class TestGaneshaRemoveBrick(NfsGaneshaClusterSetupClass): if not ret: raise ExecutionError("Failed to cleanup volume") g.log.info("Cleanup volume %s completed successfully", self.volname) - - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) diff --git a/tests/functional/nfs_ganesha/test_ganesha_replace_brick.py b/tests/functional/nfs_ganesha/test_ganesha_replace_brick.py index 12cec1a74..f87fd03f2 100644 --- a/tests/functional/nfs_ganesha/test_ganesha_replace_brick.py +++ b/tests/functional/nfs_ganesha/test_ganesha_replace_brick.py @@ -16,8 +16,7 @@ from glusto.core import Glusto as g -from glustolibs.gluster.nfs_ganesha_libs import NfsGaneshaClusterSetupClass -from glustolibs.gluster.gluster_base_class import runs_on +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass from glustolibs.gluster.exceptions import ExecutionError from glustolibs.misc.misc_libs import upload_scripts from glustolibs.io.utils import validate_io_procs, get_mounts_stat @@ -31,7 +30,7 @@ from glustolibs.gluster.heal_libs import monitor_heal_completion @runs_on([['distributed-replicated', 'replicated', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestGaneshaReplaceBrick(NfsGaneshaClusterSetupClass): +class TestGaneshaReplaceBrick(GlusterBaseClass): """ Test cases to validate remove brick functionality on volumes exported through nfs-ganesha @@ -45,12 +44,6 @@ class TestGaneshaReplaceBrick(NfsGaneshaClusterSetupClass): """ cls.get_super_method(cls, 'setUpClass')() - # Setup nfs-ganesha if not exists. - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - # Upload IO scripts for running IO on mounts g.log.info("Upload io scripts to clients %s for running IO on " "mounts", cls.clients) @@ -169,8 +162,3 @@ class TestGaneshaReplaceBrick(NfsGaneshaClusterSetupClass): if not ret: raise ExecutionError("Failed to cleanup volume") g.log.info("Cleanup volume %s completed successfully", self.volname) - - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) diff --git a/tests/functional/nfs_ganesha/test_new_mount_while_io_in_progress.py b/tests/functional/nfs_ganesha/test_new_mount_while_io_in_progress.py index 1c6fc313c..798d5b7df 100644 --- a/tests/functional/nfs_ganesha/test_new_mount_while_io_in_progress.py +++ b/tests/functional/nfs_ganesha/test_new_mount_while_io_in_progress.py @@ -15,8 +15,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from copy import deepcopy from glusto.core import Glusto as g -from glustolibs.gluster.nfs_ganesha_libs import NfsGaneshaClusterSetupClass -from glustolibs.gluster.gluster_base_class import runs_on +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass from glustolibs.gluster.exceptions import ExecutionError from glustolibs.misc.misc_libs import upload_scripts from glustolibs.io.utils import validate_io_procs, get_mounts_stat @@ -24,7 +23,7 @@ from glustolibs.io.utils import validate_io_procs, get_mounts_stat @runs_on([['replicated', 'distributed', 'distributed-replicated'], ['nfs']]) -class TestMountWhileIoInProgress(NfsGaneshaClusterSetupClass): +class TestMountWhileIoInProgress(GlusterBaseClass): """ Test cases to validate new mount while IO is going on """ @@ -37,12 +36,6 @@ class TestMountWhileIoInProgress(NfsGaneshaClusterSetupClass): """ cls.get_super_method(cls, 'setUpClass')() - # Setup nfs-ganesha if not exists. - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - # Upload IO scripts for running IO on mounts g.log.info("Upload io scripts to clients %s for running IO on " "mounts", cls.clients) @@ -141,8 +134,3 @@ class TestMountWhileIoInProgress(NfsGaneshaClusterSetupClass): if not ret: raise ExecutionError("Failed to cleanup volume") g.log.info("Cleanup volume %s completed successfully", self.volname) - - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) diff --git a/tests/functional/nfs_ganesha/test_new_volume_while_io_in_progress.py b/tests/functional/nfs_ganesha/test_new_volume_while_io_in_progress.py index c367d3006..e8491ebfb 100644 --- a/tests/functional/nfs_ganesha/test_new_volume_while_io_in_progress.py +++ b/tests/functional/nfs_ganesha/test_new_volume_while_io_in_progress.py @@ -22,8 +22,8 @@ from copy import deepcopy from glusto.core import Glusto as g from glustolibs.gluster.nfs_ganesha_libs import ( - NfsGaneshaClusterSetupClass, wait_for_nfs_ganesha_volume_to_get_exported) -from glustolibs.gluster.gluster_base_class import runs_on + wait_for_nfs_ganesha_volume_to_get_exported) +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass from glustolibs.gluster.exceptions import ExecutionError from glustolibs.misc.misc_libs import upload_scripts from glustolibs.io.utils import validate_io_procs, get_mounts_stat @@ -37,7 +37,7 @@ from glustolibs.gluster.nfs_ganesha_ops import export_nfs_ganesha_volume @runs_on([['replicated', 'distributed', 'distributed-replicated', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestNewVolumeWhileIoInProgress(NfsGaneshaClusterSetupClass): +class TestNewVolumeWhileIoInProgress(GlusterBaseClass): """ Test cases to verify creation, export and mount of new volume while IO is going on another volume exported through nfs-ganesha. @@ -50,12 +50,6 @@ class TestNewVolumeWhileIoInProgress(NfsGaneshaClusterSetupClass): """ cls.get_super_method(cls, 'setUpClass')() - # Setup nfs-ganesha if not exists. - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - # Upload IO scripts for running IO on mounts g.log.info("Upload io scripts to clients %s for running IO on " "mounts", cls.clients) @@ -242,8 +236,3 @@ class TestNewVolumeWhileIoInProgress(NfsGaneshaClusterSetupClass): if not ret: raise ExecutionError("Failed to cleanup volume %s", volume) g.log.info("Volume %s deleted successfully", volume) - - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) diff --git a/tests/functional/nfs_ganesha/test_nfs_ganesha_acls.py b/tests/functional/nfs_ganesha/test_nfs_ganesha_acls.py index 5921f3b90..7b0865c0a 100644 --- a/tests/functional/nfs_ganesha/test_nfs_ganesha_acls.py +++ b/tests/functional/nfs_ganesha/test_nfs_ganesha_acls.py @@ -19,40 +19,25 @@ ACL functionality. """ +import time +import re from glusto.core import Glusto as g from glustolibs.gluster.nfs_ganesha_ops import ( set_acl, unexport_nfs_ganesha_volume) from glustolibs.gluster.nfs_ganesha_libs import ( - NfsGaneshaClusterSetupClass, - wait_for_nfs_ganesha_volume_to_get_unexported) -from glustolibs.gluster.gluster_base_class import runs_on + wait_for_nfs_ganesha_volume_to_get_unexported) +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass from glustolibs.gluster.exceptions import ExecutionError -import time -import re @runs_on([['replicated', 'distributed', 'distributed-replicated', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestNfsGaneshaAcls(NfsGaneshaClusterSetupClass): +class TestNfsGaneshaAcls(GlusterBaseClass): """ Tests to verify Nfs Ganesha v4 ACL stability """ - - @classmethod - def setUpClass(cls): - """ - Setup nfs-ganesha if not exists. - """ - cls.get_super_method(cls, 'setUpClass')() - - # Setup nfs-ganesha - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setuo nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - def setUp(self): """ Setup Volume diff --git a/tests/functional/nfs_ganesha/test_nfs_ganesha_run_io_multiple_clients.py b/tests/functional/nfs_ganesha/test_nfs_ganesha_run_io_multiple_clients.py index 39a50766a..0f9c17156 100644 --- a/tests/functional/nfs_ganesha/test_nfs_ganesha_run_io_multiple_clients.py +++ b/tests/functional/nfs_ganesha/test_nfs_ganesha_run_io_multiple_clients.py @@ -20,9 +20,8 @@ """ from glusto.core import Glusto as g -from glustolibs.gluster.gluster_base_class import runs_on +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass from glustolibs.gluster.exceptions import ExecutionError -from glustolibs.gluster.nfs_ganesha_libs import NfsGaneshaClusterSetupClass from glustolibs.gluster.lib_utils import install_epel from glustolibs.io.utils import run_bonnie, run_fio, run_mixed_io @@ -30,7 +29,7 @@ from glustolibs.io.utils import run_bonnie, run_fio, run_mixed_io @runs_on([['replicated', 'distributed', 'distributed-replicated', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestNfsGaneshaWithDifferentIOPatterns(NfsGaneshaClusterSetupClass): +class TestNfsGaneshaWithDifferentIOPatterns(GlusterBaseClass): """ Tests Nfs Ganesha stability by running different IO Patterns """ @@ -42,12 +41,6 @@ class TestNfsGaneshaWithDifferentIOPatterns(NfsGaneshaClusterSetupClass): """ cls.get_super_method(cls, 'setUpClass')() - # Setup nfs-ganesha if not exists. - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - # Install epel if not install_epel(cls.clients): raise ExecutionError("Failed to install epel") @@ -128,8 +121,3 @@ class TestNfsGaneshaWithDifferentIOPatterns(NfsGaneshaClusterSetupClass): if not ret: raise ExecutionError("Failed to cleanup volume") g.log.info("Cleanup volume %s completed successfully", self.volname) - - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) diff --git a/tests/functional/nfs_ganesha/test_nfs_ganesha_sanity.py b/tests/functional/nfs_ganesha/test_nfs_ganesha_sanity.py index 2bca6d1c9..18feef31b 100755 --- a/tests/functional/nfs_ganesha/test_nfs_ganesha_sanity.py +++ b/tests/functional/nfs_ganesha/test_nfs_ganesha_sanity.py @@ -19,23 +19,21 @@ """ from glusto.core import Glusto as g -from glustolibs.gluster.gluster_base_class import runs_on -from glustolibs.gluster.nfs_ganesha_libs import ( - NfsGaneshaClusterSetupClass) +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass from glustolibs.gluster.exceptions import ExecutionError from glustolibs.misc.misc_libs import ( - upload_scripts, - git_clone_and_compile) + upload_scripts, + git_clone_and_compile) from glustolibs.gluster.nfs_ganesha_ops import ( - is_nfs_ganesha_cluster_in_healthy_state, - set_acl) + is_nfs_ganesha_cluster_in_healthy_state, + set_acl) from glustolibs.io.utils import validate_io_procs @runs_on([['replicated', 'distributed', 'distributed-replicated', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestNfsGaneshaSanity(NfsGaneshaClusterSetupClass): +class TestNfsGaneshaSanity(GlusterBaseClass): """ Tests to verify NFS Ganesha Sanity. """ @@ -47,12 +45,6 @@ class TestNfsGaneshaSanity(NfsGaneshaClusterSetupClass): """ cls.get_super_method(cls, 'setUpClass')() - # Setup nfs-ganesha if not exists. - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - # Upload IO scripts for running IO on mounts g.log.info("Upload io scripts to clients %s for running IO on " "mounts", cls.clients) @@ -233,8 +225,3 @@ class TestNfsGaneshaSanity(NfsGaneshaClusterSetupClass): "Check log errors for more info") else: g.log.info("Test repo cleanup successfull on all clients") - - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) diff --git a/tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py b/tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py index 1cc9a05a3..bb1f2f71e 100755 --- a/tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py +++ b/tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py @@ -26,9 +26,8 @@ from time import sleep from glusto.core import Glusto as g -from glustolibs.gluster.gluster_base_class import runs_on +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass from glustolibs.gluster.nfs_ganesha_libs import ( - NfsGaneshaClusterSetupClass, wait_for_nfs_ganesha_volume_to_get_exported, wait_for_nfs_ganesha_volume_to_get_unexported) from glustolibs.gluster.nfs_ganesha_ops import ( @@ -49,23 +48,11 @@ from glustolibs.gluster.lib_utils import get_servers_unused_bricks_dict @runs_on([['replicated', 'distributed', 'distributed-replicated', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestNfsGaneshaVolumeExports(NfsGaneshaClusterSetupClass): +class TestNfsGaneshaVolumeExports(GlusterBaseClass): """ Tests to verify Nfs Ganesha exports, cluster enable/disable functionality. """ - @classmethod - def setUpClass(cls): - """ - Setup nfs-ganesha if not exists. - """ - cls.get_super_method(cls, 'setUpClass')() - - # Setup nfs-ganesha if not exists. - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") def setUp(self): """ @@ -250,16 +237,11 @@ class TestNfsGaneshaVolumeExports(NfsGaneshaClusterSetupClass): raise ExecutionError("Failed to cleanup volume") g.log.info("Cleanup volume %s completed successfully", self.volname) - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) - @runs_on([['replicated', 'distributed', 'distributed-replicated', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestNfsGaneshaVolumeExportsWithIO(NfsGaneshaClusterSetupClass): +class TestNfsGaneshaVolumeExportsWithIO(GlusterBaseClass): """ Tests to verify nfs ganesha features when IO is in progress. """ @@ -271,12 +253,6 @@ class TestNfsGaneshaVolumeExportsWithIO(NfsGaneshaClusterSetupClass): """ cls.get_super_method(cls, 'setUpClass')() - # Setup nfs-ganesha if not exists. - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - # Upload IO scripts for running IO on mounts g.log.info("Upload io scripts to clients %s for running IO on " "mounts", cls.clients) @@ -391,16 +367,11 @@ class TestNfsGaneshaVolumeExportsWithIO(NfsGaneshaClusterSetupClass): raise ExecutionError("Failed to cleanup volume") g.log.info("Cleanup volume %s completed successfully", self.volname) - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) - @runs_on([['replicated', 'distributed', 'distributed-replicated', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestNfsGaneshaMultiVolumeExportsWithIO(NfsGaneshaClusterSetupClass): +class TestNfsGaneshaMultiVolumeExportsWithIO(GlusterBaseClass): """ Tests to verify multiple volumes gets exported when IO is in progress. """ @@ -412,12 +383,6 @@ class TestNfsGaneshaMultiVolumeExportsWithIO(NfsGaneshaClusterSetupClass): """ cls.get_super_method(cls, 'setUpClass')() - # Setup nfs-ganesha if not exists. - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - # Upload IO scripts for running IO on mounts g.log.info("Upload io scripts to clients %s for running IO on " "mounts", cls.clients) @@ -568,16 +533,11 @@ class TestNfsGaneshaMultiVolumeExportsWithIO(NfsGaneshaClusterSetupClass): raise ExecutionError("Failed to cleanup volume") g.log.info("Cleanup volume %s completed successfully", self.volname) - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) - @runs_on([['replicated', 'distributed', 'distributed-replicated', 'dispersed', 'distributed-dispersed'], ['nfs']]) -class TestNfsGaneshaSubDirExportsWithIO(NfsGaneshaClusterSetupClass): +class TestNfsGaneshaSubDirExportsWithIO(GlusterBaseClass): """ Tests to verify nfs-ganesha sub directory exports. """ @@ -589,12 +549,6 @@ class TestNfsGaneshaSubDirExportsWithIO(NfsGaneshaClusterSetupClass): """ cls.get_super_method(cls, 'setUpClass')() - # Setup nfs-ganesha if not exists. - ret = cls.setup_nfs_ganesha() - if not ret: - raise ExecutionError("Failed to setup nfs-ganesha cluster") - g.log.info("nfs-ganesha cluster is healthy") - # Upload IO scripts for running IO on mounts g.log.info("Upload io scripts to clients %s for running IO on " "mounts", cls.clients) @@ -807,8 +761,3 @@ class TestNfsGaneshaSubDirExportsWithIO(NfsGaneshaClusterSetupClass): if not ret: raise ExecutionError("Failed to cleanup volume") g.log.info("Cleanup volume %s completed successfully", self.volname) - - @classmethod - def tearDownClass(cls): - cls.get_super_method(cls, 'tearDownClass')( - delete_nfs_ganesha_cluster=False) -- cgit