diff options
author | Shwetha Panduranga <spandura@redhat.com> | 2017-02-27 18:40:27 +0530 |
---|---|---|
committer | Shwetha Panduranga <spandura@redhat.com> | 2017-02-27 18:40:27 +0530 |
commit | c7863b4ecc9b329af84999da39c892982386c339 (patch) | |
tree | e62ea94054614b2c2f259bc007290cdd24a82f7c /tests/functional/bvt | |
parent | daca62f4b7f876bf675e5b29b643e3d472903597 (diff) |
Adding steps to test to wait for glusterd to be online and
validate all peers are in connected state.
Change-Id: I3aa725aea35d404326610a2490b3f48e7fa46546
Signed-off-by: Shwetha Panduranga <spandura@redhat.com>
Diffstat (limited to 'tests/functional/bvt')
-rw-r--r-- | tests/functional/bvt/test_basic.py | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/tests/functional/bvt/test_basic.py b/tests/functional/bvt/test_basic.py index 83cac0e2c..336443940 100644 --- a/tests/functional/bvt/test_basic.py +++ b/tests/functional/bvt/test_basic.py @@ -17,16 +17,42 @@ """ Description: BVT-Basic Tests """ import pytest +import time from glusto.core import Glusto as g from glustolibs.gluster.gluster_base_class import GlusterBaseClass from glustolibs.gluster.gluster_init import ( is_glusterd_running, restart_glusterd, start_glusterd, stop_glusterd) +from glustolibs.gluster.peer_ops import is_peer_connected, peer_status class TestGlusterdSanity(GlusterBaseClass): + """GLusterd Sanity check + """ + def are_peers_in_connected_state(self): + """Validate if all the peers are in connected state from all servers. + """ + _rc = True + # Validate if peer is connected from all the servers + for server in self.servers: + ret = is_peer_connected(server, self.servers) + if not ret: + _rc = False + + # Peer Status from mnode + peer_status(self.mnode) + + return _rc + + def setUp(self): + """setUp required for tests + """ + GlusterBaseClass.setUp.im_func(self) + self.test_method_complete = False + @pytest.mark.bvt_basic def test_glusterd_restart_stop_start(self): - """Tests glusterd stop, start, restart + """Tests glusterd stop, start, restart and validate if all + peers are in connected state after glusterd restarts. """ # restart glusterd on all servers g.log.info("Restart glusterd on all servers") @@ -68,12 +94,34 @@ class TestGlusterdSanity(GlusterBaseClass): self.assertEqual(ret, 0, "Glusterd is not running on all servers") g.log.info("Glusterd is running on all the servers") + # Wait for all the glusterd's to establish communication. + time.sleep(30) + + # Validate all the peers are in connected state + g.log.info("Validating all the peers are in Cluster and Connected") + ret = self.are_peers_in_connected_state() + self.assertTrue(ret, "Validating Peers to be in Cluster Failed") + g.log.info("All peers are in connected state") + + self.test_method_complete = True + def tearDown(self): """In case of any failure restart glusterd on all servers """ - # restart glusterd on all servers - g.log.info("Restart glusterd on all servers") - ret = restart_glusterd(self.servers) - self.assertTrue(ret, "Failed to restart glusterd on all servers") - g.log.info("Successfully restarted glusterd on all servers") + if not self.test_method_complete: + # restart glusterd on all servers + g.log.info("Restart glusterd on all servers") + ret = restart_glusterd(self.servers) + self.assertTrue(ret, "Failed to restart glusterd on all servers") + g.log.info("Successfully restarted glusterd on all servers") + + # Wait for all the glusterd's to establish communication. + time.sleep(30) + + # Validate all the peers are in connected state + g.log.info("Validating all the peers are in Cluster and Connected") + ret = self.are_peers_in_connected_state() + self.assertTrue(ret, "Validating Peers to be in Cluster Failed") + g.log.info("All peers are in connected state") + GlusterBaseClass.tearDown.im_func(self) |