From 764d7bd68ec0b4ea9229c381b3b4195367b44b83 Mon Sep 17 00:00:00 2001 From: Ashmitha Date: Thu, 12 Sep 2019 11:36:56 +0530 Subject: Add testcase for passing clusterid when creating storage class Change-Id: I4a6fd02f5713b4e86a9d70cdaffd3ca9369932f4 --- .../provisioning/test_storage_class_cases.py | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/functional/provisioning/test_storage_class_cases.py') diff --git a/tests/functional/provisioning/test_storage_class_cases.py b/tests/functional/provisioning/test_storage_class_cases.py index 009504c7..380e970a 100644 --- a/tests/functional/provisioning/test_storage_class_cases.py +++ b/tests/functional/provisioning/test_storage_class_cases.py @@ -3,6 +3,8 @@ from glusto.core import Glusto as g from openshiftstoragelibs.heketi_ops import ( heketi_blockvolume_info, + heketi_cluster_list, + heketi_volume_info, verify_volume_name_prefix, ) from openshiftstoragelibs.baseclass import BaseClass @@ -383,3 +385,27 @@ class TestStorageClassCases(BaseClass): # Verify PVC did not get bound with self.assertRaises(AssertionError): verify_pvc_status_is_bound(node, pvc_name, timeout=1) + + def test_sc_create_with_clusterid(self): + """Create storage class with 'cluster id'""" + h_cluster_list = heketi_cluster_list( + self.heketi_client_node, self.heketi_server_url, json=True) + self.assertTrue(h_cluster_list, "Failed to list heketi cluster") + cluster_id = h_cluster_list["clusters"][0] + sc = self.create_storage_class(clusterid=cluster_id) + pvc_name = self.create_and_wait_for_pvc(sc_name=sc) + + # Validate if cluster id is correct in the heketi volume info + pv_name = get_pv_name_from_pvc(self.ocp_master_node[0], pvc_name) + volume_id = oc_get_custom_resource( + self.ocp_master_node[0], 'pv', + r':metadata.annotations."gluster\.kubernetes\.io' + r'\/heketi-volume-id"', name=pv_name)[0] + volume_info = heketi_volume_info( + self.heketi_client_node, self.heketi_server_url, volume_id, + json=True) + + self.assertEqual(cluster_id, volume_info["cluster"], + "Cluster ID %s has NOT been used to" + "create the PVC %s. Found %s" % + (cluster_id, pvc_name, volume_info["cluster"])) -- cgit