From 062d3a6ac70ee32f2fb9511361e47ff29bf6e87f Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Fri, 24 Nov 2023 22:27:36 -0700 Subject: [PATCH] EX-8466 tests: limit 'cmp' output in sanity-pcc.sh Limit the number of lines printed by 'cmp' when there is an error comparing two files. Often the files are multiple MB in size, and printing 1-32M lines of output when the test fails is not useful. Instead, print the first 66000 lines of output by default, which is enough to see a full 64KiB plus some lines to see if more than 64KiB of data is incorrect. This is controlled by the CMP_LINES variable. Test-Parameters: trivial testlist=sanity-pcc Signed-off-by: Andreas Dilger Change-Id: I80f4d5d3460d531ab63788185a2c88e79415a801 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53239 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alex Deiter Reviewed-by: Qian Yingjin --- lustre/tests/sanity-pcc.sh | 55 +++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/lustre/tests/sanity-pcc.sh b/lustre/tests/sanity-pcc.sh index 5fe3b0c..d84910e 100755 --- a/lustre/tests/sanity-pcc.sh +++ b/lustre/tests/sanity-pcc.sh @@ -30,6 +30,7 @@ MULTIOP=${MULTIOP:-multiop} OPENFILE=${OPENFILE:-openfile} MOUNT_2=${MOUNT_2:-"yes"} FAIL_ON_ERROR=false +CMP_LINES=${CMP_LINES:-66000} # script only handles up to 10 MDTs (because of MDT_PREFIX) [ $MDSCOUNT -gt 9 ] && @@ -434,7 +435,8 @@ test_1e() { error "failed to dd write to $file" do_facet $SINGLEAGT $RUNAS $LFS pcc attach -w -i $HSM_ARCHIVE_NUMBER \ $file || error "failed to attach file $file" - do_facet $SINGLEAGT cmp -bl $file $file.src || + do_facet $SINGLEAGT cmp -bl $file $file.src | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || error "file $file is corrupted after attach" check_lpcc_state $file "readwrite" do_facet $SINGLEAGT $RUNAS dd if=$file of=/dev/null bs=1024 count=1 || @@ -3821,7 +3823,8 @@ test_49a() { local iosize=$((1024 * 1024)) # 1 MiB ll_fid_path_copy -F $srcfid -l $MOUNT -p $dest -s $iosize || error "(0) fid_path_copy of $srcfid ($src) to $dest failed" - cmp -bl $src $dest || + cmp -bl $src $dest | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || error "(1) $dest corrupt after copy from $srcfid ($src)" rm -f $dest touch $dest @@ -3829,7 +3832,8 @@ test_49a() { # Normal copy but with DIO and multiple threads ll_fid_path_copy -F $srcfid -l $MOUNT -p $dest -s $iosize -d -t $numthreads || error "(2) fid_path_copy of $srcfid ($src) to $dest failed" - cmp -bl $src $dest || + cmp -bl $src $dest | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || error "(3) $dest corrupt after copy from $srcfid ($src)" rm -f $dest touch $dest @@ -3841,7 +3845,8 @@ test_49a() { # DIO copy with unaligned file size ll_fid_path_copy -F $srcfid -l $MOUNT -p $dest -s $iosize -d -t $numthreads || error "(5) fid_path_copy of $srcfid ($src) to $dest failed" - cmp -bl $src $dest || + cmp -bl $src $dest | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || error "(6) $dest corrupt after copy from $srcfid ($src)" rm -f $dest touch $dest @@ -3852,7 +3857,8 @@ test_49a() { srcfid=$($LFS getstripe -F "$src") ll_fid_path_copy -F $srcfid -l $MOUNT -p $dest -s $iosize -d -t $numthreads || error "(8) fid_path_copy of $srcfid ($src) to $dest failed" - cmp -bl $src $dest || + cmp -bl $src $dest | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || error "(9) $dest corrupt after copy from $srcfid ($src)" echo "NOTE: Rest of test expected to return errors" @@ -3897,7 +3903,8 @@ test_49a() { srcfid=$($LFS getstripe -F "$src") ll_fid_path_copy -F $srcfid -l $MOUNT -p $dest -s $iosize -d || error "(19) fid_path_copy of $srcfid ($src) to $dest failed" - cmp -bl $src $dest || + cmp -bl $src $dest | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || error "(20) $dest corrupt after copy from $srcfid ($src)" echo "Test completed successfully" @@ -3959,7 +3966,9 @@ test_49b() { do_facet $SINGLEAGT $LFS pcc attach -w -i $HSM_ARCHIVE_NUMBER $file || error "failed to attach file $file" check_lpcc_state $file "readwrite" - cmp -bl $file.src $file || error "$file corrupt after attach" + cmp -bl $file.src $file | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || + error "$file corrupt after attach" do_facet $SINGLEAGT $LFS pcc detach -k $file || error "failed to detach file $file" check_lpcc_state $file "none" @@ -3968,7 +3977,9 @@ test_49b() { do_facet $SINGLEAGT $LFS pcc attach -w -i $HSM_ARCHIVE_NUMBER $file || error "failed to attach file $file" check_lpcc_state $file "readwrite" - cmp -bl $file.src $file || error "$file corrupt after attach" + cmp -bl $file.src $file | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || + error "$file corrupt after attach" do_facet $SINGLEAGT $LFS pcc detach -k $file || error "failed to detach file $file" check_lpcc_state $file "none" @@ -3986,7 +3997,9 @@ test_49b() { do_facet $SINGLEAGT $LFS pcc attach -r -i $HSM_ARCHIVE_NUMBER $file || error "failed to attach file $file" check_lpcc_state $file "readonly" - cmp -bl $file.src $file || error "$file corrupt after attach" + cmp -bl $file.src $file | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || + error "$file corrupt after attach" do_facet $SINGLEAGT $LFS pcc detach -k $file || error "failed to detach file $file" check_lpcc_state $file "none" @@ -3995,7 +4008,9 @@ test_49b() { do_facet $SINGLEAGT $LFS pcc attach -r -i $HSM_ARCHIVE_NUMBER $file || error "failed to attach file $file" check_lpcc_state $file "readonly" - cmp -bl $file.src $file || error "$file corrupt after attach" + cmp -bl $file.src $file | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || + error "$file corrupt after attach" do_facet $SINGLEAGT $LFS pcc detach -k $file || error "failed to detach file $file" check_lpcc_state $file "none" @@ -4013,7 +4028,9 @@ test_49b() { do_facet $SINGLEAGT $LFS pcc attach -r -i $HSM_ARCHIVE_NUMBER $file || error "failed to attach file $file" check_lpcc_state $file "readonly" - cmp -bl $file.src $file || error "$file corrupt after attach" + cmp -bl $file.src $file | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || + error "$file corrupt after attach" do_facet $SINGLEAGT $LFS pcc detach -k $file || error "failed to detach file $file" check_lpcc_state $file "none" @@ -4030,7 +4047,9 @@ test_49b() { do_facet $SINGLEAGT $LFS pcc attach -r -i $HSM_ARCHIVE_NUMBER $file || error "failed to attach file $file" check_lpcc_state $file "readonly" - cmp -bl $file.src $file || error "$file corrupt after attach" + cmp -bl $file.src $file | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || + error "$file corrupt after attach" do_facet $SINGLEAGT $LFS pcc detach -k $file || error "failed to detach file $file" check_lpcc_state $file "none" @@ -4052,7 +4071,9 @@ test_49b() { do_facet $SINGLEAGT $LFS pcc attach -r -i $HSM_ARCHIVE_NUMBER $file || error "failed to attach file $file" check_lpcc_state $file "readonly" - cmp -bl $file.src $file || error "$file corrupt after attach" + cmp -bl $file.src $file | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || + error "$file corrupt after attach" do_facet $SINGLEAGT $LFS pcc detach -k $file || error "failed to detach file $file" check_lpcc_state $file "none" @@ -4074,7 +4095,9 @@ test_49b() { do_facet $SINGLEAGT $LFS pcc attach -r -i $HSM_ARCHIVE_NUMBER $file || error "failed to attach file $file" check_lpcc_state $file "readonly" - cmp -bl $file.src $file || error "$file corrupt after attach" + cmp -bl $file.src $file | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || + error "$file corrupt after attach" do_facet $SINGLEAGT $LFS pcc detach -k $file || error "failed to detach file $file" check_lpcc_state $file "none" @@ -4256,7 +4279,9 @@ test_49d() { # Verify file contents from PCC echo 3 > /proc/sys/vm/drop_caches ls -la $file.$size $file.cmp - cmp -bl $file.$size $file.cmp || error "$file.$size corrupt in pcc after attach" + cmp -bl $file.$size $file.cmp | head -n $CMP_LINES + (( ${PIPESTATUS[0]} == 0 )) || + error "$file.$size corrupt in pcc after attach" do_facet $SINGLEAGT $LFS pcc detach -k $file.$size || error "failed to detach file $file.$size" check_lpcc_state $file.$size "none" -- 1.8.3.1