From: Niu Yawei Date: Thu, 29 Nov 2012 09:59:40 +0000 (-0500) Subject: LU-797 tests: process lfs df output properly X-Git-Tag: 2.3.57~3 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=fb1a1ec6300a5ec3925b725d5d2b783314dff3f8 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. Signed-off-by: Niu Yawei Change-Id: I524d42a5e792a1b29db52166e92624bf42312c3f Reviewed-on: http://review.whamcloud.com/4705 Tested-by: Hudson Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu Tested-by: Maloo --- diff --git a/lustre/tests/mds-survey.sh b/lustre/tests/mds-survey.sh index a7a192a..63510e9 100644 --- a/lustre/tests/mds-survey.sh +++ b/lustre/tests/mds-survey.sh @@ -37,8 +37,7 @@ adjust_inode() { require_inode=$((file_count * thrhi)) # get available inode for mdt - avail_mdt_inode=$($LFS df -i $MOUNT | grep "filesystem summary:" | \ - awk '{print $5}') + avail_mdt_inode=$(lfs_df -i $MOUNT | grep "summary" | awk '{print $4}') avail_mdt_inode=$((avail_mdt_inode * 9 / 10)) # get available inode for ost diff --git a/lustre/tests/ost-pools.sh b/lustre/tests/ost-pools.sh index cd59fa1..f5f972f 100644 --- a/lustre/tests/ost-pools.sh +++ b/lustre/tests/ost-pools.sh @@ -1249,7 +1249,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 adac0d9..2e9f734 100644 --- a/lustre/tests/sanity-benchmark.sh +++ b/lustre/tests/sanity-benchmark.sh @@ -237,7 +237,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-quota.sh b/lustre/tests/sanity-quota.sh index 1da366a..f524b9f 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -367,8 +367,7 @@ test_0() { local MB=100 # 100M [ "$SLOW" = "no" ] && MB=10 - local free_space=$(lfs df | grep "filesystem summary" | \ - awk '{print $5}') + local free_space=$(lfs_df | grep "summary" | awk '{print $4}') [ $free_space -le $((MB * 1024)) ] && skip "not enough space ${free_space} KB, " \ "required $((MB * 1024)) KB" && return @@ -472,8 +471,7 @@ test_2() { [ "$SLOW" = "no" ] && LIMIT=1024 # 1k inodes - 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 $LIMIT ] && skip "not enough free inodes $FREE_INODES required $LIMIT" && return diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 35dfeb7..caf86b9 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -868,7 +868,7 @@ simple_cleanup_common() { 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 c4116fe..294b4966 100644 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -499,7 +499,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 921063e..6d31bf2 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -1092,11 +1092,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)) @@ -1149,6 +1149,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 @@ -1175,13 +1182,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))