From 11aae875be5fb30a88281ab47e491b75447b299b Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 7 Dec 2017 10:11:26 -0600 Subject: [PATCH] LU-10344 test: create files on local node in sanity-hsm 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 Change-Id: I923475c32fa69b0ac59b95b90b42c147cf361274 Reviewed-on: https://review.whamcloud.com/30433 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Faccini Bruno --- lustre/tests/sanity-hsm.sh | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index cef7024..778b871 100755 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -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() { -- 1.8.3.1