From: James Nunez Date: Thu, 23 Jun 2016 22:51:56 +0000 (-0600) Subject: LU-7813 tests: clean up ost-pools.sh X-Git-Tag: 2.8.58~49 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=9ae317d9b4fa0cd40365d0100172d0b8e0dbc828 LU-7813 tests: clean up ost-pools.sh Clean up the tests in ost-pools.sh to drop archaic use of "lfs getstripe -v" that parses the output text in favour of using options for "lfs getstripe -c" for OST count. Add the check for newly-created dir/file being in the pool into create_dir() and create_file(). Test-Parameters: trivial testlist=ost-pools Signed-off-by: Andreas Dilger Signed-off-by: James Nunez Change-Id: Ib2df663a62f89df48a70d07702b41f05f0194ef9 Reviewed-on: http://review.whamcloud.com/18889 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Saurabh Tandan Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/ost-pools.sh b/lustre/tests/ost-pools.sh index 6775f375..104268c 100755 --- a/lustre/tests/ost-pools.sh +++ b/lustre/tests/ost-pools.sh @@ -1,11 +1,8 @@ #!/bin/bash -# -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*- -# vim:shiftwidth=4:softtabstop=4:tabstop=4: # # Run select tests by setting ONLY, or as arguments to the script. # Skip specific tests by setting EXCEPT. # -# Run test by setting NOSETUP=true when ltest has setup env for us SRCDIR=$(dirname $0) export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin @@ -60,30 +57,32 @@ TGT_UUID=$(for i in $TGT_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done) TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done) create_dir() { - local dir=$1 - local pool=$2 - local count=${3:-"-1"} - local idx=$4 + local dir=$1 + local pool=$2 + local count=${3:-"-1"} + local idx=$4 - mkdir -p $dir - if [[ -n $idx ]]; then - $SETSTRIPE -c $count -p $pool -i $idx $dir - else - $SETSTRIPE -c $count -p $pool $dir - fi - [[ $? -eq 0 ]] || - error "$SETSTRIPE -p $pool $dir failed." + mkdir -p $dir + if [[ -n $idx ]]; then + $LFS setstripe -c $count -p $pool -i $idx $dir + else + $LFS setstripe -c $count -p $pool $dir + fi + [[ $? -eq 0 ]] || error "$LFS setstripe -p $pool $dir failed" + [[ "$($LFS getstripe --pool $dir)" == "$pool" ]] || + error "$dir not created in expected pool '$pool'" } create_file() { - local file=$1 - local pool=$2 - local count=${3:-"-1"} - local index=${4:-"-1"} - rm -f $file - $SETSTRIPE -i $index -c $count -p $pool $file - [[ $? -eq 0 ]] || - error "$SETSTRIPE -p $pool $file failed." + local file=$1 + local pool=$2 + local count=${3:-"-1"} + local index=${4:-"-1"} + rm -f $file + $LFS setstripe -i $index -c $count -p $pool $file + [[ $? -eq 0 ]] || error "$LFS setstripe -p $pool $file failed" + [[ "$($LFS getstripe --pool $file)" == "$pool" ]] || + error "$file not created in '$pool'" } osts_in_pool() { @@ -97,74 +96,70 @@ osts_in_pool() { } check_dir_in_pool() { - local dir=$1 - local pool=$2 - local res=$($GETSTRIPE $dir | grep "^stripe_count:" | - cut -d ':' -f 5 | tr -d "[:blank:]") - if [[ "$res" != "$pool" ]]; then - error found $res instead of $pool - return 1 - fi + local dir=$1 + local pool=$2 + local res=$($LFS getstripe --pool $dir) - return 0 -} + [ -n "$res" ] || error "dir '$dir' not in any pool" -check_file_in_pool() { - local osts=$(osts_in_pool $2) - check_file_in_osts $1 "$osts" $3 + [ "$res" == "$pool" ] || + error "dir '$dir' in pool '$res' instead of '$pool'" } -check_file_in_osts() { - local file=$1 - local pool_list=${2:-$TGT_LIST} - local count=$3 - local res=$($GETSTRIPE $file | grep 0x | cut -f2) - local i - for i in $res; do - found=$(echo :$pool_list: | tr " " ":" | grep :$i:) - if [[ "$found" == "" ]]; then - echo "pool list: $pool_list" - echo "striping: $res" - $GETSTRIPE $file - error "$file not allocated from OSTs $pool_list." - return 1 - fi - done +check_file_in_pool() { + local file="$1" + local pool=$2 + local count=$3 + local osts=$(osts_in_pool $pool) + local res=$($LFS getstripe --pool $file) - local ost_count=$($GETSTRIPE $file | grep 0x | wc -l) - [[ -n "$count" ]] && [[ $ost_count -ne $count ]] && - { error "Stripe count $count expected; got $ost_count" && return 1;} + [ -n "$res" ] || error "file '$file' not in any pool" + [ "$res" == "$pool" ] || + error "file '$file' in pool '$res' instead of '$pool'" + local osts=$(osts_in_pool $2) + check_file_in_osts "$file" "$osts" $count } -file_pool() { - $GETSTRIPE -v $1 | grep "^lmm_pool:" | tr -d "[:blank:]" | cut -f 2 -d ':' +check_file_in_osts() { + local file=$1 + local ost_list=${2:-$TGT_LIST} + local count=$3 + local res=$($LFS getstripe $file | awk '/0x/ { print $1 }') + local i + + for i in $res; do + found=$(echo :$ost_list: | tr " " ":" | grep :$i:) + if [[ "$found" == "" ]]; then + echo "ost list: $ost_list" + echo "striping: $res" + $LFS getstripe -v $file + error "$file not allocated from OSTs $ost_list." + fi + done + + local ost_count=$($LFS getstripe -c $file) + [[ -n "$count" ]] && [[ $ost_count -ne $count ]] && + error "$file stripe count $count expected; got $ost_count" && + return 1 + } check_file_not_in_pool() { - local file=$1 - local pool=$2 - local res=$(file_pool $file) + local file=$1 + local pool=$2 + local res=$($LFS getstripe --pool $file) - if [[ "$res" == "$pool" ]]; then - error "File $file is in pool: $res" - return 1 - else - return 0 - fi + [ "$res" != "$pool" ] || error "File '$file' is in pool: $res" } check_dir_not_in_pool() { local dir=$1 local pool=$2 - local res=$($GETSTRIPE -v $dir | grep "^stripe_count" | head -n1 | - cut -f 8 -d ' ') - if [[ "$res" == "$pool" ]]; then - error "File $dir is in pool: $res" - return 1 - fi - return 0 + local res=$($LFS getstripe --pool $dir) + + [ "$res" != "$pool" ] || error "Dir '$dir' is in pool: $res" } drain_pool() { @@ -761,8 +756,6 @@ test_11() { create_dir $POOL_ROOT/dir1 $POOL create_dir $POOL_ROOT/dir2 $POOL2 - check_dir_in_pool $POOL_ROOT/dir1 $POOL - check_dir_in_pool $POOL_ROOT/dir1 $POOL local numfiles=100 createmany -o $POOL_ROOT/dir1/$tfile $numfiles || @@ -807,8 +800,6 @@ test_12() { create_file $POOL_ROOT/file2 $POOL2 echo Checking the files created - check_dir_in_pool $POOL_ROOT/dir1 $POOL - check_dir_in_pool $POOL_ROOT/dir2 $POOL2 check_file_in_pool $POOL_ROOT/file1 $POOL check_file_in_pool $POOL_ROOT/file2 $POOL2 @@ -857,15 +848,12 @@ test_13() { check_file_in_pool $file $POOL $OSTCOUNT done - create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST - create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1)) - create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2)) - check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1 - check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1 - create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2)) - check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST)) - check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))" - check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))" + create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST + create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1)) + create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2)) + check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST)) + check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))" + check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))" create_dir $POOL_ROOT/dir2 $POOL $count createmany -o $POOL_ROOT/dir2/$tfile- $numfiles || @@ -888,17 +876,16 @@ test_13() { check_file_in_pool $file $POOL 1 done - create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2)) - createmany -o $POOL_ROOT/dir5/$tfile- $numfiles || - error "createmany $POOL_ROOT/dir5/$tfile- failed!" - for file in $POOL_ROOT/dir5/*; do - check_file_in_pool $file $POOL 1 - check_file_in_osts $file "$((TGT_FIRST + 2))" - done + create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2)) + createmany -o $POOL_ROOT/dir5/$tfile- $numfiles || + error "createmany $POOL_ROOT/dir5/$tfile- failed!" + for file in $POOL_ROOT/dir5/*; do + check_file_in_pool $file $POOL 1 + done - rm -rf $POOL_ROOT/dir[1-5]/ + rm -rf $POOL_ROOT/dir[1-5]/ - return 0 + return 0 } run_test 13 "Striping characteristics in a pool" @@ -920,19 +907,19 @@ test_14() { add_pool $POOL $TGT_HALF "$TGT_UUID2" add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID " - create_dir $POOL_ROOT/dir1 $POOL 1 - create_file $POOL_ROOT/dir1/file $POOL 1 - local OST=$($GETSTRIPE -i $POOL_ROOT/dir1/file) - i=0 - while [[ $i -lt $numfiles ]]; do - OST=$((OST + 2)) - [[ $OST -gt $((16#$TGT_MAX)) ]] && OST=$TGT_FIRST - - # echo "Iteration: $i OST: $OST" - create_file $POOL_ROOT/dir1/file${i} $POOL 1 - check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL - i=$((i + 1)) - done + create_dir $POOL_ROOT/dir1 $POOL 1 + create_file $POOL_ROOT/dir1/file $POOL 1 + local ost=$($LFS getstripe -i $POOL_ROOT/dir1/file) + i=0 + while [[ $i -lt $numfiles ]]; do + ost=$((ost + 2)) + [[ $ost -gt $((16#$TGT_MAX)) ]] && ost=$TGT_FIRST + + # echo "Iteration: $i OST: $ost" + create_file $POOL_ROOT/dir1/file${i} $POOL 1 + check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL + i=$((i + 1)) + done # Fill up OST0 until it is nearly full. # Create 9 files of size OST0_SIZE/10 each. @@ -1221,14 +1208,14 @@ test_21() { add_pool $POOL $TGT_HALF "$TGT_UUID2" - create_dir $dir $POOL $OSTCOUNT - create_file $dir/file1 $POOL $OSTCOUNT - $GETSTRIPE -v $dir/file1 - check_file_in_pool $dir/file1 $POOL + create_dir $dir $POOL $OSTCOUNT + create_file $dir/file1 $POOL $OSTCOUNT + $LFS getstripe -v $dir/file1 + check_file_in_pool $dir/file1 $POOL - rm -rf $dir + rm -rf $dir - return 0 + return 0 } run_test 21 "OST pool with fewer OSTs than stripe count" @@ -1453,53 +1440,42 @@ test_24() { mkdir $POOL_ROOT/dir4 - for i in 1 2 3 4; do - dir=${POOL_ROOT}/dir${i} - local pool - local pool1 - local count - local count1 - local index - local size - local size1 - - createmany -o $dir/${tfile} $numfiles || - error "createmany $dir/${tfile} failed!" - res=$($GETSTRIPE -v $dir | grep "^stripe_count:") - if [ $? -ne 0 ]; then - res=$($GETSTRIPE -v $dir | grep "^(Default) ") - pool=$(cut -f 9 -d ' ' <<< $res) - index=$(cut -f 7 -d ' ' <<< $res) - size=$(cut -f 5 -d ' ' <<< $res) - count=$(cut -f 3 -d ' ' <<< $res) - else - pool=$(cut -f 8 -d ' ' <<< $res) - index=$(cut -f 6 -d ' ' <<< $res) - size=$(cut -f 4 -d ' ' <<< $res) - count=$(cut -f 2 -d ' ' <<< $res) - fi - - for file in $dir/*; do - if [ "$pool" != "" ]; then - check_file_in_pool $file $pool - fi - pool1=$(file_pool $file) - count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" | - tr -d '[:blank:]' | cut -f 2 -d ':') - size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" | - tr -d '[:blank:]' | cut -f 2 -d ':') - [[ "$pool" != "$pool1" ]] && - error "Pool name ($pool) not inherited in $file($pool1)" - [[ "$count" != "$count1" ]] && - error "Stripe count ($count) not inherited in $file ($count1)" - [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && - error "Stripe size ($size) not inherited in $file ($size1)" - done - done + for i in 1 2 3 4; do + dir=${POOL_ROOT}/dir${i} + local pool + local pool1 + local count + local count1 + local index + local size + local size1 + + createmany -o $dir/${tfile} $numfiles || + error "createmany $dir/${tfile} failed!" + pool=$($LFS getstripe --pool $dir) + index=$($LFS getstripe -i $dir) + size=$($LFS getstripe -S $dir) + count=$($LFS getstripe -c $dir) + + for file in $dir/*; do + if [ "$pool" != "" ]; then + check_file_in_pool $file $pool + fi + pool1=$($LFS getstripe --pool $file) + count1=$($LFS getstripe -c $file) + size1=$($LFS getstripe -S $file) + [[ "$pool" != "$pool1" ]] && + error "Pool '$pool' not on $file:$pool1" + [[ "$count" != "$count1" ]] && + error "Stripe count $count not on $file:$count1" + [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] && + error "Stripe size $size not on $file:$size1" + done + done - rm -rf $POOL_ROOT + rm -rf $POOL_ROOT - return 0 + return 0 } run_test 24 "Independence of pool from other setstripe parameters" @@ -1526,10 +1502,10 @@ test_25() { # Veriy that the pool got created and is usable df $POOL_ROOT > /dev/null sleep 5 + # Make sure OST0 can be striped on $SETSTRIPE -i 0 -c 1 $POOL_ROOT/$tfile - STR=$($GETSTRIPE $POOL_ROOT/$tfile | grep 0x | - cut -f2 | tr -d " ") + local STR=$($LFS getstripe -i $POOL_ROOT/$tfile) rm $POOL_ROOT/$tfile if [[ "$STR" == "0" ]]; then echo "Creating a file in pool$i"