summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranav <prprakas@redhat.com>2020-09-28 10:17:09 +0530
committerArthy Loganathan <aloganat@redhat.com>2020-10-07 04:51:02 +0000
commitf3bf953cf56b66cf1ef11b6550079db9e9cf8fa8 (patch)
treee8b004ce174bd7ccad928bcad8a119ccee543c7a
parent942596395abe4330e0f04fca50b347d0b34e2d9a (diff)
[TestFix] Add check vol size after bringing min brick down
Added check to verify the behavior after bringing down the smallest brick. The available volume size should not be greater than the initial vol size Test skipped due to bug: https://bugzilla.redhat.com/show_bug.cgi?id=1883429 Change-Id: I00c0310210f6fe218cedd23e055dfaec3632ec8d Signed-off-by: Pranav <prprakas@redhat.com>
-rwxr-xr-x[-rw-r--r--]tests/functional/disperse/test_ec_brick_consumable_size.py104
1 files changed, 67 insertions, 37 deletions
diff --git a/tests/functional/disperse/test_ec_brick_consumable_size.py b/tests/functional/disperse/test_ec_brick_consumable_size.py
index e2cee80b1..c37dc834b 100644..100755
--- a/tests/functional/disperse/test_ec_brick_consumable_size.py
+++ b/tests/functional/disperse/test_ec_brick_consumable_size.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2018 Red Hat, Inc. <http://www.redhat.com>
+# Copyright (C) 2018-2020 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
@@ -21,8 +21,10 @@ EcBrickConsumableSize:
'number of data bricks * least of brick size'.
"""
+from unittest import skip
from glusto.core import Glusto as g
-from glustolibs.gluster.brick_libs import get_all_bricks
+from glustolibs.gluster.brick_libs import (get_all_bricks,
+ bring_bricks_offline)
from glustolibs.gluster.exceptions import ExecutionError
from glustolibs.gluster.volume_libs import (get_volume_info)
from glustolibs.gluster.lib_utils import get_size_of_mountpoint
@@ -41,68 +43,96 @@ class EcBrickConsumableSize(GlusterBaseClass):
raise ExecutionError("Failed to Setup_Volume and Mount_Volume")
g.log.info("Successful in Setup Volume and Mount Volume")
- # Test Case
- def test_disperse_vol_size(self):
- # pylint: disable=too-many-locals
- mnode = self.mnode
- volname = self.volname
- client = self.mounts[0].client_system
- mountpoint = self.mounts[0].mountpoint
-
- # Obtain the volume size
- vol_size = get_size_of_mountpoint(client, mountpoint)
- self.assertIsNotNone(vol_size, ("Unable to get the volsize \
- of %s.", volname))
-
- # Retrieve the minimum brick size
+ def _get_min_brick(self):
+ # Returns the brick with min size
+ bricks_list = get_all_bricks(self.mnode, self.volname)
min_brick_size = -1
- bricks_list = get_all_bricks(mnode, volname)
+ min_size_brick = None
for brick in bricks_list:
brick_node, brick_path = brick.split(":")
brick_size = get_size_of_mountpoint(brick_node, brick_path)
if ((brick_size is not None) and (min_brick_size == -1) or
(int(min_brick_size) > int(brick_size))):
min_brick_size = brick_size
+ min_size_brick = brick
+ return min_size_brick, min_brick_size
- # Calculate the consumable size
- vol_info = get_volume_info(mnode, volname)
+ def _get_consumable_vol_size(self, min_brick_size):
+ # Calculates the consumable size of the volume created
+ vol_info = get_volume_info(self.mnode, self.volname)
self.assertIsNotNone(vol_info, ("Unable to get the volinfo \
- of %s.", volname))
-
- disp_data_bricks = (int(vol_info[volname]['disperseCount']) -
- int(vol_info[volname]['redundancyCount']))
- dist_count = (int(vol_info[volname]['brickCount']) /
- int(vol_info[volname]['disperseCount']))
+ of %s.", self.volname))
+ disp_data_bricks = (int(vol_info[self.volname]['disperseCount']) -
+ int(vol_info[self.volname]['redundancyCount']))
+ dist_count = (int(vol_info[self.volname]['brickCount']) /
+ int(vol_info[self.volname]['disperseCount']))
consumable_size = ((int(min_brick_size) * int(disp_data_bricks)) *
int(dist_count))
+ return consumable_size, dist_count
+
+ @skip('Skipping this test due to Bug 1883429')
+ def test_disperse_vol_size(self):
+ # pylint: disable=too-many-locals
+ client = self.mounts[0].client_system
+ mount_point = self.mounts[0].mountpoint
+
+ # Obtain the volume size
+ vol_size = get_size_of_mountpoint(client, mount_point)
+ self.assertIsNotNone(vol_size, ("Unable to get the volsize "
+ "of %s.", self.volname))
+
+ # Retrieve the minimum brick size
+ min_size_brick, min_brick_size = self._get_min_brick()
+
+ # Calculate the consumable size
+ consumable_size, dist_count = (
+ self._get_consumable_vol_size(min_brick_size))
# Verify the volume size is in allowable range
# Volume size should be above 98% of consumable size.
delta = (100 - ((float(vol_size)/float(consumable_size)) * 100))
- self.assertTrue(delta < 2, ("Volume size is not in allowable range"))
-
+ self.assertTrue(delta < 2, "Volume size is not in allowable range")
g.log.info("Volume size is in allowable range")
# Write to the available size
block_size = 1024
- write_size = ((int(vol_size) * (0.95) * int(block_size)) /
+ write_size = ((int(vol_size) * 0.95 * int(block_size)) /
(int(dist_count)))
for i in range(1, int(dist_count)):
- ret, _, _ = g.run(client, "fallocate -l {} {}/testfile{} \
- ".format(int(write_size), mountpoint, i))
- self.assertTrue(ret == 0, ("Writing file of available size failed \
- on volume %s", volname))
+ ret, _, _ = g.run(client, "fallocate -l {} {}/testfile{} "
+ .format(int(write_size), mount_point, i))
+ self.assertTrue(ret == 0, ("Writing file of available size "
+ "failed on volume %s", self.volname))
g.log.info("Successfully verified volume size")
# Try writing more than the available size
write_size = ((int(vol_size) * int(block_size)) * 1.2)
- ret, _, _ = g.run(client, "fallocate -l {} {}/testfile1 \
- ".format(int(write_size), mountpoint))
- self.assertTrue(ret != 0, ("Writing file of more than available \
- size passed on volume %s", volname))
-
+ ret, _, _ = g.run(client, "fallocate -l {} {}/testfile1 "
+ .format(int(write_size), mount_point))
+ self.assertTrue(ret != 0, ("Writing file of more than available "
+ "size passed on volume %s", self.volname))
g.log.info("Successfully verified brick consumable size")
+ # Cleanup the mounts to verify
+ cmd = ('rm -rf %s' % mount_point)
+ ret, _, _ = g.run(client, cmd)
+ if ret:
+ g.log.error("Failed to cleanup vol data on %s", mount_point)
+ # Bring down the smallest brick
+ ret = bring_bricks_offline(self.volname, min_size_brick)
+ self.assertTrue(ret, "Failed to bring down the smallest brick")
+
+ # Find the volume size post brick down
+ post_vol_size = get_size_of_mountpoint(client, mount_point)
+ self.assertIsNotNone(post_vol_size, ("Unable to get the volsize "
+ "of %s.", self.volname))
+
+ # Vol size after bringing down the brick with smallest size should
+ # not be greater than the actual size
+ self.assertGreater(vol_size, post_vol_size,
+ ("The volume size after bringing down the volume "
+ "is greater than the initial"))
+
# Method to cleanup test setup
def tearDown(self):
# Stopping the volume