1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# Copyright (C) 2015-2016 Red Hat, Inc. <http://www.redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
""" 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 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")
ret = restart_glusterd(self.servers)
self.assertTrue(ret, "Failed to restart glusterd on all servers")
g.log.info("Successfully restarted glusterd on all servers")
# Check if glusterd is running on all servers(expected: active)
g.log.info("Check if glusterd is running on all servers"
"(expected: active)")
ret = is_glusterd_running(self.servers)
self.assertEqual(ret, 0, "Glusterd is not running on all servers")
g.log.info("Glusterd is running on all the servers")
# Stop glusterd on all servers
g.log.info("Stop glusterd on all servers")
ret = stop_glusterd(self.servers)
self.assertTrue(ret, "Failed to stop glusterd on all servers")
g.log.info("Successfully stopped glusterd on all servers")
# Check if glusterd is running on all servers(expected: not running)
g.log.info("Check if glusterd is running on all servers"
"(expected: not running)")
ret = is_glusterd_running(self.servers)
self.assertNotEqual(ret, 0, "Glusterd is still running on some "
"servers")
g.log.info("Glusterd not running on any servers as expected.")
# Start glusterd on all servers
g.log.info("Start glusterd on all servers")
ret = start_glusterd(self.servers)
self.assertTrue(ret, "Failed to start glusterd on all servers")
g.log.info("Successfully started glusterd on all servers")
# Check if glusterd is running on all servers(expected: active)
g.log.info("Check if glusterd is running on all servers"
"(expected: active)")
ret = is_glusterd_running(self.servers)
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
"""
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)
|