diff options
author | Valerii Ponomarov <vponomar@redhat.com> | 2018-12-15 23:42:25 +0530 |
---|---|---|
committer | Valerii Ponomarov <vponomar@redhat.com> | 2018-12-16 02:47:07 +0530 |
commit | 8bf07df7ebbbf228c0815aced9b624f0da3653e8 (patch) | |
tree | 05a92f880efcbf18b8a41316e04cbb9be758ca5a /tests | |
parent | d28c2f0c06ba627c39c96e93016abed678151b7e (diff) |
Rework 'heketi_ops' module
Doing following:
- Remove dead code with usage of Heketi python lib.
Because it is not used and not tested.
- Remove unused functions in general.
- Make existing functions raise exceptions with CLI error message
instead of returning 'False' boolean value hiding info about
original errors.
Change-Id: I1f0def567dd77425397ff2c8ba13f9c0640af5bc
Diffstat (limited to 'tests')
4 files changed, 31 insertions, 28 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 681c1258..261f5cc2 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,10 +1,10 @@ import time -from glustolibs.gluster.exceptions import ExecutionError from glusto.core import Glusto as g from glustolibs.gluster.volume_ops import get_volume_list, get_volume_info import six +from cnslibs.common.exceptions import ExecutionError from cnslibs.common.heketi_libs import HeketiBaseClass from cnslibs.common.heketi_ops import (heketi_volume_create, heketi_volume_list, @@ -64,10 +64,11 @@ class TestHeketiVolume(HeketiBaseClass): g.log.info("Successfully got the volumes list") # Check the volume count are equal - if (len(volumes["volumes"]) != len(out)): - raise ExecutionError("Heketi volume list %s is" - " not equal to gluster" - " volume list %s" % ((volumes), (out))) + self.assertEqual( + len(volumes["volumes"]), len(out), + "Lengths of gluster '%s' and heketi '%s' volume lists are " + "not equal." % (out, volumes) + ) g.log.info("Heketi volumes list %s and" " gluster volumes list %s" % ((volumes), (out))) @@ -141,11 +142,11 @@ class TestHeketiVolume(HeketiBaseClass): g.log.info("Trying to delete a heketi cluster" " which contains volumes and/or nodes:" " Expected to fail") - out = heketi_cluster_delete(self.heketi_client_node, - self.heketi_server_url, - cluster_id) - self.assertFalse(out, ("Successfully deleted a " - "cluster %s" % cluster_id)) + self.assertRaises( + ExecutionError, + heketi_cluster_delete, + self.heketi_client_node, self.heketi_server_url, cluster_id, + ) g.log.info("Expected result: Unable to delete cluster %s" " because it contains volumes " " and/or nodes" % cluster_id) @@ -194,8 +195,10 @@ class TestHeketiVolume(HeketiBaseClass): # Try to delete the node by its ID g.log.info("Trying to delete the node which contains devices in it. " "Expecting failure.") - out = heketi_node_delete(self.heketi_client_node, heketi_url, node_id) - self.assertFalse(out, "Node '%s' got unexpectedly deleted." % node_id) + self.assertRaises( + ExecutionError, + heketi_node_delete, + self.heketi_client_node, heketi_url, node_id) # Make sure our node hasn't been deleted g.log.info("Listing heketi node list") @@ -244,9 +247,13 @@ class TestHeketiVolume(HeketiBaseClass): # Try to create blockvolume with size bigger than available too_big_vol_size = max_freesize + 1 - blockvol2 = heketi_blockvolume_create( - self.heketi_client_node, self.heketi_server_url, - too_big_vol_size, json=True) + try: + blockvol2 = heketi_blockvolume_create( + self.heketi_client_node, self.heketi_server_url, + too_big_vol_size, json=True) + except ExecutionError: + return + if blockvol2 and blockvol2.get('id'): self.addCleanup( heketi_blockvolume_delete, self.heketi_client_node, diff --git a/tests/functional/common/heketi/test_block_volumes_heketi.py b/tests/functional/common/heketi/test_block_volumes_heketi.py index 22dcf18d..344ef9f7 100644 --- a/tests/functional/common/heketi/test_block_volumes_heketi.py +++ b/tests/functional/common/heketi/test_block_volumes_heketi.py @@ -57,7 +57,8 @@ class TestBlockVolumeOps(HeketiBaseClass): self.assertNotEqual(block_vol, False, "Block volume creation has failed") self.addCleanup(heketi_blockvolume_delete, self.heketi_client_node, - self.heketi_server_url, block_vol["id"]) + self.heketi_server_url, block_vol["id"], + raise_on_error=False) block_delete_output = heketi_blockvolume_delete( self.heketi_client_node, self.heketi_server_url, block_vol["id"], json=True) diff --git a/tests/functional/common/heketi/test_heketi_metrics.py b/tests/functional/common/heketi/test_heketi_metrics.py index a888b82b..0e29b738 100644 --- a/tests/functional/common/heketi/test_heketi_metrics.py +++ b/tests/functional/common/heketi/test_heketi_metrics.py @@ -1,3 +1,4 @@ +from cnslibs.common import exceptions from cnslibs.common.heketi_libs import HeketiBaseClass from cnslibs.common.heketi_ops import ( get_heketi_metrics, @@ -174,7 +175,7 @@ class TestHeketiMetrics(HeketiBaseClass): self.heketi_dc_name, pod_amount=1) # verify that metrics is not accessable when heketi pod is down - with self.assertRaises(AssertionError): + with self.assertRaises(exceptions.ExecutionError): get_heketi_metrics( self.heketi_client_node, self.heketi_server_url, diff --git a/tests/functional/common/heketi/test_volume_expansion_and_devices.py b/tests/functional/common/heketi/test_volume_expansion_and_devices.py index 8e8dea9a..a003ceb7 100644 --- a/tests/functional/common/heketi/test_volume_expansion_and_devices.py +++ b/tests/functional/common/heketi/test_volume_expansion_and_devices.py @@ -542,17 +542,11 @@ class TestVolumeExpansionAndDevicesTestCases(HeketiBaseClass): free_space_after_creation = self.get_devices_summary_free_space() - ret, out, err = heketi_ops.heketi_volume_expand( - self.heketi_client_node, self.heketi_server_url, - volume_id, 50, raw_cli_output=True) - - self.assertEqual(ret, 255, "volume expansion did not fail ret- %s " - "out- %s err= %s" % (ret, out, err)) - g.log.info("Volume expansion failed as expected, err- %s" % err) - - if ret == 0: - out_json = json.loads(out) - self.addCleanup(self.delete_volumes, out_json["id"]) + self.assertRaises( + ExecutionError, + heketi_ops.heketi_volume_expand, + self.heketi_client_node, self.heketi_server_url, volume_id, + 50, raw_cli_output=True) self.enable_devices(additional_devices_attached) |