summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/test_baseclass_variables.py12
-rw-r--r--examples/test_glusterd_ops.py28
-rw-r--r--examples/test_peer_ops.py45
-rw-r--r--examples/tests_using_baseclass.py16
4 files changed, 69 insertions, 32 deletions
diff --git a/examples/test_baseclass_variables.py b/examples/test_baseclass_variables.py
index 86488d6..09a0ad9 100644
--- a/examples/test_baseclass_variables.py
+++ b/examples/test_baseclass_variables.py
@@ -1,10 +1,16 @@
""" This Module demostrates how to use functions available in volume_ops
"""
from glusto.core import Glusto as g
-from glustolibs.gluster.gluster_base_class import (GlusterBaseClass)
+from glustolibs.gluster.gluster_base_class import (
+ GlusterBaseClass,
+ runs_on,
+)
-class DemoGlusyerBaseClassVariables(GlusterBaseClass):
+
+@runs_on([['distributed-replicated', 'replicated'],
+ ['glusterfs', 'nfs']])
+class DemoGlusterBaseClassVariables(GlusterBaseClass):
"""Demonstrating all the functions available in volume_ops module
"""
@classmethod
@@ -13,7 +19,7 @@ class DemoGlusyerBaseClassVariables(GlusterBaseClass):
"""
# Read all the cluster config from the g.config and assign it to
# class variables
- GlusterBaseClass.setUpClass.im_func(cls)
+ cls.get_super_method(cls, 'setUpClass')()
# Servers (list)
g.log.info("Servers:\n %s\n\n", cls.servers)
diff --git a/examples/test_glusterd_ops.py b/examples/test_glusterd_ops.py
index 39cad71..dc9bc21 100644
--- a/examples/test_glusterd_ops.py
+++ b/examples/test_glusterd_ops.py
@@ -2,28 +2,39 @@
module
"""
from glusto.core import Glusto as g
-from glustolibs.gluster.gluster_base_class import GlusterBaseClass
+
from glustolibs.gluster.exceptions import ExecutionError
+from glustolibs.gluster.gluster_base_class import (
+ GlusterBaseClass,
+ runs_on,
+)
from glustolibs.gluster.gluster_init import (
- is_glusterd_running, restart_glusterd, start_glusterd, stop_glusterd)
+ is_glusterd_running,
+ restart_glusterd,
+ start_glusterd,
+ stop_glusterd,
+)
+@runs_on([['distributed-replicated', 'replicated'],
+ ['glusterfs', 'nfs']])
class DemoGlusterInitClass(GlusterBaseClass):
"""Demonstrating all the functions available in gluster_init module
"""
@classmethod
def setUpClass(cls):
- """
+ """Define it when you need to execute something else than super's
+ setUpClass method.
"""
# Read all the cluster config from the g.config and assign it to
# class variables
- GlusterBaseClass.setUpClass.im_func(cls)
+ cls.get_super_method(cls, 'setUpClass')()
def setUp(self):
"""setUp required for tests
"""
# Calling GlusterBaseClass setUp
- GlusterBaseClass.setUp.im_func(self)
+ self.get_super_method(self, 'setUp')()
# Check if glusterd is running on all servers(expected: active)
g.log.info("Check if glusterd is running on all servers %s"
@@ -103,10 +114,11 @@ class DemoGlusterInitClass(GlusterBaseClass):
self.servers)
# Calling GlusterBaseClass tearDown
- GlusterBaseClass.tearDown.im_func(self)
+ self.get_super_method(self, 'tearDown')()
@classmethod
def tearDownClass(cls):
+ """Define it when you need to execute something else than super's
+ tearDownClass method.
"""
- """
- GlusterBaseClass.tearDownClass.im_func(cls)
+ cls.get_super_method(cls, 'tearDownClass')()
diff --git a/examples/test_peer_ops.py b/examples/test_peer_ops.py
index 12f3677..8a42f70 100644
--- a/examples/test_peer_ops.py
+++ b/examples/test_peer_ops.py
@@ -1,28 +1,41 @@
""" This Module demostrates how to use functions available in peer_ops module
"""
-import socket
import random
import re
+import socket
+
from glusto.core import Glusto as g
-from glustolibs.gluster.gluster_base_class import GlusterBaseClass
+
from glustolibs.gluster.exceptions import ExecutionError
+from glustolibs.gluster.gluster_base_class import (
+ GlusterBaseClass,
+ runs_on,
+)
from glustolibs.gluster.peer_ops import (
- pool_list, peer_probe, peer_status, peer_probe_servers,
- nodes_from_pool_list, is_peer_connected, peer_detach, peer_detach_servers,
- get_peer_status, get_pool_list)
-
-
+ get_peer_status,
+ get_pool_list,
+ is_peer_connected,
+ nodes_from_pool_list,
+ peer_detach,
+ peer_detach_servers,
+ peer_probe,
+ peer_probe_servers,
+ peer_status,
+ pool_list,
+)
+
+
+@runs_on([['distributed-replicated', 'replicated'],
+ ['glusterfs', 'nfs']])
class DemoPeerOpsClass(GlusterBaseClass):
"""Demonstrating all the functions available in peer_ops module
"""
@classmethod
def setUpClass(cls):
- """
- """
# Read all the cluster config from the g.config and assign it to
# class variables
- GlusterBaseClass.setUpClass.im_func(cls)
+ cls.get_super_method(cls, 'setUpClass')()
# Detach all the servers if it's already attached to the cluster
nodes_in_pool_list = nodes_from_pool_list(cls.mnode)
@@ -67,9 +80,8 @@ class DemoPeerOpsClass(GlusterBaseClass):
server, out)
def setUp(self):
- """
- """
- GlusterBaseClass.setUp.im_func(self)
+ self.get_super_method(self, 'setUp')()
+
# Peer probe servers
g.log.info("Peer Probe servers '%s'", self.servers)
ret = peer_probe_servers(self.mnode, self.servers)
@@ -320,10 +332,11 @@ class DemoPeerOpsClass(GlusterBaseClass):
g.log.info("Successfully detached servers %s from node %s",
nodes_in_pool_list, self.mnode)
- GlusterBaseClass.tearDown.im_func(self)
+ self.get_super_method(self, 'tearDown')()
@classmethod
def tearDownClass(cls):
+ """Define it when you need to execute something else than super's
+ tearDownClass method.
"""
- """
- GlusterBaseClass.tearDownClass.im_func(cls)
+ cls.get_super_method(cls, 'tearDownClass')()
diff --git a/examples/tests_using_baseclass.py b/examples/tests_using_baseclass.py
index 569feac..fecd412 100644
--- a/examples/tests_using_baseclass.py
+++ b/examples/tests_using_baseclass.py
@@ -14,7 +14,10 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-from glustolibs.gluster.gluster_base_class import (GlusterBaseClass, runs_on)
+from glustolibs.gluster.gluster_base_class import (
+ GlusterBaseClass,
+ runs_on,
+)
""" Example1: Using GlusterBaseClass
"""
@@ -33,7 +36,7 @@ class TestUsingGlusterBaseClass(GlusterBaseClass):
# Calling GlusterBaseClass setUpClass. This will read all the
# Variables from the g.config and will assign values to variables to
# Use in the tests
- GlusterBaseClass.setUpClass.im_func(cls)
+ cls.get_super_method(cls, 'setUpClass')()
# Add test class setup code here.
@@ -41,7 +44,7 @@ class TestUsingGlusterBaseClass(GlusterBaseClass):
"""setUp before the test
"""
# Calling GlusterBaseClass setUp
- GlusterBaseClass.setUp.im_func(self)
+ self.get_super_method(self, 'setUp')()
# Add test setup code here
@@ -60,13 +63,16 @@ class TestUsingGlusterBaseClass(GlusterBaseClass):
# Add test teardown code here
# Calling GlusterBaseClass teardown
- GlusterBaseClass.tearDown.im_func(self)
+ self.get_super_method(self, 'tearDown')()
@classmethod
def tearDownClass(cls):
"""tearDownClass. This will be executed once per class.
+
+ Define it when you need to execute something else than super's
+ tearDownClass method.
"""
# Add test class teardown code here
# Calling GlusterBaseClass tearDownClass.
- GlusterBaseClass.tearDownClass.im_func(cls)
+ cls.get_super_method(cls, 'tearDownClass')()