summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshmitha <asambast@redhat.com>2019-09-12 11:36:56 +0530
committervponomar <vponomar@redhat.com>2019-09-18 10:14:50 +0000
commit764d7bd68ec0b4ea9229c381b3b4195367b44b83 (patch)
treeebb90ffd2664a1661bb5e384f9133df785af5bdc
parentaa7321198d3c37271243879cac49a8133e43cabd (diff)
Add testcase for passing clusterid when creating storage class
Change-Id: I4a6fd02f5713b4e86a9d70cdaffd3ca9369932f4
-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 14fa09dc..c8cb1d37 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 9b81cdf4..8aaa1418 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 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"]))