From 5794376578905efb2f26a3ae5c8fcdf1d72cb5f8 Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Mon, 10 Dec 2012 21:11:16 +0800 Subject: [PATCH] LU-797 tests: process lfs df output properly There is a space in the "filesystem summary" of lfs df output, which could cause trouble for the parsing script, test_23b of ost-pool.sh is an example. We introduced lfs_df() function to remove this space internally, this will allow fixing the "lfs df" output line in the future. port of master patch fb1a1ec6300a5ec3925b725d5d2b783314dff3f8 Signed-off-by: Niu Yawei Signed-off-by: Liu Ying Change-Id: Iba57b4aac714e28ebdd985f15ff3e2444e64e007 Reviewed-on: http://review.whamcloud.com/4784 Tested-by: Hudson Reviewed-by: Niu Yawei Reviewed-by: Andreas Dilger Tested-by: Maloo --- lustre/tests/ost-pools.sh | 2 +- lustre/tests/sanity-benchmark.sh | 2 +- lustre/tests/sanity.sh | 2 +- lustre/tests/sanityn.sh | 2 +- lustre/tests/test-framework.sh | 17 +++++++++++------ 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lustre/tests/ost-pools.sh b/lustre/tests/ost-pools.sh index 4036e5f..a53774d 100644 --- a/lustre/tests/ost-pools.sh +++ b/lustre/tests/ost-pools.sh @@ -1242,7 +1242,7 @@ test_23b() { add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT" create_dir $dir $POOL - AVAIL=$($LFS df -p $POOL $dir | awk '/summary/ { print $4 }') + local AVAIL=$(lfs_df -p $POOL $dir | awk '/summary/ { print $4 }') [ $AVAIL -gt $MAXFREE ] && skip_env "Filesystem space $AVAIL is larger than $MAXFREE limit" && return 0 diff --git a/lustre/tests/sanity-benchmark.sh b/lustre/tests/sanity-benchmark.sh index e3dd8e6..387cc53 100644 --- a/lustre/tests/sanity-benchmark.sh +++ b/lustre/tests/sanity-benchmark.sh @@ -236,7 +236,7 @@ space_check () { local stripe=$($LFS getstripe -c $testdir) # if stripe_count = 1 the size should be less than min ost size, bug 24294 - local space=$($LFS df $testdir | grep "filesystem summary:" | awk '{print $3}') + local space=$(lfs_df $testdir | grep "summary" | awk '{print $2}') [ $stripe -eq 1 ] && space=$(min_ost_size) local size=$(pios_file_size) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index a933988..932137e 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -856,7 +856,7 @@ page_size() { test_24v() { local NRFILES=100000 - local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'` + local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}') [ $FREE_INODES -lt $NRFILES ] && \ skip "not enough free inodes $FREE_INODES required $NRFILES" && \ return diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh index 0d0ca1a..71db183 100644 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -468,7 +468,7 @@ run_test 24a "lfs df [-ih] [path] test =========================" test_24b() { touch $DIR1/$tfile - fsnum=`lfs df | grep -c "filesystem summary:"` + fsnum=$(lfs_df | grep -c "summary") [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems." } run_test 24b "lfs df should show both filesystems ===============" diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 45d07cf..871af13 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -790,11 +790,11 @@ setup_quota_old(){ local quota_usrs=$QUOTA_USERS # get_filesystem_size - local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}') + local disksz=$(lfs_df $mntpt | grep "summary" | awk '{print $2}') local blk_soft=$((disksz + 1024)) local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over - local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}') + local Inodes=$(lfs_df -i $mntpt | grep "summary" | awk '{print $2}') local i_soft=$Inodes local i_hard=$((i_soft + i_soft / 20)) @@ -847,6 +847,13 @@ restore_quota() { fi } +# Handle the case when there is a space in the lfs df +# "filesystem summary" line the same as when there is no space. +# This will allow fixing the "lfs df" summary line in the future. +lfs_df() { + $LFS df $* | sed -e 's/filesystem /filesystem_/' +} + setup_quota(){ if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then setup_quota_old $1 @@ -873,13 +880,11 @@ setup_quota(){ local quota_usrs=$QUOTA_USERS # get_filesystem_size - local disksz=$(lfs df $mntpt | grep "filesystem summary:" | - awk '{print $3}') + local disksz=$(lfs_df $mntpt | grep "summary" | awk '{print $2}') local blk_soft=$((disksz + 1024)) local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over - local inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | - awk '{print $3}') + local inodes=$(lfs_df -i $mntpt | grep "summary" | awk '{print $2}') local i_soft=$inodes local i_hard=$((i_soft + i_soft / 20)) -- 1.8.3.1