From 32724906d1fd5fd09759e1daf927594461c26d5e Mon Sep 17 00:00:00 2001 From: Valerii Ponomarov Date: Mon, 24 Jun 2019 01:29:41 +0530 Subject: Make Heketi commands run on a Heketi POD when main command fails It happens that heketi client located out of the Heketi POD may fail not reaching the server side. So, add back-up approach where we run Heketi commands on a Heketi POD when main commands fail. Change-Id: Ie6ae5be82082f34426f9288b02575e3abd4940f5 --- .../heketi/test_heketi_device_operations.py | 40 ++++++++-------------- 1 file changed, 14 insertions(+), 26 deletions(-) (limited to 'tests/functional/heketi/test_heketi_device_operations.py') diff --git a/tests/functional/heketi/test_heketi_device_operations.py b/tests/functional/heketi/test_heketi_device_operations.py index 76736ecf..eb016941 100644 --- a/tests/functional/heketi/test_heketi_device_operations.py +++ b/tests/functional/heketi/test_heketi_device_operations.py @@ -1,15 +1,7 @@ -try: - # py2/3 - import simplejson as json -except ImportError: - # py2 - import json - import ddt from glusto.core import Glusto as g from openshiftstoragelibs.baseclass import BaseClass -from openshiftstoragelibs.exceptions import ExecutionError from openshiftstoragelibs.heketi_ops import ( heketi_device_add, heketi_device_delete, @@ -150,17 +142,15 @@ class TestHeketiDeviceOperations(BaseClass): self.addCleanup(heketi_device_enable, self.heketi_client_node, self.heketi_server_url, online_device_id) - ret, out, err = heketi_volume_create( - self.heketi_client_node, self.heketi_server_url, - vol_size, json=True, raw_cli_output=True) - if ret == 0: + with self.assertRaises(AssertionError): + out = heketi_volume_create( + self.heketi_client_node, self.heketi_server_url, + vol_size, json=True) self.addCleanup( heketi_volume_delete, self.heketi_client_node, - self.heketi_server_url, json.loads(out)["id"]) - self.assertNotEqual(ret, 0, - ("Volume creation did not fail. ret- %s " - "out- %s err- %s" % (ret, out, err))) - g.log.info("Volume creation failed as expected, err- %s", err) + self.heketi_server_url, out["id"]) + self.assertFalse(True, "Volume creation didn't fail: %s" % out) + g.log.info("Volume creation failed as expected") # Enable back the device which was previously disabled g.log.info("Going to enable device id %s", online_device_id) @@ -267,18 +257,16 @@ class TestHeketiDeviceOperations(BaseClass): self.skipTest(skip_msg) g.log.info("Removing device id %s" % lowest_device_id) - ret, out, err = heketi_device_remove( - self.heketi_client_node, self.heketi_server_url, - lowest_device_id, raw_cli_output=True) - if ret == 0: + with self.assertRaises(AssertionError): + out = heketi_device_remove( + self.heketi_client_node, self.heketi_server_url, + lowest_device_id) self.addCleanup(heketi_device_enable, self.heketi_client_node, self.heketi_server_url, lowest_device_id) self.addCleanup(heketi_device_disable, self.heketi_client_node, self.heketi_server_url, lowest_device_id) - self.assertNotEqual(ret, 0, ( - "Device removal did not fail. ret: %s, out: %s, err: %s." % ( - ret, out, err))) - g.log.info("Device removal failed as expected, err- %s", err) + self.assertFalse(True, "Device removal didn't fail: %s" % out) + g.log.info("Device removal failed as expected") # Need to disable device before removing heketi_device_disable( @@ -414,7 +402,7 @@ class TestHeketiDeviceOperations(BaseClass): heketi_device_enable, heketi_node, heketi_url, device_id) try: self.assertRaises( - ExecutionError, heketi_device_remove, + AssertionError, heketi_device_remove, heketi_node, heketi_url, device_id) except Exception: self.addCleanup( -- cgit