Whamcloud - gitweb
LU-13404 utils: fix lfs mirror duplicate file check
[fs/lustre-release.git] / lustre / tests / sanity-flr.sh
index 8a93e26..07e52af 100644 (file)
@@ -15,9 +15,14 @@ init_logging
 
 ALWAYS_EXCEPT="$SANITY_FLR_EXCEPT "
 # Bug number for skipped test:    LU-11381
-ALWAYS_EXCEPT+="                  201"
+ALWAYS_EXCEPT+="                  201 "
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
+# skip all tests for PPC until we can get sanity-pfl to pass
+if [[ $(uname -m) = ppc64 ]]; then
+       skip "Skip FLR testing for PPC clients"
+fi
+
 build_test_filter
 
 [[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
@@ -273,6 +278,16 @@ verify_comp_attrs() {
        verify_comp_attr_with_parent pool $tf $comp_id
 }
 
+verify_flr_state()
+{
+       local tf=$1
+       local expected_state=$2
+
+       local state=$($LFS getstripe -v $tf | awk '/lcm_flags/{ print $2 }')
+       [ $expected_state = $state ] ||
+               error "expected: $expected_state, actual $state"
+}
+
 # command line test cases
 test_0a() {
        local td=$DIR/$tdir
@@ -384,7 +399,7 @@ test_0b() {
                # LU-11022 - remove mirror by pool name
                local=cnt cnt=$($LFS getstripe $tf | grep archive | wc -l)
                [ "$cnt" != "1" ] && error "unexpected mirror count $cnt"
-               $LFS mirror split --pool archive -d $tf || error "delete mirror"
+               $LFS mirror delete --pool archive $tf || error "delete mirror"
                cnt=$($LFS getstripe $tf | grep archive | wc -l)
                [ "$cnt" != "0" ] && error "mirror count after removal: $cnt"
        fi
@@ -752,6 +767,24 @@ test_0h() {
 }
 run_test 0h "set, clear and test flags for FLR files"
 
+test_0j() {
+       $LFS mirror create -N2 $DIR/$tfile || error "create $DIR/$tfile failed"
+
+       cp /etc/hosts $DIR/$tfile || error "write to $DIR/$tfile failed"
+       $LFS mirror resync $DIR/$tfile || error "resync $DIR/$tfile failed"
+       cmp /etc/hosts $DIR/$tfile || error "cmp with /etc/hosts failed"
+
+       $LFS mirror read -N2 -o $TMP/$tfile $DIR/$tfile || "read mirror failed"
+       stack_trap "rm -f $TMP/$tfile"
+       cmp $TMP/$tfile $DIR/$tfile || error "cmp with $TMP/$tfile failed"
+       $LFS mirror write -N2 -i /etc/passwd $DIR/$tfile || "write failed"
+       $LFS setstripe --comp-set -I 65537 --comp-flags=stale $DIR/$tfile ||
+               error "set component 1 stale failed"
+       $LFS mirror resync $DIR/$tfile || error "resync $DIR/$tfile failed"
+       cmp /etc/passwd $DIR/$tfile || error "cmp with /etc/passwd failed"
+}
+run_test 0j "test lfs mirror read/write commands"
+
 test_1() {
        local tf=$DIR/$tfile
        local mirror_count=16 # LUSTRE_MIRROR_COUNT_MAX
@@ -1040,7 +1073,7 @@ test_32() {
 }
 run_test 32 "data should be mirrored to newly created mirror"
 
-test_33() {
+test_33a() {
        [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
 
        rm -f $DIR/$tfile $DIR/$tfile-2
@@ -1114,7 +1147,114 @@ test_33() {
 
        start_osts 2
 }
-run_test 33 "read can choose available mirror to read"
+run_test 33a "read can choose available mirror to read"
+
+test_33b() {
+       [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
+
+       rm -f $DIR/$tfile
+
+       stack_trap "rm -f $DIR/$tfile" EXIT
+
+       # create a file with two mirrors on OST0000 and OST0001
+       $LFS setstripe -N -Eeof -o0 -N -Eeof -o1 $DIR/$tfile
+
+       # make sure that $tfile has two mirrors
+       [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] ||
+               { $LFS getstripe $DIR/$tfile; error "expected count 2"; }
+
+       # write 50M
+       dd if=/dev/urandom of=$DIR/$tfile bs=2M count=25 ||
+               error "write failed for $DIR/$tfile"
+       $LFS mirror resync $DIR/$tfile || error "resync failed for $DIR/$tfile"
+       verify_flr_state $DIR/$tfile "ro"
+       drop_client_cache
+
+       ls -l $DIR/$tfile
+
+       # read file - all OSTs are available
+       echo "reading file (data can be provided by any ost)... "
+       local t1=$SECONDS
+       time cat $DIR/$tfile > /dev/null || error "read all"
+       local t2=$SECONDS
+       ra=$((t2 - t1))
+
+       # read file again with ost1 {OST0000} failed
+       stop_osts 1
+       drop_client_cache
+       echo "reading file (data should be provided by ost2)..."
+       t1=$SECONDS
+       time cat $DIR/$tfile > /dev/null || error "read ost2"
+       t2=$SECONDS
+       r1=$((t2 - t1))
+
+       # remount ost1
+       start_osts 1
+
+       # read file again with ost2 {OST0001} failed
+       stop_osts 2
+       drop_client_cache
+
+       echo "reading file (data should be provided by ost1)..."
+       t1=$SECONDS
+       time cat $DIR/$tfile > /dev/null || error "read ost1"
+       t2=$SECONDS
+       r2=$((t2 - t1))
+
+       # remount ost2
+       start_osts 2
+
+       [ $((r1 * 100)) -gt $((ra * 105)) -a $r1 -gt $((ra + 2)) ] &&
+               error "read mirror too slow without ost1, from $ra to $r1"
+       [ $((r2 * 100)) -gt $((ra * 105)) -a $r2 -gt $((ra + 2)) ] &&
+               error "read mirror too slow without ost2, from $ra to $r2"
+
+       wait_osc_import_ready client ost2
+}
+run_test 33b "avoid reading from unhealthy mirror"
+
+test_33c() {
+       [[ $OSTCOUNT -lt 3 ]] && skip "need >= 3 OSTs" && return
+
+       rm -f $DIR/$tfile
+
+       stack_trap "rm -f $DIR/$tfile" EXIT
+
+       # create a file with two mirrors
+       # mirror1: {OST0000, OST0001}
+       # mirror2: {OST0001, OST0002}
+       $LFS setstripe -N -Eeof -c2 -o0,1 -N -Eeof -c2 -o1,2 $DIR/$tfile
+
+       # make sure that $tfile has two mirrors
+       [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] ||
+               { $LFS getstripe $DIR/$tfile; error "expected count 2"; }
+
+       # write 50M
+       dd if=/dev/urandom of=$DIR/$tfile bs=2M count=25 ||
+               error "write failed for $DIR/$tfile"
+       $LFS mirror resync $DIR/$tfile || error "resync failed for $DIR/$tfile"
+       verify_flr_state $DIR/$tfile "ro"
+       drop_client_cache
+
+       ls -l $DIR/$tfile
+
+       # read file - all OSTs are available
+       echo "reading file (data can be provided by any ost)... "
+       time cat $DIR/$tfile > /dev/null || error "read all"
+
+       # read file again with ost2 (OST0001) failed
+       stop_osts 2
+       drop_client_cache
+
+       echo "reading file (data should be provided by ost1 and ost3)..."
+       time cat $DIR/$tfile > /dev/null || error "read ost1 & ost3"
+
+       # remount ost2
+       start_osts 2
+
+       wait_osc_import_ready client ost2
+}
+run_test 33c "keep reading among unhealthy mirrors"
 
 test_34a() {
        [[ $OSTCOUNT -lt 4 ]] && skip "need >= 4 OSTs" && return
@@ -1376,16 +1516,6 @@ test_37()
 }
 run_test 37 "mirror I/O API verification"
 
-verify_flr_state()
-{
-       local tf=$1
-       local expected_state=$2
-
-       local state=$($LFS getstripe -v $tf | awk '/lcm_flags/{ print $2 }')
-       [ $expected_state = $state ] ||
-               error "expected: $expected_state, actual $state"
-}
-
 test_38() {
        local tf=$DIR/$tfile
        local ref=$DIR/${tfile}-ref
@@ -1812,7 +1942,7 @@ test_44() {
        verify_flr_state $tf "wp"
 
        # disallow destroying the last non-stale mirror
-       ! $LFS mirror split --mirror-id 1 -d $tf > /dev/null 2>&1 ||
+       ! $LFS mirror delete --mirror-id 1 $tf > /dev/null 2>&1 ||
                error "destroying mirror 1 should fail"
 
        # synchronize all mirrors of the file
@@ -2312,7 +2442,7 @@ test_203() {
        #create 2 mirrors
        $LFS mirror create -N2 -c1 $tf || error "create FLR file $tf"
        #delete first mirror
-       $LFS mirror split --mirror-id=1 -d $tf || error "delete first mirror"
+       $LFS mirror delete --mirror-id=1 $tf || error "delete first mirror"
 
        $LFS getstripe $tf
        local old_id=$($LFS getstripe --mirror-id=2 -I $tf)
@@ -2521,7 +2651,7 @@ run_test 204c "FLR write/stale/resync test with component removal"
 test_204d() {
        [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
        [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
-               skip "skipped for lustre < $SEL_VERSION"
+               skip "skipped for lustre < $SEL_VER"
 
        local comp_file=$DIR/$tdir/$tfile
        local found=""
@@ -2590,7 +2720,7 @@ run_test 204d "FLR write/stale/resync sel test with repeated comp"
 test_204e() {
        [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
        [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
-               skip "skipped for lustre < $SEL_VERSION"
+               skip "skipped for lustre < $SEL_VER"
 
        local comp_file=$DIR/$tdir/$tfile
        local found=""
@@ -2671,7 +2801,7 @@ run_test 204e "FLR write/stale/resync sel test with repeated comp"
 test_204f() {
        [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
        [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
-               skip "skipped for lustre < $SEL_VERSION"
+               skip "skipped for lustre < $SEL_VER"
 
        local comp_file=$DIR/$tdir/$tfile
        local found=""