summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/baseclass.py30
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py7
-rw-r--r--tests/functional/provisioning/test_storage_class_cases.py2
-rw-r--r--tests/glusterfs-containers-tests-config.yaml6
4 files changed, 34 insertions, 11 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/baseclass.py b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
index b000a64..cd9f24c 100644
--- a/openshift-storage-libs/openshiftstoragelibs/baseclass.py
+++ b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
@@ -28,6 +28,7 @@ from openshiftstoragelibs.node_ops import (
node_delete_iptables_rules,
)
from openshiftstoragelibs.openshift_ops import (
+ get_block_provisioner,
get_pod_name_from_dc,
get_pv_name_from_pvc,
oc_create_app_dc_with_io,
@@ -80,13 +81,13 @@ class BaseClass(unittest.TestCase):
cls.ocp_nodes_info = g.config['ocp_servers']['nodes']
# Initializes storage project config variables
- openshift_config = g.config.get("cns", g.config.get("openshift"))
- cls.storage_project_name = openshift_config.get(
+ cls.openshift_config = g.config.get("cns", g.config.get("openshift"))
+ cls.storage_project_name = cls.openshift_config.get(
'storage_project_name',
- openshift_config.get('setup', {}).get('cns_project_name'))
+ cls.openshift_config.get('setup', {}).get('cns_project_name'))
# Initializes heketi config variables
- heketi_config = openshift_config['heketi_config']
+ heketi_config = cls.openshift_config['heketi_config']
cls.heketi_dc_name = heketi_config['heketi_dc_name']
cls.heketi_service_name = heketi_config['heketi_service_name']
cls.heketi_client_node = heketi_config['heketi_client_node']
@@ -97,10 +98,12 @@ class BaseClass(unittest.TestCase):
cls.gluster_servers = list(g.config['gluster_servers'].keys())
cls.gluster_servers_info = g.config['gluster_servers']
- cls.storage_classes = openshift_config['dynamic_provisioning'][
+ cls.storage_classes = cls.openshift_config['dynamic_provisioning'][
'storage_classes']
cls.sc = cls.storage_classes.get(
'storage_class1', cls.storage_classes.get('file_storage_class'))
+ cls.secret_type = "kubernetes.io/glusterfs"
+
cmd = "echo -n %s | base64" % cls.heketi_cli_key
ret, out, err = g.run(cls.ocp_master_node[0], cmd, "root")
if ret != 0:
@@ -184,7 +187,8 @@ class BaseClass(unittest.TestCase):
current_number_of_heketi_db_inconsistencies,
error_msg)
- def create_secret(self, secret_name_prefix="autotests-secret"):
+ def create_secret(self, secret_name_prefix="autotests-secret",
+ secret_type=None):
secret_name = oc_create_secret(
self.ocp_client[0],
secret_name_prefix=secret_name_prefix,
@@ -192,7 +196,7 @@ class BaseClass(unittest.TestCase):
'secretnamespace',
self.sc.get('restsecretnamespace', 'default'))),
data_key=self.heketi_cli_key,
- secret_type=self.sc.get('provisioner', 'kubernetes.io/glusterfs'))
+ secret_type=secret_type or self.secret_type)
self.addCleanup(
oc_delete, self.ocp_client[0], 'secret', secret_name)
return secret_name
@@ -217,7 +221,7 @@ class BaseClass(unittest.TestCase):
# Create storage class
secret_name_option = "secretname"
secret_namespace_option = "secretnamespace"
- provisioner = self.sc.get("provisioner", "kubernetes.io/glusterfs")
+ provisioner = self.get_provisioner_for_sc()
if provisioner != "kubernetes.io/glusterfs":
secret_name_option = "rest%s" % secret_name_option
secret_namespace_option = "rest%s" % secret_namespace_option
@@ -264,6 +268,12 @@ class BaseClass(unittest.TestCase):
self.addCleanup(oc_delete, self.ocp_client[0], "sc", self.sc_name)
return self.sc_name
+ def get_provisioner_for_sc(self):
+ return "kubernetes.io/glusterfs"
+
+ def get_block_provisioner_for_sc(self):
+ return get_block_provisioner(self.ocp_client[0])
+
def create_and_wait_for_pvcs(self, pvc_size=1,
pvc_name_prefix="autotests-pvc",
pvc_amount=1, sc_name=None,
@@ -513,6 +523,10 @@ class GlusterBlockBaseClass(BaseClass):
super(GlusterBlockBaseClass, cls).setUpClass()
cls.sc = cls.storage_classes.get(
'storage_class2', cls.storage_classes.get('block_storage_class'))
+ cls.secret_type = "gluster.org/glusterblock"
+
+ def get_provisioner_for_sc(self):
+ return self.get_block_provisioner_for_sc()
def verify_iscsi_sessions_and_multipath(self, pvc_name, rname, rtype="dc"):
# Get storage ips of glusterfs pods
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index 9acec4e..c8b4201 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -511,6 +511,13 @@ def oc_get_custom_resource(ocp_node, rtype, custom, name=None, selector=None):
return out_list
+def get_block_provisioner(ocp_node):
+ return oc_get_custom_resource(
+ ocp_node, 'dc', selector="glusterblock",
+ custom=(r'":.spec.template.spec.containers[*].'
+ r'env[?(@.name==\"PROVISIONER_NAME\")].value"'))[0][0]
+
+
def oc_get_yaml(ocp_node, rtype, name=None, raise_on_error=True):
"""Get an OCP resource by name.
diff --git a/tests/functional/provisioning/test_storage_class_cases.py b/tests/functional/provisioning/test_storage_class_cases.py
index 72cf360..ef4728b 100644
--- a/tests/functional/provisioning/test_storage_class_cases.py
+++ b/tests/functional/provisioning/test_storage_class_cases.py
@@ -83,7 +83,7 @@ class TestStorageClassCases(BaseClass):
self.addCleanup(
oc_delete, self.ocp_master_node[0], 'secret', self.secret_name)
sc_parameter = {
- "provisioner": "gluster.org/glusterblock",
+ "provisioner": self.get_block_provisioner_for_sc(),
"restsecretnamespace": sc['restsecretnamespace'],
"restsecretname": self.secret_name,
"hacount": sc['hacount']
diff --git a/tests/glusterfs-containers-tests-config.yaml b/tests/glusterfs-containers-tests-config.yaml
index 419aaec..d73583e 100644
--- a/tests/glusterfs-containers-tests-config.yaml
+++ b/tests/glusterfs-containers-tests-config.yaml
@@ -60,13 +60,15 @@ openshift:
dynamic_provisioning:
storage_classes:
file_storage_class:
- provisioner: "kubernetes.io/glusterfs"
+ # 'provisioner' option is no longer supported.
+ # It gets autocalculated.
resturl: "<fake-url>"
restuser: "<fake-user>"
secretnamespace: "<fake-namespace-name>"
volumenameprefix: "autotests-file"
block_storage_class:
- provisioner: "gluster.org/glusterblock"
+ # 'provisioner' option is no longer supported.
+ # It gets autocalculated.
resturl: "<fake-url>"
restuser: "<fake-user>"
restsecretnamespace: "<fake-namespace-name>"