Whamcloud - gitweb
LU-691 Fix OST index errors in test suite - sanity 133c defect
authorJames Simmons <uja.ornl@gmail.com>
Thu, 3 Nov 2011 14:39:36 +0000 (10:39 -0400)
committerOleg Drokin <green@whamcloud.com>
Sat, 12 Nov 2011 05:58:27 +0000 (00:58 -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.

Change-Id: Ic31224794563964a3415d24abeebce9dacceb686
Signed-off-by: James Simmons <uja.ornl@gmail.com>
Reviewed-on: http://review.whamcloud.com/1425
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@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 208b70b..669054a 100644 (file)
@@ -106,7 +106,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
@@ -124,10 +124,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 d086fc5..b0d5a60 100755 (executable)
@@ -1706,7 +1706,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 mds $OST)
     local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
         osc.$mdtosc.prealloc_last_id)
@@ -2142,7 +2142,7 @@ test_88() { #bug 17485
     replay_barrier $SINGLEMDS
 
     # 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 $SINGLEMDS $OST)
     local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
     local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
index aeb9894..e6453e5 100644 (file)
@@ -1045,8 +1045,7 @@ exhaust_precreations() {
        local MDSIDX=$(get_mds_dir "$DIR/$tdir")
        echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
 
-       local OST=$(lfs osts | grep ${OSTIDX}": " | \
-               awk '{print $2}' | sed -e 's/_UUID$//')
+       local OST=$(ostname_from_index $OSTIDX)
        local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
                          sed -e 's/_UUID$//;s/^.*-//')
 
@@ -1222,7 +1221,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`
@@ -1263,7 +1262,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
@@ -1304,14 +1303,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 $fcount
-        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"` ] || \
@@ -3266,7 +3265,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 ] || \
@@ -6795,7 +6794,7 @@ check_stats() {
        case $1 in
        $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
                 ;;
-       ost) res=`do_facet ost $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
+       ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
                 ;;
        *) error "Wrong argument $1" ;;
        esac
@@ -6816,7 +6815,7 @@ test_133a() {
 
        # clear stats.
        do_facet $SINGLEMDS $LCTL set_param mdt.*.md_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"
@@ -6849,7 +6848,7 @@ test_133b() {
 
        # clear stats.
        do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
-       do_facet ost $LCTL set_param obdfilter.*.stats=clear
+       do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
 
        # extra mdt stats verification.
        chmod 444 ${testdir}/${tfile} || error "chmod failed"
@@ -6874,7 +6873,7 @@ test_133c() {
 
        # clear stats.
        do_facet $SINGLEMDS $LCTL set_param mdt.*.md_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} conv=notrunc bs=1024k count=1 || error "dd failed"
        sync
@@ -7680,12 +7679,12 @@ test_180b() {
         local rc=0
         local rmmod_remote=0
 
-        do_facet ost "lsmod | grep -q obdecho || "                      \
-                     "{ insmod ${LUSTRE}/obdecho/obdecho.ko || "        \
-                     "modprobe obdecho; }" && rmmod_remote=1
-        target=$(do_facet ost $LCTL dl | awk '/obdfilter/ {print $4;exit}')
-        [[ -n $target ]] && { obdecho_create_test $target ost || rc=1; }
-        [ $rmmod_remote -eq 1 ] && do_facet ost "rmmod obdecho"
+        do_facet ost1 "lsmod | grep -q obdecho || "                      \
+                      "{ insmod ${LUSTRE}/obdecho/obdecho.ko || "        \
+                      "modprobe obdecho; }" && rmmod_remote=1
+        target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
+        [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
+        [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
         return $rc
 }
 run_test 180b "test obdecho directly on obdfilter"
index 51c3d92..aacc64b 100644 (file)
@@ -3308,7 +3308,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 () {