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
|
#!/usr/bin/python
from glusto.core import Glusto as g
from glustolibs.gluster.exceptions import ExecutionError
from glustolibs.gluster.peer_ops import (get_pool_list)
from cnslibs.common.heketi_libs import HeketiClientSetupBaseClass
from cnslibs.common.heketi_ops import (heketi_node_info,
heketi_node_list)
from cnslibs.common import heketi_ops, podcmd
from cnslibs.common.openshift_ops import oc_rsh, get_ocp_gluster_pod_names
class TestHeketiVolume(HeketiClientSetupBaseClass):
"""
Class to test heketi volume create
"""
@podcmd.GlustoPod()
def test_to_get_list_of_nodes(self):
"""
Listing all nodes and compare the
node listed in previous step
"""
# List all list
heketi_node_id_list = []
ip = []
g.log.info("Listing the node id")
node_list = heketi_node_list(self.heketi_client_node,
self.heketi_server_url)
self.assertTrue(node_list, ("Failed to list heketi nodes"))
g.log.info("Successfully listed the node")
for line in node_list.strip().split("\n"):
heketi_node_id_list.append(line.strip().split(
"Cluster")[0].strip().split(":")[1])
if (len(heketi_node_id_list) == 0):
raise ExecutionError("Node list empty")
for node_id in heketi_node_id_list:
g.log.info("Retrieve the node info")
node_info = heketi_ops.heketi_node_info(
self.heketi_client_node, self.heketi_server_url,
node_id, json=True)
self.assertTrue(node_info, ("Failed to "
"retrieve the node info"))
g.log.info("Successfully retrieved the node info %s" % node_id)
ip.append(node_info["hostnames"]["storage"])
# Compare the node listed in previous step
hostname = []
g.log.info("Get the pool list")
if self.deployment_type == "cns":
gluster_pod = get_ocp_gluster_pod_names(
self.heketi_client_node)[1]
p = podcmd.Pod(self.heketi_client_node, gluster_pod)
list_of_pools = get_pool_list(p)
else:
list_of_pools = get_pool_list(self.heketi_client_node)
self.assertTrue(list_of_pools, ("Failed to get the "
"pool list from gluster pods/nodes"))
g.log.info("Successfully got the pool list from gluster pods/nodes")
for pool in list_of_pools:
hostname.append(pool["hostname"])
if (len(heketi_node_id_list) != len(list_of_pools)):
raise ExecutionError("Heketi volume list %s is not equal"
" to gluster volume list %s" % ((ip), (hostname)))
g.log.info("The node IP's from node info and list"
" is : %s/n and pool list from gluster"
" pods/nodes is %s" % ((ip), (hostname)))
def test_to_retrieve_node_info(self):
"""
List and retrieve node related info
"""
# List all list
heketi_node_id_list = []
g.log.info("Listing the node id")
node_list = heketi_node_list(self.heketi_client_node,
self.heketi_server_url)
self.assertTrue(node_list, ("Failed to list heketi nodes"))
g.log.info("Successfully listed the node")
for line in node_list.strip().split("\n"):
heketi_node_id_list.append(line.strip().split(
"Cluster")[0].strip().split(":")[1])
for node_id in heketi_node_id_list:
g.log.info("Retrieve the node info")
node_info = heketi_ops.heketi_node_info(
self.heketi_client_node, self.heketi_server_url,
node_id, json=True)
self.assertTrue(node_info, ("Failed to "
"retrieve the node info"))
g.log.info("Successfully retrieved the node info %s" % node_id)
|