From 265d7aac569098b77bbbbe718bafcdb9d51898cd Mon Sep 17 00:00:00 2001 From: Arun Kumar Date: Fri, 20 Mar 2020 11:44:30 +0530 Subject: [Test] Add TCs to validate resoure count heketi db check Change-Id: Ic79952701f0e7029fb9ddf5394e247d25347acaf Signed-off-by: Arun Kumar --- .../heketi/test_server_state_examine_gluster.py | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'tests/functional/heketi/test_server_state_examine_gluster.py') 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) -- cgit