summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xglustolibs-gluster/glustolibs/gluster/lib_utils.py22
-rw-r--r--tests/functional/dht/test_rename_with_brick_min_free_limit_crossed.py7
2 files changed, 24 insertions, 5 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/lib_utils.py b/glustolibs-gluster/glustolibs/gluster/lib_utils.py
index 7299874..26f2ad9 100755
--- a/glustolibs-gluster/glustolibs/gluster/lib_utils.py
+++ b/glustolibs-gluster/glustolibs/gluster/lib_utils.py
@@ -1199,3 +1199,25 @@ def collect_bricks_arequal(bricks_list):
arequal_list.append(arequal)
return (return_code, arequal_list)
+
+
+def get_usable_size_per_disk(brickpath, min_free_limit=10):
+ """Get the usable size per disk
+
+ Args:
+ brickpath(str): Brick path to be used to calculate usable size
+
+ Kwargs:
+ min_free_limit(int): Min free disk limit to be used
+
+ Returns:
+ (int): Usable size in GB. None in case of errors.
+ """
+ node, brick_path = brickpath.split(':')
+ size = get_size_of_mountpoint(node, brick_path)
+ if not size:
+ return None
+ size = int(size)
+ min_free_size = size * min_free_limit // 100
+ usable_size = ((size - min_free_size) // 1048576) + 1
+ return usable_size
diff --git a/tests/functional/dht/test_rename_with_brick_min_free_limit_crossed.py b/tests/functional/dht/test_rename_with_brick_min_free_limit_crossed.py
index 0745ef5..0e481fc 100644
--- a/tests/functional/dht/test_rename_with_brick_min_free_limit_crossed.py
+++ b/tests/functional/dht/test_rename_with_brick_min_free_limit_crossed.py
@@ -17,7 +17,7 @@
from glusto.core import Glusto as g
from glustolibs.gluster.gluster_base_class import GlusterBaseClass, runs_on
from glustolibs.gluster.exceptions import ExecutionError
-from glustolibs.gluster.lib_utils import get_size_of_mountpoint
+from glustolibs.gluster.lib_utils import get_usable_size_per_disk
from glustolibs.gluster.brick_libs import get_all_bricks
@@ -61,10 +61,7 @@ class TestRenameWithBricksMinFreeLimitCrossed(GlusterBaseClass):
# Calculate the usable size and fill till it reachs
# min free limit
- node, brick_path = bricks[0].split(':')
- size = int(get_size_of_mountpoint(node, brick_path))
- min_free_size = size * 10 // 100
- usable_size = ((size - min_free_size) // 1048576) + 1
+ usable_size = get_usable_size_per_disk(bricks[0])
ret, _, _ = g.run(self.first_client, "fallocate -l {}G {}/file"
.format(usable_size, self.mount_point))
self.assertFalse(ret, "Failed to fill disk to min free limit")