summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArthy Loganathan <aloganat@redhat.com>2017-11-28 01:42:05 +0530
committerArthy Loganathan <aloganat@redhat.com>2017-12-08 18:28:32 +0530
commitce81e4adc238fe41f2a031b4f75c2f6f88448e94 (patch)
tree0cb0b7b3f82e412d7fc200dbbe888e4fd217faf0 /tests
parent46cbb93cb1458484795d114bbf826a77e117e299 (diff)
Heketi library functions for topology, volume operation,
HeketiBaseClass and initial set of heketi volume testcases Change-Id: Ib700cc9ffc4bf510affdbb45710c5b27c6c7ce44 Signed-off-by: Arthy Loganathan <aloganat@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/common/heketi/test_heketi_volume_operations.py102
1 files changed, 102 insertions, 0 deletions
diff --git a/tests/functional/common/heketi/test_heketi_volume_operations.py b/tests/functional/common/heketi/test_heketi_volume_operations.py
new file mode 100644
index 00000000..3e8b4f65
--- /dev/null
+++ b/tests/functional/common/heketi/test_heketi_volume_operations.py
@@ -0,0 +1,102 @@
+#!/usr/bin/python
+
+from glusto.core import Glusto as g
+from cnslibs.common.heketi_ops import (heketi_create_topology,
+ heketi_topology_load,
+ heketi_volume_delete,
+ heketi_volume_create,
+ heketi_volume_expand,
+ heketi_volume_info)
+from cnslibs.common.heketi_libs import HeketiClientSetupBaseClass
+from cnslibs.common.exceptions import ExecutionError, ConfigError
+
+
+class TestHeketiVolumeOperations(HeketiClientSetupBaseClass):
+ """
+ Class to test heketi volume operations - create, expand
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestHeketiVolumeOperations, cls).setUpClass()
+
+ if cls.deployment_type == "crs_heketi_outside_openshift":
+ ret = heketi_create_topology(cls.heketi_client_node,
+ cls.topology_info)
+ if not ret:
+ raise ConfigError("Failed to create heketi topology file on %s"
+ % cls.heketi_client_node)
+
+ ret = heketi_topology_load(cls.heketi_client_node,
+ cls.heketi_server_url)
+ if not ret:
+ raise ConfigError("Failed to load heketi topology on %s"
+ % cls.heketi_client_node)
+
+ cls.volume_id = None
+
+ def volume_cleanup(self):
+ """
+ Method to cleanup volume in self.addCleanup()
+ """
+ if self.volume_id is not None:
+ out = heketi_volume_delete(self.heketi_client_node,
+ self.heketi_server_url, self.volume_id)
+ output_str = 'Volume %s deleted' % self.volume_id
+ if output_str not in out:
+ raise ExecutionError("Failed to delete heketi volume of id %s"
+ % self.volume_id)
+
+ def test_heketi_with_default_options(self):
+ """
+ Test to create volume with default options.
+ """
+
+ volume_size = self.heketi_volume['size']
+ kwargs = {"json": True}
+ vol_info = heketi_volume_create(self.heketi_client_node,
+ self.heketi_server_url, volume_size,
+ **kwargs)
+ self.assertTrue(vol_info, ("Failed to create heketi volume of size %s"
+ % str(volume_size)))
+ self.volume_id = vol_info['id']
+ self.addCleanup(self.volume_cleanup)
+
+ self.assertEqual(vol_info['size'], int(volume_size),
+ ("Failed to create volume with default options."
+ "Expected Size: %s, Actual Size: %s"
+ % (str(volume_size), str(vol_info['size']))))
+
+ def test_heketi_with_expand_volume(self):
+ """
+ Test volume expand and size if updated correctly in heketi-cli info
+ """
+
+ kwargs = {"json": True}
+ volume_size = self.heketi_volume['size']
+ vol_info = heketi_volume_create(self.heketi_client_node,
+ self.heketi_server_url, volume_size,
+ **kwargs)
+ self.assertTrue(vol_info, ("Failed to create heketi volume of size %s"
+ % str(volume_size)))
+ self.volume_id = vol_info['id']
+ self.addCleanup(self.volume_cleanup)
+ self.assertEqual(vol_info['size'], int(volume_size),
+ ("Failed to create volume."
+ "Expected Size: %s, Actual Size: %s"
+ % (str(volume_size), str(vol_info['size']))))
+
+ expand_size = self.heketi_volume['expand_size']
+ ret = heketi_volume_expand(self.heketi_client_node,
+ self.heketi_server_url, self.volume_id,
+ expand_size)
+ self.assertTrue(ret, ("Failed to expand heketi volume of id %s"
+ % self.volume_id))
+ volume_info = heketi_volume_info(self.heketi_client_node,
+ self.heketi_server_url,
+ self.volume_id, **kwargs)
+ expected_size = int(volume_size) + int(expand_size)
+ self.assertEqual(volume_info['size'], expected_size,
+ ("Volume Expansion failed Expected Size: %s, Actual "
+ "Size: %s" % (str(expected_size),
+ str(volume_info['size']))))