From 6837b2793bc3d2cc488aa49491f3f5ff09e925b7 Mon Sep 17 00:00:00 2001 From: M S Vishwanath Bhat Date: Thu, 19 May 2016 18:53:35 +0530 Subject: distaf: Adding GlusterBaseClass to distaflibs-gluster GlusterBaseClass is the base class for gluster related test cases. This has setup() method which takes care of creating volumes with correct volume type after checking global_mode flags etc. So all tests are recommended to use this base class. The teardown() method is to teardown the setup that test has created. Each test case should teardown, any setup it does apart from what is done in setup(). The cleanup() method is used internally for cleaning up the volumes when there is a change of volume type between the tests. This patch also makes relevant import path changes. The changes from tc.nodes[] to tc.servers[] in distaf-core broke few tests. This patch fixes them. Change-Id: I1a8ae20ca7cac13b7d25c587f98c23b430054a57 BUG: 1333738 Signed-off-by: M S Vishwanath Bhat Reviewed-on: http://review.gluster.org/14239 Tested-by: M S Vishwanath Bhat Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Apeksha D khakharia Reviewed-by: Arthy Loganathan Reviewed-by: ShwethaHPanduranga --- .../tests_d/examples/test_basic_gluster_tests.py | 33 ++++++++++++++++------ tests/distaf/tests_d/examples/test_docstring.py | 2 +- tests/distaf/tests_d/examples/test_passfail.py | 6 ++-- 3 files changed, 28 insertions(+), 13 deletions(-) (limited to 'tests/distaf/tests_d/examples') diff --git a/tests/distaf/tests_d/examples/test_basic_gluster_tests.py b/tests/distaf/tests_d/examples/test_basic_gluster_tests.py index 47dfd9372a7..d981c0b8ab5 100644 --- a/tests/distaf/tests_d/examples/test_basic_gluster_tests.py +++ b/tests/distaf/tests_d/examples/test_basic_gluster_tests.py @@ -17,10 +17,8 @@ from distaf.util import tc, testcase -from distaf.gluster_base_class import GlusterBaseClass -from distaf.gluster_libs.mount_ops import mount_volume, umount_volume -from distaf.gluster_libs.volume_ops import (setup_vol, stop_volume, - delete_volume) +from distaflibs.gluster.gluster_base_class import GlusterBaseClass +from distaflibs.gluster.mount_ops import mount_volume, umount_volume @testcase("gluster_basic_test") @@ -28,17 +26,17 @@ class gluster_basic_test(GlusterBaseClass): """ runs_on_volumes: ALL runs_on_protocol: [ glusterfs, nfs ] - reuse_setup: True + reuse_setup: False """ def run(self): _rc = True client = self.clients[0] tc.run(self.mnode, "gluster volume status %s" % self.volname) - ret, _, _ = mount_volume(self.volname, self.mount_proto, \ - self.mountpoint, mclient=client) + ret, _, _ = mount_volume(self.volname, self.mount_proto, + self.mountpoint, mclient=client) if ret != 0: - tc.logger.error("Unable to mount the volume %s in %s" \ - "Please check the logs" % (self.volname, client)) + tc.logger.error("Unable to mount the volume %s in %s" + "Please check the logs" % (self.volname, client)) return False ret, _, _ = tc.run(client, "cp -r /etc %s" % self.mountpoint) if ret != 0: @@ -47,3 +45,20 @@ class gluster_basic_test(GlusterBaseClass): tc.run(client, "rm -rf %s/etc" % self.mountpoint) umount_volume(client, self.mountpoint) return _rc + + +@testcase("dummy_testcase") +class dummy_testcase(GlusterBaseClass): + """ + runs_on_volumes: ALL + runs_on_protocol: [ glusterfs, nfs ] + reuse_setup: False + """ + def run(self): + _rc = True + ret, _, _ = tc.run(self.mnode, "gluster volume status %s" % self.volname) + if ret != 0: + tc.logger.error("Unable to thet the status of %s", self.volname) + _rc = False + + return _rc diff --git a/tests/distaf/tests_d/examples/test_docstring.py b/tests/distaf/tests_d/examples/test_docstring.py index 1a73998eb66..a939da8da9e 100644 --- a/tests/distaf/tests_d/examples/test_docstring.py +++ b/tests/distaf/tests_d/examples/test_docstring.py @@ -17,7 +17,7 @@ from distaf.util import tc, testcase -from distaf.gluster_base_class import GlusterBaseClass +from distaflibs.gluster.gluster_base_class import GlusterBaseClass # An example with both doc and config in docstring diff --git a/tests/distaf/tests_d/examples/test_passfail.py b/tests/distaf/tests_d/examples/test_passfail.py index 3b14c117190..78396349fc4 100644 --- a/tests/distaf/tests_d/examples/test_passfail.py +++ b/tests/distaf/tests_d/examples/test_passfail.py @@ -17,7 +17,7 @@ from distaf.util import tc, testcase -from distaf.gluster_base_class import GlusterBaseClass +from distaflibs.gluster.gluster_base_class import GlusterBaseClass @testcase("this_should_pass") @@ -44,7 +44,7 @@ class GoingToPass(GlusterBaseClass): config = self.config_data tc.logger.info("Testing connection and command exec") tc.logger.debug("Tag 1 is %s" % config["tags"][0]) - ret, _, _ = tc.run(self.nodes[0], "hostname") + ret, _, _ = tc.run(self.servers[0], "hostname") if ret != 0: tc.logger.error("hostname command failed") return False @@ -80,7 +80,7 @@ class GoingToFail(GlusterBaseClass): config = self.config_data tc.logger.info("Testing fail output") tc.logger.debug("Tag 1 is %s" % config["tags"][0]) - ret, _, _ = tc.run(self.nodes[0], "false") + ret, _, _ = tc.run(self.servers[0], "false") if ret != 0: tc.logger.error("false command failed") return False -- cgit