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
|
# Copyright (C) 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:
Test Default volume behavior and quorum options
"""
from time import sleep
from glusto.core import Glusto as g
from glustolibs.gluster.exceptions import ExecutionError
from glustolibs.gluster.gluster_base_class import GlusterBaseClass, runs_on
from glustolibs.gluster.lib_utils import form_bricks_list
from glustolibs.gluster.volume_libs import cleanup_volume
from glustolibs.gluster.volume_ops import (
volume_stop, get_volume_status,
volume_create, volume_start
)
@runs_on([['distributed-arbiter'],
['glusterfs']])
class GetVolumeStatusXmlDump(GlusterBaseClass):
def setUp(self):
"""Setup Volume"""
# Calling GlusterBaseClass setUp
self.get_super_method(self, 'setUp')()
# Fetching all the parameters for volume_create
list_of_three_servers = []
server_info_for_three_nodes = {}
for server in self.servers[0:3]:
list_of_three_servers.append(server)
server_info_for_three_nodes[server] = self.all_servers_info[
server]
bricks_list = form_bricks_list(
self.mnode, self.volname, 3, list_of_three_servers,
server_info_for_three_nodes)
# Creating 2nd volume
self.volname_2 = "test_volume"
ret, _, _ = volume_create(self.mnode, self.volname_2,
bricks_list)
self.assertFalse(ret, "Volume creation failed")
g.log.info("Volume %s created successfully", self.volname_2)
ret, _, _ = volume_start(self.mnode, self.volname_2)
if ret:
raise ExecutionError(
"Failed to start volume {}".format(self.volname_2))
# Setup and mount the volume
ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
if not ret:
raise ExecutionError("Failed to setup volume and mount it")
def test_gluster_volume_status_xml_dump(self):
"""
Setps:
1. stop one of the volume
(i.e) gluster volume stop <vol-name>
2. Get the status of the volumes with --xml dump
XML dump should be consistent
"""
ret, _, _ = volume_stop(self.mnode, volname=self.volname_2,
force=True)
self.assertFalse(ret,
"Failed to stop volume '{}'".format(
self.volname_2))
out = get_volume_status(self.mnode)
self.assertIsNotNone(
out, "Failed to get volume status on {}".format(self.mnode))
for _ in range(4):
sleep(2)
out1 = get_volume_status(self.mnode)
self.assertIsNotNone(
out1, "Failed to get volume status on {}".format(
self.mnode))
self.assertEqual(out1, out)
def tearDown(self):
"""tear Down Callback"""
ret = cleanup_volume(self.mnode, self.volname_2)
if not ret:
raise ExecutionError(
"Failed to remove volume '{}'".format(self.volname_2))
# Unmount volume and cleanup.
ret = self.unmount_volume_and_cleanup_volume(self.mounts)
if not ret:
raise ExecutionError("Failed to Unmount and Cleanup volume")
g.log.info("Successful in unmount and cleanup operations")
# Calling GlusterBaseClass tearDown
self.get_super_method(self, 'tearDown')()
|