summaryrefslogtreecommitdiffstats
path: root/tests/distaf
diff options
context:
space:
mode:
authorArthy Loganathan <aloganat@redhat.com>2016-05-24 15:23:43 +0530
committerM S Vishwanath Bhat <msvbhat@gmail.com>2016-06-02 01:39:53 -0700
commit851a58733fe9f78b03819080e4a6883c69d41032 (patch)
treeb2c4c7107f91dec48278447de1407d864c2708e4 /tests/distaf
parent3ae22b61f9aa01f0a97f8f1b3ef75add74c02f7d (diff)
Added timeout value to wait for rebalance to complete and removed older rebalance library file
Change-Id: I89e2e436ec9306a80a87faab6d6e53f547ce4e42 BUG: 1339166 Signed-off-by: Arthy Loganathan <aloganat@redhat.com> Reviewed-on: http://review.gluster.org/14515 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: M S Vishwanath Bhat <msvbhat@gmail.com>
Diffstat (limited to 'tests/distaf')
-rw-r--r--tests/distaf/distaf_libs/distaflibs-gluster/distaflibs/gluster/rebalance.py121
-rw-r--r--tests/distaf/distaf_libs/distaflibs-gluster/distaflibs/gluster/rebalance_ops.py8
2 files changed, 5 insertions, 124 deletions
diff --git a/tests/distaf/distaf_libs/distaflibs-gluster/distaflibs/gluster/rebalance.py b/tests/distaf/distaf_libs/distaflibs-gluster/distaflibs/gluster/rebalance.py
deleted file mode 100644
index 721e1a907dc..00000000000
--- a/tests/distaf/distaf_libs/distaflibs-gluster/distaflibs/gluster/rebalance.py
+++ /dev/null
@@ -1,121 +0,0 @@
-# This file is part of DiSTAF
-# Copyright (C) 2015-2016 Red Hat, Inc. <http://www.redhat.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-
-import re
-import time
-from distaf.util import tc
-
-"""
- Libraries containing gluster rebalance operations
-"""
-
-def get_rebal_nodes(server):
- '''
- This function finds out the number of rebalance nodes from
- gluster v info command
-
- Returns the number of nodes participating in rebalance process
- '''
- val = tc.run(server, \
-"gluster v info | grep 'Brick[0-9]' | cut -d ':' -f 2 | sed 's/\ //'")
- nlist = val[1].rstrip().split('\n')
- nnodes = list(set(nlist))
- return len(nnodes)
-
-def get_rebal_dict(status):
- '''
- This function returns the rebalance status info in the form of dictionary
- '''
- _list = status.split('\n')
- rebal_dict = {}
- for _item in _list:
- _match = re.search('.*?(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\w+\s*\w+)\s+(\S+).*', _item, re.S)
- if _match is not None:
- rebal_dict[_match.group(1)] = [_match.group(2), _match.group(3), \
- _match.group(4), _match.group(5), _match.group(6), \
- _match.group(7),_match.group(8)]
- return rebal_dict
-
-
-def get_rebal_status(volname, server=''):
- '''
- This function gives rebalance status
- Valid states are started/failed/in progress/completed
- if the server pararmeter is empty it takes node info from config file
- '''
- if server == "":
- server = tc.servers[0]
- status = tc.run(server, "gluster v rebalance %s status" %volname)
- if status[0] != 0:
- if "not started" in status[2]:
- tc.logger.error("Rebalance has not started")
- return ("not started", " ")
- else:
- tc.logger.error("error")
- return ("error", " ")
- else:
- rebal_dict = get_rebal_dict(status[1])
- if "failed" in status[1]:
- tc.logger.error("Rebalance status command failed")
- return ("failed", rebal_dict)
- elif "in progress" in status[1]:
- tc.logger.info("Rebalance is in progress")
- return ("in progress", rebal_dict)
- elif "completed" in status[1]:
- counter = status[1].count("completed")
- nnodes = get_rebal_nodes(server)
- if counter == nnodes:
- tc.logger.info("Rebalance is completed")
- return ("completed", rebal_dict)
- else:
- tc.logger.error("Rebalacne has not completed on all nodes")
- return ("invalid status", rebal_dict)
-
-def wait_rebal_complete(volname, time_out = 300, server=''):
- '''
- This function calls rebalance_status_once function and
- waits if the rebalance status is in progress, exists on timeout,
- default timeout is 300sec(5 min)
- '''
- ret = get_rebal_status(volname, server)
- while time_out != 0 and ret[0] == "in progress":
- time_out = time_out - 20
- time.sleep(20)
- ret = get_rebal_status(volname, server)
- return ret
-
-
-def rebal_start(volname, server=''):
- """
- Simple interface to start the gluster rebalance
- @ pararmeter:
- * volname
- * server - defaults to tc.servers[0]
- @ returns:
- True on success
- False otherwise
- """
- if server == '':
- server = tc.servers[0]
- ret = tc.run(server, "gluster volume rebalance %s start" % volname)
- if ret[0] != 0:
- tc.logger.error("rebalance start %s failed" % volname)
- return False
- else:
- tc.logger.debug("rebalance start %s successful" % volname)
- return True
diff --git a/tests/distaf/distaf_libs/distaflibs-gluster/distaflibs/gluster/rebalance_ops.py b/tests/distaf/distaf_libs/distaflibs-gluster/distaflibs/gluster/rebalance_ops.py
index 271d4f4001f..2679cc3eac3 100644
--- a/tests/distaf/distaf_libs/distaflibs-gluster/distaflibs/gluster/rebalance_ops.py
+++ b/tests/distaf/distaf_libs/distaflibs-gluster/distaflibs/gluster/rebalance_ops.py
@@ -290,7 +290,7 @@ def rebalance_stop_and_get_status(volname, mnode=None):
return rebal_status
-def wait_for_rebalance_to_complete(volname, mnode=None):
+def wait_for_rebalance_to_complete(volname, mnode=None, timeout=300):
"""Waits for the rebalance to complete
Args:
@@ -299,6 +299,8 @@ def wait_for_rebalance_to_complete(volname, mnode=None):
Kwargs:
mnode (str): Node on which command has to be executed.
If None, defaults to nodes[0].
+ timeout (int): timeout value in seconds to wait for rebalance
+ to complete
Returns:
True on success, False otherwise
@@ -312,7 +314,7 @@ def wait_for_rebalance_to_complete(volname, mnode=None):
count = 0
flag = 0
- while (count < 300):
+ while (count < timeout):
status_info = get_rebalance_status(volname, mnode=mnode)
if status_info is None:
return False
@@ -323,7 +325,7 @@ def wait_for_rebalance_to_complete(volname, mnode=None):
break
time.sleep(10)
- count = count + 5
+ count = count + 10
if not flag:
tc.logger.error("rebalance is not completed")
return False