diff options
Diffstat (limited to 'tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py')
-rwxr-xr-x | tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py | 114 |
1 files changed, 58 insertions, 56 deletions
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) |