diff options
12 files changed, 95 insertions, 97 deletions
diff --git a/cns-libs/cnslibs/common/heketi_ops.py b/cns-libs/cnslibs/common/heketi_ops.py index 2eceb34a..af021599 100644 --- a/cns-libs/cnslibs/common/heketi_ops.py +++ b/cns-libs/cnslibs/common/heketi_ops.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - """ Description: Library for heketi operations. """ @@ -7,10 +5,9 @@ from glusto.core import Glusto as g from collections import OrderedDict import json -import re try: from heketi import HeketiClient -except: +except ImportError: g.log.error("Please install python-client for heketi and re-run the test") from cnslibs.common import exceptions @@ -130,7 +127,7 @@ def modify_heketi_executor(heketi_client_node, executor, keyfile, user, port, with conn.builtin.open(heketi_config_file, 'w') as fh_write: conn.modules.json.dump(config_data, fh_write, sort_keys=False, indent=4, ensure_ascii=False) - except: + except Exception: g.log.error("Failed to modify heketi executor in %s" % heketi_config_file) finally: @@ -335,7 +332,7 @@ def heketi_create_topology(heketi_client_node, topology_info, with conn.builtin.open(topology_file, 'w') as fh_write: conn.modules.json.dump(modified_topology_info, fh_write, indent=4) - except: + except Exception: g.log.error("Failed to create topology file in %s" % heketi_client_node) finally: @@ -496,7 +493,8 @@ def heketi_volume_create(heketi_client_node, heketi_server_url, size, % float(kwargs.get("snapshot_factor")) if kwargs.get("snapshot_factor") else "") json_arg = "--json" if kwargs.get("json") else "" - secret_arg = "--secret %s" % kwargs.get("secret") if kwargs.get("secret") else "" + secret_arg = ( + "--secret %s" % kwargs.get("secret") if kwargs.get("secret") else "") user_arg = "--user %s" % kwargs.get("user") if kwargs.get("user") else "" err_msg = "Failed to create volume. " @@ -595,7 +593,7 @@ def heketi_volume_info(heketi_client_node, heketi_server_url, volume_id, volume_info = conn.volume_info(volume_id) if volume_info is None: return False - except: + except Exception: g.log.error("Failed to get volume info using heketi") return False return volume_info @@ -666,7 +664,7 @@ def heketi_volume_expand(heketi_client_node, heketi_server_url, volume_id, vol_req = {} vol_req['expand_size'] = int(expand_size) volume_expand_info = conn.volume_expand(volume_id, vol_req) - except: + except Exception: g.log.error("Failed to do volume expansion info using heketi") return False @@ -781,7 +779,7 @@ def heketi_volume_list(heketi_client_node, heketi_server_url, mode='cli', admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) volume_list = conn.volume_list() - except: + except Exception: g.log.error("Failed to do volume list using heketi") return False return volume_list @@ -879,7 +877,7 @@ def hello_heketi(heketi_client_node, heketi_server_url, mode='cli', **kwargs): admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) ret = conn.hello() - except: + except Exception: g.log.error("Failed to execute heketi hello command") return False return ret @@ -960,7 +958,7 @@ def heketi_cluster_create(heketi_client_node, heketi_server_url, cluster_req["block"] = block_arg cluster_req["file"] = file_arg cluster_create_info = conn.volume_create(cluster_req) - except: + except Exception: g.log.error("Failed to do cluster create using heketi") return False return cluster_create_info @@ -1013,7 +1011,7 @@ def heketi_cluster_delete(heketi_client_node, heketi_server_url, cluster_id, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) ret = conn.cluster_delete(cluster_id) - except: + except Exception: g.log.error("Failed to do volume delete using heketi") return False return ret @@ -1067,7 +1065,7 @@ def heketi_cluster_info(heketi_client_node, heketi_server_url, cluster_id, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) cluster_info = conn.cluster_info(cluster_id) - except: + except Exception: g.log.error("Failed to get cluster info using heketi") return False return cluster_info @@ -1122,7 +1120,7 @@ def heketi_cluster_list(heketi_client_node, heketi_server_url, mode='cli', admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) cluster_list = conn.cluster_list() - except: + except Exception: g.log.error("Failed to do cluster list using heketi") return False return cluster_list @@ -1188,7 +1186,7 @@ def heketi_device_add(heketi_client_node, heketi_server_url, device_name, device_req["name"] = device_name device_req["node"] = node_id device = conn.device_add(device_req) - except: + except Exception: g.log.error("Failed to do device add using heketi") return False return device @@ -1248,7 +1246,7 @@ def heketi_device_delete(heketi_client_node, heketi_server_url, device_id, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) device = conn.device_delete(device_id) - except: + except Exception: g.log.error("Failed to do device delete using heketi") return False return device @@ -1308,7 +1306,7 @@ def heketi_device_disable(heketi_client_node, heketi_server_url, device_id, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) device = conn.device_disable(device_id) - except: + except Exception: g.log.error("Failed to do device disable using heketi") return False return device @@ -1368,7 +1366,7 @@ def heketi_device_enable(heketi_client_node, heketi_server_url, device_id, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) device = conn.device_enable(device_id) - except: + except Exception: g.log.error("Failed to do device enable using heketi") return False return device @@ -1428,7 +1426,7 @@ def heketi_device_info(heketi_client_node, heketi_server_url, device_id, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) cluster_info = conn.device_info(device_id) - except: + except Exception: g.log.error("Failed to get device info using heketi") return False return cluster_info @@ -1488,7 +1486,7 @@ def heketi_device_remove(heketi_client_node, heketi_server_url, device_id, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) device = conn.device_remove(device_id) - except: + except Exception: g.log.error("Failed to do device remove using heketi") return False return device @@ -1558,7 +1556,7 @@ def heketi_node_add(heketi_client_node, heketi_server_url, zone, cluster_id, node_req['hostnames'] = {"manage": [management_host_name], "storage": [storage_host_name]} node_add_info = conn.node_add(node_req) - except: + except Exception: g.log.error("Failed to do node add using heketi") return False return node_add_info @@ -1613,7 +1611,7 @@ def heketi_node_delete(heketi_client_node, heketi_server_url, node_id, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) device = conn.node_delete(node_id) - except: + except Exception: g.log.error("Failed to do node delete using heketi") return False return device @@ -1668,7 +1666,7 @@ def heketi_node_disable(heketi_client_node, heketi_server_url, node_id, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) node = conn.device_disable(node_id) - except: + except Exception: g.log.error("Failed to do node disable using heketi") return False return node @@ -1723,7 +1721,7 @@ def heketi_node_enable(heketi_client_node, heketi_server_url, node_id, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) device = conn.node_enable(node_id) - except: + except Exception: g.log.error("Failed to do node enable using heketi") return False return device @@ -1778,7 +1776,7 @@ def heketi_node_info(heketi_client_node, heketi_server_url, node_id, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) node_info = conn.node_info(node_id) - except: + except Exception: g.log.error("Failed to get node info using heketi") return False return node_info @@ -1833,7 +1831,7 @@ def heketi_node_remove(heketi_client_node, heketi_server_url, node_id, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) node = conn.node_remove(node_id) - except: + except Exception: g.log.error("Failed to do node remove using heketi") return False return node @@ -1850,7 +1848,7 @@ def heketi_node_list(heketi_client_node, heketi_server_url, heketi_secret (str): Secret for 'heketi_user' Returns: list of strings which are node IDs - Raises: cnslibs.common.exceptions.ExecutionError in case CLI command failed. + Raises: cnslibs.common.exceptions.ExecutionError when CLI command fails. """ heketi_server_url, json_arg, admin_key, user = _set_heketi_global_flags( @@ -1925,7 +1923,7 @@ def heketi_blockvolume_info(heketi_client_node, heketi_server_url, block_volume_info = conn.blockvolume_info(block_volume_id) if block_volume_info is None: return False - except: + except Exception: g.log.error("Failed to get blockvolume info using heketi") return False return block_volume_info @@ -2001,8 +1999,8 @@ def heketi_blockvolume_create(heketi_client_node, heketi_server_url, size, if mode == 'cli': cmd = ("heketi-cli -s %s blockvolume create --size=%s %s %s %s %s " "%s %s %s %s" % (heketi_server_url, str(size), auth_arg, - clusters_arg, ha_arg, name_arg, name_arg, - admin_key, user, json_arg)) + clusters_arg, ha_arg, name_arg, name_arg, + admin_key, user, json_arg)) ret, out, _ = g.run(heketi_client_node, cmd) if ret != 0: @@ -2023,7 +2021,7 @@ def heketi_blockvolume_create(heketi_client_node, heketi_server_url, size, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) block_volume_create_info = conn.blockvolume_create(**kwargs) - except: + except Exception: g.log.error("Failed to do blockvolume create using heketi") return False @@ -2079,7 +2077,7 @@ def heketi_blockvolume_delete(heketi_client_node, heketi_server_url, admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) return conn.blockvolume_delete(block_volume_id) - except: + except Exception: g.log.error("Failed to do blockvolume delete using heketi") return False @@ -2134,7 +2132,7 @@ def heketi_blockvolume_list(heketi_client_node, heketi_server_url, mode='cli', admin_key = admin_key.split('t ')[-1] if admin_key else admin_key conn = HeketiClient(heketi_server_url, user, admin_key) return conn.blockvolume_list() - except: + except Exception: g.log.error("Failed to do blockvolume list using heketi") return False diff --git a/cns-libs/cnslibs/common/openshift_ops.py b/cns-libs/cnslibs/common/openshift_ops.py index 72906f8c..d05529d8 100644 --- a/cns-libs/cnslibs/common/openshift_ops.py +++ b/cns-libs/cnslibs/common/openshift_ops.py @@ -371,10 +371,10 @@ def oc_create_app_dc_with_io( "-ec", "trap \"rm -f /mnt/random-data-$HOSTNAME.log ; exit 0\" SIGTERM; " "while true; do " - " (mount | grep '/mnt') && " - " (head -c %s < /dev/urandom > /mnt/random-data-$HOSTNAME.log) || " - " exit 1; " - " sleep 1 ; " + " (mount | grep '/mnt') && " + " (head -c %s < /dev/urandom > /mnt/random-data-$HOSTNAME.log) ||" + " exit 1; " + " sleep 1 ; " "done" % space_to_use, ], "livenessProbe": { diff --git a/cns-libs/cnslibs/common/waiter.py b/cns-libs/cnslibs/common/waiter.py index 89a264df..0a6e72b5 100644 --- a/cns-libs/cnslibs/common/waiter.py +++ b/cns-libs/cnslibs/common/waiter.py @@ -7,6 +7,7 @@ It aims to avoid having to write boilerplate code comparing times. import time + class Waiter(object): """A wait-retry loop as iterable. This object abstracts away the wait logic allowing functions diff --git a/cns-libs/setup.py b/cns-libs/setup.py index bc376b58..1a4fe293 100644 --- a/cns-libs/setup.py +++ b/cns-libs/setup.py @@ -23,5 +23,7 @@ setup( 'Topic :: Software Development :: Testing' ], install_requires=['glusto', 'ddt', 'mock', 'rtyaml'], - dependency_links=['http://github.com/loadtheaccumulator/glusto/tarball/master#egg=glusto'], + dependency_links=[ + 'http://github.com/loadtheaccumulator/glusto/tarball/master#egg=glusto' + ], ) diff --git a/cns-tools/setup.py b/cns-tools/setup.py index 2a803c28..f29e6af8 100644 --- a/cns-tools/setup.py +++ b/cns-tools/setup.py @@ -22,5 +22,7 @@ setup( 'Topic :: Software Development :: Testing' ], install_requires=['glusto'], - dependency_links=['http://github.com/loadtheaccumulator/glusto/tarball/master#egg=glusto'], + dependency_links=[ + 'http://github.com/loadtheaccumulator/glusto/tarball/master#egg=glusto' + ], ) diff --git a/tests/functional/common/heketi/heketi_tests/test_check_entry.py b/tests/functional/common/heketi/heketi_tests/test_check_entry.py index 16fbe085..47a0b3f2 100644 --- a/tests/functional/common/heketi/heketi_tests/test_check_entry.py +++ b/tests/functional/common/heketi/heketi_tests/test_check_entry.py @@ -1,13 +1,12 @@ -#!/usr/bin/python - from glusto.core import Glusto as g from glustolibs.gluster.exceptions import ConfigError + from cnslibs.common.heketi_libs import HeketiClientSetupBaseClass from cnslibs.common.heketi_ops import (heketi_volume_create, heketi_volume_list, heketi_volume_delete) -from cnslibs.common import heketi_ops, podcmd -from cnslibs.common.openshift_ops import oc_rsh, get_ocp_gluster_pod_names +from cnslibs.common.openshift_ops import get_ocp_gluster_pod_names +from cnslibs.common import podcmd class TestHeketiVolume(HeketiClientSetupBaseClass): @@ -51,11 +50,13 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): gluster_pod = get_ocp_gluster_pod_names( self.heketi_client_node)[1] - cmd = "oc rsync "+ gluster_pod +":/var/lib/heketi/fstab /tmp" + cmd = "oc rsync " + gluster_pod + ":/var/lib/heketi/fstab /tmp" out = g.run(self.heketi_client_node, cmd) self.assertTrue(out, ("Failed to copy the file")) g.log.info("Copied the file") - out = g.run_local("scp -r root@" +self.heketi_client_node+":/tmp/fstab /tmp/file.txt") + out = g.run_local( + "scp -r root@%s:/tmp/fstab " + "/tmp/file.txt" % self.heketi_client_node) self.assertTrue(out, ("Failed to copy a file to /tmp/file.txt")) g.log.info("Successfully copied to /tmp/file.txt") out = g.run_local("ls /tmp") @@ -67,7 +68,8 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): # Check if the brick is mounted for i in path: string_to_search = i - rcode, rout, rerr = g.run_local('grep %s %s' % (string_to_search, "/tmp/file.txt")) + rcode, rout, rerr = g.run_local( + 'grep %s %s' % (string_to_search, "/tmp/file.txt")) if rcode == 0: g.log.info("Brick %s is mounted" % i) datafile.close() @@ -99,11 +101,12 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): gluster_pod = get_ocp_gluster_pod_names( self.heketi_client_node)[0] - cmd = "oc rsync "+ gluster_pod +":/var/lib/heketi/fstab /" + cmd = "oc rsync " + gluster_pod + ":/var/lib/heketi/fstab /" out = g.run(self.heketi_client_node, cmd) self.assertTrue(out, ("Failed to copy the file")) g.log.info("Copied the file") - out = g.run_local("scp -r root@" +self.heketi_client_node+":/fstab /tmp/newfile.txt") + out = g.run_local( + "scp -r root@%s:/fstab /tmp/newfile.txt" % self.heketi_client_node) self.assertTrue(out, ("Failed to copy to the file newfile.txt")) g.log.info("Successfully copied to the file newfile.txt") out = g.run_local("ls /tmp") @@ -115,7 +118,8 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): # Check if the brick is mounted for i in path: string_to_search = i - rcode, rout, rerr = g.run_local('grep %s %s' % (string_to_search, "/tmp/newfile.txt")) + rcode, rout, rerr = g.run_local( + 'grep %s %s' % (string_to_search, "/tmp/newfile.txt")) if rcode == 0: raise ConfigError("Particular %s brick entry is found" % i) datafile.close() diff --git a/tests/functional/common/heketi/heketi_tests/test_create_heketi_volume_size_60.py b/tests/functional/common/heketi/heketi_tests/test_create_heketi_volume_size_60.py index d871be30..29b39513 100644 --- a/tests/functional/common/heketi/heketi_tests/test_create_heketi_volume_size_60.py +++ b/tests/functional/common/heketi/heketi_tests/test_create_heketi_volume_size_60.py @@ -1,21 +1,19 @@ -#!/usr/bin/python - from __future__ import division import math from glusto.core import Glusto as g -from glustolibs.gluster.exceptions import ConfigError from glustolibs.gluster.volume_ops import get_volume_list, get_volume_info + +from cnslibs.common.exceptions import ExecutionError from cnslibs.common.heketi_libs import HeketiClientSetupBaseClass from cnslibs.common.heketi_ops import (heketi_node_list, heketi_node_info, heketi_volume_create, heketi_volume_list, heketi_volume_info, - heketi_volume_delete, - heketi_topology_info) -from cnslibs.common import heketi_ops, podcmd -from cnslibs.common.openshift_ops import oc_rsh, get_ocp_gluster_pod_names + heketi_volume_delete) +from cnslibs.common.openshift_ops import get_ocp_gluster_pod_names +from cnslibs.common import podcmd class TestHeketiVolume(HeketiClientSetupBaseClass): @@ -25,7 +23,6 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): Get free space in each devices """ free_spaces = [] - device_list = [] heketi_node_id_list = heketi_node_list( self.heketi_client_node, self.heketi_server_url) for node_id in heketi_node_id_list: @@ -36,10 +33,7 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): for device in node_info_dict["devices"]: total_free_space += device["storage"]["free"] free_spaces.append(total_free_space) - min_free_space = min(free_spaces) total_free_space = sum(free_spaces)/(1024**2) - optimum_space = min_free_space / (1024 * 1024 * 10) - free_space = int(math.floor(optimum_space)) total_free_space = int(math.floor(total_free_space)) return total_free_space, free_spaces @@ -70,7 +64,9 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): mount_node = (out["mount"]["glusterfs"] ["device"].strip().split(":")[0]) hosts.append(mount_node) - backup_volfile_server_list = (out["mount"]["glusterfs"]["options"] ["backup-volfile-servers"].strip().split(",")) + backup_volfile_server_list = ( + out["mount"]["glusterfs"]["options"][ + "backup-volfile-servers"].strip().split(",")) for backup_volfile_server in backup_volfile_server_list: hosts.append(backup_volfile_server) for gluster_server in g.config["gluster_servers"].keys(): @@ -81,9 +77,9 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): # Retrieve heketi volume info g.log.info("Retrieving heketi volume info") - out = heketi_ops.heketi_volume_info(self.heketi_client_node, - self.heketi_server_url, - volume_id, json=True) + out = heketi_volume_info( + self.heketi_client_node, self.heketi_server_url, volume_id, + json=True) self.assertTrue(out, ("Failed to get heketi volume info")) g.log.info("Successfully got the heketi volume info") name = out["name"] @@ -187,9 +183,11 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): # Compare the free size before and after deleting volume g.log.info("Comparing the free space before and after" " deleting volume") - self.assertTrue(free_space_after_creating_vol < free_space_after_deleting_vol) + self.assertTrue( + free_space_after_creating_vol < free_space_after_deleting_vol) g.log.info("Volume successfully deleted and space is" " reallocated. Free space after creating" " volume %s, Free space after deleting" - " volume %s" % ((free_space_after_creating_vol), - (free_space_after_deleting_vol))) + " volume %s" % ( + free_space_after_creating_vol, + free_space_after_deleting_vol)) diff --git a/tests/functional/common/heketi/heketi_tests/test_heketi_create_volume.py b/tests/functional/common/heketi/heketi_tests/test_heketi_create_volume.py index 90ae7b51..c28f455b 100644 --- a/tests/functional/common/heketi/heketi_tests/test_heketi_create_volume.py +++ b/tests/functional/common/heketi/heketi_tests/test_heketi_create_volume.py @@ -1,21 +1,21 @@ -#!/usr/bin/python - from glustolibs.gluster.exceptions import ExecutionError, ConfigError from glusto.core import Glusto as g from glustolibs.gluster.volume_ops import get_volume_list, get_volume_info + from cnslibs.common.heketi_libs import HeketiClientSetupBaseClass from cnslibs.common.heketi_ops import (heketi_volume_create, heketi_volume_list, heketi_volume_info, - heketi_volume_delete, heketi_blockvolume_create, heketi_blockvolume_delete, heketi_cluster_list, heketi_cluster_delete, + heketi_node_info, heketi_node_list, heketi_node_delete) -from cnslibs.common import heketi_ops, podcmd -from cnslibs.common.openshift_ops import oc_rsh, get_ocp_gluster_pod_names +from cnslibs.common.openshift_ops import get_ocp_gluster_pod_names +from cnslibs.common import podcmd + class TestHeketiVolume(HeketiClientSetupBaseClass): """ @@ -41,7 +41,6 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): g.log.info("Heketi volume successfully created" % out) volume_id = out["bricks"][0]["volume"] self.addCleanup(self.delete_volumes, volume_id) - name = out["name"] g.log.info("List heketi volumes") volumes = heketi_volume_list(self.heketi_client_node, @@ -87,9 +86,9 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): self.addCleanup(self.delete_volumes, volume_id) g.log.info("Retrieving heketi volume info") - out = heketi_ops.heketi_volume_info(self.heketi_client_node, - self.heketi_server_url, - volume_id, json=True) + out = heketi_volume_info( + self.heketi_client_node, self.heketi_server_url, volume_id, + json=True) self.assertTrue(out, ("Failed to get heketi volume info")) g.log.info("Successfully got the heketi volume info") name = out["name"] @@ -115,7 +114,7 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): volumes = heketi_volume_list(self.heketi_client_node, self.heketi_server_url, json=True) - if (len(volumes["volumes"])== 0): + if (len(volumes["volumes"]) == 0): g.log.info("Creating heketi volume") out = heketi_volume_create(self.heketi_client_node, self.heketi_server_url, @@ -170,7 +169,7 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): g.log.info("Successfully got the list of nodes") for node_id in heketi_node_id_list: g.log.info("Retrieve the node info") - node_info_dict = heketi_ops.heketi_node_info( + node_info_dict = heketi_node_info( self.heketi_client_node, self.heketi_server_url, node_id, json=True) if not(node_info_dict["devices"][1]["storage"]["used"]): diff --git a/tests/functional/common/heketi/heketi_tests/test_node_info.py b/tests/functional/common/heketi/heketi_tests/test_node_info.py index 81462906..26ac56f7 100644 --- a/tests/functional/common/heketi/heketi_tests/test_node_info.py +++ b/tests/functional/common/heketi/heketi_tests/test_node_info.py @@ -1,13 +1,10 @@ -#!/usr/bin/python - from glusto.core import Glusto as g from glustolibs.gluster.exceptions import ExecutionError -from glustolibs.gluster.peer_ops import (get_pool_list) +from glustolibs.gluster.peer_ops import get_pool_list + from cnslibs.common.heketi_libs import HeketiClientSetupBaseClass -from cnslibs.common.heketi_ops import (heketi_node_info, - heketi_node_list) from cnslibs.common import heketi_ops, podcmd -from cnslibs.common.openshift_ops import oc_rsh, get_ocp_gluster_pod_names +from cnslibs.common.openshift_ops import get_ocp_gluster_pod_names class TestHeketiVolume(HeketiClientSetupBaseClass): @@ -25,7 +22,7 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): # List all list ip = [] g.log.info("Listing the node id") - heketi_node_id_list = heketi_node_list( + heketi_node_id_list = heketi_ops.heketi_node_list( self.heketi_client_node, self.heketi_server_url) g.log.info("Successfully listed the node") @@ -61,8 +58,9 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): hostname.append(pool["hostname"]) if (len(heketi_node_id_list) != len(list_of_pools)): - raise ExecutionError("Heketi volume list %s is not equal" - " to gluster volume list %s" % ((ip), (hostname))) + raise ExecutionError( + "Heketi volume list %s is not equal " + "to gluster volume list %s" % ((ip), (hostname))) g.log.info("The node IP's from node info and list" " is : %s/n and pool list from gluster" " pods/nodes is %s" % ((ip), (hostname))) @@ -74,7 +72,7 @@ class TestHeketiVolume(HeketiClientSetupBaseClass): # List all list g.log.info("Listing the node id") - heketi_node_id_list = heketi_node_list( + heketi_node_id_list = heketi_ops.heketi_node_list( self.heketi_client_node, self.heketi_server_url) self.assertTrue(heketi_node_id_list, ("Node Id list is empty.")) g.log.info("Successfully listed the node") diff --git a/tests/functional/common/heketi/test_volume_deletion.py b/tests/functional/common/heketi/test_volume_deletion.py index be7b2e61..8b0adf98 100644 --- a/tests/functional/common/heketi/test_volume_deletion.py +++ b/tests/functional/common/heketi/test_volume_deletion.py @@ -1,10 +1,6 @@ from __future__ import division -import math -import unittest -from glusto.core import Glusto as g - -from cnslibs.common.exceptions import ExecutionError, ConfigError +from cnslibs.common.exceptions import ExecutionError from cnslibs.common.heketi_libs import HeketiClientSetupBaseClass from cnslibs.common import heketi_ops @@ -110,4 +106,3 @@ class TestVolumeDeleteTestCases(HeketiClientSetupBaseClass): if not heketidbexists: raise ExecutionError( "Warning: heketidbstorage doesn't exist in list of volumes") - diff --git a/tests/functional/common/heketi/test_volume_expansion_and_devices.py b/tests/functional/common/heketi/test_volume_expansion_and_devices.py index e1d912c3..17ed5d9d 100644 --- a/tests/functional/common/heketi/test_volume_expansion_and_devices.py +++ b/tests/functional/common/heketi/test_volume_expansion_and_devices.py @@ -6,7 +6,7 @@ import unittest from glusto.core import Glusto as g from glustolibs.gluster import volume_ops, rebalance_ops -from cnslibs.common.exceptions import ExecutionError, ConfigError +from cnslibs.common.exceptions import ExecutionError from cnslibs.common.heketi_libs import HeketiClientSetupBaseClass from cnslibs.common.openshift_ops import get_ocp_gluster_pod_names from cnslibs.common import heketi_ops, podcmd @@ -696,4 +696,3 @@ class TestVolumeExpansionAndDevicesTestCases(HeketiClientSetupBaseClass): free_space_after_deletion > free_space_after_expansion, "Free space is not reclaimed after volume deletion of %s" % volume_id) - diff --git a/tests/functional/common/heketi/test_volume_multi_req.py b/tests/functional/common/heketi/test_volume_multi_req.py index 957476eb..244131e9 100644 --- a/tests/functional/common/heketi/test_volume_multi_req.py +++ b/tests/functional/common/heketi/test_volume_multi_req.py @@ -397,6 +397,7 @@ class TestVolumeMultiReq(HeketiClientSetupBaseClass): # make this a condition done = threading.Event() short_tc_name = "volumes-concurrently" + def background_ops(): subname = make_unique_label(short_tc_name) for i, w in enumerate(Waiter(60 * 60)): @@ -414,6 +415,7 @@ class TestVolumeMultiReq(HeketiClientSetupBaseClass): if done.is_set(): break failures = [] + def checked_background_ops(): try: background_ops() |