diff options
author | Valerii Ponomarov <vponomar@redhat.com> | 2019-01-02 12:52:27 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.host.prod.eng.bos.redhat.com> | 2019-01-02 12:52:27 +0000 |
commit | 17e6e30010d5a26ced72a45ec3b868f92d8b9697 (patch) | |
tree | 8bd92b074b9d166fcc91eda6ba3cc81354594a0b | |
parent | 05dc2db65e600b51e0d47f3e29e33a7bef6f7294 (diff) | |
parent | 78826c43f8d01e0c8e5c3ca637fcd03302a1136d (diff) |
Merge "Fix CNS-550 test case"
-rw-r--r-- | tests/functional/common/heketi/heketi_tests/test_heketi_create_volume.py | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/tests/functional/common/heketi/heketi_tests/test_heketi_create_volume.py b/tests/functional/common/heketi/heketi_tests/test_heketi_create_volume.py index 7963413b..af9d2b44 100644 --- a/tests/functional/common/heketi/heketi_tests/test_heketi_create_volume.py +++ b/tests/functional/common/heketi/heketi_tests/test_heketi_create_volume.py @@ -1,5 +1,3 @@ -import time - from glusto.core import Glusto as g from glustolibs.gluster.volume_ops import get_volume_list, get_volume_info import six @@ -206,33 +204,31 @@ class TestHeketiVolume(HeketiBaseClass): heketi_blockvolume_delete, self.heketi_client_node, self.heketi_server_url, blockvol1['id']) - # Sleep for couple of seconds to avoid races - time.sleep(2) - - # Get info about block hosting volume available space + # Get info about block hosting volumes file_volumes = heketi_volume_list( self.heketi_client_node, self.heketi_server_url, json=True) self.assertTrue(file_volumes) - max_freesize = 0 - file_volumes_debug_info = [] + self.assertIn("volumes", file_volumes) + self.assertTrue(file_volumes["volumes"]) + max_block_hosting_vol_size, file_volumes_debug_info = 0, [] for vol_id in file_volumes["volumes"]: vol = heketi_volume_info( self.heketi_client_node, self.heketi_server_url, vol_id, json=True) - current_freesize = vol.get("blockinfo", {}).get("freesize", 0) - if current_freesize > max_freesize: - max_freesize = current_freesize - if current_freesize: + current_block_hosting_vol_size = vol.get('size', 0) + if current_block_hosting_vol_size > max_block_hosting_vol_size: + max_block_hosting_vol_size = current_block_hosting_vol_size + if current_block_hosting_vol_size: file_volumes_debug_info.append(six.text_type({ 'id': vol.get('id', '?'), 'name': vol.get('name', '?'), - 'size': vol.get('size', '?'), + 'size': current_block_hosting_vol_size, 'blockinfo': vol.get('blockinfo', '?'), })) - self.assertGreater(max_freesize, 0) + self.assertGreater(max_block_hosting_vol_size, 0) # Try to create blockvolume with size bigger than available - too_big_vol_size = max_freesize + 1 + too_big_vol_size = max_block_hosting_vol_size + 1 try: blockvol2 = heketi_blockvolume_create( self.heketi_client_node, self.heketi_server_url, @@ -244,9 +240,14 @@ class TestHeketiVolume(HeketiBaseClass): self.addCleanup( heketi_blockvolume_delete, self.heketi_client_node, self.heketi_server_url, blockvol2['id']) - self.assertFalse( - blockvol2, - "Volume unexpectedly was created. Calculated 'max free size' is " - "'%s'.\nBlock volume info is: %s \n" - "Block hosting volumes which were considered: \n%s" % ( - max_freesize, blockvol2, '\n'.join(file_volumes_debug_info))) + block_hosting_vol = heketi_volume_info( + self.heketi_client_node, self.heketi_server_url, + blockvol2.get('blockhostingvolume'), json=True) + self.assertGreater( + block_hosting_vol.get('size', -2), blockvol2.get('size', -1), + ("Block volume unexpectedly was created. " + "Calculated 'max free size' is '%s'.\nBlock volume info is: %s \n" + "File volume info, which hosts block volume: \n%s," + "Block hosting volumes which were considered: \n%s" % ( + max_block_hosting_vol_size, blockvol2, block_hosting_vol, + '\n'.join(file_volumes_debug_info)))) |