summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkshithijiyer <kshithij.ki@gmail.com>2020-07-23 16:48:06 +0530
committerBala Konda Reddy M <bala12352@gmail.com>2020-07-27 05:28:16 +0000
commit2c1c3111fd2eb39175a3f36122527ec154e85dd8 (patch)
tree0e0e988094951e3e724f15f26e89a449d64e8eab
parent5727e6a8e11e894fce2bf7814a84077a4f95c5b0 (diff)
[Libfix] Remove get_gluster_version() checks
Problem: When run for nightly gluster builds dht cases fails with below traceback: ``` def get_gluster_version(host): """Checks the gluster version on the nodes Args: host(str): IP of the host whose gluster version has to be checked. Returns: (float): The gluster version value. """ command = 'gluster --version' _, out, _ = g.run(host, command) g.log.info("The Gluster verion of the cluster under test is %s", out) > return float(out.split(' ')[1]) E ValueError: could not convert string to float: '20200719.9334a8d\nRepository ``` This is due to nightly builds returning the below output: ``` $ gluster --version glusterfs 20200708.cdf01cc Repository revision: git://git.gluster.org/glusterfs.git Copyright (c) 2006-2016 Red Hat, Inc. <https://www.gluster.org/> GlusterFS comes with ABSOLUTELY NO WARRANTY. It is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. ``` Instead of: ``` $ gluster --version glusterfs 6.0 ``` This is caused as while building the we use `VERSION="${GIT_DATE}.${GIT_HASH}` which causes the version API to return new output. Solution: Remove the checks and modify the function to return string instead of float. Fixes: https://github.com/gluster/glusto-tests/issues/22 Change-Id: I2e889bd0354a1aa75de25aedf8b14eb5ff5ecbe6 Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
-rw-r--r--glustolibs-gluster/glustolibs/gluster/brickdir.py58
-rw-r--r--glustolibs-gluster/glustolibs/gluster/dht_test_utils.py6
-rw-r--r--glustolibs-gluster/glustolibs/gluster/gluster_init.py4
-rw-r--r--glustolibs-gluster/glustolibs/gluster/layout.py31
4 files changed, 33 insertions, 66 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/brickdir.py b/glustolibs-gluster/glustolibs/gluster/brickdir.py
index ffc868b..e864e82 100644
--- a/glustolibs-gluster/glustolibs/gluster/brickdir.py
+++ b/glustolibs-gluster/glustolibs/gluster/brickdir.py
@@ -20,7 +20,6 @@
import os
from glusto.core import Glusto as g
-from glustolibs.gluster.gluster_init import get_gluster_version
from glustolibs.gluster.volume_libs import get_volume_type
@@ -81,11 +80,12 @@ def get_hashrange(brickdir_path):
"""
(host, _) = brickdir_path.split(':')
- gluster_version = get_gluster_version(host)
- # Check for the Gluster version and then volume type
- """If the GLuster version is lower than 6.0, the hash range
- can be calculated for all volume types"""
- if gluster_version < 6.0:
+ ret = get_volume_type(brickdir_path)
+ if ret in ('Replicate', 'Disperse', 'Arbiter'):
+ g.log.info("Cannot find hash-range for Replicate/Disperse/Arbiter"
+ " volume type on Gluster 6.0 and higher.")
+ return "Skipping for Replicate/Disperse/Arbiter volume type"
+ else:
ret = check_hashrange(brickdir_path)
hash_range_low = ret[0]
hash_range_high = ret[1]
@@ -94,24 +94,6 @@ def get_hashrange(brickdir_path):
else:
g.log.error("Could not get hashrange")
return None
- elif gluster_version >= 6.0:
- ret = get_volume_type(brickdir_path)
- if ret in ('Replicate', 'Disperse', 'Arbiter'):
- g.log.info("Cannot find hash-range for Replicate/Disperse/Arbiter"
- " volume type on Gluster 6.0 and higher.")
- return "Skipping for Replicate/Disperse/Arbiter volume type"
- else:
- ret = check_hashrange(brickdir_path)
- hash_range_low = ret[0]
- hash_range_high = ret[1]
- if ret is not None:
- return (hash_range_low, hash_range_high)
- else:
- g.log.error("Could not get hashrange")
- return None
- else:
- g.log.info("Failed to get hash range")
- return None
def file_exists(host, filename):
@@ -149,22 +131,14 @@ class BrickDir(object):
def _get_hashrange(self):
"""get the hash range for a brick from a remote system"""
- gluster_version = get_gluster_version(self._host)
- if gluster_version < 6.0:
+ ret = get_volume_type(self._path)
+ if ret in ('Replicate', 'Disperse', 'Arbiter'):
+ g.log.info("Cannot find hash-range as the volume type under"
+ " test is Replicate/Disperse/Arbiter")
+ else:
self._hashrange = get_hashrange(self._path)
self._hashrange_low = self._hashrange[0]
self._hashrange_high = self._hashrange[1]
- elif gluster_version >= 6.0:
- ret = get_volume_type(self._path)
- if ret in ('Replicate', 'Disperse', 'Arbiter'):
- g.log.info("Cannot find hash-range as the volume type under"
- " test is Replicate/Disperse/Arbiter")
- else:
- self._hashrange = get_hashrange(self._path)
- self._hashrange_low = self._hashrange[0]
- self._hashrange_high = self._hashrange[1]
- else:
- g.log.info("Failed to get hashrange")
@property
def path(self):
@@ -207,12 +181,10 @@ class BrickDir(object):
if self.hashrange is None or self._hashrange_high is None:
self._get_hashrange()
if self._get_hashrange() is None:
- gluster_version = get_gluster_version(self._host)
- if gluster_version >= 6.0:
- ret = get_volume_type(self._path)
- if ret in ('Replicate', 'Disperse', 'Arbiter'):
- g.log.info("Cannot find hash-range as the volume type"
- " under test is Replicate/Disperse/Arbiter")
+ ret = get_volume_type(self._path)
+ if ret in ('Replicate', 'Disperse', 'Arbiter'):
+ g.log.info("Cannot find hash-range as the volume type"
+ " under test is Replicate/Disperse/Arbiter")
else:
return self._hashrange_high
diff --git a/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py b/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py
index b01f7c5..d205211 100644
--- a/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py
+++ b/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py
@@ -29,7 +29,6 @@ import glustolibs.gluster.constants as k
import glustolibs.gluster.exceptions as gex
from glustolibs.gluster.brickdir import BrickDir
from glustolibs.gluster.volume_libs import get_subvols, get_volume_type
-from glustolibs.gluster.gluster_init import get_gluster_version
from glustolibs.misc.misc_libs import upload_scripts
@@ -39,9 +38,8 @@ def run_layout_tests(mnode, fqpath, layout, test_type):
brick_path_list = ret.get('brickdir_paths')
for brickdir_path in brick_path_list:
(server_ip, _) = brickdir_path.split(':')
- if (get_gluster_version(server_ip) >= 6.0 and
- get_volume_type(brickdir_path) in ('Replicate', 'Disperse',
- 'Arbiter')):
+ if get_volume_type(brickdir_path) in ('Replicate', 'Disperse',
+ 'Arbiter'):
g.log.info("Cannot check for layout completeness as"
" volume under test is Replicate/Disperse/Arbiter")
else:
diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_init.py b/glustolibs-gluster/glustolibs/gluster/gluster_init.py
index fd8f174..d6740b7 100644
--- a/glustolibs-gluster/glustolibs/gluster/gluster_init.py
+++ b/glustolibs-gluster/glustolibs/gluster/gluster_init.py
@@ -290,10 +290,10 @@ def get_gluster_version(host):
host(str): IP of the host whose gluster version has to be checked.
Returns:
- (float): The gluster version value.
+ str: The gluster version value.
"""
command = 'gluster --version'
_, out, _ = g.run(host, command)
g.log.info("The Gluster verion of the cluster under test is %s",
out)
- return float(out.split(' ')[1])
+ return out.split(' ')[1]
diff --git a/glustolibs-gluster/glustolibs/gluster/layout.py b/glustolibs-gluster/glustolibs/gluster/layout.py
index 8d7ae2d..ea5a5bc 100644
--- a/glustolibs-gluster/glustolibs/gluster/layout.py
+++ b/glustolibs-gluster/glustolibs/gluster/layout.py
@@ -19,7 +19,6 @@
from glusto.core import Glusto as g
from glustolibs.gluster.brickdir import BrickDir
-from glustolibs.gluster.gluster_init import get_gluster_version
class Layout(object):
@@ -35,20 +34,19 @@ class Layout(object):
self._brickdirs = []
for brickdir_path in self._pathinfo['brickdir_paths']:
(host, _) = brickdir_path.split(':')
- if get_gluster_version(host) >= 6.0:
- ret = get_volume_type(brickdir_path)
- if ret in ('Replicate', 'Disperse', 'Arbiter'):
- g.log.info("Cannot get layout as volume under test is"
- " Replicate/Disperse/Arbiter and DHT"
- " pass-through was enabled after Gluster 6.")
+ ret = get_volume_type(brickdir_path)
+ if ret in ('Replicate', 'Disperse', 'Arbiter'):
+ g.log.info("Cannot get layout as volume under test is"
+ " Replicate/Disperse/Arbiter and DHT"
+ " pass-through was enabled after Gluster 6.0")
+ else:
+ brickdir = BrickDir(brickdir_path)
+ if brickdir is None:
+ g.log.error("Failed to get the layout")
else:
- brickdir = BrickDir(brickdir_path)
- if brickdir is None:
- g.log.error("Failed to get the layout")
- else:
- g.log.debug("%s: %s" % (brickdir.path,
- brickdir.hashrange))
- self._brickdirs.append(brickdir)
+ g.log.debug("%s: %s" % (brickdir.path,
+ brickdir.hashrange))
+ self._brickdirs.append(brickdir)
def __init__(self, pathinfo):
"""Init the layout class
@@ -80,9 +78,8 @@ class Layout(object):
for brickdir_path in self._pathinfo['brickdir_paths']:
(host, _) = brickdir_path.split(':')
- if (get_gluster_version(host) >= 6.0 and
- get_volume_type(brickdir_path) in ('Replicate', 'Disperse',
- 'Arbiter')):
+ if get_volume_type(brickdir_path) in ('Replicate', 'Disperse',
+ 'Arbiter'):
g.log.info("Cannot check for layout completeness as volume"
" under test is Replicate/Disperse/Arbiter and DHT"
" pass-though was enabled after Gluster 6.")