Whamcloud - gitweb
LU-11803 tests: don't assume obd device name
[fs/lustre-release.git] / lustre / tests / sanity-flr.sh
index d48003b..74cad1a 100644 (file)
@@ -87,7 +87,7 @@ start_osts() {
 verify_mirror_count() {
        local tf=$1
        local expected=$2
-       local mirror_count=$(get_mirror_ids $tf)
+       local mirror_count=$($LFS getstripe -N $tf)
 
        [[ $mirror_count = $expected ]] || {
                $LFS getstripe -v $tf
@@ -667,7 +667,7 @@ test_0g() {
        cat $tf &> /dev/null || error "error reading file '$tf'"
 
        # verify that the data was provided by OST1 where mirror 1 resides
-       local nr_read=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-ffff*.stats |
+       local nr_read=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[-0-9a-f]*.stats |
                        awk '/ost_read/{print $2}')
        [ -n "$nr_read" ] || error "read was not provided by OST1"
 }
@@ -895,7 +895,7 @@ get_osc_lock_count() {
                local osc_name
                local count
 
-               osc_name=${FSNAME}-OST$(printf "%04x" $((idx-1)))-osc-'ffff*'
+               osc_name=${FSNAME}-OST$(printf "%04x" $((idx-1)))-osc-'[-0-9a-f]*'
                count=$($LCTL get_param -n ldlm.namespaces.$osc_name.lock_count)
                lock_count=$((lock_count + count))
        done
@@ -982,7 +982,7 @@ test_32() {
                error "extending mirrored file $DIR/$tfile failed"
 
        # make sure the mirrored file was created successfully
-       [ $(get_mirror_ids $DIR/$tfile) -eq 2 ] ||
+       [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] ||
                { $LFS getstripe $DIR/$tfile; error "expected 2 mirrors"; }
 
        drop_client_cache
@@ -1031,7 +1031,7 @@ test_33() {
                      "without verification failed"
 
        # make sure that $tfile has two mirrors and $tfile-2 does not exist
-       [ $(get_mirror_ids $DIR/$tfile) -eq 2 ] ||
+       [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] ||
                { $LFS getstripe $DIR/$tfile; error "expected count 2"; }
 
        [[ ! -e $DIR/$tfile-2 ]] || error "$DIR/$tfile-2 was not unlinked"
@@ -1060,7 +1060,7 @@ test_33() {
        start_osts 1
 
        # read file again with ost2 failed
-       $LCTL set_param ldlm.namespaces.lustre-*-osc-ffff*.lru_size=clear
+       $LCTL set_param ldlm.namespaces.lustre-*-osc-[-0-9a-f]*.lru_size=clear
 
        fail ost2 &
        sleep 1
@@ -1203,7 +1203,7 @@ test_36() {
 
        create_file_36 $tf $tf-2 $tf-3
 
-       [ $(get_mirror_ids $tf) -gt 1 ] || error "wrong mirror count"
+       [ $($LFS getstripe -N $tf) -gt 1 ] || error "wrong mirror count"
 
        # test case 1 - check file write and verify layout version
        $MULTIOP $tf oO_WRONLY:c ||
@@ -1219,13 +1219,13 @@ test_36() {
        verify_ost_layout_version $tf
 
        # test case 2
-       local mds_idx=mds$(($($LFS getstripe -m $tf-2) + 1))
+       local mds_facet=mds$(($($LFS getstripe -m $tf-2) + 1))
 
        local delay_sec=10
-       do_facet $mds_idx $LCTL set_param fail_val=$delay_sec
+       do_facet $mds_facet $LCTL set_param fail_val=$delay_sec
 
        #define OBD_FAIL_FLR_LV_DELAY 0x1A01
-       do_facet $mds_idx $LCTL set_param fail_loc=0x1A01
+       do_facet $mds_facet $LCTL set_param fail_loc=0x1A01
 
        # write should take at least $fail_loc seconds and succeed
        local st=$(date +%s)
@@ -1237,19 +1237,19 @@ test_36() {
        # verify OST layout version
        verify_ost_layout_version $tf
 
-       do_facet $mds_idx $LCTL set_param fail_loc=0
+       do_facet $mds_facet $LCTL set_param fail_loc=0
 
        # test case 3
        mds_idx=mds$(($($LFS getstripe -m $tf-3) + 1))
 
        #define OBD_FAIL_FLR_LV_INC 0x1A02
-       do_facet $mds_idx $LCTL set_param fail_loc=0x1A02
+       do_facet $mds_facet $LCTL set_param fail_loc=0x1A02
 
        # write open file should return error
        $MULTIOP $tf-3 oO_WRONLY:O_SYNC:w1024c &&
                error "write a mirrored file succeeded" || true
 
-       do_facet $mds_idx $LCTL set_param fail_loc=0
+       do_facet $mds_facet $LCTL set_param fail_loc=0
 }
 run_test 36 "write to mirrored files"
 
@@ -1273,8 +1273,11 @@ test_37()
        local tf=$DIR/$tfile
        local tf2=$DIR/$tfile-2
        local tf3=$DIR/$tfile-3
+       local tf4=$DIR/$tfile-4
 
        create_files_37 $((RANDOM + 15 * 1048576)) $tf $tf2 $tf3
+       rm -f $tf4
+       cp $tf $tf4
 
        # assume the mirror id will be 1, 2, and 3
        declare -A checksums
@@ -1297,11 +1300,20 @@ test_37()
 
        local sum
        for i in ${mirror_array[@]}; do
-               sum=$($LFS mirror dump -N $i $tf | md5sum)
+               $LCTL set_param ldlm.namespaces.*.lru_size=clear > /dev/null
+               sum=$($LFS mirror read -N $i $tf | md5sum)
                [ "$sum" = "${checksums[$i]}" ] ||
                        error "$i: mismatch: \'${checksums[$i]}\' vs. \'$sum\'"
        done
 
+       # verify mirror write
+       echo "Verifying mirror write .."
+       $LFS mirror write -N2 $tf < $tf4
+
+       sum=$($LFS mirror read -N2 $tf | md5sum)
+       [[ "$sum" = "${checksums[1]}" ]] ||
+               error "2: mismatch \'${checksums[1]}\' vs. \'$sum\'"
+
        # verify mirror copy, write to this mirrored file will invalidate
        # the other two mirrors
        echo "Verifying mirror copy .."
@@ -1320,7 +1332,7 @@ test_37()
        # verify copying is successful by checking checksums
        remount_client $MOUNT
        for i in ${mirror_array[@]}; do
-               sum=$($LFS mirror dump -N $i $tf | md5sum)
+               sum=$($LFS mirror read -N $i $tf | md5sum)
                [ "$sum" = "${checksums[1]}" ] ||
                        error "$i: mismatch checksum after copy"
        done
@@ -1379,7 +1391,7 @@ test_38() {
 
        local valid_mirror stale_mirror id mirror_cksum
        for id in "${mirror_array[@]}"; do
-               mirror_cksum=$($LFS mirror dump -N $id $tf | md5sum)
+               mirror_cksum=$($LFS mirror read -N $id $tf | md5sum)
                [ "$ref_cksum" == "$mirror_cksum" ] &&
                        { valid_mirror=$id; continue; }
 
@@ -1392,7 +1404,7 @@ test_38() {
        mirror_io resync $tf || error "resync failed"
        verify_flr_state $tf "ro"
 
-       mirror_cksum=$($LFS mirror dump -N $stale_mirror $tf | md5sum)
+       mirror_cksum=$($LFS mirror read -N $stale_mirror $tf | md5sum)
        [ "$file_cksum" = "$ref_cksum" ] || error "resync failed"
 
        # case 2: inject an error to make mirror_io exit after changing
@@ -1518,7 +1530,7 @@ test_41() {
 
        echo " **verify $tf-1 data consistency in all mirrors"
        for i in 1 2 3; do
-               local sum=$($LFS mirror dump -N$i $tf-1 | md5sum)
+               local sum=$($LFS mirror read -N$i $tf-1 | md5sum)
                [[ "$sum" = "$sum0" ]] ||
                        error "$tf-1.$i: checksum mismatch: $sum != $sum0"
        done
@@ -1997,8 +2009,8 @@ test_48() {
        verify_flr_state $tf "wp"
        verify_comp_attr lcme_flags $tf 0x20003 nosync,stale
 
-       local sum1=$($LFS mirror dump -N1 $tf | md5sum)
-       local sum2=$($LFS mirror dump -N2 $tf | md5sum)
+       local sum1=$($LFS mirror read -N1 $tf | md5sum)
+       local sum2=$($LFS mirror read -N2 $tf | md5sum)
 
        echo " ** verify mirror 2 doesn't change"
        echo "original checksum: $sum0"
@@ -2015,8 +2027,8 @@ test_48() {
        verify_flr_state $tf "ro"
        verify_comp_attr lcme_flags $tf 0x20003 nosync,^stale
 
-       sum1=$($LFS mirror dump -N1 $tf | md5sum)
-       sum2=$($LFS mirror dump -N2 $tf | md5sum)
+       sum1=$($LFS mirror read -N1 $tf | md5sum)
+       sum2=$($LFS mirror read -N2 $tf | md5sum)
 
        echo " ** verify mirror 2 resync-ed"
        echo "original checksum: $sum0"
@@ -2161,9 +2173,9 @@ test_200() {
        mirror_io resync $tf
        get_mirror_ids $tf
 
-       local csum=$($LFS mirror dump -N ${mirror_array[0]} $tf | md5sum)
+       local csum=$($LFS mirror read -N ${mirror_array[0]} $tf | md5sum)
        for id in ${mirror_array[@]:1}; do
-               [ "$($LFS mirror dump -N $id $tf | md5sum)" = "$csum" ] ||
+               [ "$($LFS mirror read -N $id $tf | md5sum)" = "$csum" ] ||
                        error "checksum error for mirror $id"
        done