# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
# skip test cases failed before landing - Jinshan
-ALWAYS_EXCEPT="$SANITY_HSM_EXCEPT 12a 12b 12n 13 30a 31a 34 35 36 58 59"
+ALWAYS_EXCEPT="$SANITY_HSM_EXCEPT 12a 12b 12n 13 30a 31a 34 35 36"
ALWAYS_EXCEPT="$ALWAYS_EXCEPT 110a 200 201 221 222a 223a 223b 225"
LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
cleanup() {
copytool_cleanup
changelog_cleanup
+ cdt_set_sanity_policy
}
search_and_kill_copytool() {
}
cdt_set_sanity_policy() {
- # clear all
- do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-nra
- do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-nbr
- do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-gc
+ if [[ "$CDT_POLICY_HAD_CHANGED" ]]
+ then
+ # clear all
+ do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=+NRA
+ do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-NBR
+ CDT_POLICY_HAD_CHANGED=
+ fi
}
cdt_set_no_retry() {
- do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=+nra
+ do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=+NRA
+ CDT_POLICY_HAD_CHANGED=true
}
cdt_clear_no_retry() {
- do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-nra
+ do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-NRA
+ CDT_POLICY_HAD_CHANGED=true
}
-cdt_set_no_blocking_restore() {
- do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=+nbr
+cdt_set_non_blocking_restore() {
+ do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=+NBR
+ CDT_POLICY_HAD_CHANGED=true
}
-cdt_clear_no_blocking_restore() {
- do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-nbr
+cdt_clear_non_blocking_restore() {
+ do_facet $SINGLEMDS $LCTL set_param $HSM_PARAM.policy=-NBR
+ CDT_POLICY_HAD_CHANGED=true
}
cdt_clear_mount_state() {
cdt_set_sanity_policy
}
-need2clients() {
- if [[ $CLIENTCOUNT -lt 2 ]]; then
- skip "Need two or more clients, have $CLIENTCOUNT"
+needclients() {
+ local clnt_count=$1
+ if [[ $CLIENTCOUNT -lt $clnt_count ]]; then
+ skip "Need $clnt_count or more clients, have $CLIENTCOUNT"
return 1
fi
return 0
path2fid $1 || error "cannot get fid on $1"
}
+cleanup_large_files() {
+ local ratio=$(df $MOUNT |awk '{print $5}' |sed 's/%//g' |grep -v Use)
+ [ $ratio -gt 50 ] && find $MOUNT -size +10M -exec rm -f {} \;
+}
+
make_large_for_striping() {
local file2=${1/$DIR/$DIR2}
local sz=$($LCTL get_param -n lov.*-clilov-*.stripesize | head -1)
+
+ cleanup_large_files
+
dd if=/dev/urandom of=$file2 count=5 bs=$sz conv=fsync ||
error "cannot create $file2"
path2fid $1 || error "cannot get fid on $1"
make_large_for_progress() {
local file2=${1/$DIR/$DIR2}
+
+ cleanup_large_files
+
# 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
make_large_for_progress_aligned() {
local file2=${1/$DIR/$DIR2}
+
+ cleanup_large_files
+
# big file is large enough, so copy time is > 30s
# so copytool make 1 progress
# size is a multiple of 1M to have stripe
make_large_for_cancel() {
local file2=${1/$DIR/$DIR2}
+
+ cleanup_large_files
+
# Copy timeout is 100s. 105MB => 105s
dd if=/dev/urandom of=$file2 count=103 bs=1M conv=fsync ||
error "cannot create $file2"
echo "Start copytool"
copytool_setup
+echo "Set sanity-hsm HSM policy"
+cdt_set_sanity_policy
+
# finished requests are quickly removed from list
set_hsm_param grace_delay 10
run_test 9 "Use of explict archive number, with dedicated copytool"
test_9a() {
- [[ $CLIENTCOUNT -ge 3 ]] ||
- { skip "Need three or more clients"; return 0; }
+ needclients 3 || return 0
local n
local file
$LFS hsm_archive $file || error "could not archive file $file"
wait_request_state $fid ARCHIVE SUCCEED
- check_hsm_flags $file "0x00000001"
+ check_hsm_flags $file "0x00000009"
done
trap - EXIT
run_test 12g "Restore a released file implicitly"
test_12h() {
- need2clients || return 0
+ needclients 2 || return 0
# test needs a running copytool
copytool_setup
test_30a() {
# restore at exec cannot work on agent node (because of Linux kernel
# protection of executables)
- need2clients || return 0
+ needclients 2 || return 0
# test needs a running copytool
copytool_setup
test_30b() {
# restore at exec cannot work on agent node (because of Linux kernel
# protection of executables)
- need2clients || return 0
+ needclients 2 || return 0
# test needs a running copytool
copytool_setup
test_57() {
# Need one client for I/O, one for request
- need2clients || return 0
+ needclients 2 || return 0
# test needs a running copytool
copytool_setup
}
run_test 57 "Archive a file with dirty cache on another node"
-test_58() {
- # test needs a running copytool
- copytool_setup
+truncate_released_file() {
+ local src_file=$1
+ local trunc_to=$2
- mkdir -p $DIR/$tdir
+ local sz=$(stat -c %s $src_file)
local f=$DIR/$tdir/$tfile
- local fid=$(make_small $f)
+ local fid=$(copy_file $1 $f)
+ local ref=$f-ref
+ cp $f $f-ref
$LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
error "could not archive file"
$LFS hsm_release $f || error "could not release file"
- $TRUNCATE $f 0 || error "truncate failed"
+ $TRUNCATE $f $trunc_to || error "truncate failed"
sync
- local sz=$(stat -c %s $f)
- [[ $sz == 0 ]] || error "size after truncate is $sz != 0"
+ local sz1=$(stat -c %s $f)
+ [[ $sz1 == $trunc_to ]] ||
+ error "size after trunc: $sz1 expect $trunc_to, original $sz"
$LFS hsm_state $f
-
check_hsm_flags $f "0x0000000b"
local state=$(get_request_state $fid RESTORE)
- [[ "$state" == "" ]] ||
- error "truncate 0 trigs a restore, state = $state"
+ [[ "$state" == "SUCCEED" ]] ||
+ error "truncate $sz does not trig restore, state = $state"
- copytool_cleanup
+ $TRUNCATE $ref $trunc_to
+ cmp $ref $f || error "file data wrong after truncate"
+
+ rm -f $f $f-ref
}
-run_test 58 "Truncate 0 on a released file must not trigger restore"
-test_59() {
+test_58() {
# test needs a running copytool
copytool_setup
mkdir -p $DIR/$tdir
- local f=$DIR/$tdir/$tfile
- local fid=$(copy_file /etc/passwd $f)
- local ref=$f-ref
- cp $f $ref
- local sz=$(stat -c %s $ref)
- sz=$((sz / 2))
- $TRUNCATE $ref $sz
-
- $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f ||
- error "could not archive file"
- wait_request_state $fid ARCHIVE SUCCEED
-
- $LFS hsm_release $f || error "could not release file"
- $TRUNCATE $f $sz || error "truncate failed"
- sync
-
- local sz1=$(stat -c %s $f)
- [[ $sz1 == $sz ]] || error "size after truncate is $sz1 != $sz"
+ local sz=$(stat -c %s /etc/passwd)
- $LFS hsm_state $f
-
- check_hsm_flags $f "0x0000000b"
+ echo "truncate up from $sz to $((sz*2))"
+ truncate_released_file /etc/passwd $((sz*2))
- local state=$(get_request_state $fid RESTORE)
- [[ "$state" == "SUCCEED" ]] ||
- error "truncate $sz does not trig a successfull restore,"\
- " state = $state"
+ echo "truncate down from $sz to $((sz/2))"
+ truncate_released_file /etc/passwd $((sz/2))
- cmp $ref $f || error "file data wrong after truncate"
+ echo "truncate to 0"
+ truncate_released_file /etc/passwd 0
copytool_cleanup
}
-run_test 59 "Truncate != 0 on a released file"
+run_test 58 "Truncate a released file will trigger restore"
test_90() {
file_count=57
}
run_test 107 "Copytool re-register after MDS restart"
+policy_set_and_test()
+{
+ local change="$1"
+ local target="$2"
+ do_facet $SINGLEMDS $LCTL set_param "$HSM_PARAM.policy=\\\"$change\\\""
+ local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
+ [[ "$policy" == "$target" ]] ||
+ error "Wrong policy after '$change': '$policy' != '$target'"
+}
+
+test_109() {
+ # to force default policy setting if error
+ CDT_POLICY_HAD_CHANGED=true
+
+ local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
+ local default="NonBlockingRestore [NoRetryAction]"
+ [[ "$policy" == "$default" ]] ||
+ error "default policy has changed,"\
+ " '$policy' != '$default' update the test"
+ policy_set_and_test "+NBR" "[NonBlockingRestore] [NoRetryAction]"
+ policy_set_and_test "+NRA" "[NonBlockingRestore] [NoRetryAction]"
+ policy_set_and_test "-NBR" "NonBlockingRestore [NoRetryAction]"
+ policy_set_and_test "-NRA" "NonBlockingRestore NoRetryAction"
+ policy_set_and_test "NRA NBR" "[NonBlockingRestore] [NoRetryAction]"
+ # useless bacause we know but safer for futur changes to use real value
+ local policy=$(do_facet $SINGLEMDS $LCTL get_param -n $HSM_PARAM.policy)
+ echo "Next set_param must failed"
+ policy_set_and_test "wrong" "$policy"
+
+ # return to default
+ echo "Back to default policy"
+ cdt_set_sanity_policy
+}
+run_test 109 "Policy display/change"
+
test_110a() {
# test needs a running copytool
copytool_setup
import_file $tdir/$tfile $f
local fid=$(path2fid $f)
- cdt_set_no_blocking_restore
+ cdt_set_non_blocking_restore
md5sum $f
local st=$?
# cleanup
wait_request_state $fid RESTORE SUCCEED
- cdt_clear_no_blocking_restore
+ cdt_clear_non_blocking_restore
# Test result
[[ $st == 1 ]] ||
wait_request_state $fid ARCHIVE SUCCEED
$LFS hsm_release $f
- cdt_set_no_blocking_restore
+ cdt_set_non_blocking_restore
md5sum $f
local st=$?
# cleanup
wait_request_state $fid RESTORE SUCCEED
- cdt_clear_no_blocking_restore
+ cdt_clear_non_blocking_restore
# Test result
[[ $st == 1 ]] ||