3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # Run test by setting NOSETUP=true when ltest has setup env for us
11 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
14 # Bug number for skipped test:
15 ALWAYS_EXCEPT="$SANITY_FLR_EXCEPT"
16 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
18 [ "$ALWAYS_EXCEPT$EXCEPT" ] &&
19 echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
22 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
25 MULTIOP=${MULTIOP:-multiop}
27 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
28 . $LUSTRE/tests/test-framework.sh
30 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
33 check_and_setup_lustre
37 if [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ]]; then
38 skip_env "Need MDS version at least 2.7.64" && exit
43 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
44 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
45 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
47 # global array to store mirror IDs
48 declare -a mirror_array
55 for id in $($LFS getstripe $tf | awk '/lcme_id/{print $2}'); do
56 array[${#array[@]}]=$((id >> 16))
59 mirror_array=($(printf "%s\n" "${array[@]}" | sort -u))
61 echo ${#mirror_array[@]}
64 # command line test cases
67 local mirror_count=16 # LUSTRE_MIRROR_COUNT_MAX
69 $LFS setstripe -E EOF -c -1 $tf
71 local stripes[0]=$OSTCOUNT
73 for ((i = 1; i < $mirror_count; i++)); do
74 # add mirrors with different stripes to the file
75 stripes[$i]=$((RANDOM % OSTCOUNT))
76 [ ${stripes[$i]} -eq 0 ] && stripes[$i]=1
78 $LFS setstripe --component-add --mirror -c ${stripes[$i]} $tf
81 [ $(get_mirror_ids $tf) -ne $mirror_count ] &&
82 error "mirror count error"
84 # can't create mirrors exceeding LUSTRE_MIRROR_COUNT_MAX
85 $LFS setstripe --component-add --mirror $tf &&
86 error "Creating the $((mirror_count+1))th mirror succeeded"
88 local ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' |
91 # verify the range of components and stripe counts
92 for ((i = 0; i < $mirror_count; i++)); do
93 local sc=$($LFS getstripe -I${ids[$i]} -c $tf)
94 local start=$($LFS getstripe -I${ids[$i]} --component-start $tf)
95 local end=$($LFS getstripe -I${ids[$i]} --component-end $tf)
97 [[ ${stripes[$i]} = $sc ]] || {
98 $LFS getstripe -v $tf;
99 error "$i: sc error: id: ${ids[$i]}, ${stripes[$i]}";
101 [ $start -eq 0 ] || {
102 $LFS getstripe -v $tf;
103 error "$i: start error id: ${ids[$i]}";
105 [ $end = "EOF" ] || {
106 $LFS getstripe -v $tf;
107 error "$i: end error id: ${ids[$i]}";
111 run_test 1 "create components with setstripe options"
115 local tf2=$DIR/$tfile-2
117 $LFS setstripe -E 1M -E EOF -c 1 $tf
118 $LFS setstripe -E 2M -E EOF -c -1 $tf2
120 local layout=$($LFS getstripe $tf2 | grep -A 4 lmm_objects)
122 $LFS setstripe --component-add --mirror=$tf2 $tf
124 [ $(get_mirror_ids $tf) -ne 2 ] && error "mirror count should be 2"
125 $LFS getstripe $tf2 | grep -q 'no stripe info' ||
126 error "$tf2 still has stripe info"
128 run_test 2 "create components from existing files"
131 [[ $MDSCOUNT -lt 2 ]] && skip "need >= 2 MDTs" && return
133 for ((i = 0; i < 2; i++)); do
134 $LFS mkdir -i $i $DIR/$tdir-$i
135 $LFS setstripe -E -1 $DIR/$tdir-$i/$tfile
138 $LFS setstripe --component-add --mirror=$DIR/$tdir-1/$tfile \
139 $DIR/$tdir-0/$tfile || error "creating mirrors"
141 # mdt doesn't support to cancel layout lock for remote objects, do
145 # make sure the mirrorted file was created successfully
146 [[ $($LFS getstripe --component-count $DIR/$tdir-0/$tfile) -eq 2 ]] ||
147 { $LFS getstripe $DIR/$tdir-0/$tfile;
148 error "expected 2 components"; }
153 run_test 3 "create components from files located on different MDTs"
156 check_and_cleanup_lustre