Whamcloud - gitweb
LU-8203 tests: Wait for archive operation to be completed.
[fs/lustre-release.git] / lustre / tests / sanity-hsm.sh
index bac941c..aba7228 100755 (executable)
@@ -681,66 +681,19 @@ check_enough_free_space() {
        return 0
 }
 
-make_large_for_striping() {
+make_custom_file_for_progress() {
        local file2=${1/$DIR/$DIR2}
-       local sz=$($LCTL get_param -n lov.*-clilov-*.stripesize | head -n1)
+       local fsize=${2:-"39"}
+       local blksz=$($LCTL get_param -n lov.*-clilov-*.stripesize | head -n1)
+       blksz=${3:-$blksz}
 
-       cleanup_large_files
-
-       check_enough_free_space 5 $sz
-       [ $? != 0 ] && return $?
-
-       dd if=/dev/urandom of=$file2 count=5 bs=$sz conv=fsync ||
-               file_creation_failure dd $file2 $?
-
-       path2fid $1 || error "cannot get fid on $1"
-}
-
-make_large_for_progress() {
-       local file2=${1/$DIR/$DIR2}
+       [[ $fsize -gt  0 ]] || error "Invalid file size"
+       [[ $blksz -gt 0 ]] || error "Invalid stripe size"
 
        cleanup_large_files
-
-       check_enough_free_space 39 1000000
+       check_enough_free_space $fsize $blksz
        [ $? != 0 ] && return $?
-
-       # big file is large enough, so copy time is > 30s
-       # so copytool make 1 progress
-       # size is not a multiple of 1M to avoid stripe
-       # aligment
-       dd if=/dev/urandom of=$file2 count=39 bs=1000000 conv=fsync ||
-               file_creation_failure dd $file2 $?
-
-       path2fid $1 || error "cannot get fid on $1"
-}
-
-make_large_for_progress_aligned() {
-       local file2=${1/$DIR/$DIR2}
-
-       cleanup_large_files
-
-       check_enough_free_space 33 1048576
-       [ $? != 0 ] && return $?
-
-       # big file is large enough, so copy time is > 30s
-       # so copytool make 1 progress
-       # size is a multiple of 1M to have stripe
-       # aligment
-       dd if=/dev/urandom of=$file2 count=33 bs=1M conv=fsync ||
-               file_creation_failure dd $file2 $?
-       path2fid $1 || error "cannot get fid on $1"
-}
-
-make_large_for_cancel() {
-       local file2=${1/$DIR/$DIR2}
-
-       cleanup_large_files
-
-       check_enough_free_space 103 1048576
-       [ $? != 0 ] && return $?
-
-       # Copy timeout is 100s. 105MB => 105s
-       dd if=/dev/urandom of=$file2 count=103 bs=1M conv=fsync ||
+       dd if=/dev/zero of=$file2 count=$fsize bs=$blksz conv=fsync ||
                file_creation_failure dd $file2 $?
        path2fid $1 || error "cannot get fid on $1"
 }
@@ -811,6 +764,66 @@ parse_json_event() {
        echo $raw_event | python -c "$json_parser"
 }
 
+get_agent_by_uuid_mdt() {
+       local uuid=$1
+       local mdtidx=$2
+       local mds=mds$(($mdtidx + 1))
+       do_facet $mds "$LCTL get_param -n ${MDT_PREFIX}${mdtidx}.hsm.agents |\
+                grep $uuid"
+}
+
+check_agent_registered_by_mdt() {
+       local uuid=$1
+       local mdtidx=$2
+       local mds=mds$(($mdtidx + 1))
+       local agent=$(get_agent_by_uuid_mdt $uuid $mdtidx)
+       if [[ ! -z "$agent" ]]; then
+               echo "found agent $agent on $mds"
+       else
+               error "uuid $uuid not found in agent list on $mds"
+       fi
+}
+
+check_agent_unregistered_by_mdt() {
+       local uuid=$1
+       local mdtidx=$2
+       local mds=mds$(($mdtidx + 1))
+       local agent=$(get_agent_by_uuid_mdt $uuid $mdtidx)
+       if [[ -z "$agent" ]]; then
+               echo "uuid not found in agent list on $mds"
+       else
+               error "uuid found in agent list on $mds: $agent"
+       fi
+}
+
+check_agent_registered() {
+       local uuid=$1
+       local mdsno
+       for mdsno in $(seq 1 $MDSCOUNT); do
+               check_agent_registered_by_mdt $uuid $((mdsno - 1))
+       done
+}
+
+check_agent_unregistered() {
+       local uuid=$1
+       local mdsno
+       for mdsno in $(seq 1 $MDSCOUNT); do
+               check_agent_unregistered_by_mdt $uuid $((mdsno - 1))
+       done
+}
+
+get_agent_uuid() {
+       local agent=${1:-$(facet_active_host $SINGLEAGT)}
+
+       # Lustre mount-point is mandatory and last parameter on
+       # copytool cmd-line.
+       local mntpnt=$(do_rpc_nodes $agent ps -C $HSMTOOL_BASE -o args= |
+                      awk '{print $NF}')
+       [ -n "$mntpnt" ] || error "Found no Agent or with no mount-point "\
+                                 "parameter"
+       do_rpc_nodes $agent get_client_uuid $mntpnt | cut -d' ' -f2
+}
+
 # initiate variables
 init_agt_vars
 
@@ -999,13 +1012,19 @@ test_8() {
 run_test 8 "Test default archive number"
 
 test_9() {
-       mkdir -p $DIR/$tdir
-       local f=$DIR/$tdir/$tfile
-       local fid=$(copy_file /etc/passwd $f)
        # we do not use the default one to be sure
        local new_an=$((HSM_ARCHIVE_NUMBER + 1))
        copytool_cleanup
        copytool_setup $SINGLEAGT $MOUNT $new_an
+
+       # give time for CT to register with MDTs
+       sleep $(($MDSCOUNT*2))
+       local uuid=$(get_agent_uuid $(facet_active_host $SINGLEAGT))
+       check_agent_registered $uuid
+
+       mkdir -p $DIR/$tdir
+       local f=$DIR/$tdir/$tfile
+       local fid=$(copy_file /etc/passwd $f)
        $LFS hsm_archive --archive $new_an $f
        wait_request_state $fid ARCHIVE SUCCEED
 
@@ -1239,7 +1258,7 @@ test_12c() {
        local f=$DIR/$tdir/$tfile
        $LFS setstripe -c 2 $f
        local fid
-       fid=$(make_large_for_striping $f)
+       fid=$(make_custom_file_for_progress $f 5)
        [ $? != 0 ] && skip "not enough free space" && return
 
        local FILE_CRC=$(md5sum $f)
@@ -2066,7 +2085,6 @@ test_24c() {
        chown $RUNAS_ID:nobody $file ||
                error "cannot chown '$file' to '$RUNAS_ID:nobody'"
 
-       set_hsm_param user_request_mask ""
        $RUNAS $LFS hsm_$action $file &&
                error "$action by user should fail"
 
@@ -2080,7 +2098,6 @@ test_24c() {
        chown nobody:$RUNAS_GID $file ||
                error "cannot chown '$file' to 'nobody:$RUNAS_GID'"
 
-       set_hsm_param group_request_mask ""
        $RUNAS $LFS hsm_$action $file &&
                error "$action by group should fail"
 
@@ -2094,7 +2111,6 @@ test_24c() {
        chown nobody:nobody $file ||
                error "cannot chown '$file' to 'nobody:nobody'"
 
-       set_hsm_param other_request_mask ""
        $RUNAS $LFS hsm_$action $file &&
                error "$action by other should fail"
 
@@ -2257,7 +2273,7 @@ test_26() {
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
@@ -2297,7 +2313,7 @@ test_27b() {
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
@@ -2319,7 +2335,7 @@ test_28() {
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
@@ -2576,7 +2592,7 @@ test_31b() {
 
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
@@ -2600,7 +2616,7 @@ test_31c() {
 
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress_aligned $f)
+       fid=$(make_custom_file_for_progress $f 33 1048576)
        [ $? != 0 ] && skip "not enough free space" && return
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
@@ -2624,7 +2640,7 @@ test_33() {
 
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
@@ -2691,7 +2707,7 @@ test_34() {
 
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
@@ -2727,7 +2743,7 @@ test_35() {
        local f=$DIR/$tdir/$tfile
        local f1=$DIR/$tdir/$tfile-1
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        local fid1=$(copy_file /etc/passwd $f1)
@@ -2766,7 +2782,7 @@ test_36() {
 
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
@@ -2930,7 +2946,7 @@ test_54() {
 
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
-       local fid=$(make_large_for_progress $f)
+       local fid=$(make_custom_file_for_progress $f 39 1000000)
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
                error "could not archive file"
@@ -2958,7 +2974,7 @@ test_55() {
 
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
-       local fid=$(make_large_for_progress $f)
+       local fid=$(make_custom_file_for_progress $f 39 1000000)
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
                error "could not archive file"
@@ -2987,7 +3003,7 @@ test_56() {
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
@@ -3128,7 +3144,7 @@ test_60() {
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 10)
        [ $? != 0 ] && skip "not enough free space" && return
 
        local mdtidx=0
@@ -3183,6 +3199,10 @@ test_60() {
                error "Expected progress update after at least $interval seconds"
        fi
 
+       echo "Wait for on going archive hsm action to complete"
+       wait_update $agent "grep -o copied $copytool_log" "copied" 10 ||
+               echo "File archiving not completed even after 10 secs"
+
        cdt_clear_no_retry
        copytool_cleanup
 }
@@ -3247,7 +3267,7 @@ test_71() {
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
@@ -3525,7 +3545,7 @@ test_104() {
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        # if cdt is on, it can serve too quickly the request
@@ -3568,66 +3588,6 @@ test_105() {
 }
 run_test 105 "Restart of coordinator"
 
-get_agent_by_uuid_mdt() {
-       local uuid=$1
-       local mdtidx=$2
-       local mds=mds$(($mdtidx + 1))
-       do_facet $mds "$LCTL get_param -n ${MDT_PREFIX}${mdtidx}.hsm.agents |\
-                grep $uuid"
-}
-
-check_agent_registered_by_mdt() {
-       local uuid=$1
-       local mdtidx=$2
-       local mds=mds$(($mdtidx + 1))
-       local agent=$(get_agent_by_uuid_mdt $uuid $mdtidx)
-       if [[ ! -z "$agent" ]]; then
-               echo "found agent $agent on $mds"
-       else
-               error "uuid $uuid not found in agent list on $mds"
-       fi
-}
-
-check_agent_unregistered_by_mdt() {
-       local uuid=$1
-       local mdtidx=$2
-       local mds=mds$(($mdtidx + 1))
-       local agent=$(get_agent_by_uuid_mdt $uuid $mdtidx)
-       if [[ -z "$agent" ]]; then
-               echo "uuid not found in agent list on $mds"
-       else
-               error "uuid found in agent list on $mds: $agent"
-       fi
-}
-
-check_agent_registered() {
-       local uuid=$1
-       local mdsno
-       for mdsno in $(seq 1 $MDSCOUNT); do
-               check_agent_registered_by_mdt $uuid $((mdsno - 1))
-       done
-}
-
-check_agent_unregistered() {
-       local uuid=$1
-       local mdsno
-       for mdsno in $(seq 1 $MDSCOUNT); do
-               check_agent_unregistered_by_mdt $uuid $((mdsno - 1))
-       done
-}
-
-get_agent_uuid() {
-       local agent=${1:-$(facet_active_host $SINGLEAGT)}
-
-       # Lustre mount-point is mandatory and last parameter on
-       # copytool cmd-line.
-       local mntpnt=$(do_rpc_nodes $agent ps -C $HSMTOOL_BASE -o args= |
-                      awk '{print $NF}')
-       [ -n "$mntpnt" ] || error "Found no Agent or with no mount-point "\
-                                 "parameter"
-       do_rpc_nodes $agent get_client_uuid $mntpnt | cut -d' ' -f2
-}
-
 test_106() {
        # test needs a running copytool
        copytool_setup
@@ -3853,7 +3813,7 @@ test_200() {
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_cancel $f)
+       fid=$(make_custom_file_for_progress $f 103 1048576)
        [ $? != 0 ] && skip "not enough free space" && return
 
        # test with cdt on is made in test_221
@@ -3901,7 +3861,7 @@ test_202() {
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f
@@ -3951,7 +3911,7 @@ test_221() {
 
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_cancel $f)
+       fid=$(make_custom_file_for_progress $f 103 1048576)
        [ $? != 0 ] && skip "not enough free space" && return
 
        changelog_setup
@@ -4060,7 +4020,7 @@ test_223b() {
 
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        changelog_setup
@@ -4122,7 +4082,7 @@ test_225() {
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_progress $f)
+       fid=$(make_custom_file_for_progress $f 39 1000000)
        [ $? != 0 ] && skip "not enough free space" && return
 
        changelog_setup
@@ -4327,7 +4287,7 @@ test_251() {
        mkdir -p $DIR/$tdir
        local f=$DIR/$tdir/$tfile
        local fid
-       fid=$(make_large_for_cancel $f)
+       fid=$(make_custom_file_for_progress $f 103 1048576)
        [ $? != 0 ] && skip "not enough free space" && return
 
        cdt_disable