Whamcloud - gitweb
LU-9324 lfs: add setstripe --copy=lustre_file_or_dir parameter
[fs/lustre-release.git] / lustre / tests / sanity-pfl.sh
index 372f9ba..98c148a 100644 (file)
@@ -36,6 +36,9 @@ build_test_filter
        error "\$RUNAS_ID set to 0, but \$UID is also 0!"
 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
 
+assert_DIR
+rm -rf $DIR/[Rdfs][0-9]*
+
 test_0() {
        [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
 
@@ -374,7 +377,8 @@ component_dump() {
 
 test_10() {
        local parent=$DIR/$tdir
-       local root_layout=$(get_layout_param $MOUNT)
+
+       save_layout_restore_at_exit $MOUNT
 
        rm -rf $parent
        $LFS setstripe -d $MOUNT || error "clear root layout"
@@ -413,7 +417,6 @@ test_10() {
        [  x$f2_expect != x$f2_entry ] &&
                error "$parent/file2 does not inherite root layout"
 
-       $LFS setstripe $root_layout $MOUNT
        return 0
 }
 run_test 10 "Inherit composite template from root"
@@ -451,7 +454,7 @@ test_11() {
        $TRUNCATE $comp_file $((1024*1024*1+1))
 
        f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
-       [[ -z $f2 ]] && error "2: 2nd component uninstantiated"
+       [[ -z $f2 ]] && error "3: 2nd component uninstantiated"
        f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
        [[ -z $f3 ]] && error "3: 3rd component uninstantiated"
        f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
@@ -636,6 +639,74 @@ test_15() {
 }
 run_test 15 "Verify component options for lfs find"
 
+verify_16() {
+       local src=$1
+       local dst=$2
+       local temp=$3
+       local msg_prefix=$4
+
+       echo "getstripe --yaml $src"
+       $LFS getstripe --yaml $src > $temp || error "getstripe $src failed"
+       echo "setstripe --yaml=$temp $dst"
+       $LFS setstripe --yaml=$temp $dst|| error "setstripe $dst failed"
+
+       echo "compare"
+       local layout1=$(get_layout_param $src)
+       local layout2=$(get_layout_param $dst)
+       # compare their layout info
+       [ "$layout1" == "$layout2" ] ||
+               error "$msg_prefix $src/$dst layouts are not equal"
+}
+
+test_16() {
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+
+       local file=$DIR/$tdir/$tfile
+       local dir=$DIR/$tdir/dir
+       local temp=$DIR/$tdir/template
+       rm -rf $DIR/$tdir
+       test_mkdir $DIR/$tdir
+
+       #####################################################################
+       #                           1. PFL file
+       # set stripe for source file
+       $LFS setstripe -E1m -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 $file ||
+               error "Create $file failed"
+
+       echo "1. PFL file"
+       verify_16 $file $file.copy $temp "1. PFL file"
+
+       #####################################################################
+       #                           2. plain file
+       # set stripe for source file
+       rm -f $file
+       $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed"
+
+       rm -f $file.copy
+       echo "2. plain file"
+       verify_16 $file $file.copy $temp "2. plain file"
+
+       #####################################################################
+       #                           3. PFL dir
+       # set stripe for source dir
+       test_mkdir $dir
+       $LFS setstripe -E1m -c2 -E2m -c1 -E-1 $dir ||
+               error "setstripe $dir failed"
+
+       test_mkdir $dir.copy
+       echo "3. PFL dir"
+       verify_16 $dir $dir.copy $temp.dir "3. PFL dir"
+
+       #####################################################################
+       #                           4. plain dir
+       # set stripe for source dir
+       $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
+
+       echo "4. plain dir"
+       verify_16 $dir $dir.copy $temp.dir "4. plain dir"
+}
+run_test 16 "Verify setstripe/getstripe with YAML config file"
+
 test_17() {
        [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
        local file=$DIR/$tdir/$tfile