summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/gluster_ops.py6
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py29
-rw-r--r--tests/functional/arbiter/test_arbiter.py4
-rw-r--r--tests/functional/gluster_stability/test_gluster_block_stability.py8
-rw-r--r--tests/functional/test_node_restart.py4
5 files changed, 27 insertions, 24 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py b/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py
index 33ffa18d..b80c587d 100644
--- a/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py
@@ -229,12 +229,12 @@ def match_heketi_and_gluster_block_volumes_by_prefix(
if block_vol.startswith(block_vol_prefix)
])
- if cmp(sorted(gluster_vol_block_list), heketi_block_volumes) != 0:
+ vol_difference = set(gluster_vol_block_list) ^ set(heketi_block_volumes)
+ if vol_difference:
err_msg = "Gluster and Heketi Block volume list match failed"
err_msg += "\nGluster Volumes: %s, " % gluster_vol_block_list
err_msg += "\nBlock volumes %s" % heketi_block_volumes
- err_msg += "\nDifference: %s" % (
- set(gluster_vol_block_list) ^ set(heketi_block_volumes))
+ err_msg += "\nDifference: %s" % vol_difference
raise AssertionError(err_msg)
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index 249a1b50..1c16426b 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -130,15 +130,16 @@ def get_ocp_gluster_pod_details(ocp_node):
if not gluster_pods[0]:
return []
- gluster_pod_details = map(
+ gluster_pod_details = list(map(
lambda pod: {
"pod_name": pod[0],
"pod_host_ip": pod[1],
"pod_ip": pod[2],
"pod_hostname": pod[3],
"pod_status": pod[4],
- "pod_restarts": pod[5]},
- gluster_pods)
+ "pod_restarts": pod[5],
+ }, gluster_pods
+ ))
return gluster_pod_details
@@ -815,8 +816,9 @@ def get_gluster_pod_names_by_pvc_name(
# Get Gluster POD names which are located on the filtered nodes
gluster_pods = get_ocp_gluster_pod_details(ocp_node)
if gluster_pods:
- matched_gluster_pods = filter(
- lambda pod: (pod["pod_host_ip"] in gluster_host_ips), gluster_pods)
+ matched_gluster_pods = list(filter(
+ lambda pod: (pod["pod_host_ip"] in gluster_host_ips), gluster_pods
+ ))
pod_count = len(matched_gluster_pods)
err_msg = (
"Expected 3 or more Gluster PODs to be found. "
@@ -1493,13 +1495,13 @@ def match_pvc_and_pv(hostname, prefix):
prefix (str): pv prefix used by user at time
of pvc creation
"""
- pvc_list = sorted([
+ pvc_list = set([
pvc[0]
for pvc in oc_get_custom_resource(hostname, "pvc", ":.metadata.name")
if pvc[0].startswith(prefix)
])
- pv_list = sorted([
+ pv_list = set([
pv[0]
for pv in oc_get_custom_resource(
hostname, "pv", ":.spec.claimRef.name"
@@ -1507,11 +1509,12 @@ def match_pvc_and_pv(hostname, prefix):
if pv[0].startswith(prefix)
])
- if cmp(pvc_list, pv_list) != 0:
+ pvc_pv_diff = pvc_list ^ pv_list
+ if pvc_pv_diff:
err_msg = "PVC and PV list match failed"
err_msg += "\nPVC list: %s, " % pvc_list
err_msg += "\nPV list %s" % pv_list
- err_msg += "\nDifference: %s" % (set(pvc_list) ^ set(pv_list))
+ err_msg += "\nDifference: %s" % pvc_pv_diff
raise AssertionError(err_msg)
@@ -1530,18 +1533,18 @@ def match_pv_and_heketi_block_volumes(
r':.metadata.annotations."pv\.kubernetes\.io\/provisioned\-by"',
r':.metadata.annotations."gluster\.org\/volume\-id"'
]
- pv_block_volumes = sorted([
+ pv_block_volumes = set([
pv[2]
for pv in oc_get_custom_resource(hostname, "pv", custom_columns)
if pv[0].startswith(pvc_prefix) and pv[1] == "gluster.org/glusterblock"
])
- if cmp(pv_block_volumes, heketi_block_volumes) != 0:
+ vol_diff = pv_block_volumes ^ set(heketi_block_volumes)
+ if vol_diff:
err_msg = "PV block volumes and Heketi Block volume list match failed"
err_msg += "\nPV Block Volumes: %s, " % pv_block_volumes
err_msg += "\nHeketi Block volumes %s" % heketi_block_volumes
- err_msg += "\nDifference: %s" % (
- set(pv_block_volumes) ^ set(heketi_block_volumes))
+ err_msg += "\nDifference: %s" % vol_diff
raise AssertionError(err_msg)
diff --git a/tests/functional/arbiter/test_arbiter.py b/tests/functional/arbiter/test_arbiter.py
index ea61c1f0..fb284e0c 100644
--- a/tests/functional/arbiter/test_arbiter.py
+++ b/tests/functional/arbiter/test_arbiter.py
@@ -351,9 +351,9 @@ class TestArbiterVolumeCreateExpandDelete(baseclass.BaseClass):
self.verify_amount_and_proportion_of_arbiter_and_data_bricks(
vol_info))
- expected_file_amount = pvc_size_gb * 1024**2 / (avg_file_size or 64)
+ expected_file_amount = pvc_size_gb * 1024**2 // (avg_file_size or 64)
expected_file_amount = (
- expected_file_amount / bricks_info['arbiter_amount'])
+ expected_file_amount // bricks_info['arbiter_amount'])
# Try to create expected amount of files on arbiter brick mount
passed_arbiter_bricks = []
diff --git a/tests/functional/gluster_stability/test_gluster_block_stability.py b/tests/functional/gluster_stability/test_gluster_block_stability.py
index 8f31fd24..15393bf4 100644
--- a/tests/functional/gluster_stability/test_gluster_block_stability.py
+++ b/tests/functional/gluster_stability/test_gluster_block_stability.py
@@ -672,12 +672,12 @@ class TestGlusterBlockStability(GlusterBlockBaseClass):
target_portal_list = sorted(set(target_portal_list))
unmatched_gips = (set(host_ips) ^ set(gluster_ips_bv_flattend))
unmatched_tpips = (set(host_ips) ^ set(target_portal_list))
- self.assertEqual(
- cmp(host_ips, gluster_ips_bv_flattend), 0,
+ self.assertFalse(
+ unmatched_gips,
"Could not match glusterips in blockvolumes, difference is %s "
% unmatched_gips)
- self.assertEqual(
- cmp(host_ips, target_portal_list), 0,
+ self.assertFalse(
+ unmatched_tpips,
"Could not match glusterips in pv describe, difference is %s "
% unmatched_tpips)
diff --git a/tests/functional/test_node_restart.py b/tests/functional/test_node_restart.py
index 8bf70f7c..6a718cbe 100644
--- a/tests/functional/test_node_restart.py
+++ b/tests/functional/test_node_restart.py
@@ -76,9 +76,9 @@ class TestNodeRestart(BaseClass):
def reboot_gluster_node_and_wait_for_services(self):
gluster_node_ip = (
g.config["gluster_servers"][self.gluster_servers[0]]["storage"])
- gluster_pod = filter(
+ gluster_pod = list(filter(
lambda pod: (pod["pod_host_ip"] == gluster_node_ip),
- get_ocp_gluster_pod_details(self.oc_node))
+ get_ocp_gluster_pod_details(self.oc_node)))
if not gluster_pod:
raise ExecutionError(
"Gluster pod Host IP '%s' not matched." % gluster_node_ip)