summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Kumar <arukumar@arukumar.remote.csb>2019-09-16 10:00:16 +0530
committerVaibhav Mahajan <vamahaja@redhat.com>2019-12-26 12:25:25 +0000
commit5ae45abc159a37af04c43acf45dd4b0a21f323a2 (patch)
tree7f3f6f15060eaaa5c3b8f0f95919f405ec306aca
parentd28b637d972aa600ed15ef437e4cb59c53e0ca5e (diff)
Add TC and config data for metrics
Test case to validate metrics add config data for metrics add config data of registry namespace to validate metrics Change-Id: I4886482ee33847f506ad898d4a313df866d0348c
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/baseclass.py21
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py35
-rw-r--r--tests/functional/metrics/__init__.py0
-rw-r--r--tests/functional/metrics/test_metrics_validation.py64
-rw-r--r--tests/glusterfs-containers-tests-config.yaml23
5 files changed, 128 insertions, 15 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/baseclass.py b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
index 24d0499..cca627f 100644
--- a/openshift-storage-libs/openshiftstoragelibs/baseclass.py
+++ b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
@@ -33,6 +33,7 @@ from openshiftstoragelibs.node_ops import (
from openshiftstoragelibs.openshift_ops import (
get_block_provisioner,
get_pod_name_from_dc,
+ get_pod_name_from_rc,
get_pv_name_from_pvc,
oc_create_app_dc_with_io,
oc_create_pvc,
@@ -631,12 +632,20 @@ class GlusterBlockBaseClass(BaseClass):
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"):
+ def verify_iscsi_sessions_and_multipath(
+ self, pvc_name, rname, rtype='dc', heketi_server_url=None,
+ is_registry_gluster=False):
+ if not heketi_server_url:
+ heketi_server_url = self.heketi_server_url
+
# Get storage ips of glusterfs pods
- keys = self.gluster_servers
+ keys = (list(g.config['gluster_registry_servers'].keys()) if
+ is_registry_gluster else self.gluster_servers)
+ servers_info = (g.config['gluster_registry_servers'] if
+ is_registry_gluster else self.gluster_servers_info)
gluster_ips = []
for key in keys:
- gluster_ips.append(self.gluster_servers_info[key]['storage'])
+ gluster_ips.append(servers_info[key]['storage'])
gluster_ips.sort()
# Find iqn and hacount from volume info
@@ -645,7 +654,7 @@ class GlusterBlockBaseClass(BaseClass):
vol_id = oc_get_custom_resource(
self.ocp_client[0], 'pv', custom, pv_name)[0]
vol_info = heketi_blockvolume_info(
- self.heketi_client_node, self.heketi_server_url, vol_id, json=True)
+ self.heketi_client_node, heketi_server_url, vol_id, json=True)
iqn = vol_info['blockvolume']['iqn']
hacount = int(vol_info['hacount'])
@@ -657,6 +666,10 @@ class GlusterBlockBaseClass(BaseClass):
elif rtype == 'pod':
pod_info = oc_get_pods(self.ocp_client[0], name=rname)
pod_name = rname
+ elif rtype == 'rc':
+ pod_name = get_pod_name_from_rc(self.ocp_client[0], rname)
+ pod_info = oc_get_pods(
+ self.ocp_client[0], selector='name=%s' % rname)
else:
raise NameError("Value of rtype should be either 'dc' or 'pod'")
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index c8460d1..da8225a 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -1102,36 +1102,39 @@ def wait_for_pods_be_ready(
raise exceptions.ExecutionError(err_msg)
-def get_pod_names_from_dc(hostname, dc_name, timeout=180, wait_step=3):
+def get_pod_names_from_dc_or_rc(
+ hostname, rname, rtype='dc', timeout=180, wait_step=3):
"""Return list of POD names by their DC.
Args:
hostname (str): hostname on which 'oc' commands will be executed.
- dc_name (str): deployment_confidg name
+ rname (str): deployment_config name or replication_controller name
+ rtype (str): resource type, 'dc' or 'rc', Default value is 'rc'
timeout (int): timeout value. Default value is 180 sec.
wait_step( int): Wait step, default value is 3 sec.
Returns:
list: list of strings which are POD names
Raises: exceptions.ExecutionError
"""
+ if rtype not in ('dc', 'rc'):
+ raise NameError("Value of rtype should be either 'dc' or 'rc'.")
get_replicas_amount_cmd = (
- "oc get dc --no-headers --all-namespaces "
+ "oc get %s --no-headers --all-namespaces "
"-o=custom-columns=:.spec.replicas,:.metadata.name "
- "| grep '%s' | awk '{print $1}'" % dc_name)
- replicas = int(command.cmd_run(
- get_replicas_amount_cmd, hostname=hostname))
-
+ "| grep '%s' | awk '{print $1}'" % (rtype, rname))
get_pod_names_cmd = (
"oc get pods --all-namespaces -o=custom-columns=:.metadata.name "
- "--no-headers=true --selector deploymentconfig=%s" % dc_name)
+ "--no-headers=true --selector %s=%s" % (
+ "deploymentconfig" if rtype == "dc" else "name", rname))
+ replicas = int(command.cmd_run(get_replicas_amount_cmd, hostname=hostname))
for w in waiter.Waiter(timeout, wait_step):
out = command.cmd_run(get_pod_names_cmd, hostname=hostname)
pod_names = [o.strip() for o in out.split('\n') if o.strip()]
if len(pod_names) != replicas:
continue
g.log.info(
- "POD names for '%s' DC are '%s'. "
- "Expected amount of PODs is '%s'.", dc_name, out, replicas)
+ "POD names for '%s %s' are '%s'. "
+ "Expected amount of PODs is '%s'.", rname, rtype, out, replicas)
return pod_names
if w.expired:
err_msg = ("Exceeded %s sec timeout waiting for PODs to appear "
@@ -1140,11 +1143,21 @@ def get_pod_names_from_dc(hostname, dc_name, timeout=180, wait_step=3):
raise exceptions.ExecutionError(err_msg)
+def get_pod_names_from_dc(hostname, rname, timeout=180, wait_step=3):
+ return get_pod_names_from_dc_or_rc(
+ hostname, rname, timeout=timeout, wait_step=wait_step)
+
+
def get_pod_name_from_dc(hostname, dc_name, timeout=180, wait_step=3):
- return get_pod_names_from_dc(
+ return get_pod_names_from_dc_or_rc(
hostname, dc_name, timeout=timeout, wait_step=wait_step)[0]
+def get_pod_name_from_rc(hostname, rc_name, timeout=180, wait_step=3):
+ return get_pod_names_from_dc_or_rc(
+ hostname, rc_name, rtype='rc', timeout=timeout, wait_step=wait_step)[0]
+
+
def get_pvc_status(hostname, pvc_name):
'''
This function verifies the if pod is running
diff --git a/tests/functional/metrics/__init__.py b/tests/functional/metrics/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/functional/metrics/__init__.py
diff --git a/tests/functional/metrics/test_metrics_validation.py b/tests/functional/metrics/test_metrics_validation.py
new file mode 100644
index 0000000..07cda67
--- /dev/null
+++ b/tests/functional/metrics/test_metrics_validation.py
@@ -0,0 +1,64 @@
+from glusto.core import Glusto as g
+
+from openshiftstoragelibs.baseclass import GlusterBlockBaseClass
+from openshiftstoragelibs import command
+from openshiftstoragelibs.openshift_ops import (
+ get_pod_name_from_rc,
+ oc_get_custom_resource,
+ switch_oc_project,
+ verify_pvc_status_is_bound,
+ wait_for_pod_be_ready,
+)
+
+
+class TestMetricsAndGlusterRegistryValidation(GlusterBlockBaseClass):
+
+ def setUp(self):
+ """Initialize all the variables necessary for test cases."""
+ super(TestMetricsAndGlusterRegistryValidation, self).setUp()
+
+ try:
+ metrics_config = g.config['openshift']['metrics']
+ self.metrics_project_name = metrics_config['metrics_project_name']
+ self.metrics_rc_hawkular_cassandra = (
+ metrics_config['metrics_rc_hawkular_cassandra'])
+ self.metrics_rc_hawkular_metrics = (
+ metrics_config['metrics_rc_hawkular_metrics'])
+ self.metrics_rc_heapster = metrics_config['metrics_rc_heapster']
+ self.registry_heketi_server_url = (
+ g.config['openshift']['registry_heketi_config'][
+ 'heketi_server_url'])
+ except KeyError as err:
+ msg = ("Config file doesn't have key %s" % err)
+ g.log.error(msg)
+ self.skipTest(msg)
+
+ self.master = self.ocp_master_node[0]
+ cmd = "oc project --short=true"
+ current_project = command.cmd_run(cmd, self.master)
+ switch_oc_project(self.master, self.metrics_project_name)
+ self.addCleanup(switch_oc_project, self.master, current_project)
+
+ def test_validate_metrics_pods_and_pvc(self):
+ """Validate metrics pods and PVC"""
+ # Get cassandra pod name and PVC name
+ hawkular_cassandra = get_pod_name_from_rc(
+ self.master, self.metrics_rc_hawkular_cassandra)
+ custom = ":.spec.volumes[*].persistentVolumeClaim.claimName"
+ pvc_name = oc_get_custom_resource(
+ self.master, "pod", custom, hawkular_cassandra)[0]
+
+ # Wait for pods to get ready and PVC to be bound
+ verify_pvc_status_is_bound(self.master, pvc_name)
+ wait_for_pod_be_ready(self.master, hawkular_cassandra)
+ hawkular_metrics = get_pod_name_from_rc(
+ self.master, self.metrics_rc_hawkular_metrics)
+ wait_for_pod_be_ready(self.master, hawkular_metrics)
+ heapster = get_pod_name_from_rc(self.master, self.metrics_rc_heapster)
+ wait_for_pod_be_ready(self.master, heapster)
+
+ # Validate iscsi and multipath
+ self.verify_iscsi_sessions_and_multipath(
+ pvc_name, self.metrics_rc_hawkular_cassandra, rtype='rc',
+ heketi_server_url=self.registry_heketi_server_url,
+ is_registry_gluster=True)
diff --git a/tests/glusterfs-containers-tests-config.yaml b/tests/glusterfs-containers-tests-config.yaml
index d73583e..6856e96 100644
--- a/tests/glusterfs-containers-tests-config.yaml
+++ b/tests/glusterfs-containers-tests-config.yaml
@@ -35,6 +35,22 @@ gluster_servers:
additional_devices: [device3, device4]
+# 'gluster_registry_servers' section covers the details of the nodes where
+# gluster registry servers are run. In the case of CNS, these are the nodes
+# where gluster pods are run under the registry namespace. In the case of CRS,
+# these are the nodes where registry servers are configured.
+gluster_registry_servers:
+ gluster_registry_server1_ip:
+ manage: gluster_registry_server1_hostname
+ storage: registry_server1_ip
+ gluster_registry_server2_ip:
+ manage: gluster_registry_server2_hostname
+ storage: registry_server2_ip
+ gluster_registry_server3_ip:
+ manage: gluster_registry_server3_hostname
+ storage: registry_server3_ip
+
+
# 'additional_gluster_servers' section covers the details of the nodes where
# we can run gluster servers. In the case of CNS, these are the nodes where
# gluster pods can be run. In the case of CRS, these are the nodes where
@@ -57,6 +73,8 @@ openshift:
heketi_server_url: "<fake-heketi-server-url>"
heketi_cli_user: "<fake-heketi-cli-user>"
heketi_cli_key: "<fake-heketi-cli-secret>"
+ registry_heketi_config:
+ heketi_server_url: "<fake-heketi-server-url>"
dynamic_provisioning:
storage_classes:
file_storage_class:
@@ -75,6 +93,11 @@ openshift:
hacount: "3"
chapauthenabled: "true"
volumenameprefix: "autotests-block"
+ metrics:
+ metrics_project_name: "<metrics-project-name>"
+ metrics_rc_hawkular_cassandra: "<hawkular-cassandra-rc-name>"
+ metrics_rc_hawkular_metrics: "<hawkular-metrics-rc-name>"
+ metrics_rc_heapster: "<heapster-rc-name>"
common:
allow_heketi_zones_update: False