Whamcloud - gitweb
LU-691 tests: Fix OST index errors in test suite
authorJames Simmons <uja.ornl@gmail.com>
Thu, 13 Dec 2012 09:28:15 +0000 (17:28 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 19 Dec 2012 18:49:20 +0000 (13:49 -0500)
Several tests 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.

This patch is backported from commit 8afd35c of LU-691.

Test-Parameters: envdefinitions=SLOW=yes,ENABLE_QUOTA=yes testlist=lfsck,sanity,replay-single
Signed-off-by: James Simmons <uja.ornl@gmail.com>
Signed-off-by: Yu Jian <yujian@whamcloud.com>
Change-Id: I97d9554a99be25db0e4f550bf8071ddc981dddc4
Reviewed-on: http://review.whamcloud.com/4821
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Lai Siyao <laisiyao@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 4e376ba..94b422d 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,8 +124,7 @@ 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_name=$(ostname_from_index $obdidx)
        ost_dev=$(get_obdfilter_param $node $ost_name mntdev)
        if [ $? -ne 0 ]; then
                printf "unable to find OST%04x on $facet\n" $obdidx
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 cb398db..1670e15 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 2c7d54a..1d2720d 100644 (file)
@@ -1111,8 +1111,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/^.*-//')
 
@@ -1288,7 +1287,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`
@@ -1328,7 +1327,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
@@ -1368,14 +1367,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"` ] || \
@@ -3328,7 +3327,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 ] || \
@@ -7884,12 +7883,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 f8f44b1..c648404 100644 (file)
@@ -3563,7 +3563,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 () {