Whamcloud - gitweb
LU-691 fix OST index errors in test suite - sanity 133c defect
authorYu Jian <yujian@whamcloud.com>
Fri, 30 Sep 2011 05:41:26 +0000 (13:41 +0800)
committerJohann Lombardi <johann@whamcloud.com>
Wed, 9 Nov 2011 23:10:42 +0000 (18:10 -0500)
Several test run do_facet ost which assumes ost is ost0 which does not exist
according to the way the test suite works. This patch address several areas
where the wrong ost index is used. This patch also introduces some short hand
functions to get OST properties from the index. Those functions ensure ost1,
ost10 and ost100 are seen as different which is not always the case.

The following patch was also ported:
b=24504 sanity test_133* and check_stats() fix
i=Vladimir.Saveliev

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Signed-off-by: Yu Jian <yujian@whamcloud.com>
Change-Id: Ia7016e3c152acd8aa75cda6f838275bee316f639
Reviewed-on: http://review.whamcloud.com/1450
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
lustre/tests/lfsck.sh
lustre/tests/llog-test.sh
lustre/tests/replay-single.sh
lustre/tests/sanity.sh
lustre/tests/test-framework.sh

index 926949e..865ac85 100644 (file)
@@ -102,7 +102,7 @@ get_ost_node() {
     local ost_node
     local node
 
-    ost_uuid=$($LFS osts | grep "^$obdidx: " | cut -d' ' -f2 | head -n1)
+    ost_uuid=$(ostuuid_from_index $obdidx)
 
     for node in $(osts_nodes); do
         do_node $node "lctl get_param -n obdfilter.*.uuid" | grep -q $ost_uuid
@@ -120,10 +120,8 @@ get_ost_dev() {
     local ost_name
     local ost_dev
 
-    ost_name=$($LFS osts | grep "^$obdidx: " | cut -d' ' -f2 | \
-                head -n1 | sed -e 's/_UUID$//')
-
-    ost_dev=$(do_node $node "lctl get_param -n obdfilter.$ost_name.mntdev")
+    ost_name=$(ostname_from_index $obdidx)
+    ost_dev=$(do_node $node "lctl get_param -n obdfilter.${ost_name}.mntdev")
     [ ${PIPESTATUS[0]} -ne 0 ] && \
         echo "failed to find the OST device with index $obdidx on $facet" && \
         return 1
index 1de2b4f..16d0ecd 100644 (file)
@@ -59,7 +59,7 @@ setup() {
        log "== test 00: target handle mismatch (bug 5317) === `date +%H:%M:%S`"
 
        #define OBD_FAIL_OST_ALL_REPLY_NET       0x211
-       do_facet ost "lctl set_param fail_loc=0x80000211"
+       do_facet ost1 "lctl set_param fail_loc=0x80000211"
 
        zconf_mount `hostname` $MOUNT && df $MOUNT && pass || error "mount fail"
     fi
index eacbecb..93a79dc 100644 (file)
@@ -1437,12 +1437,12 @@ test_61a() {
     replay_barrier ost1
 #   OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
     unlinkmany $DIR/$tdir/$tfile-%d 800
-    do_facet ost "lctl set_param fail_loc=0x80000221"
+    set_nodes_failloc "$(osts_nodes)" 0x80000221
     facet_failover ost1
     sleep 10
     fail ost1
     sleep 30
-    do_facet ost "lctl set_param fail_loc=0x0"
+    set_nodes_failloc "$(osts_nodes)" 0x0
     $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
     rmdir $DIR/$tdir
 }
@@ -1465,10 +1465,11 @@ test_61c() {
 
 #   OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
     touch $DIR/$tfile
-    do_facet ost "lctl set_param fail_loc=0x80000222"
+    set_nodes_failloc "$(osts_nodes)" 0x80000222
     rm $DIR/$tfile
     sleep 10
     fail ost1
+    set_nodes_failloc "$(osts_nodes)" 0x0
 }
 run_test 61c "test race mds llog sync vs llog cleanup"
 
@@ -1697,7 +1698,7 @@ test_67b() #bug 3055
     CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
 
     # exhaust precreations on ost1
-    local OST=$(lfs osts | grep ^0": " | awk '{print $2}' | sed -e 's/_UUID$//')
+    local OST=$(ostname_from_index 0)
     local mdtosc=$(get_mdtosc_proc_path $OST)
     local last_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_last_id)
     local next_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_next_id)
@@ -2199,7 +2200,7 @@ test_87() { #bug 17485
     replay_barrier mds
 
     # exhaust precreations on ost1
-    local OST=$(lfs osts | grep ^0": " | awk '{print $2}' | sed -e 's/_UUID$//')
+    local OST=$(ostname_from_index 0)
     local mdtosc=$(get_mdtosc_proc_path $OST)
     local last_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_last_id)
     local next_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_next_id)
index 239e38d..4b20f67 100644 (file)
@@ -986,8 +986,7 @@ exhaust_precreations() {
        local FAILLOC=$2
        local FAILIDX=${3:-$OSTIDX}
 
-       local OST=$(lfs osts | grep ${OSTIDX}": " | \
-               awk '{print $2}' | sed -e 's/_UUID$//')
+       local OST=$(ostname_from_index $OSTIDX)
 
        # on the mdt's osc
        local mdtosc=$(get_mdtosc_proc_path $OST)
@@ -1155,7 +1154,7 @@ test_27v() { # bug 4900
         touch $DIR/$tdir/$tfile
         #define OBD_FAIL_TGT_DELAY_PRECREATE     0x705
         # all except ost1
-        for (( i=0; i < OSTCOUNT; i++ )) ; do
+        for (( i=1; i < OSTCOUNT; i++ )); do
                 do_facet ost$i lctl set_param fail_loc=0x705
         done
         local START=`date +%s`
@@ -1196,7 +1195,7 @@ test_27x() {
        [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
        OFFSET=$(($OSTCOUNT - 1))
        OSTIDX=0
-       local OST=$(lfs osts | awk '/'${OSTIDX}': / { print $2 }' | sed -e 's/_UUID$//')
+       local OST=$(ostname_from_index $OSTIDX)
 
        mkdir -p $DIR/$tdir
        $SETSTRIPE $DIR/$tdir -c 1      # 1 stripe per file
@@ -1227,14 +1226,14 @@ test_27y() {
                 } fi
         done
 
-        OSTIDX=$(lfs osts | grep ${OST} | awk '{print $1}' | sed -e 's/://')
+        OSTIDX=$(index_from_ostuuid $OST)
         mkdir -p $DIR/$tdir
         $SETSTRIPE $DIR/$tdir -c 1      # 1 stripe / file
 
-        do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 1
+        do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
         sleep_maxage
         createmany -o $DIR/$tdir/$tfile $OSTCOUNT
-        do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 0
+        do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
 
         for i in `seq 0 $OFFSET`; do
                 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
@@ -2660,7 +2659,7 @@ test_56a() {      # was test_56
         [  "$OSTCOUNT" -lt 2 ] && \
                 skip_env "skipping other lfs getstripe --obd test" && return
         OSTIDX=1
-        OBDUUID=$(lfs osts | grep ${OSTIDX}": " | awk '{print $2}')
+        OBDUUID=$(ostuuid_from_index $OSTIDX)
         FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
         FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
         [ $FOUND -eq $FILENUM ] || \
@@ -6092,17 +6091,18 @@ test_130e() {
 }
 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
 
-check_stats() {
+check_stats_facet() {
        local res
        local count
-       case $1 in
-       mds) local dev=$(get_mds_mdt_device_proc_path)
-            res=`do_facet mds $LCTL get_param $dev.$FSNAME-MDT0000.stats | grep "$2"`
-                ;;
-       ost) res=`do_facet ost0 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
-                ;;
-       *) error "Wrong argument $1" ;;
-       esac
+       local facet=$1
+       local svc=${facet}_svc
+
+       local dev=obdfilter
+
+       [[ $facet = mds ]] && dev=$(get_mds_mdt_device_proc_path)
+       param=$dev.${!svc}.stats
+
+       res=$(do_facet $facet $LCTL get_param $param | grep "$2")
        echo $res
        count=`echo $res | awk '{print $2}'`
        [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
@@ -6126,25 +6126,25 @@ test_133a() {
        # clear stats.
        local dev=$(get_mds_mdt_device_proc_path)
        do_facet mds $LCTL set_param $dev.*.stats=clear
-       do_facet ost $LCTL set_param obdfilter.*.stats=clear
+       do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
 
        # verify mdt stats first.
        mkdir ${testdir} || error "mkdir failed"
-       check_stats mds "mkdir" 1
+       check_stats_facet mds "mkdir" 1
        touch ${testdir}/${tfile} || "touch failed"
        # LPROC_MDS_OPEN is incremented by 2 - in mds_open() and mds_intent_policy()
-       check_stats mds "open" 2
-       check_stats mds "close" 1
+       check_stats_facet mds "open" 2
+       check_stats_facet mds "close" 1
        mknod ${testdir}/${tfile}-pipe p || "mknod failed"
-       check_stats mds "mknod" 1
+       check_stats_facet mds "mknod" 1
        rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
-       check_stats mds "unlink" 1
+       check_stats_facet mds "unlink" 1
        rm -f ${testdir}/${tfile} || error "file remove failed"
-       check_stats mds "unlink" 2
+       check_stats_facet mds "unlink" 2
 
        # remove working dir and check mdt stats again.
        rmdir ${testdir} || error "rmdir failed"
-       check_stats mds "rmdir" 1
+       check_stats_facet mds "rmdir" 1
 
        rm -rf $DIR/${tdir}
 }
@@ -6166,15 +6166,15 @@ test_133b() {
        # clear stats.
        local dev=$(get_mds_mdt_device_proc_path)
        do_facet mds $LCTL set_param $dev.*.stats=clear
-       do_facet ost $LCTL set_param obdfilter.*.stats=clear
+       do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
 
        # extra mdt stats verification.
        stat ${testdir}/${tfile} || error "stat failed"
-       check_stats mds "getattr" 0
+       check_stats_facet mds "getattr" 0
        chmod 444 ${testdir}/${tfile} || error "chmod failed"
-       check_stats mds "setattr" 1
+       check_stats_facet mds "setattr" 1
        $LFS df || error "lfs failed"
-       check_stats mds "statfs" 1
+       check_stats_facet mds "statfs" 1
 
        rm -rf $DIR/${tdir}
 }
@@ -6199,21 +6199,21 @@ test_133c() {
        # clear stats.
        local dev=$(get_mds_mdt_device_proc_path)
        do_facet mds $LCTL set_param $dev.*.stats=clear
-       do_facet ost $LCTL set_param obdfilter.*.stats=clear
+       do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
 
        dd if=/dev/zero of=${testdir}/${tfile} bs=1024k count=1 || error "dd failed"
        sync
        cancel_lru_locks osc
-       check_stats ost "write" 1
+       check_stats_facet ost1 "write" 1
 
        dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
-       check_stats ost "read" 1
+       check_stats_facet ost1 "read" 1
 
        > ${testdir}/${tfile} || error "truncate failed"
-       check_stats ost "punch" 1
+       check_stats_facet ost1 "punch" 1
 
        rm -f ${testdir}/${tfile} || error "file remove failed"
-       check_stats ost "destroy" 1
+       check_stats_facet ost1 "destroy" 1
 
        rm -rf $DIR/${tdir}
 }
@@ -6700,11 +6700,14 @@ test_180() {
         [ $rmmod_local -eq 1 ] && rmmod obdecho
         [ $rc -ne 0 ] && return $rc
 
-        do_facet ost "lsmod | grep -q obdecho || { insmod ${LUSTRE}/obdecho/obdecho.ko || modprobe obdecho; }" && rmmod_remote=1
+        do_facet ost1 "lsmod | grep -q obdecho || \
+               { insmod $LUSTRE/obdecho/obdecho.ko || modprobe obdecho; }" && \
+               rmmod_remote=1
 
-        OBD=$(do_facet ost "$LCTL  dl | awk '/obdfilter/ { print; exit; }'" | awk '{print $4;}')
-        [ "x$OBD" != "x" ] && { obdecho_create_test $OBD ost || rc=3; }
-        [ $rmmod_remote -eq 1 ] && do_facet ost "rmmod obdecho"
+        OBD=$(do_facet ost1 "$LCTL dl | awk '/obdfilter/ { print; exit; }'" | \
+               awk '{print $4;}')
+        [ "x$OBD" != "x" ] && { obdecho_create_test $OBD ost1 || rc=3; }
+        [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
         [ $rc -ne 0 ] && return $rc
 
         true
index 0a370f0..3efefc0 100644 (file)
@@ -2944,7 +2944,17 @@ osc_to_ost()
 
 ostuuid_from_index()
 {
-    $LFS osts $2 | awk '/^'$1'/ { print $2 }'
+    $LFS osts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p"
+}
+
+ostname_from_index() {
+    local uuid=$(ostuuid_from_index $1)
+    echo ${uuid/_UUID/}
+}
+
+index_from_ostuuid()
+{
+    $LFS osts $2 | sed -ne "/${1}/s/\(.*\): .* .*$/\1/p"
 }
 
 remote_node () {