summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/baseclass.py4
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py4
-rw-r--r--tests/functional/provisioning/test_storage_class_cases.py26
3 files changed, 31 insertions, 3 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/baseclass.py b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
index 14fa09d..c8cb1d3 100644
--- a/openshift-storage-libs/openshiftstoragelibs/baseclass.py
+++ b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
@@ -166,6 +166,7 @@ class BaseClass(unittest.TestCase):
allow_volume_expansion=False,
reclaim_policy="Delete",
set_hacount=None,
+ clusterid=None,
hacount=None,
is_arbiter_vol=False, arbiter_avg_file_size=None,
heketi_zone_checking=None):
@@ -188,7 +189,8 @@ class BaseClass(unittest.TestCase):
secret_namespace_option: self.sc.get(
"secretnamespace", self.sc.get("restsecretnamespace")),
}
-
+ if clusterid:
+ parameters["clusterid"] = clusterid
if hacount:
parameters["hacount"] = six.text_type(hacount)
elif set_hacount:
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index 9b81cdf..8aaa141 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -289,8 +289,8 @@ def oc_create_sc(hostname, sc_name_prefix="autotests-sc",
allowed_parameters = (
'resturl', 'secretnamespace', 'restuser', 'secretname',
'restauthenabled', 'restsecretnamespace', 'restsecretname',
- 'hacount', 'clusterids', 'chapauthenabled', 'volumenameprefix',
- 'volumeoptions', 'volumetype'
+ 'hacount', 'clusterids', 'clusterid', 'chapauthenabled',
+ 'volumenameprefix', 'volumeoptions', 'volumetype'
)
for parameter in parameters.keys():
if parameter.lower() not in allowed_parameters:
diff --git a/tests/functional/provisioning/test_storage_class_cases.py b/tests/functional/provisioning/test_storage_class_cases.py
index 009504c..380e970 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"]))