diff options
Diffstat (limited to 'tests/functional/nfs_ganesha')
15 files changed, 905 insertions, 174 deletions
diff --git a/tests/functional/nfs_ganesha/root-squash/__init__.py b/tests/functional/nfs_ganesha/root-squash/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/functional/nfs_ganesha/root-squash/__init__.py 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 new file mode 100644 index 000000000..1f91b33d0 --- /dev/null +++ b/tests/functional/nfs_ganesha/root-squash/test_nfs_ganesha_root_squash.py @@ -0,0 +1,162 @@ +# Copyright (C) 2020 Red Hat, Inc. <http://www.redhat.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +""" + Test Cases in this module tests the nfs ganesha version 3 and 4 + rootsquash functionality cases. +""" +from glusto.core import Glusto as g +from glustolibs.gluster.exceptions import ExecutionError +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass +from glustolibs.gluster.nfs_ganesha_libs import ( + 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) + + +@runs_on([['replicated', 'distributed', 'distributed-replicated', + 'dispersed', 'distributed-dispersed'], + ['nfs']]) +class TestNfsGaneshaRootSquash(GlusterBaseClass): + """ + Tests to verify Nfs Ganesha v3/v4 rootsquash stability + Steps: + 1. Create some files and dirs inside mount point + 2. Check for owner and group + 3. Set permission as 777 for mount point + 4. Enable root-squash on volume + 5. Create some more files and dirs + 6. Check for owner and group for any file + 7. Edit file created by root user + """ + def setUp(self): + """ + Setup Volume + """ + self.get_super_method(self, 'setUp')() + + # Setup and mount volume + ret = self.setup_volume_and_mount_volume(mounts=self.mounts) + if not ret: + raise ExecutionError("Failed to setup and mount volume %s" + % self.volname) + g.log.info("Successful in setup and mount volume %s", self.volname) + + def test_rootsquash_enable(self): + # Start IO on mount point. + self.all_mounts_procs = [] + cmd = ("for i in {1..10}; do touch %s/file$i; done" + % self.mounts[0].mountpoint) + proc = g.run_async(self.mounts[0].client_system, cmd, + user=self.mounts[0].user) + self.all_mounts_procs.append(proc) + + # Validate IO + ret = validate_io_procs(self.all_mounts_procs, self.mounts) + self.assertTrue(ret, "IO failed on some of the clients") + g.log.info("IO is successful on all mounts") + + # Get stat of all the files/dirs created. + ret = get_mounts_stat(self.mounts) + self.assertTrue(ret, "Stat failed on some of the clients") + g.log.info("Successfull in getting stats of files/dirs " + "from mount point") + + # Check for owner and group of random file + for mount_obj in self.mounts: + cmd = ("ls -l %s/file5 | awk '{ print $3, $4 }' |sort" + % mount_obj.mountpoint) + ret, out, err = g.run(mount_obj.client_system, cmd) + self.assertFalse(ret, err) + self.assertIn("root root", out, "Owner and group is not ROOT") + g.log.info("Owner and group of file is ROOT") + + # Set mount point permission to 777 + for mount_obj in self.mounts: + cmd = ("chmod 777 %s" % mount_obj.mountpoint) + ret, _, err = g.run(mount_obj.client_system, cmd) + self.assertFalse(ret, err) + g.log.info("Mount point permission changed to 777") + + # Enable root-squash on volume + ret = set_root_squash(self.servers[0], self.volname) + self.assertTrue(ret, "Failed to enable root-squash on volume") + g.log.info("root-squash is enable on the volume") + + # Start IO on mount point. + self.all_mounts_procs = [] + cmd = ("for i in {1..10}; do touch %s/Squashfile$i; done" + % self.mounts[0].mountpoint) + proc = g.run_async(self.mounts[0].client_system, cmd, + user=self.mounts[0].user) + self.all_mounts_procs.append(proc) + + # Validate IO + ret = validate_io_procs(self.all_mounts_procs, self.mounts) + self.assertTrue(ret, "IO failed on some of the clients") + g.log.info("IO is successful on all mounts") + + # Get stat of all the files/dirs created. + ret = get_mounts_stat(self.mounts) + self.assertTrue(ret, "Stat failed on some of the clients") + g.log.info("Successfull in getting stats of files/dirs " + "from mount point") + + # Check for owner and group of random file + for mount_obj in self.mounts: + cmd = ("ls -l %s/Squashfile5 | awk '{print $3, $4}' | sort" + % mount_obj.mountpoint) + ret, out, err = g.run(mount_obj.client_system, cmd) + self.assertFalse(ret, err) + self.assertIn("nfsnobody nfsnobody", out, + "Owner and group of file is NOT NFSNOBODY") + g.log.info("Owner and group of file is NFSNOBODY") + + # Edit file created by root user + 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 " + "root user should FAIL") + g.log.info("nfsnobody user failed to edit file " + "created by root user") + + def tearDown(self): + + # Disable root-squash + ret = set_root_squash(self.mnode, self.volname, squash=False, + do_refresh_config=True) + if not ret: + raise ExecutionError("Failed to disable root-squash on nfs " + "ganesha cluster") + g.log.info("root-squash is disabled on volume") + + # Unexport volume + unexport_nfs_ganesha_volume(self.mnode, self.volname) + ret = wait_for_nfs_ganesha_volume_to_get_unexported(self.mnode, + self.volname) + if not ret: + raise ExecutionError("Volume %s is not unexported." % self.volname) + g.log.info("Unexporting of volume is successful") + + # Unmount and cleanup Volume + ret = self.unmount_volume_and_cleanup_volume(self.mounts) + if ret: + g.log.info("Successfull unmount and cleanup of volume") + else: + raise ExecutionError("Failed to unmount and cleanup volume") diff --git a/tests/functional/nfs_ganesha/root-squash/test_nfs_ganesha_rootsquash_multiple_client.py b/tests/functional/nfs_ganesha/root-squash/test_nfs_ganesha_rootsquash_multiple_client.py new file mode 100644 index 000000000..918f4038c --- /dev/null +++ b/tests/functional/nfs_ganesha/root-squash/test_nfs_ganesha_rootsquash_multiple_client.py @@ -0,0 +1,174 @@ +# Copyright (C) 2020 Red Hat, Inc. <http://www.redhat.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +""" + Test Cases in this module tests the nfs ganesha version 3 and 4 + rootsquash functionality cases. +""" +from glusto.core import Glusto as g +from glustolibs.gluster.exceptions import ExecutionError +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass +from glustolibs.gluster.nfs_ganesha_libs import ( + 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) +from glustolibs.gluster.lib_utils import (append_string_to_file) +from glustolibs.gluster.glusterfile import set_file_permissions + + +@runs_on([['replicated', 'distributed', 'distributed-replicated', + 'dispersed', 'distributed-dispersed'], + ['nfs']]) +class TestNfsGaneshaRootSquash(GlusterBaseClass): + + def setUp(self): + """ + Setup Volume + """ + self.get_super_method(self, 'setUp')() + + # Setup and mount volume + ret = self.setup_volume_and_mount_volume(mounts=self.mounts) + if not ret: + raise ExecutionError("Failed to setup and mount volume %s" + % self.volname) + g.log.info("Successful in setup and mount volume %s", self.volname) + + def test_root_squash_enable(self): + """ + Tests to verify Nfs Ganesha rootsquash functionality with multi + client + Steps: + 1. Create some directories on mount point. + 2. Create some files inside those directories + 3. Set permission as 777 for mount point + 4. Enable root-squash on volume + 5. Edit file created by root user from client 2 + It should not allow to edit the file + 6. Create some directories on mount point. + 7. Create some files inside the directories + Files and directories will be created by + nfsnobody user + 8. Edit the file created in step 7 + It should allow to edit the file + 9. Disable root squash + 10. Edit the file created at step 7 + It should allow to edit the file + """ + # Create Directories on Mount point + cmd = ("for i in {1..10}; do mkdir %s/dir$i; done" + % self.mounts[0].mountpoint) + ret, _, err = g.run(self.mounts[0].client_system, cmd, + user=self.mounts[0].user) + self.assertEqual(ret, 0, err) + + # Create files inside directories on mount point. + cmd = ("for i in {1..10}; do touch %s/dir$i/file$i; done" + % self.mounts[0].mountpoint) + ret, _, err = g.run(self.mounts[0].client_system, cmd, + user=self.mounts[0].user) + self.assertEqual(ret, 0, err) + + # Get stat of all the files/dirs created. + ret = get_mounts_stat(self.mounts) + self.assertTrue(ret, "Stat failed on some of the clients") + g.log.info("Successful in getting stats of files/dirs " + "from mount point") + + # Set mount point permission to 777 + ret = set_file_permissions(self.mounts[0].client_system, + self.mounts[0].mountpoint, 777) + self.assertTrue(ret, "Failed to set permission for directory") + g.log.info("Successfully set permissions for directory") + + # Enable root-squash on volume + ret = set_root_squash(self.servers[0], self.volname) + self.assertTrue(ret, "Failed to enable root-squash on volume") + g.log.info("root-squash is enable on the volume") + + # Edit file created by root user from client 2 + ret = append_string_to_file(self.mounts[1].client_system, + "%s/dir5/file5" + % self.mounts[1].mountpoint, 'hello') + self.assertFalse(ret, "Unexpected:nfsnobody user editing file " + "created by root user should FAIL") + g.log.info("Successful:nfsnobody user failed to edit file " + "created by root user") + + # Create Directories on Mount point + cmd = ("for i in {1..10}; do mkdir %s/SquashDir$i; done" + % self.mounts[0].mountpoint) + ret, _, err = g.run(self.mounts[0].client_system, cmd, + user=self.mounts[0].user) + self.assertEqual(ret, 0, err) + + # Create files inside directories on mount point + cmd = ("for i in {1..10}; do touch %s/SquashDir$i/Squashfile$i;" + "done" % self.mounts[0].mountpoint) + ret, _, err = g.run(self.mounts[0].client_system, cmd, + user=self.mounts[0].user) + self.assertEqual(ret, 0, err) + + # Get stat of all the files/dirs created. + ret = get_mounts_stat(self.mounts) + self.assertTrue(ret, "Stat failed on some of the clients") + g.log.info("Successful in getting stats of files/dirs " + "from mount point") + + # Edit the file created by nfsnobody user from client 2 + ret = append_string_to_file(self.mounts[1].client_system, + "%s/SquashDir5/Squashfile5" + % self.mounts[1].mountpoint, + 'hello') + self.assertTrue(ret, "Unexpected:nfsnobody user failed to edit " + "the file created by nfsnobody user") + g.log.info("Successful:nfsnobody user successfully edited the " + "file created by nfsnobody user") + + # Disable root-squash + ret = set_root_squash(self.servers[0], self.volname, squash=False, + do_refresh_config=True) + self.assertTrue(ret, "Failed to disable root-squash on volume") + g.log.info("root-squash is disabled on the volume") + + # Edit the file created by nfsnobody user from root user + ret = append_string_to_file(self.mounts[1].client_system, + "%s/SquashDir10/Squashfile10" + % self.mounts[1].mountpoint, 'hello') + self.assertTrue(ret, "Unexpected:root user failed to edit " + "the file created by nfsnobody user") + g.log.info("Successful:root user successfully edited the " + "file created by nfsnobody user") + + def tearDown(self): + + # Unexport volume + unexport_nfs_ganesha_volume(self.mnode, self.volname) + ret = wait_for_nfs_ganesha_volume_to_get_unexported(self.mnode, + self.volname) + if not ret: + raise ExecutionError("Failed:Volume %s is not unexported." + % self.volname) + g.log.info("Unexporting of volume is successful") + + # Unmount and cleanup Volume + ret = self.unmount_volume_and_cleanup_volume(self.mounts) + if ret: + g.log.info("Successful unmount and cleanup of volume") + else: + raise ExecutionError("Failed to unmount and cleanup volume") 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 new file mode 100644 index 000000000..5ed925400 --- /dev/null +++ b/tests/functional/nfs_ganesha/root-squash/test_root_squash_with_glusterd_restart.py @@ -0,0 +1,170 @@ +# Copyright (C) 2020 Red Hat, Inc. <http://www.redhat.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +""" + Test Cases in this module tests the nfs ganesha version 3 and 4 + rootsquash functionality cases. +""" +from glusto.core import Glusto as g +from glustolibs.gluster.exceptions import ExecutionError +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass +from glustolibs.gluster.nfs_ganesha_libs import ( + 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) +from glustolibs.gluster.gluster_init import ( + is_glusterd_running, restart_glusterd) +from glustolibs.gluster.peer_ops import wait_for_peers_to_connect +from glustolibs.gluster.lib_utils import (append_string_to_file) +from glustolibs.gluster.glusterfile import set_file_permissions + + +@runs_on([['replicated', 'distributed', 'distributed-replicated', + 'dispersed', 'distributed-dispersed'], + ['nfs']]) +class TestNfsGaneshaRootSquash(GlusterBaseClass): + def setUp(self): + """ + Setup Volume + """ + self.get_super_method(self, 'setUp')() + + # Setup and mount volume + ret = self.setup_volume_and_mount_volume(mounts=self.mounts) + if not ret: + raise ExecutionError("Failed to setup and mount volume %s" + % self.volname) + g.log.info("Successful in setup and mount volume %s", self.volname) + + def test_root_squash_enable(self): + """ + Tests to verify Nfs Ganesha rootsquash functionality when glusterd + service is restarted + Steps: + 1. Create some files and dirs inside mount point + 2. Set permission as 777 for mount point + 3. Enable root-squash on volume + 4. Create some more files and dirs + 5. Restart glusterd on all the nodes + 6. Try to edit file created in step 1 + It should not allow to edit the file + 7. Try to edit the file created in step 5 + It should allow to edit the file + """ + # Start IO on mount point. + cmd = ("for i in {1..10}; do touch %s/file$i; done" + % self.mounts[0].mountpoint) + ret, _, err = g.run(self.mounts[0].client_system, cmd, + user=self.mounts[0].user) + self.assertEqual(ret, 0, err) + + # Get stat of all the files/dirs created. + ret = get_mounts_stat(self.mounts) + self.assertTrue(ret, "Stat failed on some of the clients") + g.log.info("Successful in getting stats of files/dirs " + "from mount point") + + # Set mount point permission to 777 + ret = set_file_permissions(self.mounts[0].client_system, + self.mounts[0].mountpoint, 777) + self.assertTrue(ret, "Failed to set permission for directory") + g.log.info("Successfully set permissions for directory") + + # Enable root-squash on volume + ret = set_root_squash(self.servers[0], self.volname) + self.assertTrue(ret, "Failed to enable root-squash on volume") + g.log.info("root-squash is enable on the volume") + + # Start IO on mount point. + cmd = ("for i in {1..10}; do touch %s/Squashfile$i; done" + % self.mounts[0].mountpoint) + ret, _, err = g.run(self.mounts[0].client_system, cmd, + user=self.mounts[0].user) + self.assertEqual(ret, 0, err) + + # Get stat of all the files/dirs created. + ret = get_mounts_stat(self.mounts) + self.assertTrue(ret, "Stat failed on some of the clients") + g.log.info("Successfull in getting stats of files/dirs " + "from mount point") + + # Restart glusterd on all servers + ret = restart_glusterd(self.servers) + self.assertTrue(ret, ("Failed to restart glusterd on all servers %s", + self.servers)) + g.log.info("Successfully restarted glusterd on all servers %s", + self.servers) + + # Check if glusterd is running on all servers + ret = is_glusterd_running(self.servers) + self.assertEqual(ret, 0, ("Failed:Glusterd is not running on all " + "servers %s", + self.servers)) + g.log.info("Glusterd is running on all the servers %s", self.servers) + + # Checking if peer is connected. + ret = wait_for_peers_to_connect(self.mnode, self.servers) + self.assertTrue(ret, "Failed:Peer is not in connected state.") + g.log.info("Peers are in connected state.") + + # Edit file created by root user + for mount_obj in self.mounts: + ret = append_string_to_file(mount_obj.client_system, + "%s/file10" % mount_obj.mountpoint, + 'hello') + self.assertFalse(ret, "Unexpected:nfsnobody user editing file " + "created by root user should FAIL") + g.log.info("Successful:nfsnobody user failed to edit file " + "created by root user") + + # Edit the file created by nfsnobody user + for mount_obj in self.mounts: + ret = append_string_to_file(mount_obj.client_system, + "%s/Squashfile5" + % mount_obj.mountpoint, + 'hello') + self.assertTrue(ret, "Unexpected:nfsnobody user failed to edit " + "the file created by nfsnobody user") + g.log.info("Successful:nfsnobody user successfully edited the " + "file created by nfsnobody user") + + def tearDown(self): + + # Disable root-squash + ret = set_root_squash(self.mnode, self.volname, squash=False, + do_refresh_config=True) + if not ret: + raise ExecutionError("Failed to disable root-squash on nfs " + "ganesha cluster") + g.log.info("root-squash is disabled on volume") + + # Unexport volume + unexport_nfs_ganesha_volume(self.mnode, self.volname) + ret = wait_for_nfs_ganesha_volume_to_get_unexported(self.mnode, + self.volname) + if not ret: + raise ExecutionError("Failed:Volume %s is not unexported." + % self.volname) + g.log.info("Unexporting of volume is successful") + + # Unmount and cleanup Volume + ret = self.unmount_volume_and_cleanup_volume(self.mounts) + if ret: + g.log.info("Successful unmount and cleanup of volume") + else: + raise ExecutionError("Failed to unmount and cleanup volume") diff --git a/tests/functional/nfs_ganesha/root-squash/test_root_squash_with_volume_restart.py b/tests/functional/nfs_ganesha/root-squash/test_root_squash_with_volume_restart.py new file mode 100755 index 000000000..424cda09b --- /dev/null +++ b/tests/functional/nfs_ganesha/root-squash/test_root_squash_with_volume_restart.py @@ -0,0 +1,177 @@ +# Copyright (C) 2020 Red Hat, Inc. <http://www.redhat.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +""" + Test Cases in this module tests the nfs ganesha version 3 and 4 + rootsquash functionality cases. +""" +from glusto.core import Glusto as g +from glustolibs.gluster.exceptions import ExecutionError +from glustolibs.gluster.gluster_base_class import runs_on, GlusterBaseClass +from glustolibs.gluster.nfs_ganesha_libs import ( + wait_for_nfs_ganesha_volume_to_get_unexported, + wait_for_nfs_ganesha_volume_to_get_exported) +from glustolibs.io.utils import get_mounts_stat +from glustolibs.gluster.nfs_ganesha_ops import ( + set_root_squash, + unexport_nfs_ganesha_volume) +from glustolibs.gluster.volume_ops import (volume_stop, volume_start) +from glustolibs.gluster.lib_utils import (append_string_to_file) +from glustolibs.gluster.glusterfile import set_file_permissions + + +@runs_on([['replicated', 'distributed', 'distributed-replicated', + 'dispersed', 'distributed-dispersed'], + ['nfs']]) +class TestNfsGaneshaRootSquash(GlusterBaseClass): + + def setUp(self): + """ + Setup Volume + """ + self.get_super_method(self, 'setUp')() + + # Setup and mount volume + ret = self.setup_volume_and_mount_volume(mounts=self.mounts) + if not ret: + raise ExecutionError("Failed to setup and mount volume %s" + % self.volname) + g.log.info("Successful in setup and mount volume %s", self.volname) + + def test_root_squash_enable(self): + """ + Tests to verify Nfs Ganesha rootsquash functionality when volume + is restarted + Steps: + 1. Create some files and dirs inside mount point + 2. Set permission as 777 for mount point + 3. Enable root-squash on volume + 4. Create some more files and dirs + 5. Restart volume + 6. Try to edit file created in step 1 + It should not allow to edit the file + 7. Try to edit the file created in step 5 + It should allow to edit the file + """ + # Start IO on mount point. + cmd = ("for i in {1..10}; do touch %s/file$i; done" + % self.mounts[0].mountpoint) + ret, _, err = g.run(self.mounts[0].client_system, cmd, + user=self.mounts[0].user) + self.assertEqual(ret, 0, err) + + # Get stat of all the files/dirs created. + ret = get_mounts_stat(self.mounts) + self.assertTrue(ret, "Stat failed on some of the clients") + g.log.info("Successful in getting stats of files/dirs " + "from mount point") + + # Set mount point permission to 777 + ret = set_file_permissions(self.mounts[0].client_system, + self.mounts[0].mountpoint, 777) + self.assertTrue(ret, "Failed to set permission for directory") + g.log.info("Successfully set permissions for directory") + + # Enable root-squash on volume + ret = set_root_squash(self.servers[0], self.volname) + self.assertTrue(ret, "Failed to enable root-squash on volume") + g.log.info("root-squash is enable on the volume") + + # Start IO on mount point. + cmd = ("for i in {1..10}; do touch %s/Squashfile$i; done" + % self.mounts[0].mountpoint) + ret, _, err = g.run(self.mounts[0].client_system, cmd, + user=self.mounts[0].user) + self.assertEqual(ret, 0, err) + + # Get stat of all the files/dirs created. + ret = get_mounts_stat(self.mounts) + self.assertTrue(ret, "Stat failed on some of the clients") + g.log.info("Successful in getting stats of files/dirs " + "from mount point") + + # Stopping volume + ret = volume_stop(self.mnode, self.volname) + self.assertTrue(ret, ("Failed to stop volume %s" % self.volname)) + g.log.info("Successful in stopping volume %s" % self.volname) + + # Waiting for few seconds for volume unexport. Max wait time is + # 120 seconds. + ret = wait_for_nfs_ganesha_volume_to_get_unexported(self.mnode, + self.volname) + self.assertTrue(ret, ("Failed to unexport volume %s after " + "stopping volume" % self.volname)) + g.log.info("Volume is unexported successfully") + + # Starting volume + ret = volume_start(self.mnode, self.volname) + self.assertTrue(ret, ("Failed to start volume %s" % self.volname)) + g.log.info("Successful in starting volume %s" % self.volname) + + # Waiting for few seconds for volume export. Max wait time is + # 120 seconds. + ret = wait_for_nfs_ganesha_volume_to_get_exported(self.mnode, + self.volname) + self.assertTrue(ret, ("Failed to export volume %s after " + "starting volume" % self.volname)) + g.log.info("Volume is exported successfully") + + # Edit file created by root user + for mount_obj in self.mounts: + ret = append_string_to_file(mount_obj.client_system, + "%s/file10" % mount_obj.mountpoint, + 'hello') + self.assertFalse(ret, "Unexpected:nfsnobody user editing file " + "created by root user should FAIL") + g.log.info("Successful:nfsnobody user failed to edit file " + "created by root user") + + # Edit the file created by nfsnobody user + for mount_obj in self.mounts: + ret = append_string_to_file(mount_obj.client_system, + "%s/Squashfile5" + % mount_obj.mountpoint, + 'hello') + self.assertTrue(ret, "Unexpected:nfsnobody user failed to edit " + "the file created by nfsnobody user") + g.log.info("Successful:nfsnobody user successfully edited the " + "file created by nfsnobody user") + + def tearDown(self): + + # Disable root-squash + ret = set_root_squash(self.mnode, self.volname, squash=False, + do_refresh_config=True) + if not ret: + raise ExecutionError("Failed to disable root-squash on nfs " + "ganesha cluster") + g.log.info("root-squash is disabled on volume") + + # Unexport volume + unexport_nfs_ganesha_volume(self.mnode, self.volname) + ret = wait_for_nfs_ganesha_volume_to_get_unexported(self.mnode, + self.volname) + if not ret: + raise ExecutionError("Failed:Volume %s is not unexported." + % self.volname) + g.log.info("Unexporting of volume is successful") + + # Unmount and cleanup Volume + ret = self.unmount_volume_and_cleanup_volume(self.mounts) + if ret: + g.log.info("Successful unmount and cleanup of volume") + else: + raise ExecutionError("Failed to unmount and cleanup volume") 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 new file mode 100644 index 000000000..9e9cf39c2 --- /dev/null +++ b/tests/functional/nfs_ganesha/test_ganesha_remove_brick.py @@ -0,0 +1,140 @@ +# Copyright (C) 2020 Red Hat, Inc. <http://www.redhat.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +from glusto.core import Glusto as g +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 +from glustolibs.gluster.volume_libs import ( + log_volume_info_and_status, shrink_volume, + wait_for_volume_process_to_be_online) + + +@runs_on([['distributed', 'distributed-arbiter', + 'distributed-replicated', 'distributed-dispersed'], + ['nfs']]) +class TestGaneshaRemoveBrick(GlusterBaseClass): + """ + This test case validates remove brick functionality on volumes exported + through nfs-ganesha + """ + + @classmethod + def setUpClass(cls): + """ + Setup nfs-ganesha if not exists. + Upload IO scripts to clients + """ + cls.get_super_method(cls, 'setUpClass')() + + # Upload IO scripts for running IO on mounts + cls.script_upload_path = ("/usr/share/glustolibs/io/scripts/" + "file_dir_ops.py") + ret = upload_scripts(cls.clients, cls.script_upload_path) + if not ret: + raise ExecutionError("Failed to upload IO scripts to clients %s" % + cls.clients) + g.log.info("Successfully uploaded IO scripts to clients %s", + cls.clients) + + def setUp(self): + """ + Setup Volume and Mount Volume + """ + ret = self.setup_volume_and_mount_volume(mounts=self.mounts) + if not ret: + raise ExecutionError("Failed to setup and mount volume %s" + % self.volname) + g.log.info("Successful in setup and mount volume %s", self.volname) + + def test_nfs_ganesha_remove_brick(self): + """ + Verify remove brick operation while IO is running + Steps: + 1. Start IO on mount points + 2. Perform remove brick operation + 3. Validate IOs + """ + # pylint: disable=too-many-statements + # Start IO on all mount points + all_mounts_procs, count = [], 1 + for mount_obj in self.mounts: + cmd = ("/usr/bin/env python %s create_deep_dirs_with_files " + "--dirname-start-num %d " + "--dir-depth 2 " + "--dir-length 10 " + "--max-num-of-dirs 5 " + "--num-of-files 5 %s" % (self.script_upload_path, count, + mount_obj.mountpoint)) + proc = g.run_async(mount_obj.client_system, cmd, + user=mount_obj.user) + all_mounts_procs.append(proc) + count += 10 + + # Get stat of all the files/dirs created. + ret = get_mounts_stat(self.mounts) + self.assertTrue(ret, "Stat failed on some of the clients") + g.log.info("Successfully got stat of all files/dirs created") + + # Perform remove brick operation + ret = shrink_volume(self.mnode, self.volname) + self.assertTrue(ret, ("Remove brick operation failed on " + "%s", self.volname)) + g.log.info("Remove brick operation is successful on " + "volume %s", self.volname) + + # Wait for volume processes to be online + ret = wait_for_volume_process_to_be_online(self.mnode, self.volname) + self.assertTrue(ret, ("All volume %s processes failed to come up " + "online", self.volname)) + g.log.info("All volume %s processes came up " + "online successfully after remove brick operation", + self.volname) + + # Log volume info and status after performing remove brick + ret = log_volume_info_and_status(self.mnode, self.volname) + self.assertTrue(ret, ("Logging volume info and status failed on " + "volume %s", self.volname)) + g.log.info("Successful in logging volume info and status of volume %s", + self.volname) + + # Validate IO + ret = validate_io_procs(all_mounts_procs, self.mounts) + self.assertTrue(ret, "IO failed on some of the clients") + g.log.info("Successfully validated all io's") + + # Get stat of all the files/dirs created. + ret = get_mounts_stat(self.mounts) + self.assertTrue(ret, "Stat failed on some of the clients") + g.log.info("Successfully got stat of all files/dirs created") + + def tearDown(self): + """ + Unmount and cleanup volume + """ + # Unmount volume + ret = self.unmount_volume(self.mounts) + if ret: + g.log.info("Successfully unmounted the volume") + else: + g.log.error("Failed to unmount volume") + + # Cleanup volume + ret = self.cleanup_volume() + if not ret: + raise ExecutionError("Failed to cleanup volume") + g.log.info("Cleanup volume %s completed successfully", self.volname) 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 8c90f953d..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): """ @@ -172,6 +159,59 @@ class TestNfsGaneshaVolumeExports(NfsGaneshaClusterSetupClass): "ganesha.enable 'on'" % self.volname) g.log.info("Exported volume after enabling nfs-ganesha cluster") + def test_nfs_ganesha_exportID_after_vol_restart(self): + """ + Tests script to check nfs-ganesha volume gets exported with same + Export ID after multiple volume restarts. + Steps: + 1. Create and Export the Volume + 2. Stop and Start the volume multiple times + 3. Check for export ID + Export ID should not change + """ + for i in range(1, 4): + g.log.info("Testing nfs ganesha exportID after volume stop and " + "start.\n Count : %s", str(i)) + + # Stopping volume + ret = volume_stop(self.mnode, self.volname) + self.assertTrue(ret, ("Failed to stop volume %s" % self.volname)) + g.log.info("Volume is stopped") + + # Waiting for few seconds for volume unexport. Max wait time is + # 120 seconds. + ret = wait_for_nfs_ganesha_volume_to_get_unexported(self.mnode, + self.volname) + self.assertTrue(ret, ("Failed to unexport volume %s after " + "stopping volume" % self.volname)) + g.log.info("Volume is unexported via ganesha") + + # Starting volume + ret = volume_start(self.mnode, self.volname) + self.assertTrue(ret, ("Failed to start volume %s" % self.volname)) + g.log.info("Volume is started") + + # Waiting for few seconds for volume export. Max wait time is + # 120 seconds. + ret = wait_for_nfs_ganesha_volume_to_get_exported(self.mnode, + self.volname) + self.assertTrue(ret, ("Failed to export volume %s after " + "starting volume" % self.volname)) + g.log.info("Volume is exported via ganesha") + + # Check for Export ID + cmd = ("cat /run/gluster/shared_storage/nfs-ganesha/exports/" + "export.*.conf | grep Export_Id | grep -Eo '[0-9]'") + ret, out, _ = g.run(self.mnode, cmd) + self.assertEqual(ret, 0, "Unable to get export ID of the volume %s" + % self.volname) + g.log.info("Successful in getting volume export ID: %s " % out) + self.assertEqual(out.strip("\n"), "2", + "Export ID changed after export and unexport " + "of volume: %s" % out) + g.log.info("Export ID of volume is same after export " + "and export: %s" % out) + def tearDown(self): """ Unexport volume @@ -197,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. """ @@ -218,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) @@ -338,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. """ @@ -359,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) @@ -515,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. """ @@ -536,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) @@ -754,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) |