summaryrefslogtreecommitdiffstats
path: root/tests/functional/heketi/test_heketi_create_volume.py
diff options
context:
space:
mode:
authorArun Kumar <arukumar@redhat.com>2019-04-05 12:46:22 +0530
committervponomar <vponomar@redhat.com>2019-07-19 13:54:35 +0000
commit68c24931b4c43c374c8a0230e5700a8f3aa56be7 (patch)
tree073f69d5ecdbd5a461e3737f11fb68d584d9dc31 /tests/functional/heketi/test_heketi_create_volume.py
parent13ae8998a1338dad74337762af0db069b9ddc3d0 (diff)
Add TC create volume and validate in heketi topology info
Create 3 volumes using heketi-cli command, verify their presence in heketi topology info, delete 2 volumes and validate their deletions and presence of 3rd volume in heketi topology info Change-Id: I78298d2aec21ff8031ff01efd53f11ba31e269c9
Diffstat (limited to 'tests/functional/heketi/test_heketi_create_volume.py')
-rw-r--r--tests/functional/heketi/test_heketi_create_volume.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/functional/heketi/test_heketi_create_volume.py b/tests/functional/heketi/test_heketi_create_volume.py
index 3e242667..115810b8 100644
--- a/tests/functional/heketi/test_heketi_create_volume.py
+++ b/tests/functional/heketi/test_heketi_create_volume.py
@@ -1,3 +1,10 @@
+try:
+ # py2/3
+ import simplejson as json
+except ImportError:
+ # py2
+ import json
+
from glusto.core import Glusto as g
from glustolibs.gluster.volume_ops import get_volume_list, get_volume_info
import six
@@ -11,8 +18,10 @@ from openshiftstoragelibs.heketi_ops import (
heketi_node_delete,
heketi_node_info,
heketi_node_list,
+ heketi_topology_info,
heketi_volume_create,
heketi_volume_delete,
+ heketi_volume_expand,
heketi_volume_info,
heketi_volume_list,
)
@@ -102,6 +111,71 @@ class TestHeketiVolume(BaseClass):
self.assertTrue(vol_info, "Failed to get volume info %s" % name)
g.log.info("Successfully got the volume info %s" % name)
+ def topology_volumes_with_bricks(self):
+ g.log.info("Retrieving heketi topology info")
+ topology_info_out = heketi_topology_info(self.heketi_client_node,
+ self.heketi_server_url,
+ json=True)
+ indented_topology = json.dumps(topology_info_out, indent=4)
+ g.log.info("Successfully got the heketi topology info")
+ topology_volumes = dict()
+ for c in topology_info_out['clusters']:
+ for v in c['volumes']:
+ topology_volumes.update({v['name']: len(v['bricks'])})
+ return topology_volumes, indented_topology
+
+ def test_create_vol_and_retrieve_topology_info(self):
+ volume_names = []
+ volume_ids = []
+
+ # Create 3 volumes and make 3rd volume of type distributed replica
+ g.log.info("Creating 3 volumes")
+ for i in range(3):
+ out = heketi_volume_create(self.heketi_client_node,
+ self.heketi_server_url,
+ self.volume_size, json=True)
+ g.log.info("Heketi volume %s successfully created" % out)
+ volume_names.append(out["name"])
+ volume_ids.append(out["bricks"][0]["volume"])
+ self.addCleanup(heketi_volume_delete, self.heketi_client_node,
+ self.heketi_server_url, volume_ids[i],
+ raise_on_error=(i == 2))
+ heketi_volume_expand(self.heketi_client_node,
+ self.heketi_server_url, volume_ids[1], 1)
+
+ # Check if volume is shown in the heketi topology
+ topology_volumes, indented_topology = (
+ self.topology_volumes_with_bricks())
+ for vol_name in volume_names:
+ self.assertIn(vol_name, topology_volumes.keys(), (
+ "volume %s not found in the heketi topology\n Topology "
+ "info:\n%s" % (vol_name, indented_topology)))
+ bricks = 6 if vol_name == volume_names[1] else 3
+ self.assertGreaterEqual(
+ topology_volumes[vol_name], bricks, 'Bricks of the volume:'
+ '%s are %s and it should be more or equal to %s' %
+ (vol_name, topology_volumes[vol_name], bricks))
+
+ # Delete first 2 volumes and verify their deletion in the topology
+ for vol_id in volume_ids[:2]:
+ g.log.info("Deleting volume %s" % vol_id)
+ heketi_volume_delete(self.heketi_client_node,
+ self.heketi_server_url, vol_id)
+ topology_volumes.clear()
+ topology_volumes, indented_topology = (
+ self.topology_volumes_with_bricks())
+ for vol_name in volume_names[:2]:
+ self.assertNotIn(vol_name, topology_volumes.keys(), (
+ "volume %s shown in the heketi topology after "
+ "deletion\nTopology info:\n%s" % (
+ vol_name, indented_topology)))
+
+ # Check the existence of third volume
+ self.assertIn(volume_names[2], topology_volumes.keys(), ("volume %s "
+ "not shown in the heketi topology\nTopology info\n%s" % (
+ volume_ids[2], indented_topology)))
+ g.log.info("Sucessfully verified the topology info")
+
def test_to_check_deletion_of_cluster(self):
"""Validate deletion of cluster with volumes"""
# List heketi volumes