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
|
from openshiftstoragelibs.baseclass import BaseClass
from openshiftstoragelibs import heketi_ops
from openshiftstoragelibs import heketi_version
from openshiftstoragelibs import openshift_ops
class TestHeketiServerStateExamineGluster(BaseClass):
def setUp(self):
self.node = self.ocp_master_node[0]
version = heketi_version.get_heketi_version(self.heketi_client_node)
if version < '8.0.0-7':
self.skipTest("heketi-client package %s does not support server "
"state examine gluster" % version.v_str)
def test_volume_inconsistencies(self):
# Examine Gluster cluster and Heketi that there is no inconsistencies
out = heketi_ops.heketi_examine_gluster(
self.heketi_client_node, self.heketi_server_url)
if ("heketi volume list matches with volume list of all nodes"
not in out['report']):
self.skipTest(
"heketi and Gluster are inconsistent to each other")
# create volume
vol = heketi_ops.heketi_volume_create(
self.heketi_client_node, self.heketi_server_url, 1, json=True)
self.addCleanup(
heketi_ops.heketi_volume_delete, self.heketi_client_node,
self.heketi_server_url, vol['id'])
# delete volume from gluster cluster directly
openshift_ops.cmd_run_on_gluster_pod_or_node(
self.node,
"gluster vol stop %s force --mode=script" % vol['name'])
openshift_ops.cmd_run_on_gluster_pod_or_node(
self.node,
"gluster vol delete %s --mode=script" % vol['name'])
# verify that heketi is reporting inconsistencies
out = heketi_ops.heketi_examine_gluster(
self.heketi_client_node, self.heketi_server_url)
self.assertNotIn(
"heketi volume list matches with volume list of all nodes",
out['report'])
def test_compare_real_vol_count_with_db_check_info(self):
"""Validate volumes using heketi db check"""
# Create volume
vol = heketi_ops.heketi_volume_create(
self.heketi_client_node, self.heketi_server_url, 1, json=True)
self.addCleanup(
heketi_ops.heketi_volume_delete, self.heketi_client_node,
self.heketi_server_url, vol['id'])
# Check heketi db
db_result = heketi_ops.heketi_db_check(
self.heketi_client_node, self.heketi_server_url)
vol_count = db_result["volumes"]["total"]
vol_list = heketi_ops.heketi_volume_list(
self.heketi_client_node, self.heketi_server_url, json=True)
count = len(vol_list["volumes"])
self.assertEqual(
count, vol_count, "Volume count doesn't match expected"
" result %s, actual result is %s" % (
count, vol_count))
|