summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvamahaja <vamahaja@redhat.com>2020-06-29 13:03:53 +0530
committervamahaja <vamahaja@redhat.com>2020-07-02 13:20:11 +0530
commitc69180accc49392b242f56f226cf5efeaa9cebcb (patch)
tree1b7dab7879a4b57cf4b729078f68be0e1d8f4d21
parent78411ce2697b2e3b176bbe4d7fe35298ed308262 (diff)
[LibFix] Add 'collect_logs' param in 'oc_delete' lib
Change-Id: I9d99f367b82c6570e1390c6b137e0b9bf401a19c Signed-off-by: vamahaja <vamahaja@redhat.com>
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/baseclass.py3
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py17
-rw-r--r--tests/functional/heketi/test_restart_heketi_pod.py3
-rw-r--r--tests/glusterfs-containers-tests-config.yaml1
4 files changed, 18 insertions, 6 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/baseclass.py b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
index 2d6ba69..99082ac 100644
--- a/openshift-storage-libs/openshiftstoragelibs/baseclass.py
+++ b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
@@ -116,6 +116,9 @@ class BaseClass(unittest.TestCase):
'storage_class1', cls.storage_classes.get('file_storage_class'))
cls.secret_type = "kubernetes.io/glusterfs"
+ cls.heketi_logs_before_delete = bool(
+ g.config.get("common", {}).get("heketi_logs_before_delete", False))
+
cmd = "echo -n %s | base64" % cls.heketi_cli_key
ret, out, err = g.run(cls.ocp_master_node[0], cmd, "root")
if ret != 0:
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index 93bd847..ccacfeb 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -452,8 +452,9 @@ def oc_create_tiny_pod_with_volume(hostname, pvc_name, pod_name_prefix='',
return pod_name
-def oc_delete(ocp_node, rtype, name, raise_on_absence=True):
- """Delete an OCP resource by name.
+def oc_delete(
+ ocp_node, rtype, name, raise_on_absence=True, collect_logs=False):
+ """Delete an OCP resource by name
Args:
ocp_node (str): Node on which the ocp command will run.
@@ -463,16 +464,22 @@ def oc_delete(ocp_node, rtype, name, raise_on_absence=True):
exception if value is true,
else return
default value: True
+ collect_logs (bool): Collect logs before deleting resource
"""
- if not oc_get_yaml(ocp_node, rtype, name,
- raise_on_error=raise_on_absence):
+ if not oc_get_yaml(ocp_node, rtype, name, raise_on_error=raise_on_absence):
return
+
+ if rtype == "pod" and collect_logs:
+ cmd = [
+ 'oc', 'logs', name,
+ '&>', '{}_$(date +%Y-%m-%d-%H-%m-%s).log'.format(name)]
+ command.cmd_run(cmd, hostname=ocp_node)
+
cmd = ['oc', 'delete', rtype, name]
if openshift_version.get_openshift_version() >= '3.11':
cmd.append('--wait=false')
command.cmd_run(cmd, hostname=ocp_node)
- g.log.info('Deleted resource: %r %r', rtype, name)
def oc_get_custom_resource(ocp_node, rtype, custom, name=None, selector=None,
diff --git a/tests/functional/heketi/test_restart_heketi_pod.py b/tests/functional/heketi/test_restart_heketi_pod.py
index 90f4968..a6c973e 100644
--- a/tests/functional/heketi/test_restart_heketi_pod.py
+++ b/tests/functional/heketi/test_restart_heketi_pod.py
@@ -49,7 +49,8 @@ class TestRestartHeketi(BaseClass):
self.heketi_dc_name)
# delete heketi-pod (it restarts the pod)
- oc_delete(self.ocp_master_node[0], 'pod', heketi_pod_name)
+ oc_delete(self.ocp_master_node[0], 'pod',
+ heketi_pod_name, collect_logs=self.heketi_logs_before_delete)
wait_for_resource_absence(self.ocp_master_node[0],
'pod', heketi_pod_name)
diff --git a/tests/glusterfs-containers-tests-config.yaml b/tests/glusterfs-containers-tests-config.yaml
index 8b7816a..3629f3a 100644
--- a/tests/glusterfs-containers-tests-config.yaml
+++ b/tests/glusterfs-containers-tests-config.yaml
@@ -105,6 +105,7 @@ common:
check_heketi_db_inconsistencies: True
stop_on_first_failure: False
heketi_command_timeout: 120
+ heketi_logs_before_delete: False
scaleup:
run_scale_up_on_start: True