Whamcloud - gitweb
LU-14632 tests: fix sanity-hsm test_606()
[fs/lustre-release.git] / lustre / tests / sanity-hsm.sh
index 8bbdc50..82b7c5a 100755 (executable)
@@ -84,7 +84,7 @@ CLIENT2=${CLIENT2:-$CLIENT1}
 
 search_copytools() {
        local hosts=${1:-$(facet_active_host $SINGLEAGT)}
-       do_nodesv $hosts "libtool execute pgrep -x $HSMTOOL"
+       do_nodesv $hosts "pgrep --pidfile=$HSMTOOL_PID_FILE hsmtool"
 }
 
 wait_copytools() {
@@ -147,10 +147,13 @@ fid2archive()
 {
        local fid="$1"
 
-       case "$HSMTOOL" in
-       lhsmtool_posix)
-               printf "%s" "$(hsm_root)/*/*/*/*/*/*/$fid"
-               ;;
+       case "$HSMTOOL_ARCHIVE_FORMAT" in
+               v1)
+                       printf "%s" "$(hsm_root)/*/*/*/*/*/*/$fid"
+                       ;;
+               v2)
+                       printf "%s" "$(hsm_root)/*/$fid"
+                       ;;
        esac
 }
 
@@ -168,9 +171,8 @@ get_copytool_event_log() {
 copytool_suspend() {
        local agents=${1:-$(facet_active_host $SINGLEAGT)}
 
-       stack_trap \
-               "do_nodesv $agents libtool execute pkill -CONT -x '$HSMTOOL' || true" EXIT
-       do_nodesv $agents "libtool execute pkill -STOP -x $HSMTOOL" || return 0
+       stack_trap "pkill_copytools $agents CONT || true" EXIT
+       pkill_copytools $agents STOP || return 0
        echo "Copytool is suspended on $agents"
 }
 
@@ -488,7 +490,8 @@ get_agent_uuid() {
 
        # Lustre mount-point is mandatory and last parameter on
        # copytool cmd-line.
-       local mntpnt=$(do_rpc_nodes $agent libtool execute ps -C $HSMTOOL -o args= |
+       local mntpnt=$(do_rpc_nodes $agent \
+                       pgrep --pidfile=$HSMTOOL_PID_FILE --list-full hsmtool |
                       awk '{print $NF}')
        [ -n "$mntpnt" ] || error "Found no Agent or with no mount-point "\
                                  "parameter"
@@ -635,8 +638,8 @@ test_1c() {
                error "wrong archive number, $st != $LOCAL_HSM_ARCHIVE_NUMBER"
 
        LOCAL_HSM_ARCHIVE_NUMBER=33
-       if [ $(lustre_version_code client) -ge $(version_code 2.11.56) ] &&
-          [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.11.56) ]; then
+       if [ "$CLIENT_VERSION" -ge $(version_code 2.11.56) ] &&
+          [ "$MDS1_VERSION" -ge $(version_code 2.11.56) ]; then
                # lustre in the new version supports unlimited archiveID.
                # Test whether setting archive number > 32 is supported
                $LFS hsm_set --exists --archive-id $LOCAL_HSM_ARCHIVE_NUMBER $f ||
@@ -682,7 +685,7 @@ test_1d() {
 run_test 1d "Archive, Release and Restore DoM file"
 
 test_1e() {
-       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
+       [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
                skip "skipped for lustre < $SEL_VER"
 
        mkdir -p $DIR/$tdir
@@ -994,6 +997,18 @@ test_11b() {
 }
 run_test 11b "Import a deleted file using its FID"
 
+test_11c() {
+       pool_add $TESTNAME || error "Pool creation failed"
+       pool_add_targets $TESTNAME 1 1 || error "pool_add_targets failed"
+
+       mkdir -p $DIR/$tdir
+       $LFS setstripe -p "$TESTNAME" $DIR/$tdir
+
+       copy2archive /etc/hosts $tdir/$tfile
+       copytool import $tdir/$tfile $DIR/$tdir/$tfile
+}
+run_test 11c "Import a file to a directory with a pool"
+
 test_12a() {
        # test needs a running copytool
        copytool setup
@@ -1531,7 +1546,7 @@ test_21() {
 
        # LU-4388/LU-4389 - ZFS does not report full number of blocks
        # used until file is flushed to disk
-       if [  $(facet_fstype ost1) == "zfs" ]; then
+       if [ "$ost1_FSTYPE" == "zfs" ]; then
            # this causes an OST_SYNC rpc to be sent
            dd if=/dev/zero of=$f bs=512 count=1 oflag=sync conv=notrunc,fsync
            # clear locks to reread file data
@@ -3299,12 +3314,12 @@ test_90() {
        wait_for_grace_delay
        $LFS hsm_archive --filelist $FILELIST ||
                error "cannot archive a file list"
-       wait_all_done 100
+       wait_all_done 200
        $LFS hsm_release --filelist $FILELIST ||
                error "cannot release a file list"
        $LFS hsm_restore --filelist $FILELIST ||
                error "cannot restore a file list"
-       wait_all_done 100
+       wait_all_done 200
 }
 run_test 90 "Archive/restore a file list"
 
@@ -5045,13 +5060,13 @@ run_test 407 "Check for double RESTORE records in llog"
 
 test_500()
 {
-       [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
+       [ "$MDS1_VERSION" -lt $(version_code 2.6.92) ] &&
                skip "HSM migrate is not supported"
 
        test_mkdir -p $DIR/$tdir
 
-       if [ $(lustre_version_code client) -lt $(version_code 2.11.56) ] ||
-            [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ];
+       if [ "$CLIENT_VERSION" -lt $(version_code 2.11.56) ] ||
+            [ "$MDS1_VERSION" -lt $(version_code 2.11.56) ];
        then
                llapi_hsm_test -d $DIR/$tdir -b ||
                        error "One llapi HSM test failed"
@@ -5063,7 +5078,7 @@ test_500()
 run_test 500 "various LLAPI HSM tests"
 
 test_600() {
-       [ $MDS1_VERSION -lt $(version_code 2.10.58) ] &&
+       [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
                skip "need MDS version at least 2.10.58"
 
        mkdir -p $DIR/$tdir
@@ -5355,8 +5370,7 @@ test_606() {
        local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
        llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
        [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
-                       skip_env "missing llog_reader" && return
-       local fstype=$(facet_fstype mds1)
+                       skip_env "missing llog_reader"
 
        mkdir -p $DIR/$tdir
 
@@ -5376,8 +5390,9 @@ test_606() {
        local entry
 
        #remount mds1 as ldiskfs or zfs type
-       stack_trap "stop mds1; start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS" EXIT
        stop mds1 || error "stop mds1 failed"
+       stack_trap "unmount_fstype mds1; start mds1 $(mdsdevname 1)\
+               $MDS_MOUNT_OPTS" EXIT
        mount_fstype mds1 || error "remount mds1 failed"
 
        for ((i = 0; i < 1; i++)); do