From: Andreas Dilger Date: Sat, 2 Feb 2013 09:02:40 +0000 (-0700) Subject: LU-1538 tests: improve sanityn test_51 error messages X-Git-Tag: 2.9.56~58 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=de7d11b4e1115274c32b82e84829710741a8958d;p=fs%2Flustre-release.git LU-1538 tests: improve sanityn test_51 error messages While changing sanityn.sh it caused test_51[abc] to fail in an obscure manner, and no error messages were being printed or reporting test failures. Improve the messages in these tests and fix some code style. Test-Parameters: trivial testlist=sanityn Signed-off-by: Andreas Dilger Change-Id: I798f6a7f5ab40714e867b537f4e32e59ea500c1e Reviewed-on: https://review.whamcloud.com/5256 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Wei Liu Reviewed-by: James Nunez Reviewed-by: Saurabh Tandan Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh index 4fd09a2..bf71bdf 100644 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -2410,13 +2410,13 @@ test_51a() { local filesize local origfile=/etc/hosts - filesize=`stat -c %s $origfile` + filesize=$(stat -c %s $origfile) # create an empty file - $MCREATE $DIR1/$tfile + $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile" # cache layout lock on both mount point - stat $DIR1/$tfile > /dev/null - stat $DIR2/$tfile > /dev/null + stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed" + stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed" # open and sleep 2 seconds then read $MULTIOP $DIR2/$tfile o_2r${filesize}c & @@ -2424,12 +2424,13 @@ test_51a() { sleep 1 # create the layout of testing file - dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null + dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null || + error "dd $DIR1/$tfile failed" # MULTIOP proc should be able to read enough bytes and exit sleep 2 - kill -0 $pid && error "multiop is still there" - cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs" + kill -0 $pid 2> /dev/null && error "multiop is still there" + cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs" rm -f $DIR1/$tfile } @@ -2442,7 +2443,7 @@ test_51b() { local tmpfile=`mktemp` # create an empty file - $MCREATE $DIR1/$tfile + $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed" # delay glimpse so that layout has changed when glimpse finish #define OBD_FAIL_GLIMPSE_DELAY 0x1404 @@ -2452,10 +2453,11 @@ test_51b() { sleep 1 # create layout of testing file - dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null + dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null || + error "dd $DIR1/$tfile failed" wait $pid - local fsize=`cat $tmpfile` + local fsize=$(cat $tmpfile) [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024" @@ -2467,11 +2469,12 @@ test_51c() { [ $OSTCOUNT -ge 2 ] || { skip "need at least 2 osts"; return; } # set default layout to have 1 stripe - mkdir -p $DIR1/$tdir + mkdir $DIR1/$tdir $LFS setstripe -c 1 $DIR1/$tdir # create a file with empty layout - $MCREATE $DIR1/$tdir/$tfile + $MCREATE $DIR1/$tdir/$tfile || + error "$MCREATE $DIR1/$tdir/$tfile failed" #define OBD_FAIL_MDS_LL_BLOCK 0x172 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172 @@ -2484,8 +2487,14 @@ test_51c() { # write something to the file, it should be blocked on fetching layout dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc - local cnt=$($LFS getstripe -c $DIR2/$tdir/$tfile) - [ $cnt -eq $OSTCOUNT ] || error "have $cnt stripes, expected $OSTCOUNT" + local stripecnt=$($LFS getstripe -c $DIR2/$tdir/$tfile) + wait $pid + + # lod_qos.c::min_stripe_count() allows setstripe with a default stripe + # count to succeed with only 3/4 of the number of stripes (rounded up), + # so creating striped files does not fail if an OST is offline or full + [ $stripecnt -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] || + error "layout wrong: getstripe -c $stripecnt < $OSTCOUNT * 3/4" rm -fr $DIR1/$tdir } diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index fa87bea..bd2dd52 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -1,7 +1,7 @@ #!/bin/bash trap 'print_summary && touch $TF_FAIL && \ - echo "test-framework exiting on error"' ERR + echo "$TESTSUITE: FAIL: test-framework exiting on error"' ERR set -e #set -x