diff options
author | Nigel Babu <nigelb@redhat.com> | 2018-03-05 15:49:23 +0530 |
---|---|---|
committer | Nigel Babu <nigelb@redhat.com> | 2018-03-27 16:05:15 +0530 |
commit | fb5145be2db1a7c96b008af8a40e3b7b18df9673 (patch) | |
tree | 3ca087e0996bfd975e97b4f0235421a37d2e4767 /tests/functional/nfs_ganesha | |
parent | 8804c9499e9ed0d37823dc55d03eb7792907cf0b (diff) |
Fix up coding style issues in tests
Change-Id: I14609030983d4485dbce5a4ffed1e0353e3d1bc7
Diffstat (limited to 'tests/functional/nfs_ganesha')
-rw-r--r-- | tests/functional/nfs_ganesha/__init__.py | 0 | ||||
-rw-r--r-- | tests/functional/nfs_ganesha/test_nfs_ganesha_acls.py (renamed from tests/functional/nfs_ganesha/acls/test_nfs_ganesha_acls.py) | 17 | ||||
-rw-r--r-- | tests/functional/nfs_ganesha/test_nfs_ganesha_run_io_multiple_clients.py | 7 | ||||
-rw-r--r-- | tests/functional/nfs_ganesha/test_nfs_ganesha_sanity.py (renamed from tests/functional/nfs_ganesha/sanity/test_nfs_ganesha_sanity.py) | 0 | ||||
-rw-r--r-- | tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py (renamed from tests/functional/nfs_ganesha/exports/test_nfs_ganesha_volume_exports.py) | 59 |
5 files changed, 35 insertions, 48 deletions
diff --git a/tests/functional/nfs_ganesha/__init__.py b/tests/functional/nfs_ganesha/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/functional/nfs_ganesha/__init__.py diff --git a/tests/functional/nfs_ganesha/acls/test_nfs_ganesha_acls.py b/tests/functional/nfs_ganesha/test_nfs_ganesha_acls.py index 871ad1090..12a825c2e 100644 --- a/tests/functional/nfs_ganesha/acls/test_nfs_ganesha_acls.py +++ b/tests/functional/nfs_ganesha/test_nfs_ganesha_acls.py @@ -47,6 +47,7 @@ class TestNfsGaneshaAcls(NfsGaneshaVolumeBaseClass): "ganesha cluster") def test_nfsv4_acls(self): + # pylint: disable=too-many-locals source_file = ("/usr/share/glustolibs/io/scripts/nfs_ganesha/" "nfsv4_acl_test.sh") @@ -75,32 +76,32 @@ class TestNfsGaneshaAcls(NfsGaneshaVolumeBaseClass): if option_flag: g.log.info("This acl test required mount option to be " - "vers=4 in %s" % client) + "vers=4 in %s", client) continue dirname = mountpoint + "/" + "testdir_" + client cmd = "[ -d %s ] || mkdir %s" % (dirname, dirname) ret, _, _ = g.run(client, cmd) - self.assertEqual(ret, 0, ("Failed to create dir %s for running " - "acl test" % dirname)) + self.assertEqual(ret, 0, "Failed to create dir %s for running " + "acl test" % dirname) cmd = "sh %s %s" % (test_acl_file, dirname) ret, out, _ = g.run(client, cmd) self.assertEqual(ret, 0, ("Failed to execute acl test on %s" % client)) - g.log.info("ACL test output in %s : %s" % (client, out)) + g.log.info("ACL test output in %s : %s", client, out) acl_output = out.split('\n')[:-1] for output in acl_output: match = re.search("^OK.*", output) if match is None: - self.assertTrue(False, ("Unexpected behaviour in acl " - "functionality in %s" % client)) + self.assertTrue(False, "Unexpected behaviour in acl " + "functionality in %s" % client) cmd = "rm -rf %s" % dirname ret, _, _ = g.run(client, cmd) - self.assertEqual(ret, 0, ("Failed to remove dir %s after running " - "acl test" % dirname)) + self.assertEqual(ret, 0, "Failed to remove dir %s after running " + "acl test" % dirname) def tearDown(self): ret = disable_acl(self.servers[0], self.volname) 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 4a414c09f..b6a1a4391 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 @@ -84,10 +84,3 @@ class TestNfsGaneshaWithDifferentIOPatterns(NfsGaneshaVolumeBaseClass): # pcs status output _, _, _ = g.run(self.servers[0], "pcs status") - - @classmethod - def tearDownClass(cls): - (NfsGaneshaVolumeBaseClass. - tearDownClass. - im_func(cls, - teardown_nfs_ganesha_cluster=False)) diff --git a/tests/functional/nfs_ganesha/sanity/test_nfs_ganesha_sanity.py b/tests/functional/nfs_ganesha/test_nfs_ganesha_sanity.py index a00c22a5a..a00c22a5a 100644 --- a/tests/functional/nfs_ganesha/sanity/test_nfs_ganesha_sanity.py +++ b/tests/functional/nfs_ganesha/test_nfs_ganesha_sanity.py diff --git a/tests/functional/nfs_ganesha/exports/test_nfs_ganesha_volume_exports.py b/tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py index 0594d2118..06cd221ba 100644 --- a/tests/functional/nfs_ganesha/exports/test_nfs_ganesha_volume_exports.py +++ b/tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py @@ -19,6 +19,9 @@ refresh configs, cluster enable/disable functionality. """ +import time +import os +import re from glusto.core import Glusto as g from glustolibs.gluster.gluster_base_class import runs_on from glustolibs.gluster.nfs_ganesha_libs import ( @@ -37,13 +40,10 @@ from glustolibs.gluster.volume_ops import (volume_stop, volume_start, from glustolibs.gluster.volume_libs import (get_volume_options, setup_volume, cleanup_volume, is_volume_exported, log_volume_info_and_status) -import time from glustolibs.io.utils import (validate_io_procs, list_all_files_and_dirs_mounts, wait_for_io_to_complete) from glustolibs.gluster.exceptions import ExecutionError -import os -import re @runs_on([['replicated', 'distributed', 'distributed-replicated', @@ -67,7 +67,7 @@ class TestNfsGaneshaVolumeExports(NfsGaneshaVolumeBaseClass): for i in range(5): g.log.info("Testing nfs ganesha export after volume stop/start." - "Count : %s " % str(i)) + "Count : %s", str(i)) # Stoping volume ret = volume_stop(self.mnode, self.volname) @@ -99,7 +99,7 @@ class TestNfsGaneshaVolumeExports(NfsGaneshaVolumeBaseClass): for i in range(5): g.log.info("Executing multiple enable/disable of nfs ganesha " - "cluster. Count : %s " % str(i)) + "cluster. Count : %s ", str(i)) ret, _, _ = disable_nfs_ganesha(self.mnode) self.assertEqual(ret, 0, ("Failed to disable nfs-ganesha cluster")) @@ -111,9 +111,9 @@ class TestNfsGaneshaVolumeExports(NfsGaneshaVolumeBaseClass): self.assertEqual(ret, 0, ("Failed to get ganesha.enable volume" " option for %s " % self.volume)) - if vol_option['ganesha.enable'] != 'off': - self.assertTrue(False, ("Failed to unexport volume by default " - "after disabling cluster")) + self.assertEqual(vol_option.get('ganesha.enable'), 'off', "Failed " + "to unexport volume by default after disabling " + "cluster") ret, _, _ = enable_nfs_ganesha(self.mnode) self.assertEqual(ret, 0, ("Failed to enable nfs-ganesha cluster")) @@ -125,11 +125,10 @@ class TestNfsGaneshaVolumeExports(NfsGaneshaVolumeBaseClass): self.assertEqual(ret, 0, ("Failed to get ganesha.enable volume" " option for %s " % self.volume)) - if vol_option['ganesha.enable'] != 'off': - self.assertTrue(False, ("Volume %s is exported by default " - "after disable and enable of cluster" - "which is unexpected." - % self.volname)) + self.assertEqual(vol_option.get('ganesha.enable'), 'off', "Volume " + "%s is exported by default after disable and " + "enable of cluster which is unexpected." % + self.volname) # Export volume after disable and enable of cluster ret, _, _ = export_nfs_ganesha_volume( @@ -250,21 +249,17 @@ class TestNfsGaneshaMultiVolumeExportsWithIO(NfsGaneshaIOBaseClass): # Export volume with nfs ganesha, if it is not exported already vol_option = get_volume_options(self.mnode, self.volume['name'], option='ganesha.enable') - if vol_option is None: - self.assertTrue(False, ("Failed to get ganesha.enable volume" - " option for %s " - % self.volume['name'])) + self.assertIsNotNone(vol_option, "Failed to get ganesha.enable " + "volume option for %s" % self.volume['name']) if vol_option['ganesha.enable'] != 'on': - ret, out, err = export_nfs_ganesha_volume( + ret, _, _ = export_nfs_ganesha_volume( mnode=self.mnode, volname=self.volume['name']) - if ret != 0: - self.assertTrue(False, ("Failed to export volume %s " - "as NFS export" - % self.volume['name'])) + self.assertEqual(ret, 0, "Failed to export volume %s as NFS " + "export" % self.volume['name']) time.sleep(5) else: - g.log.info("Volume %s is exported already" - % self.volume['name']) + g.log.info("Volume %s is exported already", + self.volume['name']) # Waiting for few seconds for volume export. Max wait time is # 120 seconds. @@ -277,9 +272,8 @@ class TestNfsGaneshaMultiVolumeExportsWithIO(NfsGaneshaIOBaseClass): # Log Volume Info and Status ret = log_volume_info_and_status(self.mnode, self.volume['name']) - if not ret: - self.assertTrue(False, ("Logging volume %s info and status ", - "failed " % self.volume['name'])) + self.assertTrue(ret, "Logging volume %s info and status failed" + % self.volume['name']) # Validate IO g.log.info("Wait for IO to complete and validate IO ...") @@ -301,8 +295,8 @@ class TestNfsGaneshaMultiVolumeExportsWithIO(NfsGaneshaIOBaseClass): volname = "nfsvol" + str(i) volinfo = get_volume_info(self.mnode, volname) if volinfo is None or volname not in volinfo: - g.log.info("Volume %s does not exist in %s" - % (volname, self.mnode)) + g.log.info("Volume %s does not exist in %s", + volname, self.mnode) continue # Unexport volume, if it is not unexported already @@ -313,15 +307,14 @@ class TestNfsGaneshaMultiVolumeExportsWithIO(NfsGaneshaIOBaseClass): " option for %s " % volname) if vol_option['ganesha.enable'] != 'off': if is_volume_exported(self.mnode, volname, "nfs"): - ret, out, err = unexport_nfs_ganesha_volume( + ret, _, _ = unexport_nfs_ganesha_volume( mnode=self.mnode, volname=volname) if ret != 0: raise ExecutionError("Failed to unexport volume %s " % volname) time.sleep(5) else: - g.log.info("Volume %s is unexported already" - % volname) + g.log.info("Volume %s is unexported already", volname) _, _, _ = g.run(self.mnode, "showmount -e") @@ -420,7 +413,7 @@ class TestNfsGaneshaSubDirExportsWithIO(NfsGaneshaIOBaseClass): # Select the subdirectory required for the test. cmd = "find %s -type d -links 2 | grep -ve '.trashcan'" % mountpoint - ret, out, err = g.run(client, cmd) + ret, out, _ = g.run(client, cmd) if ret != 0: raise ExecutionError("Failed to list the deep level directories") self.subdir_path = out.split("\n")[0] |