From ddbf42c510836019e88d15d97519855bdb44deaf Mon Sep 17 00:00:00 2001 From: Sri Vignesh Date: Mon, 18 May 2020 13:11:03 +0530 Subject: [TestFix] Fix tc to cleanup existing BHV and assertion Fix consits of - 1. Add steps to check existing BHV and delete in case BV(s) are not exists. 2. Fix assertion to validate 'brickCount' and 'distCont' Change-Id: I25bb9d0767f102ec0344b0486fbf4007daca70a0 Signed-off-by: Sri Vignesh --- tests/functional/heketi/test_volume_creation.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/functional/heketi/test_volume_creation.py b/tests/functional/heketi/test_volume_creation.py index acedc1ba..0af49f9d 100644 --- a/tests/functional/heketi/test_volume_creation.py +++ b/tests/functional/heketi/test_volume_creation.py @@ -255,8 +255,17 @@ class TestVolumeCreationTestCases(BaseClass): device. """ h_node, h_url = self.heketi_client_node, self.heketi_server_url - topology = heketi_ops.heketi_topology_info(h_node, h_url, json=True) + # Remove existing BHV to calculate freespace + bhv_list = heketi_ops.get_block_hosting_volume_list(h_node, h_url) + if bhv_list: + for bhv in bhv_list: + bhv_info = heketi_ops.heketi_volume_info( + h_node, h_url, bhv, json=True) + if bhv_info['blockinfo'].get('blockvolume') is None: + heketi_ops.heketi_volume_delete(h_node, h_url, bhv) + + topology = heketi_ops.heketi_topology_info(h_node, h_url, json=True) nodes_free_space, nodes_ips = [], [] selected_nodes, selected_devices = [], [] cluster = topology['clusters'][0] @@ -368,15 +377,15 @@ class TestVolumeCreationTestCases(BaseClass): # Verify distCount in gluster v info msg = "Volume %s distCount is %s instead of distCount as 3" % ( - vol_name, gluster_v_info['distCount']) + vol_name, int(gluster_v_info['distCount'])) self.assertEqual( - six.text_type(int(gluster_v_info['brickCount']) / 3), - gluster_v_info['distCount']) + int(gluster_v_info['brickCount']) // 3, + int(gluster_v_info['distCount']), msg) # Verify bricks count in gluster v info msg = ("Volume %s does not have bricks count multiple of 3. It has %s" % (vol_name, gluster_v_info['brickCount'])) - self.assertFalse(int(gluster_v_info['brickCount']) % 3) + self.assertFalse(int(gluster_v_info['brickCount']) % 3, msg) @pytest.mark.tier1 def test_create_volume_with_same_name(self): -- cgit