From 06ed7dc11166975b80c35ec56d82a08b8686f6de Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Tue, 15 Oct 2019 15:29:48 +0530 Subject: tests: Remove hard-coding of lower bound Problem: Total blocks of XFS partition are dependent on XFS parameters used for formatting. So hardcoded lower-bound may not be the lower bound for different default parameters. Used blocks are lesser on my machine for a freshly formatted XFS partition compared to where the test fails. On my machine: Filesystem 1024-blocks Used Available Capacity Mounted on /dev/loop0 98980 5472 93508 6% /d/backends/patchy1 /dev/loop1 98980 5472 93508 6% /d/backends/patchy2 On a machine where this test fails: Filesystem 1024-blocks Used Available Capacity Mounted on /dev/loop0 96928 6112 90816 7% /d/backends/patchy1 /dev/loop1 96928 6112 90816 7% /d/backends/patchy2 Fix: Make lower bound 2% less than the brick-blocks available fixes: bz#1761759 Change-Id: I974d5e75766f7ff44780a2e4c2a19cd5d1d14a79 Signed-off-by: Pranith Kumar K --- tests/basic/posix/shared-statfs.t | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/basic/posix/shared-statfs.t b/tests/basic/posix/shared-statfs.t index 33439562ec9..0e4a1bb409f 100644 --- a/tests/basic/posix/shared-statfs.t +++ b/tests/basic/posix/shared-statfs.t @@ -20,15 +20,18 @@ TEST mkdir -p $B0/${V0}1 $B0/${V0}2 TEST MOUNT_LOOP $LO1 $B0/${V0}1 TEST MOUNT_LOOP $LO2 $B0/${V0}2 +total_brick_blocks=$(df -P $B0/${V0}1 $B0/${V0}2 | tail -2 | awk '{sum = sum+$2}END{print sum}') +#Account for rounding error +brick_blocks_two_percent_less=$((total_brick_blocks*98/100)) # Create a subdir in mountpoint and use that for volume. TEST $CLI volume create $V0 $H0:$B0/${V0}1/1 $H0:$B0/${V0}2/1; TEST $CLI volume start $V0 EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" online_brick_count TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0 -total_space=$(df -P $M0 | tail -1 | awk '{ print $2}') +total_mount_blocks=$(df -P $M0 | tail -1 | awk '{ print $2}') # Keeping the size less than 200M mainly because XFS will use # some storage in brick to keep its own metadata. -TEST [ $total_space -gt 194000 -a $total_space -lt 200000 ] +TEST [ $total_mount_blocks -gt $brick_blocks_two_percent_less -a $total_mount_blocks -lt 200000 ] TEST force_umount $M0 @@ -41,8 +44,8 @@ TEST $CLI volume add-brick $V0 $H0:$B0/${V0}1/2 $H0:$B0/${V0}2/2 $H0:$B0/${V0}1/ TEST $CLI volume start $V0 EXPECT_WITHIN $PROCESS_UP_TIMEOUT "6" online_brick_count TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0 -total_space=$(df -P $M0 | tail -1 | awk '{ print $2}') -TEST [ $total_space -gt 194000 -a $total_space -lt 200000 ] +total_mount_blocks=$(df -P $M0 | tail -1 | awk '{ print $2}') +TEST [ $total_mount_blocks -gt $brick_blocks_two_percent_less -a $total_mount_blocks -lt 200000 ] TEST force_umount $M0 TEST $CLI volume stop $V0 -- cgit