summaryrefslogtreecommitdiffstats
path: root/tests/functional/heketi/test_server_state_examine_gluster.py
diff options
context:
space:
mode:
authorArun Kumar <aanand01762@gmail.com>2020-03-20 11:44:30 +0530
committerVaibhav Mahajan <vamahaja@redhat.com>2020-04-07 04:59:38 +0000
commit265d7aac569098b77bbbbe718bafcdb9d51898cd (patch)
tree9742dc3c9c3c8dd20b9469c2ac7786cd7ee87d70 /tests/functional/heketi/test_server_state_examine_gluster.py
parentcbfb8d69396347de15d355b23346165aa1e1e17b (diff)
[Test] Add TCs to validate resoure count heketi db check
Change-Id: Ic79952701f0e7029fb9ddf5394e247d25347acaf Signed-off-by: Arun Kumar <aanand01762@gmail.com>
Diffstat (limited to 'tests/functional/heketi/test_server_state_examine_gluster.py')
-rw-r--r--tests/functional/heketi/test_server_state_examine_gluster.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/functional/heketi/test_server_state_examine_gluster.py b/tests/functional/heketi/test_server_state_examine_gluster.py
index 210111ca..755e2095 100644
--- a/tests/functional/heketi/test_server_state_examine_gluster.py
+++ b/tests/functional/heketi/test_server_state_examine_gluster.py
@@ -89,3 +89,49 @@ class TestHeketiServerStateExamineGluster(BaseClass):
calculated_nodes_count, db_nodes_count,
"Nodes count from 'DB check' (%s) doesn't match calculated nodes "
"count (%s)." % (db_nodes_count, calculated_nodes_count))
+
+ @ddt.data('device_count', 'node_count', 'bricks_count')
+ def test_verify_db_check(self, count_type):
+ """Validate the nodes, devices and bricks count in heketi db"""
+ # Get the total number of nodes, devices and bricks from db check
+ db_info = heketi_ops.heketi_db_check(
+ self.heketi_client_node, self.heketi_server_url)
+ db_devices_count = db_info["devices"]["total"]
+ db_nodes_count = db_info["nodes"]["total"]
+ db_bricks_count = db_info["bricks"]["total"]
+
+ # Get the total number of nodes, devices and bricks from topology info
+ topology_info = heketi_ops.heketi_topology_info(
+ self.heketi_client_node, self.heketi_server_url, json=True)
+ topology_devices_count, topology_nodes_count = 0, 0
+ topology_bricks_count = 0
+ for cluster in topology_info['clusters']:
+ topology_nodes_count += len(cluster['nodes'])
+
+ if count_type == 'bricks_count' or 'device_count':
+ for node in cluster['nodes']:
+ topology_devices_count += len(node['devices'])
+
+ if count_type == 'bricks_count':
+ for device in node['devices']:
+ topology_bricks_count += len(device['bricks'])
+
+ # Compare the device count
+ if count_type == 'device_count':
+ msg = ("Devices count in db check {} and in topology info {} is "
+ "not same".format(db_devices_count, topology_devices_count))
+ self.assertEqual(topology_devices_count, db_devices_count, msg)
+
+ # Compare the node count
+ elif count_type == 'node_count':
+ msg = (
+ "Nodes count in db check {} and nodes count in topology info "
+ "{} is not same".format(db_nodes_count, topology_nodes_count))
+ self.assertEqual(topology_nodes_count, db_nodes_count, msg)
+
+ # Compare the bricks count
+ elif count_type == 'bricks_count':
+ msg = ("Bricks count in db check {} and bricks count in topology "
+ "info {} is not same".format(
+ db_bricks_count, topology_bricks_count))
+ self.assertEqual(topology_bricks_count, db_bricks_count, msg)