Whamcloud - gitweb
LU-10344 test: create files on local node in sanity-hsm 33/30433/3
authorJohn L. Hammond <john.hammond@intel.com>
Thu, 7 Dec 2017 16:11:26 +0000 (10:11 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 13 Dec 2017 01:21:47 +0000 (01:21 +0000)
In sanity-hsm, rewrite create_file() to call dd ... directly rather
than do_facet $SINGLEAGT dd ... Rewrite create_archive_file() to call
do_facet $SINGLEAGT ... directly instead of calling
create_file(). Move the Lustre parent directory creation from
create_archive_file() to import_file().

Test-Parameters: trivial testlist=sanity-hsm

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I923475c32fa69b0ac59b95b90b42c147cf361274
Reviewed-on: https://review.whamcloud.com/30433
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
lustre/tests/sanity-hsm.sh

index cef7024..778b871 100755 (executable)
@@ -388,6 +388,9 @@ copytool_remove_backend() {
 }
 
 import_file() {
+       mkdir -p "$(dirname "$2")" ||
+               error "cannot create directory '$(dirname "$2")'"
+
        do_facet $SINGLEAGT \
                "$HSMTOOL --archive $HSM_ARCHIVE_NUMBER --hsm-root $HSM_ARCHIVE\
                --import $1 $2 $MOUNT" ||
@@ -416,26 +419,24 @@ create_file() {
        local bs=$2
        local count=$3
        local conv=$4
-       local if=${5:-/dev/zero}
-       local facet=$SINGLEAGT
+       local source=${5:-/dev/zero}
+       local args=""
+       local err
 
-       local cmd
-       printf -v cmd 'do_facet "%s" dd if="%s" of="%s" count=%s bs=%s' \
-               "$facet" "$if" "$file" "$count" "$bs"
-       [ -n "$conv" ] && cmd+=" conv=$conv"
+       if [ -n "$conv" ]; then
+               args+=" conv=$conv"
+       fi
 
        # Create the directory in case it does not exist
-       do_facet "$facet" mkdir -p "$(dirname "$file")"
+       mkdir -p "$(dirname "$file")"
        # Delete the file in case it already exist
-       do_facet "$facet" rm -f "$file"
+       rm -f "$file"
 
-       if eval "$cmd"; then
-               # print the FID if the file is not an archive
-               [[ "$file" =~ ^$HSM_ARCHIVE ]] || path2fid "$file" ||
-                       error "cannot get fid on '$file'"
+       if dd if="$source" of="$file" count="$count" bs="$bs" $args; then
+               path2fid "$file" || error "cannot get FID of '$file'"
        else
-               local err=$?
-               printf "$cmd failed with $err\n" >&2;
+               err=$?
+               echo "cannot create file '$file'" >&2;
                # Let the caller decide what to do on error
                return $err;
        fi
@@ -461,15 +462,16 @@ create_small_sync_file() {
 }
 
 create_archive_file() {
-       local if=/dev/urandom
+       local file="$HSM_ARCHIVE/$1"
        local count=${2:-39}
-       local bs=1M
-       local facet=$SINGLEAGT
+       local source=/dev/urandom
 
        # Create the counterpart directory of the archive
-       do_facet "$facet" mkdir -p "$DIR2/$(dirname "$1")"
-       create_file "${HSM_ARCHIVE}/$1" $bs $count "" $if ||
-               file_creation_failure dd "${HSM_ARCHIVE}/$1" $?
+       do_facet "$SINGLEAGT" mkdir -p "$(dirname "$file")" ||
+               error "cannot create archive directory '$(dirname "$file")'"
+
+       do_facet "$SINGLEAGT" dd if=$source of="$file" bs=1M count=$count ||
+               error "cannot create archive file '$file'"
 }
 
 copy2archive() {