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
|
# Copyright (C) 2018-2020 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:
No Errors should generate in glusterd.log while detaching
node from gluster
"""
import random
from glusto.core import Glusto as g
from glustolibs.gluster.exceptions import ExecutionError
from glustolibs.gluster.gluster_base_class import GlusterBaseClass
from glustolibs.gluster.peer_ops import (peer_detach_servers,
peer_probe_servers,
is_peer_connected)
class GlusterdLogsWhilePeerDetach(GlusterBaseClass):
def tearDown(self):
"""
tearDown for every test
"""
# checking for peer status from every node
ret = is_peer_connected(self.mnode, self.servers)
if not ret:
ret = peer_probe_servers(self.mnode, self.random_server)
if not ret:
raise ExecutionError("Failed to peer probe failed in "
"servers %s" % self.random_server)
g.log.info("All peers are in connected state")
# Calling GlusterBaseClass tearDown
self.get_super_method(self, 'tearDown')()
def test_logs_while_peer_detach(self):
'''
-> Detach the node from peer
-> Check that any error messages related to peer detach
in glusterd log file
-> No errors should be there in glusterd log file
'''
# Getting timestamp
_, timestamp, _ = g.run_local('date +%s')
timestamp = timestamp.strip()
# glusterd logs
ret, _, _ = g.run(self.mnode,
'cp /var/log/glusterfs/glusterd.log '
'/var/log/glusterfs/glusterd_%s.log' % timestamp)
if ret:
raise ExecutionError("Failed to copy glusterd logs")
# Clearing the existing glusterd log file
ret, _, _ = g.run(self.mnode, 'echo > /var/log/glusterfs/glusterd.log')
if ret:
raise ExecutionError("Failed to clear glusterd.log file on %s"
% self.mnode)
# Performing peer detach
self.random_server = random.choice(self.servers[1:])
ret = peer_detach_servers(self.mnode, self.random_server)
self.assertTrue(ret, "Failed to detach peer %s"
% self.random_server)
g.log.info("Peer detach successful for %s", self.random_server)
# Searching for error message in log
ret, out, _ = g.run(
self.mnode,
"grep ' E ' /var/log/glusterfs/glusterd.log | wc -l")
self.assertEqual(ret, 0, "Failed to get error message count in "
"glusterd log file")
g.log.info("Successful getting error message count in log file")
self.assertEqual(int(out), 0, "Found Error messages in glusterd log "
"file after peer detach")
g.log.info("No error messages found in gluterd log file after peer "
"detach")
|