summaryrefslogtreecommitdiffstats
path: root/tests/functional/heketi/test_volume_deletion.py
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2019-03-06 16:15:25 +0530
committerValerii Ponomarov <vponomar@redhat.com>2019-03-06 16:28:52 +0530
commit3de9a4ea9623cd3a928ce30cbae3364beeac5edb (patch)
tree1746204da26e4648d20b656b2421ef42c78044a4 /tests/functional/heketi/test_volume_deletion.py
parent3d4ab96edfa54ec7f2dd9682d1ee3e3077dfa79c (diff)
Reorder test files removing redundant dirs
Move all the files of 'tests/functional/common/' dir to the 'tests/functional/', because 'common' is the only dir there, which doesn't really makes sense. Do the same about 'tests/functional/common/heketi/heketi_tests' and 'tests/functional/common/heketi/'. Change-Id: I1fa55e2e7bf09e9b9115629b06e1fd160e291a36
Diffstat (limited to 'tests/functional/heketi/test_volume_deletion.py')
-rw-r--r--tests/functional/heketi/test_volume_deletion.py98
1 files changed, 98 insertions, 0 deletions
diff --git a/tests/functional/heketi/test_volume_deletion.py b/tests/functional/heketi/test_volume_deletion.py
new file mode 100644
index 0000000..6f27989
--- /dev/null
+++ b/tests/functional/heketi/test_volume_deletion.py
@@ -0,0 +1,98 @@
+from __future__ import division
+
+from cnslibs.common.exceptions import ExecutionError
+from cnslibs.common.baseclass import BaseClass
+from cnslibs.common import heketi_ops
+
+
+class TestVolumeDeleteTestCases(BaseClass):
+ """
+ Class for volume deletion related test cases
+
+ """
+
+ def get_free_space_summary_devices(self):
+ """
+ Calculates free space across all devices
+ """
+
+ heketi_node_id_list = heketi_ops.heketi_node_list(
+ self.heketi_client_node, self.heketi_server_url)
+
+ total_free_space = 0
+ for node_id in heketi_node_id_list:
+ node_info_dict = heketi_ops.heketi_node_info(
+ self.heketi_client_node, self.heketi_server_url,
+ node_id, json=True)
+ for device in node_info_dict["devices"]:
+ total_free_space += (device["storage"]
+ ["free"] / (1024 ** 2))
+
+ return total_free_space
+
+ def test_delete_heketi_volume(self):
+ """
+ Method to test heketi volume deletion and whether it
+ frees up used space after deletion
+ """
+
+ creation_output_dict = heketi_ops.heketi_volume_create(
+ self.heketi_client_node,
+ self.heketi_server_url, 10, json=True)
+
+ volume_id = creation_output_dict["name"].strip().split("_")[1]
+ free_space_after_creation = self.get_free_space_summary_devices()
+
+ heketi_ops.heketi_volume_delete(
+ self.heketi_client_node, self.heketi_server_url, volume_id)
+
+ free_space_after_deletion = self.get_free_space_summary_devices()
+
+ self.assertTrue(
+ free_space_after_deletion > free_space_after_creation,
+ "Free space is not reclaimed after deletion of %s" % volume_id)
+
+ def test_delete_heketidb_volume(self):
+ """
+ Method to test heketidb volume deletion via heketi-cli
+ """
+ heketidbexists = False
+ msg = "Error: Cannot delete volume containing the Heketi database"
+
+ for i in range(0, 2):
+ volume_info = heketi_ops.heketi_volume_create(
+ self.heketi_client_node, self.heketi_server_url,
+ 10, json=True)
+
+ self.addCleanup(
+ heketi_ops.heketi_volume_delete, self.heketi_client_node,
+ self.heketi_server_url, volume_info["id"])
+
+ volume_list_info = heketi_ops.heketi_volume_list(
+ self.heketi_client_node,
+ self.heketi_server_url, json=True)
+
+ if volume_list_info["volumes"] == []:
+ raise ExecutionError("Heketi volume list empty")
+
+ for volume_id in volume_list_info["volumes"]:
+ volume_info = heketi_ops.heketi_volume_info(
+ self.heketi_client_node, self.heketi_server_url,
+ volume_id, json=True)
+
+ if volume_info["name"] == "heketidbstorage":
+ heketidbexists = True
+ delete_ret, delete_output, delete_error = (
+ heketi_ops.heketi_volume_delete(
+ self.heketi_client_node,
+ self.heketi_server_url, volume_id,
+ raw_cli_output=True))
+
+ self.assertNotEqual(delete_ret, 0, "Return code not 0")
+ self.assertEqual(
+ delete_error.strip(), msg,
+ "Invalid reason for heketidb deletion failure")
+
+ if not heketidbexists:
+ raise ExecutionError(
+ "Warning: heketidbstorage doesn't exist in list of volumes")